{"id":21869,"library":"regions","title":"Regions","description":"An Astropy coordinated package for region handling, providing tools for representing and working with astronomical regions (e.g., circles, ellipses, polygons) in various coordinate systems. Current version is 0.11, requiring Python >= 3.11. Releases follow irregular cadence.","status":"active","version":"0.11","language":"python","source_language":"en","source_url":"https://github.com/astropy/regions","tags":["astronomy","astropy","region"],"install":[{"cmd":"pip install regions","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Core dependency for array operations","package":"numpy","optional":false},{"reason":"Coordinate system and table support","package":"astropy","optional":false}],"imports":[{"note":"","wrong":"","symbol":"regions","correct":"import regions"}],"quickstart":{"code":"import regions\nfrom astropy.coordinates import SkyCoord\nimport astropy.units as u\n\n# Create a circular region at RA=10.68458, Dec=41.26917 (degrees) with radius=0.1 deg\ncenter = SkyCoord(10.68458, 41.26917, unit=u.deg)\nregion = regions.CircleSkyRegion(center, 0.1 * u.deg)\nprint(region)","lang":"python","description":"Creates a circular sky region using SkyCoord and basic units."},"warnings":[{"fix":"Replace `regions.Region('circle ...')` with `regions.CircleSkyRegion(...)` or `regions.Region.parse('circle ...')`.","message":"The old convenience function `regions.Region` for auto-detecting region format from a string is deprecated. Use explicit constructors like `CircleSkyRegion` or `regions.Region.parse()`.","severity":"deprecated","affected_versions":"<0.9"},{"fix":"Always convert coordinates to `SkyCoord` before passing to region constructors.","message":"Region constructors expect `center` as a `SkyCoord` object for sky regions, not bare tuples or strings. Passing a tuple leads to confusing errors.","severity":"gotcha","affected_versions":">=0.1"},{"fix":"Update imports: `from regions.io.ds9 import write_all` instead of `from regions.io import write_ds9`.","message":"In version 0.7, the `regions.io` module was reorganized. Functions like `write_ds9` moved to `regions.io.ds9.write_all`. Old imports break.","severity":"breaking","affected_versions":"<0.7"},{"fix":"Use `regions = regions.io.ds9.read_ds9(filename)` then iterate or index.","message":"When reading DS9 region files, the `read_ds9` function returns a `Regions` (list-like) object, not a single region. Looping or indexing is needed to access individual regions.","severity":"gotcha","affected_versions":">=0.1"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use explicit region constructors like `regions.CircleSkyRegion(...)` or `regions.EllipseSkyRegion(...)`.","cause":"Using `regions.Region(...)` which is deprecated and no longer works in newer versions.","error":"TypeError: 'module' object is not callable"},{"fix":"Use `from regions.io.ds9 import read_ds9` or `regions.io.ds9.read_ds9(filename)`.","cause":"The `read_ds9` function was moved to `regions.io.ds9` in version 0.7.","error":"AttributeError: module 'regions' has no attribute 'read_ds9'"},{"fix":"Convert the string to `SkyCoord` first: `center = SkyCoord('10.68458 41.26917', unit=u.deg)`.","cause":"Passing a string coordinate (e.g., '10.68458 41.26917') instead of a `SkyCoord` object to a region constructor.","error":"TypeError: 'str' object has no attribute 'ra'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}