[AstroPy] fits table column values

Aldcroft, Thomas aldcroft at head.cfa.harvard.edu
Mon Dec 23 12:40:25 EST 2013


On Mon, Dec 23, 2013 at 11:16 AM, Slavin, Jonathan
<jslavin at cfa.harvard.edu>wrote:

> Hi all,
>
> Maybe I'm being dense today, but I'm not clear on how to do something
> pretty basic.  The issue is that I have essentially 3-D data wherein the
> data is not known on a uniform grid.  That is, although the data is on an
> x-y grid, neither the x values nor the y values are uniform.  I want to
> save the values (i.e. z values) at each point in the grid in a fits file.
>  The natural thing to do is either create an image or a table, but
> specifying the grid is not quite so straightforward in either case.  For a
> table one could have one column be an axis (e.g. 'y') and save the y
> values, but then the x values are the table column 'names', which I think
> have to be strings.  Nothing is fundamentally unworkable about that, it's
> just a little awkward to have string versions of the numeric axis values.
>  If I output an image instead, then I'm left with specifying the grid
> locations in the header.
>

If I understand, you have data values Z on a rectilinear 2-d grid (X, Y).
 If so one solution I've seen before [1] is storing an image in the primary
HDU and then the X and Y grid values in the second HDU as a table with two
columns X, Y and just one row.  Each of those two columns is actually a
vector of the appropriate length.  This is a little contorted, but FITS is
not an ideal match for this.

[1] I forget exactly where, but there is a FITS standard for calibration
data products that uses this layout for N-d data defined on rectilinear
grids.


>
> So, I do have ways of doing what I want to do, but it just seems that the
> ways I've thought of are not the simplest ways.  And I wonder if there
> isn't some other way that I haven't thought of.  Any hints on this would be
> appreciated.  Maybe some other output format (e.g. hdf5) would be better?
>

Certainly HDF5 is more flexible and would let you store the two vectors of
X and Y grid locations in a more natural way.

- Tom


>
> Jon
>
> --
> ________________________________________________________
> Jonathan D. Slavin                 Harvard-Smithsonian CfA
> jslavin at cfa.harvard.edu       60 Garden Street, MS 83
> phone: (617) 496-7981       Cambridge, MA 02138-1516
> fax: (617) 496-7577            USA
> ________________________________________________________
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20131223/2c655f58/attachment.html>


More information about the AstroPy mailing list