VIRCAM Pipeline  1.3.4
Functions

These are utility routines of various types. More...

Functions

const char * vircam_get_license (void)
 
int vircam_compare_tags (const cpl_frame *frame1, const cpl_frame *frame2)
 
cpl_frameset * vircam_frameset_subgroup (cpl_frameset *frameset, cpl_size *labels, cpl_size nlab, const char *tag)
 
cpl_frame * vircam_frameset_subgroup_1 (cpl_frameset *frameset, cpl_size *labels, cpl_size nlab, const char *tag)
 
int vircam_frameset_fexists (cpl_frameset *frameset)
 
void vircam_exten_range (int inexten, const cpl_frame *fr, int *out1, int *out2)
 
void vircam_madfit (int npts, float *xdata, float *ydata, float *intercept, float *slope)
 
void vircam_linfit (int npts, double *xdata, double *ydata, double *intercept, double *slope, double *sig)
 
int vircam_solve_gauss (double **a, double *b, int m)
 
int vircam_polyfit (const cpl_array *xarray, const cpl_array *yarray, int ncoefs, int ilim, int niter, float lclip, float hclip, cpl_array **polycf, double *sigfit)
 
void vircam_difference_image (cpl_image *master, cpl_image *prog, unsigned char *bpm, cpl_table *chantab, int ncells, int oper, float *global_diff, float *global_rms, cpl_image **diffim, cpl_table **diffimstats)
 
cpl_table * vircam_create_diffimg_stats (int nrows)
 
void vircam_sort (float **a, int n, int m)
 
long vircam_getnpts (cpl_image *in)
 
int vircam_fndmatch (float x, float y, float *xlist, float *ylist, int nlist, float err)
 
int * vircam_dummy_confidence (long n)
 
int vircam_compare_dims (cpl_image *im1, cpl_image *im2)
 
void vircam_prov (cpl_propertylist *p, vir_fits **inlist, int n)
 
void vircam_merge_propertylists (cpl_propertylist *p1, cpl_propertylist *p2)
 
void vircam_dummy_property (cpl_propertylist *p)
 
int vircam_is_dummy (cpl_propertylist *p)
 
void vircam_overexp (vir_fits **fitslist, int *n, int ndit, float lthr, float hthr, int ditch, float *minv, float *maxv, float *avev)
 
cpl_image * vircam_dummy_image (vir_fits *model)
 
cpl_table * vircam_dummy_catalogue (int type)
 
cpl_table * vircam_illcor_newtab (int nrows)
 
void vircam_timestamp (char *out, int n)
 
void vircam_backmap (vir_fits *in, vir_mask *mask, int nbsize, cpl_image **out, float *med)
 
int vircam_findcol (cpl_propertylist *p, const char *col)
 
void vircam_rename_property (cpl_propertylist *p, const char *oldname, char *newname)
 
int vircam_catpars (cpl_frame *indx, char **catpath, char **catname)
 
int vircam_gaincor_calc (cpl_frame *frame, int *n, float **cors, int *status)
 
int vircam_check_crval (cpl_propertylist *phu, cpl_propertylist *ehu)
 

Detailed Description

These are utility routines of various types.

Author
Jim Lewis, CASU

Function Documentation

void vircam_backmap ( vir_fits *  in,
vir_mask *  mask,
int  nbsize,
cpl_image **  out,
float *  med 
)
Name:
vircam_backmap
Purpose:
Create a background map from an input image
Description:
Data from an input image are median smoothed in cells. A background map for the image is then created by a 2 point interpolation of the smoothed data.
Language:
C
Parameters
inThe input image
maskThe input bad pixel mask
nbsizeThe input size of the smoothing cells
outThe output background map (corrected for to zero median)
medThe global median of the input image
DRS headers:
None
Returns
Nothing
Author
Jim Lewis, CASU

Definition at line 1800 of file vircam_utils.c.

References vircam_fits_get_image(), vircam_mask_get_data(), and vircam_med().

int vircam_catpars ( cpl_frame *  indx,
char **  catpath,
char **  catname 
)
Name:
vircam_catpars
Purpose:
Find the name of the standard catalogue being used and its location
Description:
Find the name of the standard catalogue being used and its location. The former should be in a header keyword in the specified FITS file. The latter is the full path of the FITS file. Both values need to be deallocated when you're finished with them.
Language:
C
Parameters
indxThe frame for the index FITS file
catpathThe full path to the catalgoue FITS files
catnameThe name of the catalogue
Return values
VIR_OKif everything is ok
VIR_WARNif the catalogue isn't identified in the header
VIR_FATALif the index file is missing or if there is missing header info
Author
Jim Lewis, CASU

Definition at line 2057 of file vircam_utils.c.

int vircam_check_crval ( cpl_propertylist *  phu,
cpl_propertylist *  ehu 
)
Name:
vircam_check_crval
Purpose:
Check CRVAL == 0 problem
Description:
The extension header is checked to see if CRVAL values exist. If they don't that's an error. If they do and they are exactly zero, then this is considered an error. In this case the primary header is searched for RA and DEC values and these are silently substituted into the extension header as CRVALs
Language:
C
Parameters
phuThe primary header propertylist
ehuThe extension header propertylist
Return values
VIR_OKif everything is ok
VIR_FATALif no values of CRVAL are in the extension or no values of RA,DEC are available in the primary
Author
Jim Lewis, CASU

Definition at line 2234 of file vircam_utils.c.

References vircam_pfits_get_crval1(), vircam_pfits_get_crval2(), vircam_pfits_get_dec(), and vircam_pfits_get_ra().

int vircam_compare_dims ( cpl_image *  im1,
cpl_image *  im2 
)
Name:
vircam_compare_dims
Purpose:
Compare dimensions of data arrays of two images
Description:
The dimensions of two different images are compared. If they are not the same, then an fatal error status is returned. Otherwise a good status is returned
Language:
C
Parameters
im1The first image
im2The second image
Return values
VIR_OKIf the dimensions are the same
VIR_FATALIf the dimensions are different
Author
Jim Lewis, CASU

Definition at line 1396 of file vircam_utils.c.

Referenced by vircam_darkcor(), and vircam_flatcor().

int vircam_compare_tags ( const cpl_frame *  frame1,
const cpl_frame *  frame2 
)
Name:
vircam_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 141 of file vircam_utils.c.

cpl_table* vircam_create_diffimg_stats ( int  nrows)
Name:
vircam_create_diffimg_stats
Purpose:
Create an empty difference image stats table
Description:
Create an empty difference image stats table
Language:
C
Parameters
nrowsThe number of rows for the table
Returns
The cpl_table pointer for the new stats table
Author
Jim Lewis, CASU

Definition at line 1148 of file vircam_utils.c.

Referenced by vircam_difference_image().

void vircam_difference_image ( cpl_image *  master,
cpl_image *  prog,
unsigned char *  bpm,
cpl_table *  chantab,
int  ncells,
int  oper,
float *  global_diff,
float *  global_rms,
cpl_image **  diffim,
cpl_table **  diffimstats 
)
Name:
vircam_difference_image
Purpose:
Create a difference/ratio image and difference/ratio image stats table
Description:
A difference/ratio image is created from an input image and a master image. A global difference and RMS are calculated from the difference image. If a channel table has been included, then a difference image stats table will be created. This breaks up the difference image into cells and calculates some basic stats in each cell.
Language:
C
Parameters
masterThe master calibration image
progThe new mean image
bpmInput bad pixel mask
chantabThe channel table for the detector
ncellsThe number of cells per channel
operThe operation to be performed:
  • 1. Subtract the images
  • 2. Divide the images
global_diffThe median difference over the whole difference image
global_rmsThe rms difference over the whole difference image
diffimThe output difference/ratio image
diffimstatsThe output difference/ratio image statistics table
Returns
Nothing
Author
Jim Lewis, CASU

Definition at line 950 of file vircam_utils.c.

References vircam_create_diffimg_stats(), vircam_meansig(), and vircam_medmad().

cpl_table* vircam_dummy_catalogue ( int  type)
Name:
vircam_dummy_catalogue
Purpose:
Create a dummy catalogue with no rows
Description:
Create a dummy catalogue with no rows
Language:
C
Parameters
typeThe type of catalogue to create
Returns
A new dummy catalogue
Author
Jim Lewis, CASU

Definition at line 1687 of file vircam_utils.c.

References tabinit().

Referenced by vircam_jmp_save_catalogue().

int* vircam_dummy_confidence ( long  n)
Name:
vircam_dummy_confidence
Purpose:
Create a dummy confidence map with all pixels equally good
Description:
An integer array is returned with all values equal to 100. This array will need to be deallocated when you're finished with it.
Language:
C
Parameters
nThe number of pixels
Returns
The output dummy confidence map. This array will need to be deallocated when you're finished with it.
Author
Jim Lewis, CASU

Definition at line 1362 of file vircam_utils.c.

cpl_image* vircam_dummy_image ( vir_fits *  model)
Name:
vircam_dummy_image
Purpose:
Create a dummy image based on another one.
Description:
Use an input image to create a new image full of zeros.
Language:
C
Parameters
modelThe model on which the new image will be based.
Returns
A new dummy image
Author
Jim Lewis, CASU

Definition at line 1652 of file vircam_utils.c.

References vircam_fits_get_image().

Referenced by vircam_jmp_dither_images(), and vircam_jmp_interleave().

void vircam_dummy_property ( cpl_propertylist *  p)
Name:
vircam_dummy_property
Purpose:
Set a keyword in the property list of a dummy product
Description:
The key ESO DRS IMADUMMY is set in the input property list
Language:
C
Parameters
pThe input propertylist
DRS headers:
The following DRS keywords are written to the propertylist
  • IMADUMMY Boolean value set to T to indicate a dummy data product
Author
Jim Lewis, CASU

Definition at line 1514 of file vircam_utils.c.

Referenced by vircam_jmp_save_catalogue(), vircam_jmp_save_illum(), vircam_jmp_save_offsky(), vircam_jmp_save_simple(), vircam_jmp_save_simple_offsets(), vircam_jmp_save_stack(), and vircam_jmp_save_super().

void vircam_exten_range ( int  inexten,
const cpl_frame *  fr,
int *  out1,
int *  out2 
)
Name:
vircam_exten_range
Purpose:
Define the range of image extensions to use
Description:
If the input extension specified is zero, then all the extensions in a vircam MEF should be done. If not, then just the extension specified should be done.
Language:
C
Parameters
inextenInput image extension from the recipe invocation
frAn input frame used to test whether the requested frame(s) exist or not
out1Lower part of extension range (-1 if there is an error)
out2Upper part of extension range (-1 if there is an error)
Returns
Nothing
Author
Jim Lewis, CASU

Definition at line 353 of file vircam_utils.c.

int vircam_findcol ( cpl_propertylist *  p,
const char *  col 
)
Name:
vircam_findcol
Purpose:
Find a column of a particular name in a FITS table
Description:
Find a column of a particular name in a FITS table (can't be done within CPL).
Language:
C
Parameters
pThe input propertylist for the table
colThe column you want to find
Returns
The column number that matches the column name. If no match is found then -1 is returned.
Author
Jim Lewis, CASU

Definition at line 1961 of file vircam_utils.c.

Referenced by vircam_platesol().

int vircam_fndmatch ( float  x,
float  y,
float *  xlist,
float *  ylist,
int  nlist,
float  err 
)
Name:
vircam_fndmatch
Purpose:
Match the x,y coordinates of an object to one of list of coordinates
Description:
The routine is given the coordinates of an object (x,y) and a list of x,y coordinates. If one of the list matches the coordinates of the given object, the index Of the matching entry is returned. If none match then -1 is returned.
Language:
C
Parameters
xThe X coordinate of the object
yThe Y coordinate of the object
xlistThe list of catalogue X coordinates
ylistThe list of catalogue Y coordinates
nlistThe number of entries in the lists
errThe maximum error radius for a match
Returns
The index of the list object that matches the given coordinates. If none match, then -1 is returned.
Author
Jim Lewis

Definition at line 1297 of file vircam_utils.c.

Referenced by vircam_matchstds(), and vircam_matchxy().

int vircam_frameset_fexists ( cpl_frameset *  frameset)
Name:
vircam_frameset_fexists
Purpose:
See whether the files listed in a frameset exist
Description:
Loop through all the frames in a frameset. If a frame doesn't exist, then send out a error message and return a bad status.
Language:
C
Parameters
framesetInput frameset
Return values
VIR_OKIf everything went OK
VIR_FATALIf any of the files in the frameset are missing
Author
Jim Lewis, CASU

Definition at line 285 of file vircam_utils.c.

cpl_frameset* vircam_frameset_subgroup ( cpl_frameset *  frameset,
cpl_size *  labels,
cpl_size  nlab,
const char *  tag 
)
Name:
vircam_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 193 of file vircam_utils.c.

Referenced by vircam_frameset_subgroup_1().

cpl_frame* vircam_frameset_subgroup_1 ( cpl_frameset *  frameset,
cpl_size *  labels,
cpl_size  nlab,
const char *  tag 
)
Name:
vircam_frameset_subgroup_1
Purpose:
Extract a frameset of a given label from a master frameset and return the first frame only.
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 first frame from the extracted frameset is returned. If none of the frames match the input tag then a NULL frame 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 first of all frames matching input tag or NULL if none match
Author
Jim Lewis, CASU

Definition at line 247 of file vircam_utils.c.

References vircam_frameset_subgroup().

Referenced by vircam_mask_define().

int vircam_gaincor_calc ( cpl_frame *  frame,
int *  n,
float **  cors,
int *  status 
)
Name:
vircam_gaincor_calc
Purpose:
Work out gain corrections
Description:
The headers of an input twilight flat frame are searched to find the relative flux of each of the MEF images before they were normalised. A gain correction is calculated by scaling the medians to a common value, which is the ensemble median of the good images in the input frame.
Language:
C
Parameters
frameThe input twilight frame
nThe number of image extensions
corsAn array of output corrections
statusThe input/output status variable
Return values
VIR_OKif everything is ok
QC headers:
None
DRS headers:
None
Author
Jim Lewis, CASU

Definition at line 2142 of file vircam_utils.c.

const char* vircam_get_license ( void  )
Name:
vircam_get_license
Purpose:
Get the pipeline copyright and license
Description:
The function returns a pointer to the statically allocated license string. This string should not be modified using the returned pointer.
Language:
C
Returns
The copyright and license string
Author
Jim Lewis, CASU

Definition at line 92 of file vircam_utils.c.

long vircam_getnpts ( cpl_image *  in)
Name:
vircam_getnpts
Purpose:
Get the number of pixels in an image
Description:
The number of pixels in an image is returned.
Language:
C
Parameters
inThe input image
Returns
The total number of pixels in the image
Author
Jim Lewis

Definition at line 1247 of file vircam_utils.c.

Referenced by vircam_genbpm(), vircam_imcombine(), and vircam_jmp_interleave().

cpl_table* vircam_illcor_newtab ( int  nrows)
Name:
vircam_illcor_newtab
Purpose:
Create a new illumination correction table
Description:
Given the number of rows, create an illumination correction table with no information in it.
Language:
C
Parameters
nrowsThe number of rows in the table
Returns
The pointer to the new table
Author
Jim Lewis, CASU

Definition at line 1714 of file vircam_utils.c.

Referenced by vircam_illum(), and vircam_jmp_save_illum().

int vircam_is_dummy ( cpl_propertylist *  p)
Name:
vircam_is_dummy
Purpose:
See if an image or table is a dummy output product
Description:
The input propertylist is searched for the key ESO DRS IMADUMMY. If it exists, then this header is part of a dummy image or table.
Language:
C
Parameters
pThe input propertylist
Author
Jim Lewis, CASU

Definition at line 1547 of file vircam_utils.c.

void vircam_linfit ( int  npts,
double *  xdata,
double *  ydata,
double *  intercept,
double *  slope,
double *  sig 
)
Name:
vircam_linfit
Purpose:
Fit a line to data using standard linear least squares
Description:
Standard linear fit routine,
Language:
C
Parameters
nptsThe number of data points
xdataThe X data
ydataThe Y data
interceptThe fitted intercept
slopeThe fitted slope
sigThe fit error
Returns
Nothing
Author
Jim Lewis, CASU

Definition at line 570 of file vircam_utils.c.

void vircam_madfit ( int  npts,
float *  xdata,
float *  ydata,
float *  intercept,
float *  slope 
)
Name:
vircam_madfit
Purpose:
Fit a line to data by minimising the sum of MADs
Description:
Standard linear fit routine, with the modification that the minimisation scheme is done on the sum of MADs.
Language:
C
Parameters
nptsThe number of data points
xdataThe X data
ydataThe Y data
interceptThe fitted intercept
slopeThe fitted slope
Returns
Nothing
Author
Jim Lewis, CASU

Definition at line 427 of file vircam_utils.c.

void vircam_merge_propertylists ( cpl_propertylist *  p1,
cpl_propertylist *  p2 
)
Name:
vircam_merge_propertylists
Purpose:
Merge the properties from a propertylist into another one
Description:
All of the properties from a second propertylist are copied into the first one.
Language:
C
Parameters
p1The first propertylist
p2The second propertylist
Author
Jim Lewis, CASU

Definition at line 1470 of file vircam_utils.c.

Referenced by vircam_jmp_save_catalogue(), vircam_jmp_save_illum(), vircam_jmp_save_stack(), and vircam_jmp_skycor().

void vircam_overexp ( vir_fits **  fitslist,
int *  n,
int  ndit,
float  lthr,
float  hthr,
int  ditch,
float *  minv,
float *  maxv,
float *  avev 
)
Name:
vircam_overexp
Purpose:
Sort out a list of fits images to remove those that are either over or under exposed.
Description:
A list of fits images is examined to locate images that are either over or under exposed.
Language:
C
Parameters
fitslistThe input fits list. This will be replaced by another list that has the rejected images removed.
nThe number of fits images in the input list. This will be changed if any of these get rejected.
nditThe number of coadds
lthrThe lower threshold for underexposed images
hthrThe upper threshold for overexposed images
ditchIf set, then the bad vir_fits image descriptors will be explicitly deleted.
minvOutput value with the lowest flux in the sample
maxvOutput value with the highest flux in the sample
avevOutput value with the average flux in the sample
Returns
Nothing
Author
Jim Lewis, CASU

Definition at line 1599 of file vircam_utils.c.

References vircam_fits_delete(), and vircam_fits_get_image().

int vircam_polyfit ( const cpl_array *  xarray,
const cpl_array *  yarray,
int  ncoefs,
int  ilim,
int  niter,
float  lclip,
float  hclip,
cpl_array **  polycf,
double *  sigfit 
)
Name:
vircam_polyfit
Purpose:
Fit a polynomial to a set of points
Description:
Fit a polynomial to a set of points. If requested the fit will be done iteratively. If requested the lower order coefficients will be defined as zero. This is done by adjusting the parameter ilim. The number of coefficients returned will be ncoefs - ilim.
Language:
C
Parameters
xarrayThe independent variable array
yarrayThe dependent variable array
ncoefsThe requested polynomial order plus 1.
ilimThe number of low order coefficients not to fit.
niterThe number of iterations
lclipThe number of sigma for the lower clipping threshold
hclipThe number of sigma for the upper clipping threshold
polycfThe returned array of polynomial coefficients.
sigfitThe total error of the fit
Return values
VIR_OKIf everything went OK
VIR_FATALIf there was some sort of error
Author
Jim Lewis, CASU

Definition at line 759 of file vircam_utils.c.

References vircam_solve_gauss().

Referenced by vircam_genlincur().

void vircam_prov ( cpl_propertylist *  p,
vir_fits **  inlist,
int  n 
)
Name:
vircam_prov
Purpose:
Write provenance cards to a header
Description:
A list of file names and extensions is written to the DRS extension to a header to indicate the provenance of the file. This is useful for output files that are formed from a list of input files.
Language:
C
Parameters
pThe combined image propertylist
inlistThe list of images that went into ifile.
nThe number of images in the input list
Author
Jim Lewis, CASU

Definition at line 1428 of file vircam_utils.c.

References vircam_fits_get_fullname().

Referenced by vircam_imcombine(), vircam_imdither(), vircam_imstack(), and vircam_interleave().

void vircam_rename_property ( cpl_propertylist *  p,
const char *  oldname,
char *  newname 
)
Name:
vircam_rename_property
Purpose:
Rename a property in a propertylist
Description:
Rename a property in a propertylist
Language:
C
Parameters
pThe input propertylist for the table
oldnameThe old property name
newnameThe new property name
Returns
Nothing
Author
Jim Lewis, CASU

Definition at line 2000 of file vircam_utils.c.

Referenced by vircam_tabwcs().

int vircam_solve_gauss ( double **  a,
double *  b,
int  m 
)
Name:
vircam_solve_gauss
Purpose:
Use Gauss-elimination method to solve for fit coefficients
Description:
This is a standard Gauss-elimination method routine.
Language:
C
Parameters
aThe matrix part of the system (a[m][m])
bThe vector part of the system (b[m]). The output fit coefficients overwrite the input values in this vector.
mThe size of the vectors
Return values
VIR_OKIf everything went OK
VIR_FATALIf matrix a has a zero determinant
Author
Jim Lewis, CASU

Definition at line 644 of file vircam_utils.c.

Referenced by vircam_genlincur(), and vircam_polyfit().

void vircam_sort ( float **  a,
int  n,
int  m 
)
Name:
vircam_sort
Purpose:
Sort a 2d array by the first element and co-sort the rest.
Description:
Basic Shell sorting routine that sorts a 2d array by its first column and cosorts the rest. The storage of the array is basically backwards to what is intuitive and this probably should be changed soon.
Language:
C
Parameters
aThe input 2d array (a[m][n])
nThe number of rows in the array
mThe number of columns in the array
Returns
Nothing
Author
Jim Lewis, CASU

Definition at line 1200 of file vircam_utils.c.

void vircam_timestamp ( char *  out,
int  n 
)
Name:
vircam_timestamp
Purpose:
Create a timestamp string
Description:
Create a timestamp string similar to DATE-OBS. This can be used to associate files together.
Language:
C
Parameters
outThe output string. It should be at least 25 characters long. NB: if it isn't at least 25 characters long (and provided you haven't done something stupid like pass in a value of n which is larger than the size of the string) then the output value will truncated to n characters
nThe maximum size of the string.
Returns
Nothing
Author
Jim Lewis, CASU

Definition at line 1752 of file vircam_utils.c.

Referenced by vircam_imdither(), and vircam_interleave().