Miscellaneous Utilities


Functions

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).
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.
void irplib_reset (void)
 Reset IRPLIB state.
int irplib_compare_tags (cpl_frame *frame1, cpl_frame *frame2)
 Comparison function to identify different input frames.
const char * irplib_frameset_find_file (const cpl_frameset *self, const char *tag)
 Find the filename with the given tag in a frame set.
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.
cpl_error_code irplib_apertures_find_max_flux (const cpl_apertures *self, int *ind, int nfind)
 Find the aperture(s) with the greatest flux.
int irplib_isinf (double value)
 portable isinf
int irplib_isnan (double value)
 portable isnan
void irplib_errorstate_warning (unsigned self, unsigned first, unsigned last)
 Dump a single CPL error.

Function Documentation

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:
self Table with labels (and units) but no row data
allframes The list of input frames for the recipe
useframes The frames to process for the product
maxlinelen The maximum line length in the input file(s)
commentchar Skip lines that start with this character, e.g. '#'
product_name The name of the created FITS table product or NULL
procatg The PROCATG of the created FITS table product
parlist The list of input parameters
recipe_name The name of the calling recipe
mainlist Optional propertylist to append to main header or NULL
extlist Optional propertylist to append to ext. header or NULL
remregexp Optional regexp of properties not to put in main header
instrume The value to use for the INSTRUME key, uppercase PACKAGE
pipe_id PACKAGE "/" PACKAGE_VERSION
table_set_row Caller-defined function to insert one row in the table
table_check Optional 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 115 of file irplib_utils.c.

References 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:
self Table with labels (and units) but no row data
useframes The frames to process for the table
maxlinelen The maximum line length in the input file(s)
commentchar Skip lines that start with this character, e.g. '#'
parlist The list of input parameters
table_set_row Caller-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 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 succesful 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 243 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 367 of file irplib_utils.c.

Referenced by flames_utl_unpack_create(), and flames_utl_unpack_exec().

int irplib_compare_tags ( cpl_frame *  frame1,
cpl_frame *  frame2 
)

Comparison function to identify different input frames.

Parameters:
frame1 first frame
frame2 second frame
Returns:
0 if frame1!=frame2, 1 if frame1==frame2, -1 in error case

Definition at line 380 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:
self A frame set.
tag The 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 416 of file irplib_utils.c.

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:
self The frameset
group The 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 446 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:
self The aperture object
ind The aperture-indices in order of decreasing flux
nfind Number 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 480 of file irplib_utils.c.

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

Dump a single CPL error.

Parameters:
self The number of the current error to be dumped
first The number of the first error to be dumped
last The number of the last error to be dumped
Returns:
void
Note:
This function differs from cpl_errorstate_dump_one only in message level
See also:
cpl_errorstate_dump_one

Definition at line 561 of file irplib_utils.c.


Generated on Fri Apr 18 14:11:45 2008 for UVES Pipeline Reference Manual by  doxygen 1.5.1