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

Cutout data but also WCS #580

Open
HealthyPear opened this issue Nov 27, 2024 · 2 comments
Open

Cutout data but also WCS #580

HealthyPear opened this issue Nov 27, 2024 · 2 comments

Comments

@HealthyPear
Copy link

If I am not wrong this package is missing the equivalent of

https://docs.astropy.org/en/stable/nddata/utils.html#saving-a-2d-cutout-to-a-fits-file-with-an-updated-wcs

Am I right?

The regions.RegionMask.cutout methods makes a cutout only of the data, but not of the WCS (that might come with it?).

Is this a bug or design choice?

Does it make sense to update that method to use astropy.nddata.Cutout2D with e.g. an optional keyword argument?

@keflavich
Copy link
Contributor

Agree, this is a missing feature and something I do very often. I'm surprised there isn't already an open issue about it; I'd swear I'd made one.

Yes, I think the cutout2d approach is a good one.

@keflavich
Copy link
Contributor

fwiw, my pattern for this is generally:

    preg = reg.to_pixel(wcs)
    mask = preg.to_mask()
    slc_lg, slc_sm = mask.get_overlap_slices(data.shape)
    ww_sl = wcs[slc_lg]

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

3 participants