[AstroPy] fits table column values

Slavin, Jonathan jslavin at cfa.harvard.edu
Mon Dec 23 13:08:43 EST 2013

Hi Tom,

You have it right.  I actually like that approach -- i.e. store the z data
as the primary image and the grid as a table in an extension, though
because the axis arrays are different lengths it is a bit awkward --
requiring as you say vector columns.  I should learn to use HDF5, but then
I would also have to learn how to access the data (in my case) in IDL (not
my choice).  I wish the docs for h5py were a bit better.

Evert, I think you're not understanding the data structure quite.  The data
has a non-uniform distribution in x and y, though there are (z) values for
every x and y on the grid -- that is, it is a grid but a non-uniform one.
 If the grid were uniform I would just specify something like the start
point and spacing for each dimension in the header.  In this case, it is
possible to specify all the values for each dimension in the header, though
not quite so convenient.


On Mon, Dec 23, 2013 at 12:40 PM, Aldcroft, Thomas <
aldcroft at head.cfa.harvard.edu> wrote:

> 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

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20131223/7a6262d0/attachment.html>

More information about the AstroPy mailing list