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:
filename Name of the file to create.
paf_id PAF identificator.
paf_desc PAF 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:
image Image to subtract bias brom
bias Bias image
Returns:
0 on success or -1 in case of error

Definition at line 726 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:
master Input master image
refframe Reference frame
diffstats statistics of the difference
Returns:
0 if OK, -1 in error case.
Author:
Sandra Castro

Definition at line 393 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:
frame1 The first frame
frame2 The second frame
Return values:
0 if frame1 != frame2
1 if frame1 == frame2
-1 if 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:
instrument string with instrument name
name middle part of the output name
suffix suffix 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 700 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:
inexten Input image extension from the recipe invocation
out1 Lower part of extension range
out2 Upper 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 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:
frame Frame
inexten Input image extension from the recipe invocation
out1 Lower part of extension range
out2 Upper 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:
frameset The input frameset
labels The labels for the input frameset
nlab The number of labels for the input frameset
tag The 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:
ext FITS extension
Returns:
The orientation number, 1 or 2.

Definition at line 871 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:
ext FITS 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 751 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:
filename Full 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 446 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:
filename File 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:
wcslist1 Propertylist containg the wcs informations.
wcslist2 Propertylist containg the wcs informations.
xshift Pointer where the shift in x direction is written
yshift Pointer where the shift in y direction is written.
Returns:
An appropriate error code if failing.

Definition at line 1146 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:
filename Name of product tag PRO CATG tag of product type Type of product (image or table)
Returns:
Pointer to product frame.

Definition at line 488 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:
set frameset
parlist Parameter list
type Type of product
bitpix BITPIX
outfile name of output file
plist extension property list
recipe recipe name
product_frame product frame
Returns:
0 in success of -1 in case of error.

Definition at line 522 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:
scifits omega_fits structure containing the image to save
set original set of frames
pars original parameters list
qclist QC property list or NULL
bpp CPL_TYPE_BPP to save product
name output name of product
recipe recipe name
product_frame output frame of product
inherit optional frame to inherit header from
isfirst Tells whether to create primary header or not
Returns:
status 0 on success or -1 in case of error

Definition at line 1045 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:
img Image to save
set Frame set
pars Parameters list
alist Optional property list
qclist Optional QC list
bpp CPL_TYPE_BPP of product
name Name of product
recipe Name of recipe
frame Frame describing product
inherit Frame to inherit header from or NULL
isfirst Tell whether to create a primary header or not.
Returns:
0 on success or -1 in case of error.

Definition at line 905 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:
set frameset
parlist Parameter list
outfile name of output file
recipe recipe name
plist primary header or NULL
product_frame product frame
inherit Frame to inherit header from or NULL
Returns:
0 in success of -1 in case of error.

Definition at line 590 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:
tbl Table to save
set Set of frames
pars Parameters list
alist Optional property list
qclist Optional QC list
name Name of product
recipe Name of recipe
frame Frame describing the product
inherit Frame to inherit header from or NULL
isfirst Tell whether to create a primary header or not.
Returns:
0 on success or -1 in case of error.

Definition at line 976 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:
in image to be smoothed
size size of kernel matrix to use in filtering
Returns:
out smoothed image

Definition at line 637 of file omega_utils.c.

Referenced by omega_jitter_process(), and omega_std_process().


Generated on 11 Mar 2013 for OMEGA Pipeline Reference Manual by  doxygen 1.6.1