Context
In Astronomy the de facto standard for images and data is FITS
.
I would like to export heterogenous data sets into a single fits file.
Attempt
I am interested in exporting into a fits file some data, say.
dat = Table[i, {i, 5}]
(* {1,2,3,4,5} *)
and additionally some metadata, say a range of $\nu$s:
rnus = ("nu" <> ToString[#] -> 0.5 + # & /@ ( Range[5]))
(* {nu1->1.5,nu2->2.5,nu3->3.5,nu4->4.5,nu5->5.5} *)
Following closely the documentation I can write:
Export["image.fits", {"Data" -> dat,
"Metadata" -> Join[rnus, {"Object" -> "something"}]}, "Rules"]
(* image.fits *)
and read back accordingly both the data:
Import["image.fits", "RawData"][[1]]
(* {1,2,3,4,5} *)
and the metadata:
"NU1" /. Import["image.fits", "Metadata"]
"OBJECT" /. Import["image.fits", "Metadata"]
(* 1.5 ) ( Something *)
BUT, what I would like to do is to write different (large) tables of different sizes into a single fits file. So using a single keyword for each element is unrealistic.
If the table were of the same size I could join them into a single list, as in
Export["image.fits", {"Data" -> {dat,dat}}, "Rules"]
but in my case the tables are not of the same size.
In principle the documentation says "For FITS files that contain multiple images or data extensions, the above elements are taken to be lists of the respective expressions."
Question
How can I write multiple images or data extensions into a unique fits file? Or in other words, what does the documentation mean?
Update
As requested, here is an example of fits with an extension containing {1,2,3,4,5} and {1,2,3,4,5,6} :
https://dl.dropboxusercontent.com/u/659996/test.fits
or it can be produced in python as
python
import pyfits
import numpy
data=numpy.array([1.,2.,3.,4.,5.])
pyfits.writeto("test.fits",data)
data=numpy.array([1.,2.,3.,4.,5.,6.])
pyfits.append("test.fits",data)
exit
Write
the file rather thanExport
fits.gsfc.nasa.gov/fits_primer.html $\endgroup$