-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Cutout2D behaviour for non-rectangular pixel sizes #11362
Comments
From a quick look at the code, I think I already found the bug:
If someone confirms the bug, I could possibly implement a fix myself. |
Feel free to open an exploratory PR with a test added for this use case. If the CI passes (minus the unrelated failures), then you have proof. Thanks! 😄 |
I am not sure this is a bug. For your WCS, >>> proj_plane_pixel_scales(wcs)
array([10., 5.]) Let's look at the WCS itself. You said that the pixel scale along the first image coordinate is 10 deg and along the second image coordinate is 5 deg. Given the shape of the extraction box is |
@mcara The point is just, that the |
Could you please provide a reference? |
Also, documentation says:
|
The docstring says as well:
So it is the y axis (lat) first, which is also the behaviour I see in the first (correct) example I provided in my initial post. |
Based on my reading of the docs, I think there is an issue either with the documentation or with the code. Indeed, when I now believe this is a bug, but I am not yet sure what is the fix: it would be helpful to know original developer's intention. |
Hard to tell where this crept in but a quick |
And since For example, specifying a size of |
What's interesting, is that the code is written in such a way that it would allow size specification of the form I would remove support for angles altogether, but if they must be used, I would re-design the code to:
|
@mcara I think specifying the width / height of the cutout box as an angle is a nice additional convenience from the user perspective. For projection regions with few distortions this just works fine and I think I certainly agree on the mixed units, I think this is confusing and super rare as a use case and not worth supporting. I could also try to replace the for loop in #11363 with a corresponding Numpy expression. |
It has been a while, but my memory of this is essentially what is here in the docs: "If size is in angular units, the cutout size is converted to pixels using the pixel scales along each axis of the image at the CRPIX location. Projection and other non-linear distortions are not taken into account." So, essentially |
Thanks @larrybradley! However I think the statement is ambiguous: "If size is in angular units, the cutout size is converted to pixels using the pixel scales along each axis of the image at the CRPIX location. Projection and other non-linear distortions are not taken into account." Does "axis of the image" correspond to the axis of the data or the axis of the WCS? I think internally |
"axis of the image" refers to the axis of data, e.g. (x, y) not WCS axis. In general (lat, lon) (in whichever order) aren't going to be aligned along the (x, y) axes, so I don't know another way to do this other than to use
where the x and y pixel scales are computed using Would that help? |
Description
When specifying a non-rectangular pixel size for the WCS provided to the
Cutout2D
class, the cutout does not return the expected cutout size and data shape.Steps to Reproduce
Prints:
So it behaves as expected and returns a data array with half the input shape in all axes.
In case of specifying an un-even pixel size:
It prints:
While I would have expected (18, 18). Maybe it seems the lon and lat axes are switched in this case? cc @LauraOlivera
System Details
The text was updated successfully, but these errors were encountered: