UVES Pipeline Reference Manual  5.4.6
Functions
Miscellaneous Utilities

Functions

void irplib_errorstate_dump_warning (unsigned self, unsigned first, unsigned last)
 Dump a single CPL error at the CPL warning level. More...
 
static cpl_polynomial * irplib_polynomial_fit_1d_create_common (const cpl_vector *x_pos, const cpl_vector *values, int degree, double *mse, double *rechisq)
 
void irplib_errorstate_dump_info (unsigned self, unsigned first, unsigned last)
 Dump a single CPL error at the CPL info level. More...
 
void irplib_errorstate_dump_debug (unsigned self, unsigned first, unsigned last)
 Dump a single CPL error at the CPL debug level. More...
 
cpl_error_code irplib_dfs_save_image (cpl_frameset *allframes, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_image *image, cpl_type_bpp bpp, const char *recipe, const char *procat, const cpl_propertylist *applist, const char *remregexp, const char *pipe_id, const char *filename)
 Save an image as a DFS-compliant pipeline product. More...
 
cpl_error_code irplib_dfs_save_propertylist (cpl_frameset *allframes, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const char *recipe, const char *procat, const cpl_propertylist *applist, const char *remregexp, const char *pipe_id, const char *filename)
 Save a propertylist as a DFS-compliant pipeline product. More...
 
cpl_error_code irplib_dfs_save_imagelist (cpl_frameset *allframes, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_imagelist *imagelist, cpl_type_bpp bpp, const char *recipe, const char *procat, const cpl_propertylist *applist, const char *remregexp, const char *pipe_id, const char *filename)
 Save an imagelist as a DFS-compliant pipeline product. More...
 
cpl_error_code irplib_dfs_save_table (cpl_frameset *allframes, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_table *table, const cpl_propertylist *tablelist, const char *recipe, const char *procat, const cpl_propertylist *applist, const char *remregexp, const char *pipe_id, const char *filename)
 Save a table as a DFS-compliant pipeline product. More...
 
cpl_error_code irplib_dfs_save_image_ (cpl_frameset *allframes, cpl_propertylist *header, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_frame *inherit, const cpl_image *image, cpl_type type, const char *recipe, const cpl_propertylist *applist, const char *remregexp, const char *pipe_id, const char *filename)
 Save an image as a DFS-compliant pipeline product. More...
 
static cpl_error_code irplib_dfs_product_save (cpl_frameset *allframes, cpl_propertylist *header, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_frame *inherit, const cpl_imagelist *imagelist, const cpl_image *image, cpl_type type, const cpl_table *table, const cpl_propertylist *tablelist, const char *recipe, const cpl_propertylist *applist, const char *remregexp, const char *pipe_id, const char *filename)
 Save either an image or table as a pipeline product. More...
 
cpl_error_code irplib_image_split (const cpl_image *self, cpl_image *im_low, cpl_image *im_mid, cpl_image *im_high, double th_low, cpl_boolean isleq_low, double th_high, cpl_boolean isgeq_high, double alt_low, double alt_high, cpl_boolean isbad_low, cpl_boolean isbad_mid, cpl_boolean isbad_high)
 Split the values in an image in three according to two thresholds. More...
 
cpl_error_code irplib_dfs_table_convert (cpl_table *self, cpl_frameset *allframes, const cpl_frameset *useframes, int maxlinelen, char commentchar, const char *product_name, const char *procatg, const cpl_parameterlist *parlist, const char *recipe_name, const cpl_propertylist *mainlist, const cpl_propertylist *extlist, const char *remregexp, const char *instrume, const char *pipe_id, cpl_boolean(*table_set_row)(cpl_table *, const char *, int, const cpl_frame *, const cpl_parameterlist *), cpl_error_code(*table_check)(cpl_table *, const cpl_frameset *, const cpl_parameterlist *))
 Create a DFS product with one table from one or more (ASCII) file(s) More...
 
cpl_error_code irplib_table_read_from_frameset (cpl_table *self, const cpl_frameset *useframes, int maxlinelen, char commentchar, const cpl_parameterlist *parlist, cpl_boolean(*table_set_row)(cpl_table *, const char *, int, const cpl_frame *, const cpl_parameterlist *))
 Set the rows of a table with data from one or more (ASCII) files. More...
 
void irplib_reset (void)
 Reset IRPLIB state. More...
 
int irplib_compare_tags (cpl_frame *frame1, cpl_frame *frame2)
 Comparison function to identify different input frames. More...
 
const char * irplib_frameset_find_file (const cpl_frameset *self, const char *tag)
 Find the filename with the given tag in a frame set. More...
 
const cpl_frame * irplib_frameset_get_first_from_group (const cpl_frameset *self, cpl_frame_group group)
 Find the first frame belonging to the given group. More...
 
cpl_error_code irplib_apertures_find_max_flux (const cpl_apertures *self, int *ind, int nfind)
 Find the aperture(s) with the greatest flux. More...
 

Detailed Description

Function Documentation

void irplib_errorstate_dump_warning ( unsigned  self,
unsigned  first,
unsigned  last 
)

Dump a single CPL error at the CPL warning level.

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
Returns
void
See Also
cpl_errorstate_dump_one

FIXME: Move this function to the CPL errorstate module.

Definition at line 113 of file irplib_utils.c.

void irplib_errorstate_dump_info ( unsigned  self,
unsigned  first,
unsigned  last 
)

Dump a single CPL error at the CPL info level.

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
Returns
void
See Also
cpl_errorstate_dump_one

Definition at line 140 of file irplib_utils.c.

void irplib_errorstate_dump_debug ( unsigned  self,
unsigned  first,
unsigned  last 
)

Dump a single CPL error at the CPL debug level.

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
Returns
void
See Also
cpl_errorstate_dump_one

Definition at line 160 of file irplib_utils.c.

Referenced by irplib_polynomial_find_1d_from_correlation_all(), and irplib_vector_fill_line_spectrum_model().

cpl_error_code irplib_dfs_save_image ( cpl_frameset *  allframes,
const cpl_parameterlist *  parlist,
const cpl_frameset *  usedframes,
const cpl_image *  image,
cpl_type_bpp  bpp,
const char *  recipe,
const char *  procat,
const cpl_propertylist *  applist,
const char *  remregexp,
const char *  pipe_id,
const char *  filename 
)

Save an image as a DFS-compliant pipeline product.

Parameters
allframesThe list of input frames for the recipe
parlistThe list of input parameters
usedframesThe list of raw/calibration frames used for this product
imageThe image to be saved
bppBits per pixel
recipeThe recipe name
procatThe product category tag
applistOptional propertylist to append to primary header or NULL
remregexpOptional regexp of properties not to put in main header
pipe_idPACKAGE "/" PACKAGE_VERSION
filenameFilename of created product
Note
The image may be NULL in which case only the header information is saved but passing a NULL image is deprecated, use cpl_dfs_save_propertylist().
remregexp may be NULL
Returns
CPL_ERROR_NONE or the relevant CPL error code on error
See Also
cpl_dfs_save_image().

Definition at line 191 of file irplib_utils.c.

References irplib_dfs_save_image_().

cpl_error_code irplib_dfs_save_propertylist ( cpl_frameset *  allframes,
const cpl_parameterlist *  parlist,
const cpl_frameset *  usedframes,
const char *  recipe,
const char *  procat,
const cpl_propertylist *  applist,
const char *  remregexp,
const char *  pipe_id,
const char *  filename 
)

Save a propertylist as a DFS-compliant pipeline product.

Parameters
allframesThe list of input frames for the recipe
parlistThe list of input parameters
usedframesThe list of raw/calibration frames used for this product
recipeThe recipe name
procatThe product category tag
applistOptional propertylist to append to primary header or NULL
remregexpOptional regexp of properties not to put in main header
pipe_idPACKAGE "/" PACKAGE_VERSION
filenameFilename of created product
Note
remregexp may be NULL
Returns
CPL_ERROR_NONE or the relevant CPL error code on error
See Also
cpl_dfs_save_propertylist().

Definition at line 239 of file irplib_utils.c.

cpl_error_code irplib_dfs_save_imagelist ( cpl_frameset *  allframes,
const cpl_parameterlist *  parlist,
const cpl_frameset *  usedframes,
const cpl_imagelist *  imagelist,
cpl_type_bpp  bpp,
const char *  recipe,
const char *  procat,
const cpl_propertylist *  applist,
const char *  remregexp,
const char *  pipe_id,
const char *  filename 
)

Save an imagelist as a DFS-compliant pipeline product.

Parameters
allframesThe list of input frames for the recipe
parlistThe list of input parameters
usedframesThe list of raw/calibration frames used for this product
imagelistThe imagelist to be saved
bppBits per pixel
recipeThe recipe name
procatThe product category tag
applistOptional propertylist to append to primary header or NULL
remregexpOptional regexp of properties not to put in main header
pipe_idPACKAGE "/" PACKAGE_VERSION
filenameFilename of created product
Note
remregexp may be NULL
Returns
CPL_ERROR_NONE or the relevant CPL error code on error
See Also
cpl_dfs_save_imagelist().

Definition at line 286 of file irplib_utils.c.

cpl_error_code irplib_dfs_save_table ( cpl_frameset *  allframes,
const cpl_parameterlist *  parlist,
const cpl_frameset *  usedframes,
const cpl_table *  table,
const cpl_propertylist *  tablelist,
const char *  recipe,
const char *  procat,
const cpl_propertylist *  applist,
const char *  remregexp,
const char *  pipe_id,
const char *  filename 
)

Save a table as a DFS-compliant pipeline product.

Parameters
allframesThe list of input frames for the recipe
parlistThe list of input parameters
usedframesThe list of raw/calibration frames used for this product
tableThe table to be saved
tablelistOptional propertylist to use in table extension or NULL
recipeThe recipe name
procatThe product category tag
applistOptional propertylist to append to primary header or NULL
remregexpOptional regexp of properties not to put in main header
pipe_idPACKAGE "/" PACKAGE_VERSION
filenameFilename of created product
Returns
CPL_ERROR_NONE or the relevant CPL error code on error
See Also
cpl_dfs_save_table().

Definition at line 334 of file irplib_utils.c.

Referenced by irplib_dfs_table_convert().

cpl_error_code irplib_dfs_save_image_ ( cpl_frameset *  allframes,
cpl_propertylist *  header,
const cpl_parameterlist *  parlist,
const cpl_frameset *  usedframes,
const cpl_frame *  inherit,
const cpl_image *  image,
cpl_type  type,
const char *  recipe,
const cpl_propertylist *  applist,
const char *  remregexp,
const char *  pipe_id,
const char *  filename 
)

Save an image as a DFS-compliant pipeline product.

Parameters
allframesThe list of input frames for the recipe
headerNULL, or filled with properties written to product header
parlistThe list of input parameters
usedframesThe list of raw/calibration frames used for this product
inheritNULL or product frames inherit their header from this frame
imageThe image to be saved
typeThe type used to represent the data in the file
recipeThe recipe name
applistPropertylist to append to primary header, w. PRO.CATG
remregexpOptional regexp of properties not to put in main header
pipe_idPACKAGE "/" PACKAGE_VERSION
filenameFilename of created product
Note
The image may be NULL in which case only the header information is saved but passing a NULL image is deprecated, use cpl_dfs_save_propertylist().
remregexp may be NULL
applist must contain a string-property with key CPL_DFS_PRO_CATG
On success and iff header is non-NULL, it will be emptied and then filled with the properties written to the primary header of the product
Returns
CPL_ERROR_NONE or the relevant CPL error code on error
See Also
cpl_dfs_save_image()
Note
applist is copied with cpl_propertylist_copy_property_regexp() instead pf cpl_propertylist_append()

Definition at line 394 of file irplib_utils.c.

References irplib_dfs_product_save().

Referenced by irplib_dfs_save_image().

static cpl_error_code irplib_dfs_product_save ( cpl_frameset *  allframes,
cpl_propertylist *  header,
const cpl_parameterlist *  parlist,
const cpl_frameset *  usedframes,
const cpl_frame *  inherit,
const cpl_imagelist *  imagelist,
const cpl_image *  image,
cpl_type  type,
const cpl_table *  table,
const cpl_propertylist *  tablelist,
const char *  recipe,
const cpl_propertylist *  applist,
const char *  remregexp,
const char *  pipe_id,
const char *  filename 
)
static

Save either an image or table as a pipeline product.

Parameters
allframesThe list of input frames for the recipe
headerNULL, or filled with properties written to product header
parlistThe list of input parameters
usedframesThe list of raw/calibration frames used for this product
inheritNULL, or frame from which header information is inherited
imagelistThe imagelist to be saved or NULL
imageThe image to be saved or NULL
typeThe type used to represent the data in the file
tableThe table to be saved or NULL
tablelistOptional propertylist to use in table extension or NULL
recipeThe recipe name
applistOptional propertylist to append to main header or NULL
remregexpOptional regexp of properties not to put in main header
pipe_idPACKAGE "/" PACKAGE_VERSION
filenameFilename of created product
Returns
CPL_ERROR_NONE or the relevant CPL error code on error
See Also
cpl_dfs_product_save()
Note
applist is copied with cpl_propertylist_copy_property_regexp() instead pf cpl_propertylist_append()

Definition at line 443 of file irplib_utils.c.

Referenced by irplib_dfs_save_image_().

cpl_error_code irplib_image_split ( const cpl_image *  self,
cpl_image *  im_low,
cpl_image *  im_mid,
cpl_image *  im_high,
double  th_low,
cpl_boolean  isleq_low,
double  th_high,
cpl_boolean  isgeq_high,
double  alt_low,
double  alt_high,
cpl_boolean  isbad_low,
cpl_boolean  isbad_mid,
cpl_boolean  isbad_high 
)

Split the values in an image in three according to two thresholds.

Parameters
selfThe image to split
im_lowIf non-NULL low-valued pixels are assigned to this image
im_midIf non-NULL middle-valued pixels are assigned to this image
im_highIf non-NULL high-valued pixels are assigned to this image
th_lowThe lower threshold
isleq_lowIft true use less than or equal
th_highThe upper threshold, must be at least th_low
isgeq_highIff true use greater than or equal
alt_lowAssign this value when the pixel value is not low
alt_highAssign this value, when the pixel value is not high
isbad_lowFlag non-low pixels as bad
isbad_midFlag non-mid pixels as bad
isbad_highFlag non-high pixels as bad
Returns
CPL_ERROR_NONE or the relevant CPL error code on error
Note
At least one output image must be non-NULL; all non-NULL images must be of identical size, but may be of any pixel-type. self may be passed as one of the output images for an in-place split.

FIXME: This function is way too slow and perhaps over-engineered...

A split in two is achieved with th_low equal th_high (in this case there is little reason for im_mid to be non-NULL).

All pixel values in the output images are reset, as well as their bad pixels maps.

If an input pixel-value is flagged as bad, then the receiving pixel in the output image is flagged as well.

The same image may be passed more than once which allows a split
into one image with the mid-valued pixels and another with both the low and high-valued pixels, i.e.
irplib_image_split(source, dest, im_mid, dest,
th_low, isleq_low, th_high, isgeq_high,
alt_low, alt_high,
isbad_low, isbad_mid, isbad_high);
These two calls are equivalent:
cpl_image_threshold(img, th_low, th_high, alt_low, alt_high);
irplib_image_split(img, NULL, img, NULL,
th_low, CPL_TRUE, th_high, CPL_TRUE,
alt_low, alt_high, dontcare, CPL_FALSE, dontcare);

Definition at line 648 of file irplib_utils.c.

cpl_error_code irplib_dfs_table_convert ( cpl_table *  self,
cpl_frameset *  allframes,
const cpl_frameset *  useframes,
int  maxlinelen,
char  commentchar,
const char *  product_name,
const char *  procatg,
const cpl_parameterlist *  parlist,
const char *  recipe_name,
const cpl_propertylist *  mainlist,
const cpl_propertylist *  extlist,
const char *  remregexp,
const char *  instrume,
const char *  pipe_id,
cpl_boolean(*)(cpl_table *, const char *, int, const cpl_frame *, const cpl_parameterlist *)  table_set_row,
cpl_error_code(*)(cpl_table *, const cpl_frameset *, const cpl_parameterlist *)  table_check 
)

Create a DFS product with one table from one or more (ASCII) file(s)

Parameters
selfTable with labels (and units) but no row data
allframesThe list of input frames for the recipe
useframesThe frames to process for the product
maxlinelenThe maximum line length in the input file(s)
commentcharSkip lines that start with this character, e.g. '#'
product_nameThe name of the created FITS table product or NULL
procatgThe PROCATG of the created FITS table product
parlistThe list of input parameters
recipe_nameThe name of the calling recipe
mainlistOptional propertylist to append to main header or NULL
extlistOptional propertylist to append to ext. header or NULL
remregexpOptional regexp of properties not to put in main header
instrumeThe value to use for the INSTRUME key, uppercase PACKAGE
pipe_idPACKAGE "/" PACKAGE_VERSION
table_set_rowCaller-defined function to insert one row in the table
table_checkOptional caller-defined function to check table or NULL
Returns
CPL_ERROR_NONE or the relevant CPL error code on error
See Also
irplib_table_read_from_frameset(), cpl_dfs_save_table()
Note
If product_name is NULL, the product will be named <recipe_name>.fits.
Example (error handling omitted for brevity):
extern cpl_boolean my_table_set_row(cpl_table *, const char *, int,
const cpl_frame *,
const cpl_parameterlist *);
extern cpl_error_code my_table_check(cpl_table *,
const cpl_frameset *,
const cpl_parameterlist *);
const int expected_rows = 42;
cpl_table * self = cpl_table_new(expected_rows);
cpl_table_new_column(self, "MYLABEL1", CPL_TYPE_STRING);
cpl_table_new_column(self, "MYLABEL2", CPL_TYPE_DOUBLE);
cpl_table_set_column_unit(self, "MYLABEL2", "Some_SI_Unit");
irplib_dfs_table_convert(self, allframes, useframes, 1024, '#', NULL,
"MYPROCATG", parlist, "myrecipe", NULL, NULL,
NULL, "MYINSTRUME", PACKAGE "/" PACKAGE_VERSION,
my_table_set_row, my_table_check);
cpl_table_delete(self);

Definition at line 843 of file irplib_utils.c.

References irplib_dfs_save_table(), and irplib_table_read_from_frameset().

cpl_error_code irplib_table_read_from_frameset ( cpl_table *  self,
const cpl_frameset *  useframes,
int  maxlinelen,
char  commentchar,
const cpl_parameterlist *  parlist,
cpl_boolean(*)(cpl_table *, const char *, int, const cpl_frame *, const cpl_parameterlist *)  table_set_row 
)

Set the rows of a table with data from one or more (ASCII) files.

Parameters
selfTable with labels (and units) but no row data
useframesThe frames to process for the table
maxlinelenThe maximum line length in the input file(s)
commentcharSkip lines that start with this character, e.g. '#'
parlistThe list of input parameters
table_set_rowCaller-defined function to insert one row in the table
Returns
CPL_ERROR_NONE or the relevant CPL error code on error

table_set_row() is a function that sets the specified row in a table

  • it may optionally include a check of the line for consistency. An integer is passed to table_set_row() to indicate which row to set. Instead of setting the row table_set_row() may decide to discard the data. Iff the row was set, table_set_row() should return CPL_TRUE.

It needs to know: 1) How to parse the lines - each line is read with fgets(). 2) For each column: type/format (lg/s/d) + label

During a successful call self will have rows added or removed to exactly match the number of lines converted. Any a priori knowledge about the expected number of converted rows can be used in the creation of the table (to reduce memory reallocation overhead). On error the number of rows in self is undefined.

Example (error handling omitted for brevity):
extern cpl_boolean my_table_set_row(cpl_table *, const char *, int,
const cpl_frame *,
const cpl_parameterlist *);
const int expected_rows = 42;
cpl_table * self = cpl_table_new(expected_rows);
cpl_table_new_column(self, "MYLABEL1", CPL_TYPE_STRING);
cpl_table_new_column(self, "MYLABEL2", CPL_TYPE_DOUBLE);
cpl_table_set_column_unit(self, "MYLABEL2", "Some_SI_Unit");
irplib_table_read_from_frameset(self, useframes, 1024, '#', parlist,
my_table_set_row);
// Use self...
cpl_table_delete(self);

Definition at line 972 of file irplib_utils.c.

Referenced by irplib_dfs_table_convert().

void irplib_reset ( void  )

Reset IRPLIB state.

This function resets all static memory used by IRPLIB to a well-defined, initial state.

The function should be called (during initialization) by any application using static memory facilities in IRPLIB.

Currently, this function does nothing.

Definition at line 1119 of file irplib_utils.c.

Referenced by flames_utl_unpack_create(), flames_utl_unpack_exec(), uves_utl_ima_arith_create(), uves_utl_ima_arith_exec(), uves_utl_physmod_create(), uves_utl_physmod_exec(), uves_utl_rcosmic_create(), uves_utl_rcosmic_exec(), uves_utl_remove_crh_single_create(), and uves_utl_remove_crh_single_exec().

int irplib_compare_tags ( cpl_frame *  frame1,
cpl_frame *  frame2 
)

Comparison function to identify different input frames.

Parameters
frame1first frame
frame2second frame
Returns
0 if frame1!=frame2, 1 if frame1==frame2, -1 in error case

Definition at line 1132 of file irplib_utils.c.

const char* irplib_frameset_find_file ( const cpl_frameset *  self,
const char *  tag 
)

Find the filename with the given tag in a frame set.

Parameters
selfA frame set.
tagThe frame tag to search for.
Returns
The filename or NULL if none found and on error.
See Also
cpl_frameset_find
Note
If called with a CPL error code, the location will be updated and NULL returned.

NULL is returned and no error code set if the tag is not found.

If the file is not unique, the name of the first one is returned and with a warning.

Definition at line 1168 of file irplib_utils.c.

const cpl_frame* irplib_frameset_get_first_from_group ( const cpl_frameset *  self,
cpl_frame_group  group 
)

Find the first frame belonging to the given group.

Parameters
selfThe frameset
groupThe group attribute
Returns
The first frame belonging to the given group, or NULL if no such frame was found. The function returns NULL if an error occurs and sets the appropriate error code.

Definition at line 1199 of file irplib_utils.c.

cpl_error_code irplib_apertures_find_max_flux ( const cpl_apertures *  self,
int *  ind,
int  nfind 
)

Find the aperture(s) with the greatest flux.

Parameters
selfThe aperture object
indThe aperture-indices in order of decreasing flux
nfindNumber of indices to find
Returns
CPL_ERROR_NONE or the relevant cpl_error_code on error

nfind must be at least 1 and at most the size of the aperture object.

The ind array must be able to hold (at least) nfind integers. On success the first nfind elements of ind point to indices of the aperture object.

To find the single ind of the aperture with the maximum flux use simply: int ind; irplib_apertures_find_max_flux(self, &ind, 1);

Definition at line 1236 of file irplib_utils.c.