VIRCAM Pipeline  2.3.12
Functions
casu_utils

These miscellaneous utilitiy routines. More...

Functions

int casu_compare_tags (const cpl_frame *frame1, const cpl_frame *frame2)
 Compare input tags. More...
 
cpl_frameset * casu_frameset_subgroup (cpl_frameset *frameset, cpl_size *labels, cpl_size nlab, const char *tag)
 Extract a frameset from another frameset. More...
 
cpl_frame * casu_frameset_subgroup_1 (cpl_frameset *frameset, cpl_size *labels, cpl_size nlab, const char *tag)
 Extract a frame of a given label from a frameset. More...
 
long casu_getnpts (cpl_image *in)
 Get the number of pixels in a 2d image. More...
 
void casu_prov (cpl_propertylist *p, casu_fits **inlist, int n, int isextn)
 Write provenance keywords. More...
 
void casu_sort (float **a, int n, int m)
 Sort a 2d array by the first column and co-sort the rest. More...
 
void casu_merge_propertylists (cpl_propertylist *p1, cpl_propertylist *p2)
 Merge two propertylists. More...
 
void casu_dummy_property (cpl_propertylist *p)
 Set dummy property keyword. More...
 
void casu_rename_property (cpl_propertylist *p, const char *oldname, char *newname)
 Rename a property in a given propertylist. More...
 
cpl_image * casu_dummy_image (casu_fits *model)
 Create a dummy image of zeros based on a model. More...
 
cpl_table * casu_dummy_catalogue (int type)
 Create a dummy catalogue of a given type with no rows. More...
 
int casu_is_dummy (cpl_propertylist *p)
 See if the header of an image or table says its a dummy. More...
 
void casu_overexp (casu_fits **fitslist, int *n, int ndit, float lthr, float hthr, int ditch, float *minv, float *maxv, float *avev)
 Remove over- or under-exposed images from a list. More...
 
int casu_compare_dims (cpl_image *im1, cpl_image *im2)
 Compare dimensions of two 2d images. More...
 
int casu_gaincor_calc (cpl_frame *frame, int *n, float **cors, int *status)
 Work out gain corrections. More...
 
void casu_timestamp (char *out, int n)
 Create a timestamp string. More...
 
int casu_catpars (cpl_frame *indx, char **catpath, char **catname)
 Find the name of the standard catalogue and its location. More...
 
int casu_fndmatch (float x, float y, float *xlist, float *ylist, int nlist, float err)
 Match the x,y coordinates of an object to one from a list. More...
 
int casu_findcol (cpl_propertylist *p, const char *col)
 Find from catalogue header which are x,y columns. More...
 
int casu_night_from_dateobs (char *dateobs)
 Use the dateobs value to work out the night of an observation. More...
 
void casu_propertylist_update_float (cpl_propertylist *plist, const char *name, float val)
 
void casu_propertylist_update_double (cpl_propertylist *plist, const char *name, double val)
 

Detailed Description

These miscellaneous utilitiy routines.

Author
Jim Lewis, CASU

Function Documentation

◆ casu_catpars()

int casu_catpars ( cpl_frame *  indx,
char **  catpath,
char **  catname 
)

Find the name of the standard catalogue and its location.

Name:
casu_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
CASU_OKif everything is ok
CASU_WARNif the catalogue isn't identified in the header
CASU_FATALif the index file is missing or if there is missing header info
Author
Jim Lewis, CASU

Definition at line 899 of file casu_utils.c.

◆ casu_compare_dims()

int casu_compare_dims ( cpl_image *  im1,
cpl_image *  im2 
)

Compare dimensions of two 2d images.

Name:
casu_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
CASU_OKIf the dimensions are the same
CASU_FATALIf the dimensions are different
Author
Jim Lewis, CASU

Definition at line 713 of file casu_utils.c.

Referenced by casu_darkcor(), and casu_flatcor().

◆ casu_compare_tags()

int casu_compare_tags ( const cpl_frame *  frame1,
const cpl_frame *  frame2 
)

Compare input tags.

Name:
casu_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 96 of file casu_utils.c.

◆ casu_dummy_catalogue()

cpl_table* casu_dummy_catalogue ( int  type)

Create a dummy catalogue of a given type with no rows.

Name:
casu_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 570 of file casu_utils.c.

References imcore_tabinit().

Referenced by vircam_jmp_save_catalogue().

◆ casu_dummy_image()

cpl_image* casu_dummy_image ( casu_fits *  model)

Create a dummy image of zeros based on a model.

Name:
casu_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 533 of file casu_utils.c.

References casu_fits_get_image().

Referenced by casu_pawsky_mask(), casu_pawsky_mask_pre(), casu_pawsky_minus(), casu_simplesky_mask(), vircam_jmp_dither_images(), and vircam_jmp_interleave().

◆ casu_dummy_property()

void casu_dummy_property ( cpl_propertylist *  p)

Set dummy property keyword.

Name:
casu_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 445 of file casu_utils.c.

Referenced by casu_pawsky_mask(), casu_pawsky_mask_pre(), casu_pawsky_minus(), casu_simplesky_mask(), and vircam_jmp_save_illum().

◆ casu_findcol()

int casu_findcol ( cpl_propertylist *  p,
const char *  col 
)

Find from catalogue header which are x,y columns.

Name:
casu_findcol
Purpose:
Find which column in a catalogue is the x or y position
Description:
Find which column in a catalogue is the x or y position
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 1050 of file casu_utils.c.

Referenced by casu_platesol().

◆ casu_fndmatch()

int casu_fndmatch ( float  x,
float  y,
float *  xlist,
float *  ylist,
int  nlist,
float  err 
)

Match the x,y coordinates of an object to one from a list.

Name:
casu_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 982 of file casu_utils.c.

Referenced by casu_matchstds(), and casu_matchxy().

◆ casu_frameset_subgroup()

cpl_frameset* casu_frameset_subgroup ( cpl_frameset *  frameset,
cpl_size *  labels,
cpl_size  nlab,
const char *  tag 
)

Extract a frameset from another frameset.

Name:
casu_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 149 of file casu_utils.c.

Referenced by casu_frameset_subgroup_1().

◆ casu_frameset_subgroup_1()

cpl_frame* casu_frameset_subgroup_1 ( cpl_frameset *  frameset,
cpl_size *  labels,
cpl_size  nlab,
const char *  tag 
)

Extract a frame of a given label from a frameset.

Name:
casu_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 206 of file casu_utils.c.

References casu_frameset_subgroup().

Referenced by casu_mask_define().

◆ casu_gaincor_calc()

int casu_gaincor_calc ( cpl_frame *  frame,
int *  n,
float **  cors,
int *  status 
)

Work out gain corrections.

Name:
casu_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
CASU_OKif everything is ok
QC headers:
None
DRS headers:
None
Author
Jim Lewis, CASU

Definition at line 757 of file casu_utils.c.

◆ casu_getnpts()

long casu_getnpts ( cpl_image *  in)

Get the number of pixels in a 2d image.

Name:
casu_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 243 of file casu_utils.c.

Referenced by casu_genbpm(), casu_imcombine(), vircam_genbpm(), and vircam_jmp_interleave().

◆ casu_is_dummy()

int casu_is_dummy ( cpl_propertylist *  p)

See if the header of an image or table says its a dummy.

Name:
casu_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 598 of file casu_utils.c.

◆ casu_merge_propertylists()

void casu_merge_propertylists ( cpl_propertylist *  p1,
cpl_propertylist *  p2 
)

Merge two propertylists.

Name:
casu_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 399 of file casu_utils.c.

Referenced by vircam_jmp_save_illum(), and vircam_jmp_skycor().

◆ casu_night_from_dateobs()

int casu_night_from_dateobs ( char *  dateobs)

Use the dateobs value to work out the night of an observation.

Name:
casu_night_from_dateobs
Purpose:
Find the night of an observation from the date-obs value
Description:
Find the 'night' of an observation. This is the date of the observation but starting at noon.
Language:
C
Parameters
dateobsThe value of DATE-OBS for the observation
Returns
An 8 digit integer with the night expressed as yyyymmdd
Author
Jim Lewis, CASU

Definition at line 1088 of file casu_utils.c.

◆ casu_overexp()

void casu_overexp ( casu_fits **  fitslist,
int *  n,
int  ndit,
float  lthr,
float  hthr,
int  ditch,
float *  minv,
float *  maxv,
float *  avev 
)

Remove over- or under-exposed images from a list.

Name:
casu_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 casu_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 652 of file casu_utils.c.

References casu_fits_delete(), and casu_fits_get_image().

◆ casu_propertylist_update_double()

void casu_propertylist_update_double ( cpl_propertylist *  plist,
const char *  name,
double  val 
)
Name:
casu_propertylist_update_double
Purpose:
Update a double property to a propertylist
Description:
Update a double property to a propertylist. It's not possible to write a double to a floating point property, which really is incredibly unhelpful. This is especially annoying as it's almost impossible to predict whether a property is going to be float or double
Language:
C
Parameters
plistThe input propertylist
nameThe name of the property to be updated
valThe value of the property
Author
Jim Lewis, CASU

Definition at line 1212 of file casu_utils.c.

Referenced by casu_platesol().

◆ casu_propertylist_update_float()

void casu_propertylist_update_float ( cpl_propertylist *  plist,
const char *  name,
float  val 
)
Name:
casu_propertylist_update_float
Purpose:
Update a floating point property to a propertylist
Description:
Update a floating point property to a propertylist. If a floating point property is written by hand to the propertylist as a float, then it remains a float and can be updated as such. However if it's read from a FITS header, then it defaults to double and any attempt to update it using cpl_propertylist_update_float fails. Very annoying! This routine attempts to fix this...
Language:
C
Parameters
plistThe input propertylist
nameThe name of the property to be updated
valThe value of the property
Author
Jim Lewis, CASU

Definition at line 1163 of file casu_utils.c.

Referenced by casu_imcore().

◆ casu_prov()

void casu_prov ( cpl_propertylist *  p,
casu_fits **  inlist,
int  n,
int  isextn 
)

Write provenance keywords.

Name:
casu_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
isextnSet if this is an extension rather than the primary
Author
Jim Lewis, CASU

Definition at line 287 of file casu_utils.c.

References casu_fits_get_filename(), and casu_fits_get_fullname().

Referenced by casu_imcombine(), casu_imdither(), casu_imstack(), casu_pawsky_minus(), and vircam_interleave().

◆ casu_rename_property()

void casu_rename_property ( cpl_propertylist *  p,
const char *  oldname,
char *  newname 
)

Rename a property in a given propertylist.

Name:
casu_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 485 of file casu_utils.c.

Referenced by casu_tabwcs().

◆ casu_sort()

void casu_sort ( float **  a,
int  n,
int  m 
)

Sort a 2d array by the first column and co-sort the rest.

Name:
casu_sort
Purpose:
Sort a 2d array by the first column 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 349 of file casu_utils.c.

◆ casu_timestamp()

void casu_timestamp ( char *  out,
int  n 
)

Create a timestamp string.

Name:
casu_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 849 of file casu_utils.c.

Referenced by casu_imdither().