Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Conversion guide from pyregion #488

Open
pllim opened this issue Nov 30, 2022 · 3 comments
Open

DOC: Conversion guide from pyregion #488

pllim opened this issue Nov 30, 2022 · 3 comments

Comments

@pllim
Copy link
Member

pllim commented Nov 30, 2022

As suggested by @prajwel in astropy/pyregion#161 (comment)

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 🤔?

@neutrinoceros
Copy link
Contributor

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 ?

@larrybradley
Copy link
Member

I think you are looking for Regions.read and Regions.parse. Examples here: https://astropy-regions.readthedocs.io/en/stable/region_io.html

@prajwel
Copy link
Member

prajwel commented Dec 6, 2022

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants