FORS Pipeline Reference Manual 4.9.20
Defines | Functions
DFS Utilities

Defines

#define WCS_KEYS   "^((CRVAL|CRPIX|CTYPE|CDELT)[0-9]|RADECSYS|CD[0-9]_[0-9])$"
#define cleanup
#define cleanup
#define cleanup
#define cleanup

Functions

static char * strlower (char *s)
char * dfs_generate_filename (const char *category)
char * dfs_generate_filename_tfits (const char *category)
static void errorstate_dump_one (unsigned self, unsigned first, unsigned last)
 Dump a single CPL error.
void fors_begin (cpl_frameset *frames, const char *description_short)
 Start recipe execution.
int fors_end (const cpl_frameset *frames, cpl_errorstate before_exec)
 End recipe execution.
void fors_dfs_set_groups (cpl_frameset *set)
 Set the group as RAW or CALIB in a frameset.
const char * fors_dfs_pipeline_version (const cpl_propertylist *header, const char **instrument_version)
 Get pipeline and instrument versions.
int dfs_get_parameter_int (cpl_parameterlist *parlist, const char *name, const cpl_table *defaults)
 Reading a recipe integer parameter value.
double dfs_get_parameter_double (cpl_parameterlist *parlist, const char *name, const cpl_table *defaults)
 Reading a recipe double parameter value.
const char * dfs_get_parameter_string (cpl_parameterlist *parlist, const char *name, const cpl_table *defaults)
 Reading a recipe string parameter value.
int dfs_get_parameter_bool (cpl_parameterlist *parlist, const char *name, const cpl_table *defaults)
 Reading a recipe boolean parameter value.
int dfs_get_parameter_bool_const (const cpl_parameterlist *parlist, const char *name)
int dfs_get_parameter_int_const (const cpl_parameterlist *parlist, const char *name)
double dfs_get_parameter_double_const (const cpl_parameterlist *parlist, const char *name)
const char * dfs_get_parameter_string_const (const cpl_parameterlist *parlist, const char *name)
cpl_image * dfs_load_image (cpl_frameset *frameset, const char *category, cpl_type type, int ext, int calib)
 Loading image data of given category.
cpl_table * dfs_load_table (cpl_frameset *frameset, const char *category, int ext)
 Loading table data of given category.
cpl_propertylist * dfs_load_header (cpl_frameset *frameset, const char *category, int ext)
 Loading header associated to data of given category.
static void dfs_save (cpl_frameset *frameset, const void *object, cpl_frame_type type, const char *category, cpl_propertylist *header, const cpl_parameterlist *parlist, const char *recipename, const cpl_frame *raw_frame)
 Save DFS product.
void fors_dfs_save_image (cpl_frameset *frameset, const fors_image *image, const char *category, cpl_propertylist *header, const cpl_parameterlist *parlist, const char *recipename, const cpl_frame *raw_frame)
 Save DFS product (image)
void fors_dfs_add_wcs (cpl_propertylist *header, const cpl_frame *frame, const fors_setting *setting)
 add WCS keywords to header
void fors_dfs_add_exptime (cpl_propertylist *header, const cpl_frame *frame, double exptime)
 Add keyword EXPTIME to header.
void fors_dfs_save_table (cpl_frameset *frameset, const cpl_table *table, const char *category, cpl_propertylist *header, const cpl_parameterlist *parlist, const char *recipename, const cpl_frame *raw_frame)
 Save DFS product (table)
int dfs_save_image (cpl_frameset *frameset, const cpl_image *image, const char *category, cpl_propertylist *header, const cpl_parameterlist *parlist, const char *recipename, const char *version)
 Saving image data of given category.
int dfs_save_table (cpl_frameset *frameset, const cpl_table *table, const char *category, cpl_propertylist *header, const cpl_parameterlist *parlist, const char *recipename, const char *version)
 Saving table data of given category.
int dfs_files_dont_exist (cpl_frameset *frameset)
 Check if all SOF files exist.
int dfs_equal_keyword (cpl_frameset *frameset, const char *keyword)
 Saving table data of given category.
cpl_error_code dfs_save_table_ext (cpl_table *table, const char *tag, cpl_propertylist *extheader)
 Save a table in a extension (different from the first one)
cpl_error_code dfs_save_image_ext (cpl_image *image, const char *tag, cpl_propertylist *extheader)
 Save an image in a extension.
cpl_error_code dfs_save_image_null (cpl_frameset *frameset, cpl_parameterlist *parlist, const char *tag, const char *recipename, const char *version)
 Save a product with an empty primary extension.

Detailed Description

The module fors_dfs collects medium level functions related to DFS data IO.


Define Documentation

#define cleanup
Value:
do { \
    cpl_propertylist_delete(wcs_header); \
} while (0)

Definition at line 1222 of file fors_dfs.c.

#define cleanup
Value:
do { \
    cpl_propertylist_delete(time_header); \
} while (0)

Definition at line 1222 of file fors_dfs.c.


Function Documentation

static void errorstate_dump_one ( unsigned  self,
unsigned  first,
unsigned  last 
) [static]

Dump a single CPL error.

Parameters:
selfThe number of the current error to be dumped
firstThe number of the first error to be dumped
lastThe number of the last error to be dumped

This is a callback function to cpl_errorstate_dump()

See also:
cpl_errorstate_dump

Definition at line 147 of file fors_dfs.c.

Referenced by fors_end().

void fors_begin ( cpl_frameset *  frames,
const char *  description_short 
)

Start recipe execution.

Parameters:
framesrecipe input frameset
description_shortrecipe short description

This function classifies and prints the input frames. It exists in order to avoid duplicating these recipe independent steps in every recipe.

Definition at line 230 of file fors_dfs.c.

References fors_dfs_set_groups(), and fors_frameset_print().

Referenced by fors_bias_exec(), fors_dark_exec(), fors_img_science_exec(), fors_img_screen_flat_exec(), fors_img_sky_flat_exec(), fors_photometry_exec(), fors_recipe_exec(), and fors_zeropoint_exec().

int fors_end ( const cpl_frameset *  frames,
cpl_errorstate  before_exec 
)

End recipe execution.

Parameters:
framesrecipe output frameset
before_execCPL error state at recipe execution start
Returns:
zero if and only if no CPL error is set

The function prints the product frames successfully produced by the recipe, including the frame tags.

If a CPL error is set, the error history since recipe execution start is printed.

Definition at line 258 of file fors_dfs.c.

References errorstate_dump_one(), and fors_frame_print().

Referenced by fors_bias_exec(), fors_dark_exec(), fors_img_science_exec(), fors_img_screen_flat_exec(), fors_img_sky_flat_exec(), fors_photometry_exec(), fors_recipe_exec(), and fors_zeropoint_exec().

void fors_dfs_set_groups ( cpl_frameset *  set)

Set the group as RAW or CALIB in a frameset.

Parameters:
setthe input frameset

Definition at line 296 of file fors_dfs.c.

References assure.

Referenced by fors_begin().

const char* fors_dfs_pipeline_version ( const cpl_propertylist *  header,
const char **  instrument_version 
)

Get pipeline and instrument versions.

Parameters:
headerraw header
instrument_version(output) if non-NULL, newly allocated instrument name
Returns:
newly allocated pipeline version string

Definition at line 363 of file fors_dfs.c.

References assure.

Referenced by dfs_save(), and fors_setting_new_level().

int dfs_get_parameter_int ( cpl_parameterlist *  parlist,
const char *  name,
const cpl_table *  defaults 
)

Reading a recipe integer parameter value.

Parameters:
parlistThe input parameter list
nameThe parameter name
defaultsThe defaults table
Returns:
The parameter value

This function is just a wrapper to the basic CPL function cpl_parameter_get_int(), but if a defaults table is passed then the parameter value is searched in that table. If it is found, the parameter value will be modified also on the input parameter list before being returned, so that it would appear on the recipe products headers. If the parameter is not found, then the parameter value is simply read from the input parameter list. If a defaults table is not specified, then this function works exactly as the function cpl_parameter_get_int().

Definition at line 410 of file fors_dfs.c.

Referenced by dfs_get_parameter_int_const(), and vimos_calib_impl().

double dfs_get_parameter_double ( cpl_parameterlist *  parlist,
const char *  name,
const cpl_table *  defaults 
)

Reading a recipe double parameter value.

Parameters:
parlistThe input parameter list
nameThe parameter name
defaultsThe defaults table
Returns:
The parameter value

This function is just a wrapper to the basic CPL function cpl_parameter_get_double(), but if a defaults table is passed then the parameter value is searched in that table. If it is found, the parameter value will be modified also on the input parameter list before being returned, so that it would appear on the recipe products headers. If the parameter is not found, then the parameter value is simply read from the input parameter list. If a defaults table is not specified, then this function works exactly as the function cpl_parameter_get_double().

Definition at line 507 of file fors_dfs.c.

Referenced by dfs_get_parameter_double_const(), and vimos_calib_impl().

const char* dfs_get_parameter_string ( cpl_parameterlist *  parlist,
const char *  name,
const cpl_table *  defaults 
)

Reading a recipe string parameter value.

Parameters:
parlistThe input parameter list
nameThe parameter name
defaultsThe defaults table
Returns:
The parameter value

This function is just a wrapper to the basic CPL function cpl_parameter_get_string(), but if a defaults table is passed then the parameter value is searched in that table. If it is found, the parameter value will be modified also on the input parameter list before being returned, so that it would appear on the recipe products headers. If the parameter is not found, then the parameter value is simply read from the input parameter list. If a defaults table is not specified, then this function works exactly as the function cpl_parameter_get_string().

Definition at line 605 of file fors_dfs.c.

Referenced by dfs_get_parameter_string_const(), and vimos_calib_impl().

int dfs_get_parameter_bool ( cpl_parameterlist *  parlist,
const char *  name,
const cpl_table *  defaults 
)

Reading a recipe boolean parameter value.

Parameters:
parlistThe input parameter list
nameThe parameter name
defaultsThe defaults table
Returns:
The parameter value

This function is just a wrapper to the basic CPL function cpl_parameter_get_bool(), but if a defaults table is passed then the parameter value is searched in that table. If it is found, the parameter value will be modified also on the input parameter list before being returned, so that it would appear on the recipe products headers. If the parameter is not found, then the parameter value is simply read from the input parameter list. If a defaults table is not specified, then this function works exactly as the function cpl_parameter_get_bool().

Definition at line 704 of file fors_dfs.c.

Referenced by dfs_get_parameter_bool_const(), and vimos_calib_impl().

int dfs_get_parameter_bool_const ( const cpl_parameterlist *  parlist,
const char *  name 
)
See also:
dfs_get_parameter_bool

Definition at line 799 of file fors_dfs.c.

References dfs_get_parameter_bool().

int dfs_get_parameter_int_const ( const cpl_parameterlist *  parlist,
const char *  name 
)
double dfs_get_parameter_double_const ( const cpl_parameterlist *  parlist,
const char *  name 
)
const char* dfs_get_parameter_string_const ( const cpl_parameterlist *  parlist,
const char *  name 
)
See also:
dfs_get_parameter_string

Definition at line 829 of file fors_dfs.c.

References dfs_get_parameter_string().

Referenced by fors_extract_method_new(), and fors_stack_method_new().

cpl_image* dfs_load_image ( cpl_frameset *  frameset,
const char *  category,
cpl_type  type,
int  ext,
int  calib 
)

Loading image data of given category.

Parameters:
framesetThe input set-of-frames
categoryThe category of the image to load
typeThe data type of the loaded image
extThe FITS file extension to access (first = 0)
calib1 = calibration file, 0 = raw file
Returns:
The loaded image

This function is just a wrapper to the basic CPL functions cpl_frameset_find() and cpl_image_load(), as they typically are called every time an image should be loaded by a recipe. Error checking and proper messaging are also included here, to give a more readable look to the main recipe code.

In case of any error, a NULL pointer is returned. The error codes that are set in this case are the same set by the above mentioned CPL functions. The "where" string (accessible via a call to cpl_error_get_where() ) is not modified by this function, and therefore the function where the failure occurred is also reported.

Definition at line 863 of file fors_dfs.c.

Referenced by vimos_calib_impl().

cpl_table* dfs_load_table ( cpl_frameset *  frameset,
const char *  category,
int  ext 
)

Loading table data of given category.

Parameters:
framesetThe input set-of-frames
categoryThe category of the table to load
extThe FITS file extension to access (first = 0)
Returns:
The loaded table

This function is just a wrapper to the basic CPL functions cpl_frameset_find() and cpl_table_load(), as they typically are called every time a table should be loaded by a recipe. Error checking and proper messaging are also included here, to give a more readable look to the main recipe code.

In case of any error, a NULL pointer is returned. The error codes that are set in this case are the same set by the above mentioned CPL functions. The "where" string (accessible via a call to cpl_error_get_where() ) is not modified by this function, and therefore the function where the failure occurred is also reported.

Definition at line 919 of file fors_dfs.c.

Referenced by vimos_calib_impl().

cpl_propertylist* dfs_load_header ( cpl_frameset *  frameset,
const char *  category,
int  ext 
)

Loading header associated to data of given category.

Parameters:
framesetThe input set-of-frames
categoryThe category of the frame containing the header
extThe FITS file extension to access (first = 0)
Returns:
The loaded property list

This function is just a wrapper to the basic CPL functions cpl_frameset_find() and cpl_propertylist_load(), as they typically are called every time a header should be loaded by a recipe. Error checking and proper messaging are also included here, to give a more readable look to the main recipe code.

In case of any error, a NULL pointer is returned. The error codes that are set in this case are the same set by the above mentioned CPL functions. The "where" string (accessible via a call to cpl_error_get_where() ) is not modified by this function, and therefore the function where the failure occurred is also reported.

Definition at line 969 of file fors_dfs.c.

Referenced by vimos_calib_impl().

static void dfs_save ( cpl_frameset *  frameset,
const void *  object,
cpl_frame_type  type,
const char *  category,
cpl_propertylist *  header,
const cpl_parameterlist *  parlist,
const char *  recipename,
const cpl_frame *  raw_frame 
) [static]

Save DFS product.

Parameters:
typeCPL_FRAME_TYPE_IMAGE or CPL_FRAME_TYPE_TABLE
objectmust be of type fors_image or cpl_table, depending on the parameter type

Definition at line 1001 of file fors_dfs.c.

References fors_dfs_pipeline_version(), and fors_image_save().

Referenced by fors_dfs_save_image(), and fors_dfs_save_table().

void fors_dfs_save_image ( cpl_frameset *  frameset,
const fors_image image,
const char *  category,
cpl_propertylist *  header,
const cpl_parameterlist *  parlist,
const char *  recipename,
const cpl_frame *  raw_frame 
)

Save DFS product (image)

Parameters:
framesetsee dfs_save_image()
imageimage (containing data and error bars) to save
categorysee dfs_save_image()
headersee dfs_save_image()
parlistsee dfs_save_image()
recipenamesee dfs_save_image()
raw_frameany raw frame used for this product

This function is the same as dfs_save_image(), except the image is saved using fors_image_save().

The instrument version number is determined from the header of the input raw frame.

Definition at line 1164 of file fors_dfs.c.

References dfs_save().

Referenced by fors_bias(), fors_dark(), fors_img_science(), fors_img_screen_flat(), fors_img_sky_flat(), fors_photometry(), and fors_zeropoint().

void fors_dfs_add_wcs ( cpl_propertylist *  header,
const cpl_frame *  frame,
const fors_setting setting 
)

add WCS keywords to header

Parameters:
headerto write to
frameget keywords from this frame

Definition at line 1185 of file fors_dfs.c.

References assure.

Referenced by fors_img_science(), and fors_zeropoint().

void fors_dfs_add_exptime ( cpl_propertylist *  header,
const cpl_frame *  frame,
double  exptime 
)

Add keyword EXPTIME to header.

Parameters:
headerto write to
frameget keyword from this frame

If frame is NULL, a keyword EXPTIME is created in header with the value given in exptime. Otherwise, the value is read from the header of frame. In case of error (i.e., the keyword EXPTIME doesn't exist in frame), nothing is done (and the error is reset).

Definition at line 1239 of file fors_dfs.c.

Referenced by fors_img_science(), and fors_zeropoint().

void fors_dfs_save_table ( cpl_frameset *  frameset,
const cpl_table *  table,
const char *  category,
cpl_propertylist *  header,
const cpl_parameterlist *  parlist,
const char *  recipename,
const cpl_frame *  raw_frame 
)

Save DFS product (table)

See also:
fors_dfs_save_image()

Definition at line 1279 of file fors_dfs.c.

References dfs_save().

Referenced by fors_img_science(), fors_photometry(), and fors_zeropoint().

int dfs_save_image ( cpl_frameset *  frameset,
const cpl_image *  image,
const char *  category,
cpl_propertylist *  header,
const cpl_parameterlist *  parlist,
const char *  recipename,
const char *  version 
)

Saving image data of given category.

Parameters:
framesetThe input set-of-frames (to be upgraded)
imageThe image to save
categoryThe category of the image to save
headerHeader to input to cpl_dfs_setup_product_header()
parlistThe recipe parameter list
recipenameThe name of the recipe
versionThe version of the pipeline
Returns:
0 in case of success.

This function is just a wrapper to the basic CPL functions that are routinely called every time an image product must be saved to disk by a recipe. Error checking and proper messaging are also included here, to give a more readable look to the main recipe code.

The output file name will be derived from the specified category by lowercasing it and by appending the suffix ".fits". The new image is properly logged in the input set-of-frames in case of success.

The error codes that are set in this case are the same set by the above mentioned CPL functions. The "where" string (accessible via a call to cpl_error_get_where() ) is not modified by this function, and therefore the function where the failure occurred is also reported.

Definition at line 1323 of file fors_dfs.c.

Referenced by fors_img_science(), fors_zeropoint(), and vimos_calib_impl().

int dfs_save_table ( cpl_frameset *  frameset,
const cpl_table *  table,
const char *  category,
cpl_propertylist *  header,
const cpl_parameterlist *  parlist,
const char *  recipename,
const char *  version 
)

Saving table data of given category.

Parameters:
framesetThe input set-of-frames (to be upgraded)
tableThe table to save
categoryThe category of the table to save
headerHeader to input to cpl_dfs_setup_product_header()
parlistThe recipe parameter list
recipenameThe name of the recipe
versionThe version of the pipeline
Returns:
0 in case of success.

This function is just a wrapper to the basic CPL functions that are routinely called every time a table product must be saved to disk by a recipe. Error checking and proper messaging are also included here, to give a more readable look to the main recipe code.

The output file name will be derived from the specified category by lowercasing it and by appending the suffix ".fits". The new table is properly logged in the input set-of-frames in case of success.

The error codes that are set in this case are the same set by the above mentioned CPL functions. The "where" string (accessible via a call to cpl_error_get_where() ) is not modified by this function, and therefore the function where the failure occurred is also reported.

Definition at line 1458 of file fors_dfs.c.

Referenced by vimos_calib_impl().

int dfs_files_dont_exist ( cpl_frameset *  frameset)

Check if all SOF files exist.

Parameters:
framesetThe input set-of-frames
Returns:
1 if not all files exist, 0 if they all exist.

Definition at line 1577 of file fors_dfs.c.

Referenced by vimos_calib_impl().

int dfs_equal_keyword ( cpl_frameset *  frameset,
const char *  keyword 
)

Saving table data of given category.

Parameters:
framesetThe input set-of-frames
keywordThe keyword that should be identical in all frames
Returns:
1 if consistent, 0 if inconsistent

The specified FITS header keyword should be identical in all the input frames. Only the FITS primary header is examined. If keyword is missing this is considered a case of identical keywords. Only integer and string keywords are compared: in case of other types 0 is always returned. If a file is not FITS, it is ignored.

Definition at line 1629 of file fors_dfs.c.

Referenced by vimos_calib_impl().

cpl_error_code dfs_save_table_ext ( cpl_table *  table,
const char *  tag,
cpl_propertylist *  extheader 
)

Save a table in a extension (different from the first one)

Parameters:
tableTable to save
tagPRO.CATG of the table
extheaderHeader for the extension or NULL
Returns:
CPL_ERROR_NONE of corresponding cpl_error_code on error.

Definition at line 1757 of file fors_dfs.c.

cpl_error_code dfs_save_image_ext ( cpl_image *  image,
const char *  tag,
cpl_propertylist *  extheader 
)

Save an image in a extension.

Parameters:
imageImage to save
tagPRO.CATG of the image
extheaderHeader for the extension or NULL
Returns:
CPL_ERROR_NONE of corresponding cpl_error_code on error.

Definition at line 1796 of file fors_dfs.c.

cpl_error_code dfs_save_image_null ( cpl_frameset *  frameset,
cpl_parameterlist *  parlist,
const char *  tag,
const char *  recipename,
const char *  version 
)

Save a product with an empty primary extension.

Parameters:
framesetFrameset
parlistParlist
tagPRO.CATG of the product
recipenameName of the recipe
versionVersion
Returns:
CPL_ERROR_NONE of corresponding cpl_error_code on error.

Definition at line 1839 of file fors_dfs.c.