OMEGA Pipeline Reference Manual  1.0.5
Functions
Utility Functions

Functions

FILE * oc_paf_print_header (char *filename, char *paf_id, char *paf_desc)
 Open a new PAF file, output a default header.
int omega_biascor (cpl_image *image, const cpl_image *bias)
 Subtract bias from an image.
int omega_compare_reference (const cpl_image *master, const cpl_frame *refframe, int ext, cpl_stats **diffstats)
int omega_compare_tags (const cpl_frame *frame1, const cpl_frame *frame2)
char * omega_create_name (const char *instrument, const char *name, const char *suffix)
 Create a string with a name.
void omega_exten_range (int inexten, int *out1, int *out2)
void omega_extensions (const cpl_frame *frame, int inexten, int *out1, int *out2)
cpl_frameset * omega_frameset_subgroup (cpl_frameset *frameset, cpl_size *labels, cpl_size nlab, const char *tag)
int omega_get_chip_orientation (int ext)
 Get the readout orientation of a chip based on the FITS extension number.
const char * omega_get_extension_chipid (int ext)
 Get the value of CHIP ID for a given extension.
const char * omega_get_license (void)
 Get the pipeline copyright and license.
char * omega_get_pathname (const char *filename)
 Find the directory name in the given string.
char * omega_get_root_name (const char *filename)
 Find out the root part of a basename (name without extension).
cpl_error_code omega_get_wcsshift (cpl_propertylist *wcslist1, cpl_propertylist *wcslist2, double *xshift, double *yshift)
 Compute the wcs shift in x and y direction.
cpl_frame * omega_product_frame (const char *filename, const char *tag, cpl_frame_type type)
 Setup a frame to save a product.
int omega_save_dummy (cpl_frameset *set, cpl_parameterlist *parlist, cpl_frame_type type, cpl_type_bpp bitpix, const char *outfile, const cpl_propertylist *plist, const char *recipe, cpl_frame *product_frame)
 Save a dummy image or table in an extension.
int omega_save_fits (omega_fits *scifits, cpl_frameset *set, const cpl_parameterlist *pars, const cpl_propertylist *qclist, cpl_type_bpp bpp, const char *name, const char *recipe, cpl_frame *product_frame, const cpl_frame *inherit, const int isfirst)
 Save an image which is taken from a omega_fits strucutre.
int omega_save_image (const cpl_image *img, cpl_frameset *set, const cpl_parameterlist *pars, cpl_propertylist *alist, const cpl_propertylist *qclist, cpl_type_bpp bpp, const char *name, const char *recipe, cpl_frame *frame, const cpl_frame *inherit, int isfirst)
 Save an image as a DFS compliant product.
int omega_save_primary (cpl_frameset *set, const cpl_parameterlist *parlist, const char *outfile, const char *recipe, const cpl_propertylist *plist, cpl_frame *product_frame, const cpl_frame *inherit)
 Save the primary header of a product.
int omega_save_table (const cpl_table *tbl, cpl_frameset *set, const cpl_parameterlist *pars, cpl_propertylist *alist, const cpl_propertylist *qclist, const char *name, const char *recipe, cpl_frame *frame, const cpl_frame *inherit, int isfirst)
 Save a table as a DFS compliant product.
cpl_image * omega_smooth_image (cpl_image *in, int size)
 Smooth an image using a median filter.

Detailed Description

Synopsis
Several utility functions to manipulate images or headers.
#include omega_utils.h
#include omega_dfs.h

Function Documentation

FILE* oc_paf_print_header ( char *  filename,
char *  paf_id,
char *  paf_desc 
)

Open a new PAF file, output a default header.

Parameters:
filenameName of the file to create.
paf_idPAF identificator.
paf_descPAF description.
Returns:
Opened file pointer.

This function creates a new PAF file with the requested file name. If another file already exists with the same name, it will be overwritten (if the file access rights allow it).

This function returns an opened file pointer, ready to receive more data through fprintf's. The caller is responsible for fclose()ing the file.

Definition at line 106 of file omega_utils.c.

int omega_biascor ( cpl_image *  image,
const cpl_image *  bias 
)

Subtract bias from an image.

Parameters:
imageImage to subtract bias brom
biasBias image
Returns:
0 on success or -1 in case of error

Definition at line 737 of file omega_utils.c.

Referenced by omega_fringes_flat_process(), omega_jitter_process(), omega_nsky_process(), and omega_std_process().

int omega_compare_reference ( const cpl_image *  master,
const cpl_frame *  refframe,
int  ext,
cpl_stats **  diffstats 
)
Name:
omega_reference_compare
Purpose:
Compare master frame with reference frame
Description:
Takes the difference between a master frame and a reference frame and calculates statistics of it.
Language:
C
Parameters:
masterInput master image
refframeReference frame
diffstatsstatistics of the difference
Returns:
0 if OK, -1 in error case.
Author:
Sandra Castro

Definition at line 404 of file omega_utils.c.

int omega_compare_tags ( const cpl_frame *  frame1,
const cpl_frame *  frame2 
)
Name:
omega_compare_tags
Purpose:
Comparison function to identify different input frames
Description:
The tags for two frames are compared to see whether they are the same. An error occurs if either frame is missing its tag.
Language:
C
Parameters:
frame1The first frame
frame2The second frame
Return values:
0if frame1 != frame2
1if frame1 == frame2
-1if either frame is missing its tag
Author:
Jim Lewis, CASU

Definition at line 206 of file omega_utils.c.

char* omega_create_name ( const char *  instrument,
const char *  name,
const char *  suffix 
)

Create a string with a name.

Parameters:
instrumentstring with instrument name
namemiddle part of the output name
suffixsuffix name or NULL in which case fits is used
Returns:
outname or NULL in case of error

It composes a string in the following way: instrument_name.suffix

Definition at line 711 of file omega_utils.c.

void omega_exten_range ( int  inexten,
int *  out1,
int *  out2 
)
Name:
omega_exten_range
Purpose:
Define the range of image extensions to use
Description:
If the input extension specified is -1, then all the extensions in a OmegaCAM MEF should be done. If not, then just the extension specified should be done. 0 means that there are no extensions.
Language:
C
Parameters:
inextenInput image extension from the recipe invocation
out1Lower part of extension range
out2Upper part of extension range
Returns:
Nothing
Author:
Jim Lewis, CASU

Definition at line 305 of file omega_utils.c.

void omega_extensions ( const cpl_frame *  frame,
int  inexten,
int *  out1,
int *  out2 
)
Name:
omega_extensions
Purpose:
Define the range of image extensions to use
Description:
If the input extension specified is -1, then all the 32 extensions in a OmegaCAM MEF should be done. If not, then just the extension specified should be done. 0 means that there are no extensions.
Language:
C
Parameters:
frameFrame
inextenInput image extension from the recipe invocation
out1Lower part of extension range
out2Upper part of extension range
Returns:
Nothing
Author:
Jim Lewis, CASU

Definition at line 348 of file omega_utils.c.

cpl_frameset* omega_frameset_subgroup ( cpl_frameset *  frameset,
cpl_size *  labels,
cpl_size  nlab,
const char *  tag 
)
Name:
omega_frameset_subgroup
Purpose:
Extract a frameset of a given label from a master frameset
Description:
For each label in an input frameset a frameset with that label is extracted. The tag for the first frame in the extracted set is compared to an input tag. If they match, then the extracted frameset is returned. If none of the frames match the input tag then a NULL frameset is returned
Language:
C
Parameters:
framesetThe input frameset
labelsThe labels for the input frameset
nlabThe number of labels for the input frameset
tagThe tag for the frames in the output frameset
Returns:
The set of all frames matching input tag or NULL if none match
Author:
Jim Lewis, CASU

Definition at line 257 of file omega_utils.c.

int omega_get_chip_orientation ( int  ext)

Get the readout orientation of a chip based on the FITS extension number.

Parameters:
extFITS extension
Returns:
The orientation number, 1 or 2.

Definition at line 882 of file omega_utils.c.

Referenced by get_trim_region(), and omega_get_trim_region().

const char* omega_get_extension_chipid ( int  ext)

Get the value of CHIP ID for a given extension.

Parameters:
extFITS extension for the particular CHIP
Returns:
The name stored in the keyword HIERARCH ESO DET CHIP# ID of OmegaCAM images or NULL in case of error.

Definition at line 762 of file omega_utils.c.

const char* omega_get_license ( void  )

Get the pipeline copyright and license.

Returns:
The copyright and license string

The function returns a pointer to the statically allocated license string. This string should not be modified using the returned pointer.

Definition at line 67 of file omega_utils.c.

Referenced by cpl_plugin_get_info().

char* omega_get_pathname ( const char *  filename)

Find the directory name in the given string.

Parameters:
filenameFull path name to scan.
Returns:
Pointer to statically allocated string.

Provide a full path name and you get in return a pointer to a statically allocated string containing the name of the directory only, without trailing slash. If the input string does not contain a slash (i.e. it is not a full path), the returned string is '.', corresponding to the current working directory. Since the returned string is statically allocated, do not try to free it or modify it.

This function does not check for the existence of the path or the file.

Examples:

    omega_get_pathname("/cdrom/data/image.fits") returns "/cdrom/data"
    omega_get_pathname("filename.fits") returns "."

Definition at line 457 of file omega_utils.c.

Referenced by omega_get_usnoa_table().

char* omega_get_root_name ( const char *  filename)

Find out the root part of a basename (name without extension).

Parameters:
filenameFile name to scan.
Returns:
Pointer to statically allocated string.

Find out the root part of a file name, i.e. the file name without extension. Since in Unix a file name can have several dots, only a number of extensions are supported. This includes:

  • .fits and .FITS
  • .tfits and .TFITS
  • .paf and .PAF
  • .ascii and .ASCII
  • .dat and .DAT
  • .txt and .TXT

This function does not check for the existence of the path or the file.

Examples:

    omega_get_root_name("/cdrom/filename.fits") returns "/cdrom/filename"
    omega_get_root_name("filename.paf") returns "filename"
    omega_get_root_name("filename") returns "filename"
    omega_get_root_name("filename.ext") returns "filename.ext"

Since the returned string is statically allocated in this module, do not try to free it or modify its contents.

Note: hacked from qfits.

Definition at line 158 of file omega_utils.c.

Referenced by omega_darkcurrent_save().

cpl_error_code omega_get_wcsshift ( cpl_propertylist *  wcslist1,
cpl_propertylist *  wcslist2,
double *  xshift,
double *  yshift 
)

Compute the wcs shift in x and y direction.

Parameters:
wcslist1Propertylist containg the wcs informations.
wcslist2Propertylist containg the wcs informations.
xshiftPointer where the shift in x direction is written
yshiftPointer where the shift in y direction is written.
Returns:
An appropriate error code if failing.

Definition at line 1157 of file omega_utils.c.

Referenced by omega_std_process().

cpl_frame* omega_product_frame ( const char *  filename,
const char *  tag,
cpl_frame_type  type 
)

Setup a frame to save a product.

Parameters:
filenameName of product tag PRO CATG tag of product type Type of product (image or table)
Returns:
Pointer to product frame.

Definition at line 499 of file omega_utils.c.

int omega_save_dummy ( cpl_frameset *  set,
cpl_parameterlist *  parlist,
cpl_frame_type  type,
cpl_type_bpp  bitpix,
const char *  outfile,
const cpl_propertylist *  plist,
const char *  recipe,
cpl_frame *  product_frame 
)

Save a dummy image or table in an extension.

Parameters:
setframeset
parlistParameter list
typeType of product
bitpixBITPIX
outfilename of output file
plistextension property list
reciperecipe name
product_frameproduct frame
Returns:
0 in success of -1 in case of error.

Definition at line 533 of file omega_utils.c.

int omega_save_fits ( omega_fits *  scifits,
cpl_frameset *  set,
const cpl_parameterlist *  pars,
const cpl_propertylist *  qclist,
cpl_type_bpp  bpp,
const char *  name,
const char *  recipe,
cpl_frame *  product_frame,
const cpl_frame *  inherit,
const int  isfirst 
)

Save an image which is taken from a omega_fits strucutre.

Parameters:
scifitsomega_fits structure containing the image to save
setoriginal set of frames
parsoriginal parameters list
qclistQC property list or NULL
bppCPL_TYPE_BPP to save product
nameoutput name of product
reciperecipe name
product_frameoutput frame of product
inheritoptional frame to inherit header from
isfirstTells whether to create primary header or not
Returns:
status 0 on success or -1 in case of error

Definition at line 1056 of file omega_utils.c.

References omega_fits_get_ehu(), omega_fits_get_image(), omega_fits_get_phu(), and omega_save_primary().

int omega_save_image ( const cpl_image *  img,
cpl_frameset *  set,
const cpl_parameterlist *  pars,
cpl_propertylist *  alist,
const cpl_propertylist *  qclist,
cpl_type_bpp  bpp,
const char *  name,
const char *  recipe,
cpl_frame *  frame,
const cpl_frame *  inherit,
int  isfirst 
)

Save an image as a DFS compliant product.

Parameters:
imgImage to save
setFrame set
parsParameters list
alistOptional property list
qclistOptional QC list
bppCPL_TYPE_BPP of product
nameName of product
recipeName of recipe
frameFrame describing product
inheritFrame to inherit header from or NULL
isfirstTell whether to create a primary header or not.
Returns:
0 on success or -1 in case of error.

Definition at line 916 of file omega_utils.c.

References omega_pfits_update_header(), and omega_save_primary().

int omega_save_primary ( cpl_frameset *  set,
const cpl_parameterlist *  parlist,
const char *  outfile,
const char *  recipe,
const cpl_propertylist *  plist,
cpl_frame *  product_frame,
const cpl_frame *  inherit 
)

Save the primary header of a product.

Parameters:
setframeset
parlistParameter list
outfilename of output file
reciperecipe name
plistprimary header or NULL
product_frameproduct frame
inheritFrame to inherit header from or NULL
Returns:
0 in success of -1 in case of error.

Definition at line 601 of file omega_utils.c.

Referenced by omega_save_fits(), omega_save_image(), and omega_save_table().

int omega_save_table ( const cpl_table *  tbl,
cpl_frameset *  set,
const cpl_parameterlist *  pars,
cpl_propertylist *  alist,
const cpl_propertylist *  qclist,
const char *  name,
const char *  recipe,
cpl_frame *  frame,
const cpl_frame *  inherit,
int  isfirst 
)

Save a table as a DFS compliant product.

Parameters:
tblTable to save
setSet of frames
parsParameters list
alistOptional property list
qclistOptional QC list
nameName of product
recipeName of recipe
frameFrame describing the product
inheritFrame to inherit header from or NULL
isfirstTell whether to create a primary header or not.
Returns:
0 on success or -1 in case of error.

Definition at line 987 of file omega_utils.c.

References omega_pfits_update_header(), and omega_save_primary().

cpl_image* omega_smooth_image ( cpl_image *  in,
int  size 
)

Smooth an image using a median filter.

Parameters:
inimage to be smoothed
sizesize of kernel matrix to use in filtering
Returns:
out smoothed image

Definition at line 648 of file omega_utils.c.

Referenced by omega_jitter_process(), and omega_std_process().