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

Method to get flattened world coordinates #146

Merged
merged 2 commits into from
Sep 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
datacube/dataset objects
(https://github.com/radio-astro-tools/spectral-cube/pull/90,
https://github.com/radio-astro-tools/spectral-cube/pull/129)
- add `flattened_world` method to get the world coordinates corresponding to
each pixel in the flattened array
(https://github.com/radio-astro-tools/spectral-cube/pull/146)

0.1 (2014-06-01)
----------------
Expand Down
14 changes: 14 additions & 0 deletions spectral_cube/spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,20 @@ def flattened(self, slice=(), weights=None):
else:
return u.Quantity(data, self.unit, copy=False)

def flattened_world(self, view=()):
"""
Retrieve the world coordinates corresponding to the extracted flattened
version of the cube
"""
lon,lat,spec = self.world[view]
spec = self._mask._flattened(data=spec, wcs=self._wcs,
view=slice)
lon = self._mask._flattened(data=lon, wcs=self._wcs,
view=slice)
lat = self._mask._flattened(data=lat, wcs=self._wcs,
view=slice)
return lat,lon,spec

def median(self, axis=None, **kwargs):
"""
Compute the median of an array, optionally along an axis.
Expand Down