|
ERIS Pipeline Reference Manual 1.9.2
|
#include <sc_conv.h>Go to the source code of this file.
Functions | |
| cpl_error_code | sc_conv_checkfitsformat (int *fitsformat, const char *filename) |
| cpl_error_code | sc_conv_setcolnames (cpl_array *colnames, const cpl_parameterlist *parlist) |
| cpl_error_code | sc_conv_setextnames_varr (cpl_table *extnames, const scvarr *vecdat, const cpl_parameterlist *parlist) |
| cpl_error_code | sc_conv_setextnames_iarr (cpl_table *extnames, const sciarr *imadat, const cpl_parameterlist *parlist) |
| cpl_error_code | sc_conv_varr2tarr (sctarr *tabdat, const scvarr *vecdat, const cpl_table *extnames) |
| double | sc_conv_getwcskey (const cpl_propertylist *plist, const char *key) |
| cpl_error_code | sc_conv_modtable (sctarr *tabdat, const cpl_parameterlist *parlist) |
| cpl_error_code | sc_conv_readprepfits (sctarr *tabdat, const cpl_parameterlist *parlist) |
| cpl_error_code | sc_conv_results2tarr (sctarr *tabdat, cpl_table *results) |
| cpl_error_code | sc_conv_erasemaskcol (sctarr *tabdat, const cpl_parameterlist *parlist) |
| cpl_error_code | sc_conv_resultstarr2varr (scvarr *vecdat, const cpl_table *extnames, const sctarr *tabdat) |
| cpl_error_code | sc_conv_getmaskval (double maskval[2], const sctarr *tabdat, const cpl_table *extnames) |
| cpl_error_code | sc_conv_iarr2varr_sci (scvarr *vecdat, cpl_vector *selpix, const sciarr *imadat, const cpl_table *extnames, const double minrelprofflux) |
| cpl_error_code | sc_conv_iarr2varr_sky (scvarr *vecdat, const sciarr *imadat, const cpl_table *extnames, const double lowpixfrac, const cpl_vector *selpix) |
| cpl_error_code | sc_conv_ascii_read (sctarr *tabdat, const char *filename, const cpl_array *colnames) |
| cpl_error_code | sc_conv_ascii_write (const char *filename, const sctarr *tabdat) |
| cpl_error_code | sc_conv_tarr_init (sctarr *tabdat, const int next) |
| cpl_error_code | sc_conv_tarr_read (sctarr *tabdat, const char *filename) |
| cpl_error_code | sc_conv_tarr_write (const char *filename, const sctarr *tabdat) |
| cpl_error_code | sc_conv_tarr_delete (sctarr *tabdat) |
| cpl_error_code | sc_conv_varr_init (scvarr *vecdat, const int next) |
| cpl_error_code | sc_conv_varr_read (scvarr *vecdat, const char *filename) |
| cpl_error_code | sc_conv_varr_write (const char *filename, const scvarr *vecdat) |
| cpl_error_code | sc_conv_varr_delete (scvarr *vecdat) |
| cpl_error_code | sc_conv_iarr_init (sciarr *imadat, const int next) |
| cpl_error_code | sc_conv_iarr_read (sciarr *imadat, const char *filename) |
| cpl_error_code | sc_conv_iarr_write (const char *filename, const sciarr *imadat) |
| cpl_error_code | sc_conv_iarr_delete (sciarr *imadat) |
| cpl_error_code sc_conv_ascii_read | ( | sctarr * | tabdat, |
| const char * | filename, | ||
| const cpl_array * | colnames | ||
| ) |
Fills CPL table of a sctarr structure by data read from an ASCII file. The number and names of the expected columns are provided by a CPL array. Header lines in the ASCII file are allowed if they are marked by '#'.
INPUT:
| filename | path and name of input ASCII file |
| colnames | CPL array of column names for reading of ASCII file |
OUTPUT:
| tabdat | sctarr structure with data of ASCII file |
ERRORS:
Definition at line 2114 of file sc_conv.c.
References sc_basic_readline(), sc_conv_tarr_delete(), sc_conv_tarr_init(), SC_LENLINE, SC_MAXLEN, and SC_MAXPAR.
| cpl_error_code sc_conv_ascii_write | ( | const char * | filename, |
| const sctarr * | tabdat | ||
| ) |
Writes the table data of an sctarr structure into an ASCII file. Only one extension is allowed. The column names are written into a header line starting with '#'. The routine supports the column types STRING, INT, FLOAT, and DOUBLE.
INPUT:
| filename | path and name of output ASCII file |
| tabdat | sctarr structure with tabulated data |
ERRORS:
Definition at line 2238 of file sc_conv.c.
References SC_LENLINE, and SC_MAXLEN.
| cpl_error_code sc_conv_checkfitsformat | ( | int * | fitsformat, |
| const char * | filename | ||
| ) |
Identifies the FITS type (table or image) by means of the header keyword XTENSION of the first FITS extension. If an extension is not present, the image format is assumed. The keyword NAXIS is used to distinguish between 1D, 2D, and 3D images. The routine returns 0 for non-FITS format (e.g. ASCII), 1 for FITS table, 2 for 1D FITS image, 3 for 2D FITS image, 4 for 3D FITS image, and -1 in the case of errors. It is assumed that all extensions have the same FITS type.
INPUT:
| filename | path and name of input FITS file |
OUTPUT:
| fitsformat | flag for FITS format |
ERRORS:
Definition at line 47 of file sc_conv.c.
Referenced by sc_conv_iarr_read(), sc_conv_tarr_read(), and sc_conv_varr_read().
| cpl_error_code sc_conv_erasemaskcol | ( | sctarr * | tabdat, |
| const cpl_parameterlist * | parlist | ||
| ) |
Erases the integer mask column for SKYCORR in an sctarr structure. The column was created by sc_conv_modtable.
INPUT:
| tabdat | sctarr structure with read data |
| parlist | general CPL parameter list |
OUTPUT:
| tabdat | sctarr structure without integer mask column |
ERRORS:
Definition at line 1206 of file sc_conv.c.
References SC_DEFMASKCOL, SC_LENLINE, and SC_MAXLEN.
| cpl_error_code sc_conv_getmaskval | ( | double | maskval[2], |
| const sctarr * | tabdat, | ||
| const cpl_table * | extnames | ||
| ) |
Gets the bad (maskval[0]) and good (maskval[1]) mask values from an :sctarr structure containing the data of the FITS table prepared for SKYCORR.
INPUT:
| tabdat | sctarr structure with input data |
| extnames | CPL table with FITS extension numbers and names |
OUTPUT:
| maskval | array for bad and good mask value |
ERRORS:
Definition at line 1412 of file sc_conv.c.
References SC_DEFMASKCOL, SC_LENLINE, and SC_MAXLEN.
Referenced by sc_conv_resultstarr2varr().
| double sc_conv_getwcskey | ( | const cpl_propertylist * | plist, |
| const char * | key | ||
| ) |
Retrieves a FITS WCS key from a property list
INPUT:
| plist | cpl_propertylist |
| key | key to retrieve |
RETURN:
ERRORS:
Definition at line 669 of file sc_conv.c.
Referenced by sc_conv_varr2tarr().
| cpl_error_code sc_conv_iarr2varr_sci | ( | scvarr * | vecdat, |
| cpl_vector * | selpix, | ||
| const sciarr * | imadat, | ||
| const cpl_table * | extnames, | ||
| const double | minrelprofflux | ||
| ) |
Fills CPL vectors and CPL property lists of a scvarr structure by data read from a 2D FITS image with optional extensions for error, mask, and wavelength, and added in spatial direction. The image data is provided by a sciarr structure. The extension numbers and names are given by a CPL table. Extensions are not read if names are missing or wrong.
The flux summation only considers pixels with a flux of the spatial slit profile relative to the maximum value above a given minimum. Morover, only good pixels are added if a mask extension is provided. If pixels along the spatial direction are not considered, the summed flux is corrected by means of a model of the spatial flux distribution. The latter is derived from a projection of the 2D spectrum. If errors exist, they are added quadratically. Possible correlations of the pixels are not considered.
The effective number of pixels that are added up for each wavelength is output by means of an CPL vector. These data can be used to extract a corresponding 1D sky spectrum.
INPUT:
| selpix | empty CPL vector |
| imadat | sciarr structure with data of 2D FITS image |
| extnames | CPL table with FITS extension numbers and names |
| minrelprofflux | minimum relative profile flux |
OUTPUT:
| vecdat | scvarr structure with summed data of 2D FITS image |
| selpix | vector of effective pixel numbers |
ERRORS:
Definition at line 1515 of file sc_conv.c.
References sc_basic_getmaskval_image(), sc_conv_varr_delete(), sc_conv_varr_init(), SC_MAXLEN, and SC_TOL.
| cpl_error_code sc_conv_iarr2varr_sky | ( | scvarr * | vecdat, |
| const sciarr * | imadat, | ||
| const cpl_table * | extnames, | ||
| const double | lowpixfrac, | ||
| const cpl_vector * | selpix | ||
| ) |
Fills CPL vectors and CPL property lists of a scvarr structure by data read from a 2D FITS image with optional extensions for error, mask, and wavelength, and median-averaged in spatial direction. The image data is provided by a sciarr structure. The extension numbers and names are given by a CPL table. Extensions are not read if names are missing or wrong.
The median calculation only considers good pixels provided that a mask extension is provided. The input parameter lowpixfrac allows one to take a pixel in the sorted pixel list which deviates from the middle one (0.5). Values below 0.5 (full available range: 0 to 1) reduce the influence of spectra of bright objects on the calculation of the background median flux. The output flux is scaled to equal the sky flux for the input effective number of pixels provided by a CPL vector for each wavelength.
INPUT:
| imadat | sciarr structure with data of 2D FITS image |
| extnames | CPL table with FITS extension numbers and names |
| lowpixfrac | column-specific fraction of pixels with flux below selected pixel |
| selpix | CPL vector of effective pixel numbers |
OUTPUT:
| vecdat | scvarr structure with median-averaged data of 2D FITS image |
ERRORS:
Definition at line 1843 of file sc_conv.c.
References sc_basic_getmaskval_image(), sc_conv_varr_delete(), sc_conv_varr_init(), SC_MAXLEN, and SC_MIN.
| cpl_error_code sc_conv_iarr_delete | ( | sciarr * | imadat | ) |
| cpl_error_code sc_conv_iarr_init | ( | sciarr * | imadat, |
| const int | next | ||
| ) |
Initialises array of CPL images and CPL property lists as sciarr structure depending on the input number of FITS extensions.
INPUT:
| next | number of FITS extensions |
OUTPUT:
| imadat | empty sciarr structure for 2D FITS image data |
ERRORS:
Definition at line 2650 of file sc_conv.c.
Referenced by sc_conv_iarr_read().
| cpl_error_code sc_conv_iarr_read | ( | sciarr * | imadat, |
| const char * | filename | ||
| ) |
Reads a 2D FITS image with an arbritrary number of extensions and puts the data into an sciarr structure consisting of an array of CPL images and CPL property lists.
INPUT:
| filename | path and name of input 2D FITS image |
OUTPUT:
| imadat | sciarr structure with 2D FITS image data |
ERRORS:
Definition at line 2674 of file sc_conv.c.
References sc_conv_checkfitsformat(), sc_conv_iarr_init(), and SC_MAXLEN.
| cpl_error_code sc_conv_iarr_write | ( | const char * | filename, |
| const sciarr * | imadat | ||
| ) |
| cpl_error_code sc_conv_modtable | ( | sctarr * | tabdat, |
| const cpl_parameterlist * | parlist | ||
| ) |
Modifies data in sctarr structure in order to be consistent with requirements of SKYCORR. Only the first table extension is considered. The routine creates a column with the integer mask values 0 (rejected) and 1 (ok). By default, it is expected that input mask values agree with this definition. If other values are found, 0 is assumed to be ok and all other values cause pixel rejection. Possible nan in the flux and error columns are substituted by zero flux and indicated by mask = 0. The same is performed for negative errors. Finally, unreliable fluxes at the edges (defined by SC_EDGEFRAC) are masked.
INPUT:
| tabdat | sctarr structure with read data |
| parlist | general CPL parameter list |
OUTPUT:
| tabdat | sctarr structure with modified data |
ERRORS:
Definition at line 787 of file sc_conv.c.
References SC_DEFFLUXCOL, SC_DEFLAMCOL, SC_DEFMASKCOL, SC_EDGEFRAC, SC_LENLINE, SC_MAXFLUXFAC, and SC_MAXLEN.
| cpl_error_code sc_conv_readprepfits | ( | sctarr * | tabdat, |
| const cpl_parameterlist * | parlist | ||
| ) |
Fills CPL table of a new sctarr structure by data read from a FITS table prepared for SKYCORR.
INPUT:
| parlist | general CPL parameter list |
OUTPUT:
| tabdat | sctarr structure with data of FITS file |
ERRORS:
Definition at line 1067 of file sc_conv.c.
References sc_basic_abspath(), sc_conv_tarr_read(), and SC_MAXLEN.
| cpl_error_code sc_conv_results2tarr | ( | sctarr * | tabdat, |
| cpl_table * | results | ||
| ) |
Writes results from SKYCORR into an sctarr structure that already contains data from the input file. A new table column "scflux" is created, which contains the data from the "scflux" column of the results data table. If columns named "scdflux" and "scmask" exist in the results data table, they are also copied by using the same names for the output table.
INPUT:
| tabdat | sctarr structure with data of FITS file prepared for SKYCORR |
| results | CPL table with results of SKYCORR |
OUTPUT:
| tabdat | input sctarr structure extended for SKYCORR results |
ERRORS:
Definition at line 1122 of file sc_conv.c.
References SC_MAXLEN.
| cpl_error_code sc_conv_resultstarr2varr | ( | scvarr * | vecdat, |
| const cpl_table * | extnames, | ||
| const sctarr * | tabdat | ||
| ) |
Writes sky subtracted spectrum from SKYCORR into an scvarr structure representing a FITS image of the same format as the input data file.
INPUT:
| vecdat | scvarr structure with data of input 1D FITS image |
| extnames | CPL table with FITS extension numbers and names |
| tabdat | sctarr structure with input data and SKYCORR results |
OUTPUT:
| vecdat | scvarr structure with applied sky subtraction |
ERRORS:
Definition at line 1268 of file sc_conv.c.
References sc_conv_getmaskval(), and SC_MAXLEN.
| cpl_error_code sc_conv_setcolnames | ( | cpl_array * | colnames, |
| const cpl_parameterlist * | parlist | ||
| ) |
Gets column names for ASCII file from the general parameter list. The mandatory columns are wavelength and flux. Optionally, error and mask can also be provided. If this is not the case, this is indicated by 'NULL' in the parameter structure.
INPUT:
| colnames | empty CPL array for strings |
| parlist | general CPL parameter list |
OUTPUT:
| colnames | CPL array of column names for reading of ASCII file |
ERRORS:
| cpl_error_code sc_conv_setextnames_iarr | ( | cpl_table * | extnames, |
| const sciarr * | imadat, | ||
| const cpl_parameterlist * | parlist | ||
| ) |
Prepares CPL table with FITS extension numbers and names of a sciarr structure. Extension names are provided by the columns parameter of the driver file. The name "NONE" will be replaced by the default label for the data type.
INPUT:
| extnames | empty CPL table |
| imadat | sciarr structure with data of 1D FITS image |
| parlist | general CPL parameter list |
OUTPUT:
| extnames | CPL table with FITS extension numbers and names |
ERRORS:
Definition at line 372 of file sc_conv.c.
References SC_DEFFLUXCOL, SC_DEFLAMCOL, SC_LENLINE, and SC_MAXLEN.
| cpl_error_code sc_conv_setextnames_varr | ( | cpl_table * | extnames, |
| const scvarr * | vecdat, | ||
| const cpl_parameterlist * | parlist | ||
| ) |
Prepares CPL table with FITS extension numbers and names of a scvarr structure. Extension names are provided by the columns parameter of the driver file. The name "NONE" will be replaced by the default label for the data type.
INPUT:
| extnames | empty CPL table |
| vecdat | scvarr structure with data of 1D FITS image |
| parlist | general CPL parameter list |
OUTPUT:
| extnames | CPL table with FITS extension numbers and names |
ERRORS:
Definition at line 228 of file sc_conv.c.
References SC_DEFFLUXCOL, SC_DEFLAMCOL, SC_LENLINE, and SC_MAXLEN.
| cpl_error_code sc_conv_tarr_delete | ( | sctarr * | tabdat | ) |
Deletes an sctarr structure, which contains an array of CPL tables and CPL property lists.
INPUT:
| tabdat | sctarr structure with FITS table data |
ERRORS:
Definition at line 2476 of file sc_conv.c.
Referenced by sc_conv_ascii_read(), and sc_conv_varr2tarr().
| cpl_error_code sc_conv_tarr_init | ( | sctarr * | tabdat, |
| const int | next | ||
| ) |
Initialises array of CPL tables and CPL property lists as sctarr structure depending on the input number of FITS extensions.
INPUT:
| next | number of FITS extensions |
OUTPUT:
| tabdat | empty sctarr structure for FITS table data |
ERRORS:
Definition at line 2361 of file sc_conv.c.
Referenced by sc_conv_ascii_read(), sc_conv_tarr_read(), and sc_conv_varr2tarr().
| cpl_error_code sc_conv_tarr_read | ( | sctarr * | tabdat, |
| const char * | filename | ||
| ) |
Reads a FITS table with an arbritrary number of extensions and puts the data into an sctarr structure consisting of an array of CPL tables and CPL property lists.
INPUT:
| filename | path and name of input FITS table |
OUTPUT:
| tabdat | sctarr structure with FITS table data |
ERRORS:
Definition at line 2385 of file sc_conv.c.
References sc_conv_checkfitsformat(), sc_conv_tarr_init(), and SC_MAXLEN.
Referenced by sc_conv_readprepfits().
| cpl_error_code sc_conv_tarr_write | ( | const char * | filename, |
| const sctarr * | tabdat | ||
| ) |
| cpl_error_code sc_conv_varr2tarr | ( | sctarr * | tabdat, |
| const scvarr * | vecdat, | ||
| const cpl_table * | extnames | ||
| ) |
Fills CPL tables and CPL property lists of a sctarr structure by data read from a 1D FITS image with optional extensions for error, mask, and wavelength. The image data is provided by a scvarr structure. The extension numbers and names are given by a CPL table. Extensions are not read if names are missing or wrong. Images for different chips have to be converted separately.
INPUT:
| vecdat | scvarr structure with data of 1D FITS image |
| extnames | CPL table with FITS extension numbers and names |
OUTPUT:
| tabdat | sctarr structure with data of FITS table |
ERRORS:
Definition at line 516 of file sc_conv.c.
References sc_conv_getwcskey(), sc_conv_tarr_delete(), sc_conv_tarr_init(), and SC_MAXLEN.
| cpl_error_code sc_conv_varr_delete | ( | scvarr * | vecdat | ) |
Deletes an scvarr structure, which contains an array of CPL vectors and CPL property lists.
INPUT:
| vecdat | scvarr structure with 1D FITS image data |
ERRORS:
Definition at line 2617 of file sc_conv.c.
Referenced by sc_conv_iarr2varr_sci(), and sc_conv_iarr2varr_sky().
| cpl_error_code sc_conv_varr_init | ( | scvarr * | vecdat, |
| const int | next | ||
| ) |
Initialises array of CPL vectors and CPL property lists as scvarr structure depending on the input number of FITS extensions.
INPUT:
| next | number of FITS extensions |
OUTPUT:
| vecdat | empty scvarr structure for 1D FITS image data |
ERRORS:
Definition at line 2509 of file sc_conv.c.
Referenced by sc_conv_iarr2varr_sci(), sc_conv_iarr2varr_sky(), and sc_conv_varr_read().
| cpl_error_code sc_conv_varr_read | ( | scvarr * | vecdat, |
| const char * | filename | ||
| ) |
Reads a 1D FITS image with an arbritrary number of extensions and puts the data into an scvarr structure consisting of an array of CPL vectors and CPL property lists.
INPUT:
| filename | path and name of input 1D FITS image |
OUTPUT:
| vecdat | scvarr structure with 1D FITS image data |
ERRORS:
Definition at line 2533 of file sc_conv.c.
References sc_conv_checkfitsformat(), sc_conv_varr_init(), and SC_MAXLEN.
| cpl_error_code sc_conv_varr_write | ( | const char * | filename, |
| const scvarr * | vecdat | ||
| ) |