vircam_utils
[Groups of Support Routines]


Detailed Description

These are utility routines of various types.

Author:
Jim Lewis, CASU


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, int *labels, int nlab, const char *tag)
cpl_frame * vircam_frameset_subgroup_1 (cpl_frameset *frameset, int *labels, int nlab, const char *tag)
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, float lthr, float hthr, int ditch)
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, char *col)
void vircam_rename_property (cpl_propertylist *p, char *oldname, char *newname)
int vircam_catpars (cpl_frame *index, char **catpath, char **catname)
int vircam_gaincor_calc (cpl_frame *frame, int *n, float **cors, int *status)


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:
in The input image
mask The input bad pixel mask
nbsize The input size of the smoothing cells
out The output background map (corrected for to zero median)
med The global median of the input image
DRS headers:
None
Returns:
Nothing
Author:
Jim Lewis, CASU

Definition at line 1714 of file vircam_utils.c.

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

int vircam_catpars ( cpl_frame *  index,
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:
index The frame for the index FITS file
catpath The full path to the catalgoue FITS files
catname The name of the catalogue
Return values:
VIR_OK if everything is ok
VIR_WARN if the catalogue isn't identified in the header
VIR_FATAL if the index file is missing or if there is missing header info
Author:
Jim Lewis, CASU

Definition at line 1965 of file vircam_utils.c.

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:
im1 The first image
im2 The second image
Return values:
VIR_OK If the dimensions are the same
VIR_FATAL If the dimensions are different
Author:
Jim Lewis, CASU

Definition at line 1335 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:
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 140 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:
nrows The number of rows for the table
Returns:
The cpl_table pointer for the new stats table
Author:
Jim Lewis, CASU

Definition at line 1078 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:
master The master calibration image
prog The new mean image
bpm Input bad pixel mask
chantab The channel table for the detector
ncells The number of cells per channel
oper The operation to be performed:
  • 1. Subtract the images
  • 2. Divide the images
global_diff The median difference over the whole difference image
global_rms The rms difference over the whole difference image
diffim The output difference/ratio image
diffimstats The output difference/ratio image statistics table
Returns:
Nothing
Author:
Jim Lewis, CASU

Definition at line 883 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:
type The type of catalogue to create
Returns:
A new dummy catalogue
Author:
Jim Lewis, CASU

Definition at line 1601 of file vircam_utils.c.

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:
n The 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 1301 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:
model The model on which the new image will be based.
Returns:
A new dummy image
Author:
Jim Lewis, CASU

Definition at line 1566 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:
p The 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 1446 of file vircam_utils.c.

Referenced by vircam_jmp_save_simple(), 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:
inexten Input image extension from the recipe invocation
fr An input frame used to test whether the requested frame(s) exist or not
out1 Lower part of extension range (-1 if there is an error)
out2 Upper part of extension range (-1 if there is an error)
Returns:
Nothing
Author:
Jim Lewis, CASU

Definition at line 289 of file vircam_utils.c.

int vircam_findcol ( cpl_propertylist *  p,
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:
p The input propertylist for the table
col The 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 1869 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:
x The X coordinate of the object
y The Y coordinate of the object
xlist The list of catalogue X coordinates
ylist The list of catalogue Y coordinates
nlist The number of entries in the lists
err The 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 1236 of file vircam_utils.c.

Referenced by vircam_matchstds(), and vircam_matchxy().

cpl_frameset* vircam_frameset_subgroup ( cpl_frameset *  frameset,
int *  labels,
int  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:
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 192 of file vircam_utils.c.

Referenced by vircam_frameset_subgroup_1().

cpl_frame* vircam_frameset_subgroup_1 ( cpl_frameset *  frameset,
int *  labels,
int  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:
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 first of all frames matching input tag or NULL if none match
Author:
Jim Lewis, CASU

Definition at line 245 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
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 frmae.
Language:
C
Parameters:
frame The input twilight frame
n The number of image extensions
cors An array of output corrections
Return values:
VIR_OK if everything is ok
QC headers:
None
DRS headers:
None
Author:
Jim Lewis, CASU

Definition at line 2047 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 91 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:
in The input image
Returns:
The total number of pixels in the image
Author:
Jim Lewis

Definition at line 1186 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:
nrows The number of rows in the table
Returns:
The pointer to the new table
Author:
Jim Lewis, CASU

Definition at line 1628 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:
p The input propertylist
Author:
Jim Lewis, CASU

Definition at line 1479 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:
npts The number of data points
xdata The X data
ydata The Y data
intercept The fitted intercept
slope The fitted slope
sig The fit error
Returns:
Nothing
Author:
Jim Lewis, CASU

Definition at line 504 of file vircam_utils.c.

Referenced by vircam_genlincur().

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:
npts The number of data points
xdata The X data
ydata The Y data
intercept The fitted intercept
slope The fitted slope
Returns:
Nothing
Author:
Jim Lewis, CASU

Definition at line 361 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:
p1 The first propertylist
p2 The second propertylist
Author:
Jim Lewis, CASU

Definition at line 1409 of file vircam_utils.c.

Referenced by vircam_jmp_save_stack().

void vircam_overexp ( vir_fits **  fitslist,
int *  n,
float  lthr,
float  hthr,
int  ditch 
)

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:
fitslist The input fits list. This will be replaced by another list that has the rejected images removed.
n The number of fits images in the input list. This will be changed if any of these get rejected.
lthr The lower threshold for underexposed images
hthr The upper threshold for overexposed images
ditch If set, then the bad vir_fits image descriptors will be explicitly deleted.
Returns:
A new fits list with the bad images removed.
Author:
Jim Lewis, CASU

Definition at line 1523 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:
xarray The independent variable array
yarray The dependent variable array
ncoefs The requested polynomial order plus 1.
ilim The number of low order coefficients not to fit.
niter The number of iterations
lclip The number of sigma for the lower clipping threshold
hclip The number of sigma for the upper clipping threshold
polycf The returned array of polynomial coefficients.
sigfit The total error of the fit
Return values:
VIR_OK If everything went OK
VIR_FATAL If there was some sort of error
Author:
Jim Lewis, CASU

Definition at line 693 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:
p The combined image propertylist
inlist The list of images that went into ifile.
n The number of images in the input list
Author:
Jim Lewis, CASU

Definition at line 1367 of file vircam_utils.c.

References vircam_fits_get_fullname().

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

void vircam_rename_property ( cpl_propertylist *  p,
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:
p The input propertylist for the table
oldname The old property name
newname The new property name
Returns:
Nothing
Author:
Jim Lewis, CASU

Definition at line 1908 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:
a The matrix part of the system (a[m][m])
b The vector part of the system (b[m]). The output fit coefficients overwrite the input values in this vector.
m The size of the vectors
Return values:
VIR_OK If everything went OK
VIR_FATAL If matrix a has a zero determinant
Author:
Jim Lewis, CASU

Definition at line 578 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:
a The input 2d array (a[m][n])
n The number of rows in the array
m The number of columns in the array
Returns:
Nothing
Author:
Jim Lewis, CASU

Definition at line 1130 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:
out The 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
n The maximum size of the string.
Returns:
Nothing
Author:
Jim Lewis, CASU

Definition at line 1666 of file vircam_utils.c.

Referenced by vircam_imdither(), and vircam_interleave().


Generated on Wed Apr 10 04:01:58 2013 for VIRCAM Pipeline by  doxygen 1.5.1