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

WCS information lost in unit conversion of LowerDimensionalObject #256

Merged
merged 3 commits into from
Jan 6, 2016

Conversation

keflavich
Copy link
Contributor

A similar custom to attribute should be defined (as is already done for SpectralCube).

@e-koch
Copy link
Contributor Author

e-koch commented Dec 23, 2015

It seems this is true for slicing as well.

@keflavich
Copy link
Contributor

Yeah, I've run into this. It shouldn't be too hard. PR may be forthcoming.

@keflavich
Copy link
Contributor

@e-koch care to review this?


if new_qty.ndim < 2:
# do not return a projection
return u.Quantity(new_qty)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what should be returned here. If a Quantity is returned, then you still lose all of the WCS info. If you have a PV slice, you would want a OneDSpectrum when slicing along the spectral axis, but something else when slicing in the spatial dimension.

Could we check for the axis type when a slice reduces ndim<2? A OneDSpectrum would be returned when the remaining axis is spectral. I'm not sure how to treat 1D spatial slices. Treat it like a mock-projection with a 1 pixel second dimension or define a spatial 1D slice class? Is there a use case for such a thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be. I chose to ignore it for now because it's not trivial, but I think we could inspect the WCS and see if one of the axes is spectral; if so, we'd then return the OneDSpectrum

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I think for single pixels, we really want to drop all the way to a Quantity with no wcs information

@e-koch
Copy link
Contributor Author

e-koch commented Jan 4, 2016

@keflavich - Apart from the one comment, it looks good! I tested on the use case the brought this up and everything checks out.

Depending on what you think about the comment above, test_slices_of_projections_not_projections may need to be altered/become more specific on the returned object.

@keflavich
Copy link
Contributor

There is a bug in WCS that prevents creating 1D slices from 2D WCSs that are half celestial, half spectral:

In [15]: w2 = cube[:,0,:].wcs
WARNING: FITSFixedWarning: 'spcfix' made the change 'Changed CTYPE3 from 'VELO-LSR' to 'VOPT', and SPECSYS to 'LSRK''. [astropy.wcs.wcs]

In [16]: w2.sub([wcs.WCSSUB_SPECTRAL])
Traceback (most recent call last):
  File "<ipython-input-16-0b9117b7127a>", line 1, in <module>
    w2.sub([wcs.WCSSUB_SPECTRAL])
  File "/Users/adam/repos/astropy/astropy/wcs/wcs.py", line 541, in sub
    copy = self.deepcopy()
  File "/Users/adam/repos/astropy/astropy/wcs/wcs.py", line 538, in deepcopy
    return copy.deepcopy(self)
  File "/Users/adam/anaconda/envs/astropy35/lib/python3.5/copy.py", line 166, in deepcopy
    y = copier(memo)
  File "/Users/adam/repos/astropy/astropy/wcs/wcs.py", line 514, in __deepcopy__
    copy.deepcopy(self.wcs, memo),
  File "/Users/adam/anaconda/envs/astropy35/lib/python3.5/copy.py", line 166, in deepcopy
    y = copier(memo)
InconsistentAxisTypesError: ERROR 4 in wcs_types() at line 2516 of file cextern/wcslib/C/wcs.c:
Unmatched celestial axes.

I'll make a separate issue for this.

keflavich added a commit that referenced this pull request Jan 6, 2016
WCS information lost in unit conversion of LowerDimensionalObject
@keflavich keflavich merged commit 2347ca0 into radio-astro-tools:master Jan 6, 2016
@keflavich keflavich deleted the issue256 branch January 6, 2016 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants