next up previous contents
Next: 3.2.3 Converting IUE FITS Up: 3.2 FITS Files Previous: 3.2.1 Reading General FITS

3.2.2 Writing General FITS Files

  The most flexible FITS format uses the binary table extension. This format can accommodate (simultaneously) scalars, vectors, arrays (in various data types) as well as character strings. To write out a FITS file with a binary table, you can use IFITSWRT:

IFITSWRT,H,P1,...p15,OFN=fname,P1T=p1type,...P15T=p15type, $
P1U=p1unit,...P15U=p15unit,/update,typearr=typearr, $
unitarr=unitarr,instruc=instruc,tcomm=tcomm,/silent
 

H The main FITS header (if you do not have one, specify a scalar and one will be created).
P1,...p15 These are the IDL variables you wish to write to the FITS binary table. At least one is required.
P1T,...p15t These keywords are where you specify data types (e.g., 'wavelength') for each of the Pn variables.
P1U,...p15u These keywords allow you to specify the units (e.g., 'angstroms'). These will be included as keywords in the extension header to be written.
OFN The default filename will be data.fits unless you specify a different name via the OFN keyword.
update allows data to be appended to an existing binary table FITS file.
typearr a string vector containing data types for the fields to be written (as an alternative to using the PnT keywords. The value of any PnT keywords however will supersede the values in typearr.
unitarr a string vector analogous to typearr for specifying units which can be used instead of the PnU keywords.
instruc an (anonymous) IDL structure containing the fields to be written to the FITS file, stored in the order they should appear in the file. Instruc can be used instead of the Pn keywords. Note when instruc is used with the typearr and unitarr keywords, the number of fields generated is not limited to 15.
tcomm a string array for specifying comments for the TTYPEn FITS keywords. The default comment is "Data Type for Field n".
silent allows standard print statements to be suppressed.

IFITSWRT does not currently support variable length arrays, so when the update option is used, each row must follow the same format. Since the calling sequence can become rather complex, IFITSWRT is usually executed from an IDL procedure. A number of IUEDAC programs write files with IFITSWRT (e.g. GEX, BOXCAR, COADD). See Table 3.1 for examples of IFITSRD and IFITSWRT.

To write IDL vectors to a FITS primary array file, use VECFITS:

VECFITS,H,X,Y1,y2,y3,y4,y5,filename=filename,nu=nu,eps=eps, $
/com,/linear
 

H This can be one of several things:
  • An existing FITS header, specified as a string array,
  • The ``scale factor record'' (record 0, the H vector) for IUESIPS data,
  • A scalar value--in this case, a basic FITS header will be generated depending on the input data.
The value of the input H is not changed.
X Independent variable vector (e.g., wavelength).
Y1 Dependent variable vector (e.g., fluxes).
y2,y3,y4,y5 Optional dependent variable vectors (e.g., sigmas).
filename Output filename (hdu.fit is the default).
nu If you wish to include $\nu$ quality flags, do so via this keyword.
eps If you wish to include $\epsilon$ quality flags, do so via this keyword (note that resampling methods differ for $\nu$ and $\epsilon$ flags).
com If this keyword is set, you will be prompted for comments to add to the FITS header.
linear If set, the X vector is checked for monotonicity and if not linear, it and the other input vectors will be resampled to be linear. The resampling is done such that the range and number of points is preserved. (Note, if X is an IUESIPS wavelength array, the discontinuity due to the vacuum-to-air correction at 2000 Åcause problems).

For writing two-dimensional data, you will need to create a FITS header using the program KEYGEN, and then use HDUGEN to create a primary array FITS file:

KEYGEN,HIN,H,in=mode 

HIN Depending on the value of in, HIN is either treated as data for which a FITS header will be created, or an IUESIPS ``scale factor record'' (the H vector from IUESPEC) to be converted to FITS keywords.
H Output FITS header, stored as a string array. This can also be specified as an input FITS header in which case the existing entries will be included and/or updated (this is for ``data'' mode).
in This specifies the input mode. There are three possibilities:
EXTR   Assume HIN is an IUESIPS scale factor record from a MELO, MEHI, or LBL file. This is the default mode.
IMAG   Assume HIN is an IUESIPS ``header'' vector for raw, PI, or FES data.
DATA   Assume HIN contains data to be stored in a FITS file.
Enclose in quotes (e.g., in='data').

Once you have a FITS header, you can write out the primary array file:

HDUGEN,H,IMAGE,fname=fname 

H FITS header. This is an INPUT parameter.
IMAGE The data to write out.
fname Name of the output file (include an extension). If not included, HDU.FIT is the default.


next up previous contents
Next: 3.2.3 Converting IUE FITS Up: 3.2 FITS Files Previous: 3.2.1 Reading General FITS

2/9/1998