[AstroPy] Changing dimensionality of WCS

Adam Ginsburg adam.ginsburg at colorado.edu
Tue Sep 24 21:03:16 EDT 2013


Thanks for the replies, and I'm glad to see this discussion going.

In terms of a somewhat generalized version of the problem, but not
entirely general: is it possible, in the current implementation of
wcs, to create a WCS axis that is a simple transformation of another?
i.e., RA with a position angle?  That would easily provide for most 2D
slit spectra, which would be useful for specutils.  I think that topic
has been discussed elsewhere, though, perhaps with respect to
modeling.

For my current more specific case, I've found that at least APLpy will
accept an "arbitrary" WCS axis, which is what I need for now.  I'm
dealing with a perhaps weird case where I want the spectra tracking
arbitrary positions - a position velocity diagram along a filament.

An example case is shown here:
http://keflavich.github.io/pvextractor/examples/IRAS05358Slicing.html

What I've done works, but I suspect there are better ways to do it.
On the WCS side, I'm using the hack shown here:
https://github.com/keflavich/pvextractor/blob/50b634484612b83f82169229faf11acceaadea93/pvextractor/pvwcs.py
basically just copying over parameters that I think are important.

On Tue, Sep 24, 2013 at 3:03 PM, David Berry <d.berry at jach.hawaii.edu> wrote:
> On 24 September 2013 21:14, Perry Greenfield <stsci.perry at gmail.com> wrote:
>> Keep in mind that something like this will only work if the coordinates being sliced are separable. For example, if the WCS involve a rotation of x,y, it doesn't make much sense to extract the wcs for x only since it requires as input both coordinates.
>>
>> Given that, I'm not sure slicing is a good approach. This would need some careful thought as far as a user interface goes (sure, you can raise an exception when it doesn't work, but is there a simple way to see what coordinates are coupled?)
>
> There are two parts to the problem:
>
> 1) picking the axes from the coordinate system. This requires a way of
> identifying the axes to be picked, tacking into account the fact that
> they may potentially have been permuted (i.e. you may have (dec,ra)
> rather than (ra,dec), and they may be in some related system rather
> than actual system you want (i.e. (ra,dec) rather than (glon,glat)).
> Then some way is needed of extracting the picked axes into a new
> coordinate system, and then some way of creating a Mapping that
> describes how to get from the old frame to the new frame (pyast uses a
> "PermMap" ("permutation mapping")).
>
> 2) Modifying any mappings that exist between the original coordinate
> frame and any other related coordinate frames. For instance say you
> have two Frames - one describing 3D (x,y,z) pixel coords, and another
> describing (ra,dec,frequency) world coordinates with some suitable
> mapping between them, and you then extract a (x,y) slice from the
> pixel array. You pick the (x,y) axes from the 3D pixel Frame to create
> a new 2D pixel frame as described in point 1) above, and likewise pick
> the (ra,dec) axes from the 3D WCS Frame to create a 2D WCS Frame. You
> then need to modify the original mapping between pixel and WCS so that
> instead of being 3D in and 3D out, it is 2D in and 2D out. If the axes
> are separable it's easy - you just need all Mapping classes to
> implement a method such as astMapSplit
> http://starlink.jach.hawaii.edu/docs/sun211.htx/node328.html. For
> non-seperable axes, you need to utilize the fact that you know the z
> value at which the slice was extracted, and create a mapping that will
> "feed in" that value for the missing axis in the original mapping. We
> use a PermMap for this - see
> http://starlink.jach.hawaii.edu/docs/sun211.htx/node347.html.
>
> David
>
>
> You use the fact that you know the Z value at which the slice was extracted
>
>
>
>> Perry
>>
>> On Sep 24, 2013, at 4:06 PM, James Turner wrote:
>>
>>> I don't know the answer re. astropy.wcs but it would be good if
>>> one could ultimately slice an nddata object and have the
>>> dimensionality and WCS reduced automatically if applicable (a bit
>>> like in IRAF but, hopefully, better) :-). It seems that an NDData
>>> can already be sliced directly but "support for WCS and units is
>>> not yet implemented". Maybe some more WCS manipulation routines
>>> are needed first...
>>>
>>> Cheers,
>>>
>>> James.
>>>
>>>
>>> On 24/09/13 15:49, David Berry wrote:
>>>> On 24 September 2013 19:23, Adam Ginsburg <adam.ginsburg at colorado.edu> wrote:
>>>>> When working with data cubes, I often need to extract WCS information
>>>>> for 1 or 2 of the WCS dimensions.   The docs
>>>>> (http://docs.astropy.org/en/latest/wcs/index.html) give decent
>>>>> examples of how to generate a WCS from scratch, but I don't see any
>>>>> obvious way to extract a lower-dimensional WCS from a WCS.  Does such
>>>>> functionality exist?  If not, does it make sense to generate a WCS
>>>>> from scratch and copy over just the relevant parameters?
>>>>
>>>> This is an example of the general problem - given two arbitrary
>>>> coordinate systems, one with N axes and one with M axes, is there a
>>>> transformation between them, and if so, what is it? It is addressed in
>>>> pyast by the "convert" method. If you need ideas for an API see
>>>>
>>>> http://starlink.jach.hawaii.edu/docs/sun211.htx/node245.html
>>>>
>>>> Implementing this sort of feature in a general way is tricky but can
>>>> be done. For simpler cases where you just want to pick a specified
>>>> subset or superset of axes from a coordinate system, pyast uses
>>>> "pickaxes". See
>>>>
>>>> http://starlink.jach.hawaii.edu/docs/sun211.htx/node348.html
>>>>
>>>> I know pyast is not astropy, but I point these out in case ideas are
>>>> need for how to approach these issues.
>>>>
>>>> David
>>>> _______________________________________________
>>>> AstroPy mailing list
>>>> AstroPy at scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/astropy
>>> _______________________________________________
>>> AstroPy mailing list
>>> AstroPy at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/astropy
>>
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at scipy.org
>> http://mail.scipy.org/mailman/listinfo/astropy
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy



-- 
Adam Ginsburg
Fellow, European Southern Observatory
http://www.adamgginsburg.com/



More information about the AstroPy mailing list