regions
regions copied to clipboard
DOC: Conversion guide from pyregion
As suggested by @prajwel in https://github.com/astropy/pyregion/pull/161#issuecomment-1326154571
I knew this was just a matter of time. Pyregion is part of many packages due to its age. Perhaps we can create easy porting guidelines for people wanting to port their code to Regions 🤔?
Sorry if this isn't the right place to ask, but are there any equivalent to pyregion.open and pyregion.parse in regions per chance ?
I think you are looking for Regions.read and Regions.parse. Examples here: https://astropy-regions.readthedocs.io/en/stable/region_io.html
I think the following comparisson could be useful.
Pyregion
contours = pyregion.open('contours.reg').as_imagecoord(wcs.to_header())
patch_list, artist_list = contours.get_mpl_patches_texts()
for p in patch_list:
ax.add_patch(p)
for t in artist_list:
ax.add_artist(t)
Regions
contours = Regions.read('contours.reg', format='ds9')
for sky_region in contours:
pixel_region = sky_region.to_pixel(wcs)
_ = pixel_region.plot(ax=ax)