VIRCAM Pipeline 2.3.15
Functions
casu_modules

These are the main CASU processing modules. More...

Functions

int casu_backmap (float *map, cpl_binary *bpm, int nx, int ny, int nbsize, float *avback, float **skymap, int *status)
 Model background of an image.
 
int casu_getstds (cpl_propertylist *plist, int cache, char *path, char *catname, int cdssearch, char *cacheloc, cpl_table **stds, int *status)
 Get a table of standard stars that appear on an image from a catalogue.
 
int casu_getstds_cdslist (int cdschoice, char **cdscatname, char **cdscatid, int *status)
 
int casu_get_cdschoice (const char *cdscatname)
 
int casu_darkcor (casu_fits *infile, casu_fits *darksrc, float darkscl, int *status)
 Correct input data for dark current.
 
int casu_defringe (casu_fits **infiles, int nimages, casu_fits **fringes, int nfringes, casu_mask *mask, int nbsize, int *status)
 Correct input data to remove fringes.
 
int casu_flatcor (casu_fits *infile, casu_fits *flatsrc, int *status)
 Correct input data for flat field response.
 
int casu_gaincor (casu_fits *infile, float gainscl, int *status)
 Gain correct input data frame.
 
int casu_genbpm (casu_fits **flatlist, int nflatlist, cpl_image *master, float lthr, float hthr, const char *expkey, cpl_array **bpm_array, int *nbad, float *badfrac, int *status)
 Generate a bad pixel mask from a list of dome flats.
 
int casu_imcombine (casu_fits **fset, casu_fits **fsetv, int nfits, int combtype, int scaletype, int xrej, float thresh, const char *expkey, cpl_image **outimage, cpl_image **outvimage, unsigned char **rejmask, unsigned char **rejplus, cpl_propertylist **drs, int *status)
 Stack images into a mean or median image with rejection.
 
int casu_imcore (casu_fits *infile, casu_fits *conf, int ipix, float threshold, int icrowd, float rcore, int nbsize, int cattype, float filtfwhm, casu_tfits **outtab, float gainloc, int *status)
 Generate object catalogues from input images.
 
int casu_imdither (casu_fits **inf, casu_fits **inconf, int nimages, int nconfs, float lthr, float hthr, cpl_propertylist **p, const char *expkey, cpl_image **out, cpl_image **outc, int *status)
 Dither a set of jittered observations.
 
int casu_imstack (casu_fits **inf, casu_fits **inconf, casu_fits **invar, casu_tfits **cats, int nimages, int nconfs, float lthr, float hthr, int method, int seeing, int fast, int unmap, const char *expkey, casu_fits **out, casu_fits **outc, casu_fits **outv, int *status)
 Stack images into a mean image using WCS info.
 
int casu_inpaint (casu_fits *in, int nbsize, int *status)
 Inpaint pixels or patches in a map.
 
int casu_matchxy (cpl_table *progtab, cpl_table *template, float srad, float *xoffset, float *yoffset, int *nm, cpl_table **outtab, int *status)
 Match two lists of x,y coordinates from two tables to find the cartesian offset between them.
 
int casu_matchstds (cpl_table *objtab, cpl_table *stdstab, float srad, cpl_table **outtab, int *status)
 Match object and standard star tables by their xy coordinates.
 
int casu_mkconf (cpl_image *flat, char *flatfile, casu_mask *bpm, cpl_image **outconf, cpl_propertylist **drs, int *status)
 Create a confidence map.
 
int casu_nditcor (casu_fits *infile, int ndit, const char *expkey, int *status)
 Correct input data for number of dits.
 
int casu_nebuliser (casu_fits *infile, casu_fits *inconf, int medfilt, int linfilt, int niter, int axis, int twod, int takeout_sky, int norm, int wantback, float signeg, float sigpos, casu_fits **backmap, int *status)
 Remove small scale background variations.
 
int casu_opm (casu_fits *infile, casu_fits *conf, int ipix, float threshold, int nbsize, float filtfwhm, int niter, int *status)
 Generate an object mask from an input image.
 
int casu_pawsky_minus (casu_fits **infiles, casu_fits **invar, casu_fits *conf, casu_fits *objmaskfits, int nfiles, casu_fits **skyout, casu_fits **skyvar, int *status)
 Background correct images using pawsky_minus algorithm.
 
int casu_photcal_extinct (casu_fits **images, casu_tfits **mstds, casu_tfits **cats, int nimages, char *filt, cpl_table *phottab, int minstars, cpl_frame *schlf_n, cpl_frame *schlf_s, const char *expkey, const char *amkey, float magerrcut, int *status)
 Do photometric calibration.
 
int casu_platesol (cpl_propertylist *plist, cpl_propertylist *tlist, cpl_table *matchedstds, int nconst, int shiftan, int *status)
 Work out a WCS for an image.
 
int casu_platexy (cpl_table *matchedxy, int nconst, cpl_array **coefs, int *status)
 Work out an xy transformation for two coodinate lists.
 
int casu_pawsky_mask (casu_fits **inlist, casu_fits **invar, int nfiles, casu_fits *conf, casu_mask *mask, casu_fits **skyout, casu_fits **skyvar, int niter, int ipix, float thresh, int nbsize, float smkern, int *status)
 Work out a masked sky estimate from an input jitter series.
 
int casu_pawsky_mask_pre (casu_fits **inlist, casu_fits **invar, int nfiles, casu_mask *mask, casu_fits *objmask, int nbsize, casu_fits **skyout, casu_fits **skyvar, int *status)
 Work out a sky estimate from an input jitter series and a pre-existing object mask.
 
int casu_simplesky_mask (casu_fits **inlist, casu_fits **invar, int nfiles, casu_fits *conf, casu_mask *mask, casu_fits **skyout, casu_fits **skyvar, int niter, int ipix, float thresh, int nbsize, float smkern, int *status)
 Work out a masked sky estimate from a jitter series with large offsets.
 

Detailed Description

These are the main CASU processing modules.

Author
Jim Lewis, CASU

Function Documentation

◆ casu_backmap()

int casu_backmap ( float *  map,
cpl_binary *  bpm,
int  nx,
int  ny,
int  nbsize,
float *  avback,
float **  skymap,
int *  status 
)

Model background of an image.

Name:
casu_backmap
Purpose:
Model the background of an input map
Description:
The large scale variation of a input map is modelled by robust median estimates in cells of a given size. This background map itself is then smoothed to ensure there are no sharp edges. Bad pixels are taken into account.
Language:
C
Parameters
mapThe input data image
bpmThe input bad pixel mask
nxThe X dimension of the input maps
nyThe Y dimension of the input maps
nbsizeThe size of the cells for the smoothing boxes
avbackThe average of the sky in the cells
skymapAn output sky map.
statusAn input/output status that is the same as the returned values
Return values
CASU_OKif everything is ok
CASU_FATALif input parameters are faulty or all pixels are bad in bpm
QC headers:
None
DRS headers:
None
Author
Jim Lewis, CASU

Definition at line 108 of file casu_backmap.c.

References casu_med().

Referenced by casu_inpaint().

◆ casu_darkcor()

int casu_darkcor ( casu_fits *  infile,
casu_fits *  darksrc,
float  darkscl,
int *  status 
)

Correct input data for dark current.

Name:
casu_darkcor
Purpose:
Correct input data for dark current
Description:
Two images are given – one is the data for an observation, the other is for a mean dark frame. The latter is subtracted from the former. The result overwrites the input data array for the object image. The data for the dark array can be scaled by a factor before subtraction if a scaling factor other than 1 is specified.
Language:
C
Parameters
infileThe input data image (overwritten by result).
darksrcThe input dark image
darksclThe dark scaling factor
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_WARNif the output property list is NULL.
CASU_FATALif image data fails to load, the images have different dimensionality or if the image subtraction in CPL fails
QC headers:
None
DRS headers:
The following DRS keywords are written to the infile extension header
  • DARKCOR The name of the originating FITS file for the dark image
  • DARKSCL: The scale factor applied to the dark frame before subtraction.
Author
Jim Lewis, CASU

Definition at line 86 of file casu_darkcor.c.

References casu_compare_dims(), casu_fits_get_ehu(), casu_fits_get_fullname(), and casu_fits_get_image().

◆ casu_defringe()

int casu_defringe ( casu_fits **  infiles,
int  nimages,
casu_fits **  fringes,
int  nfringes,
casu_mask *  mask,
int  nbsize,
int *  status 
)

Correct input data to remove fringes.

Name:
casu_defringe
Purpose:
Correct input data to remove fringes
Description:
A list of input images are given along with a fringe frame image. Each image is analysed to model out any large scale background variation which would bias the fitting procedure if it were left in. The background corrected fringe data is scaled by a series of different factors subtracted from the image data. The median absolute deviation of each the difference image is worked out and the run of MAD with scale factor is examined to see at what point the scale factor minimises the MAD. This scale factor is then used to correct the input data.
Language:
C
Parameters
infilesThe input data images (overwritten by result).
nimagesThe number of input images
fringesThe input fringe frames
nfringesThe number of input fringe frames
maskThe bad pixel mask
nbsizeThe size of each cell for the background modelling
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
QC headers:
The following QC keywords are written to the infile extension header
  • FRINGE_RATIO The ratio of the background RMS of the input image before fringe correction vs after.
DRS headers:
The following QC keywords are written to the infile extension header
  • FRINGEi The ith fringe frame used in defringing
  • FRNGSCi The scale factor of the ith fringe frame used in correcting the input image
Author
Jim Lewis, CASU

Definition at line 115 of file casu_defringe.c.

References casu_fits_get_ehu(), casu_fits_get_fullname(), casu_fits_get_image(), casu_mask_get_data(), and casu_medmad().

◆ casu_flatcor()

int casu_flatcor ( casu_fits *  infile,
casu_fits *  flatsrc,
int *  status 
)

Correct input data for flat field response.

Name:
casu_flatcor
Purpose:
Correct input data for flat field response
Description:
Two images are given – one is the data for an observation, the other is for a mean flat frame. The latter is divided into the former. The result overwrites the input data array for the object image.
Language:
C
Parameters
infileThe input data image (overwritten by result).
flatsrcThe input flat image
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_WARNif there is a zero divide or if the output property list is NULL.
CASU_FATALif image data fails to load or the division fails
QC headers:
None
DRS headers:
The following DRS keywords are written to the infile extension header
  • FLATCOR The name of the originating FITS file for the flat image
Author
Jim Lewis, CASU

Definition at line 79 of file casu_flatcor.c.

References casu_compare_dims(), casu_fits_get_ehu(), casu_fits_get_fullname(), and casu_fits_get_image().

◆ casu_gaincor()

int casu_gaincor ( casu_fits *  infile,
float  gainscl,
int *  status 
)

Gain correct input data frame.

Name:
casu_gaincor
Purpose:
Correct input data for inter-detector gain difference
Description:
An input image is scaled by a constant value so as to put all the images in a single observation onto the same gain scale.
Language:
C
Parameters
infileThe input data image (overwritten by result).
gainsclThe input scale factor
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_WARNif the scale factor is <= zero
CASU_FATALif image data fails to load
QC headers:
None
DRS headers:
The following DRS keywords are written to the infile extension header
  • GAINCOR The gain correction factor
Author
Jim Lewis, CASU

Definition at line 77 of file casu_gaincor.c.

References casu_fits_get_ehu(), and casu_fits_get_image().

◆ casu_genbpm()

int casu_genbpm ( casu_fits **  flatlist,
int  nflatlist,
cpl_image *  master,
float  lthr,
float  hthr,
const char *  expkey,
cpl_array **  bpm_array,
int *  nbad,
float *  badfrac,
int *  status 
)

Generate a bad pixel mask from a list of dome flats.

Name:
casu_genbpm
Purpose:
Generate a bad pixel mask from a list of dark corrected dome flat images.
Description:
A list of dark corrected dome flat images is given. A master flat is created from all the input flats in the list. Each input flat is then divided by the master. Bad pixels are marked on the new image as those that are above or below the threshold (in sigma) in the new image. Any pixel which has been marked as bad for more than a quarter of the input images is defined as bad in the output mask.
Language:
C
Parameters
flatlistThe list of input dark corrected dome flat images.
nflatlistThe number of input images
masterA master flat. If this is NULL then a master will be created from the input list
lthrThe low rejection threshold in units of sigma
hthrThe high rejection threshold in units of sigma
expkeyThe header keyword for the exposure time.
bpm_arrayThe output bad pixel mask
nbadThe number of bad pixels found
badfracThe fraction of pixels in the map that are bad
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKIf everything is ok
CASU_FATALThe flat combination failed
QC headers:
None
DRS headers:
None
Author
Jim Lewis, CASU

Definition at line 97 of file casu_genbpm.c.

References casu_fits_get_image(), casu_getnpts(), casu_imcombine(), casu_medmad(), and casu_medsig().

◆ casu_get_cdschoice()

int casu_get_cdschoice ( const char *  cdscatname)
Name:
casu_get_cdschoice
Purpose:
Get the internal integer that matches the designation of CDS catalogues served through the casu_getstds interface
Description:
Looks up the appropriate integer number representing the choice of CDS catalogue.
Language:
C
Parameters
cdscatnameThe CDS designation for the catalogue
Return values
0if the string doesn't match a catalogue choice
1.. maxcds the matching catalogue choice
QC headers:
None
DRS headers:
None
Author
Jon Nielsen

Definition at line 479 of file casu_getstds.c.

◆ casu_getstds()

int casu_getstds ( cpl_propertylist *  plist,
int  cache,
char *  path,
char *  catname,
int  cdssearch,
char *  cacheloc,
cpl_table **  stds,
int *  status 
)

Get a table of standard stars that appear on an image from a catalogue.

Name:
casu_getstds
Purpose:
Get a table of standard stars that appear on an image from a catalogue.
Description:
The propertylist of an image is given. The WCS from that propertylist is extracted and the region in equatorial coordinates covered by the image is calculated. From that information standard stars are extracted from the requested source catalogues which reside either in a location specified by a given path or at the CDS. For each object in the table an x,y pixel coordinate pair is calculated from the WCS and added to the table.
Language:
C
Parameters
plistThe input propertylist for the image in question
cacheIf set, then we can cache results which should result in faster access for several observations of the same region
pathThe full path to the catalogue FITS files if they are stored locally
catnameThe name of the input catalogue. This is just used for labelling purposes
cdssearchIf this is not zero, then it refers to a catalogue to be searched at the CDS (this takes precedence over local catalogues if both cdssearch and a catpath are specfied). Current values are:
  • 1: 2MASS PSC
  • 2: USNOB
  • 3: PPMXL
  • 4: Landolt
  • 5: WISE
  • 6: APASS
cachelocA directory where we want to write the cache directory
stdsThe output table of standards
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_WARNif the output standards table has no rows in it
CASU_FATALif a failure occurs in either accessing or extracting the standard data.
QC headers:
None
DRS headers:
None
Author
Jim Lewis, CASU

Definition at line 167 of file casu_getstds.c.

References casu_coverage(), and casu_radectoxy().

Referenced by vircam_jmp_illum(), and vircam_jmp_matched_stds().

◆ casu_getstds_cdslist()

int casu_getstds_cdslist ( int  cdschoice,
char **  cdscatname,
char **  cdscatid,
int *  status 
)

Definition at line 431 of file casu_getstds.c.

◆ casu_imcombine()

int casu_imcombine ( casu_fits **  fset,
casu_fits **  fsetv,
int  nfits,
int  combtype,
int  scaletype,
int  xrej,
float  thresh,
const char *  expkey,
cpl_image **  outimage,
cpl_image **  outvimage,
unsigned char **  rejmask,
unsigned char **  rejplus,
cpl_propertylist **  drs,
int *  status 
)

Stack images into a mean or median image with rejection.

Name:
casu_imcombine
Purpose:
Stack images into a mean or median image with rejection
Description:
A list of frames is given. The images can be stacked by doing pixel by pixel means or medians. Images can be scaled or biassed to a common background value before any combination or rejection is done. The rejection algorithm has the option of doing an extra cycle which looks at the area surrounding a rejected pixel to see if the rejection is really justified. The output consists of a mean/median image, a rejection mask and a second rejection mask that only marks positive rejections. The latter could be useful if trying to assess the number of cosmic ray hits.
Language:
C
Parameters
fset
Input image list
fsetv
Input image variance list (NULL if not using)
nfitsThe number of input images
combtype
Combination type: 1 == Median, 2 == Mean
scaletype
Scaling type: 0 == none, 1 == additive, 2 == multiplicative, 3 == multiplicative by exp time then additive by flux
xrej
Extra rejection cycle flag
threshRejection threshold in sigma above background
expkeyThe header keyword with the exposure time
outimageOutput image
outvimageOutput variance image (if input variances are included)
rejmaskOutput rejection mask
rejplusOutput mask of rejected pixels with positive residual
drsA propertylist to be used to write DRS info
statusAn input/output status that is the same as the returned values below
Return values
CASU_OKif everything is ok
CASU_WARNif fset has zero length
CASU_FATALfor all other conditions
QC headers:
None
DRS headers:
The following DRS keywords are written to the drs propertylist
  • PROV**** The provenance keywords
Author
Jim Lewis, CASU

Definition at line 165 of file casu_imcombine.c.

References casu_fits_get_ehu(), casu_fits_get_filename(), casu_fits_get_image(), casu_fits_get_nexten(), casu_fits_get_phu(), casu_getnpts(), casu_med(), and casu_prov().

Referenced by casu_genbpm(), casu_pawsky_mask(), casu_pawsky_mask_pre(), casu_simplesky_mask(), vircam_genbpm(), vircam_jmp_skycor(), and vircam_tilesky().

◆ casu_imcore()

int casu_imcore ( casu_fits *  infile,
casu_fits *  conf,
int  ipix,
float  threshold,
int  icrowd,
float  rcore,
int  nbsize,
int  cattype,
float  filtfwhm,
casu_tfits **  outtab,
float  gainloc,
int *  status 
)

Generate object catalogues from input images.

Name:
casu_imcore
Purpose:
Generate object catalogues from input images
Description:
A frame and its confidence map are given. Detection thresholds and various other parameters are also given. Output is a table with all the extracted objects with object classifications included.
Language:
C
Parameters
infileThe input frame with the image to be analysed
confThe input frame with the confidence map
ipixThe minimum allowable size of an object
thresholdThe detection threshold in sigma above sky
icrowdIf set then the deblending software will be used
rcoreThe core radius in pixels
nbsizeThe smoothing box size for background map estimation
cattypeThe type of catalogue to be produced
filtfwhmThe FWHM of the smoothing kernel in the detection algorithm
outtabThe output table of object
gainlocThe detector gain in e-/ADU
statusThe input/output status that has the same return value a below
Return values
CASU_OKif everything is ok
CASU_WARN,CASU_FATALerrors in the called routines
QC headers:
The following values will go into the extension propertylist
  • SATURATION Saturation level in ADU
  • MEAN_SKY Mean sky brightness in ADU
  • SKY_NOISE Pixel noise at sky level in ADU
  • IMAGE_SIZE The average FWHM of stellar objects in arcsec
  • ELLIPTICITY The average stellar ellipticity (1 - b/a)
  • POSANG The average position angle in degrees from North towards East. NB: this value only makes sense if the ellipticity is significant
  • APERTURE_CORR The stellar aperture correction for 1x core flux
  • NOISE_OBJ The number of noise objects
DRS headers:
The following values will go into the extension propertylist
  • THRESHOL The detection threshold in ADU
  • MINPIX The minimum number of pixels per image
  • CROWDED Flag for crowded field analysis
  • RCORE The core radius for default profile fit in pixels
  • FILTFWHM The FWHM of the smoothing kernel in the detection algorithm
  • SEEING The average FWHM of stellar objects in pixels
  • XCOL The column containing the X position
  • YCOL The column containing the Y position
  • NXOUT The X dimension of the original image array
  • NYOUT The Y dimension of the original image array
  • CLASSIFD A flag to say that the catalgoue has been classified
  • SKYLEVEL Mean sky brightness in ADU
  • SKYNOISE Pixel noise at sky level in ADU
  • IMAGE_SIZE The average FWHM of stellar objects in arcsec
Other headers:
The following values will go into the extension propertylist
  • APCORxx A series of aperture correction values for each of the core radius apertures.
  • SYMBOLx A series of keywords to be used by GAIA for plotting ellipses
Author
Jim Lewis, CASU

Definition at line 149 of file casu_imcore.c.

References casu_fits_delete(), casu_fits_duplicate(), casu_fits_get_ehu(), casu_fits_get_filename(), casu_fits_get_fullname(), casu_fits_get_phu(), casu_propertylist_update_float(), casu_tfits_get_ehu(), casu_tfits_get_table(), imcore_classify(), and imcore_conf().

Referenced by vircam_jmp_catalogue(), vircam_jmp_dither_offsets(), and vircam_jmp_illum().

◆ casu_imdither()

int casu_imdither ( casu_fits **  inf,
casu_fits **  inconf,
int  nimages,
int  nconfs,
float  lthr,
float  hthr,
cpl_propertylist **  p,
const char *  expkey,
cpl_image **  out,
cpl_image **  outc,
int *  status 
)

Dither a set of jittered observations.

Name:
casu_imdither
Purpose:
Dither a set of jittered observations
Description:
A set of jittered observations and their confidence maps (optional) are given. The cartesian offsets for each image are also given in the header. The observations and the confidence maps are dithered into output maps taking the jitter offsets into account. No interpolation is done.
Language:
C
Parameters
infThe list of input jittered observation images. Their extension propertylists need to have: ESO DRS XOFFDITHER (the dither offset in X), ESO DRS YOFFDITHER (the dither offset in Y). These have to be added by the calling routine.
inconfThe list of input confidence maps. If the list is NULL or has a size of zero, then no output confidence map will be created. If the list has a size that is less than the size of the input files list, then only the first one will be used (i.e. each input image has the same confidence map). If the list has the same number as the input images then all of the listed confidence maps will be used to form the output confidence map.
nimagesThe number of input observation images
nconfsThe number of input confidence maps
lthrThe lower clipping threshold (in sigma)
hthrThe upper clipping threshold (in sigma)
pA propertylist that will be used for the output image. This will be the header for the first image in the input image frameset (infiles) with appropriate modifications to the WCS.
expkeyThe header keyword for the exposure time
outThe output dithered image
outcThe output confidence map
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_FATALif a failure occurs in either accessing input data or the input image list has not images in it.
QC headers:
None
DRS headers:
The following DRS keywords are written to the p propertylist
  • PROV**** The provenance keywords
Author
Jim Lewis, CASU

Definition at line 151 of file casu_imdither.c.

References casu_fits_get_ehu(), casu_fits_get_fullname(), casu_fits_get_image(), casu_fits_get_phu(), casu_prov(), and casu_timestamp().

Referenced by casu_pawsky_mask(), and vircam_jmp_dither_images().

◆ casu_imstack()

int casu_imstack ( casu_fits **  inf,
casu_fits **  inconf,
casu_fits **  invar,
casu_tfits **  cats,
int  nimages,
int  nconfs,
float  lthr,
float  hthr,
int  method,
int  seeing,
int  fast,
int  unmap,
const char *  expkey,
casu_fits **  out,
casu_fits **  outc,
casu_fits **  outv,
int *  status 
)

Stack images into a mean image using WCS info.

Name:
casu_imstack
Purpose:
Stack images into a mean image using WCS info
Description:
A list of frames is given. A mean image is stack by using the given WCS to work out the shift of an input pixel relative to the grid defined by the first image in the list. At first all are stacked using a nearest neighbour algorithm. Any discordant pixels are marked at this stage. If a different stacking algorithm is required, then the images are restacked, but with the discordant pixels found earlier removed. If object catalogues for each input image are available, then these are used to refine the coordinate transformation further. Variance maps can also be included.
Language:
C
Parameters
infInput image list
inconfInput list of confidence maps
invarInput list of variance maps (NULL if not using)
catsInput list of object catalogues. If NULL, then no refinement will be done.
nimagesThe number of input images and (if given) the number of input object catalogues
nconfsThe number of input confidence maps
lthrThe lower rejection threshold
hthrThe upper rejection threshold
methodThe interpolation method:
  • 0: Nearest neighbour
  • 1: Bi-linear interpolation
seeingIf set, then the input frames will be weighted by the seeing specified in the header keyword ESO DRS SEEING.
fastIf set, then the 'fast' algorithm will be used. The fast algorithm uses much more memory, so if the input image list is large it is best to use the slow algorithm.
unmapIf set then the images can be unmapped from time to time and then re-read. This should only be set if the input images also exist on disc
expkeyThe keyword in the headers that specify the exposure time
outThe output stacked image
outcThe output confidence map
outvThe output variance map
statusThe usual input/output status variable
Return values
CASU_OKif everything is ok
CASU_FATALif there are no images to combine or there is a mismatch between the confidence map sizes and image sizes.
DRS headers:
The following DRS keywords are written to the drs propertylist
  • PROV**** The provenance keywords
Author
Jim Lewis, CASU

Definition at line 187 of file casu_imstack.c.

References casu_coverage(), casu_fits_duplicate(), casu_fits_get_ehu(), casu_fits_get_fullname(), casu_fits_get_image(), casu_fits_get_phu(), casu_fits_unload_im(), casu_matchxy(), casu_platexy(), casu_prov(), and casu_tfits_get_table().

◆ casu_inpaint()

int casu_inpaint ( casu_fits *  in,
int  nbsize,
int *  status 
)

Inpaint pixels or patches in a map.

Name:
casu_inpaint
Purpose:
Inpoint pixels or patches in a map
Description:
An image and its bad pixel mask are given. The background of the image is modelled by using robust medians of cells. This background map is smoothed. Any bad pixels in the input map are replaced by the value in the background map.
Language:
C
Parameters
inThe input data image (overwritten by result).
nbsizeThe size of the cells for the smoothing boxes
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_WARNif the output property list is NULL.
CASU_FATALif image data arrays don't have matching dimensions
QC headers:
None
DRS headers:
None
Author
Jim Lewis, CASU

Definition at line 83 of file casu_inpaint.c.

References casu_backmap(), and casu_fits_get_image().

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

◆ casu_matchstds()

int casu_matchstds ( cpl_table *  objtab,
cpl_table *  stdstab,
float  srad,
cpl_table **  outtab,
int *  status 
)

Match object and standard star tables by their xy coordinates.

Name:
casu_matchstds
Purpose:
Match object and standard star tables by their xy coordinates
Description:
An object table (nominally from casu_imcore) and a standard star table (nominally from casu_getstds) are given. The x,y coordinates of each are searched to find the offsets that maximises the number of matched objects. Objects that match are written to an output table with both sets of cartesian coordinates plus any ancillary information that might be in the standards table.
Language:
C
Parameters
objtabThe input table with the programme objects. Must have columns called X_coordinate and Y_coordinate (as one gets from casu_imcore).
stdstabThe input table with the template objects. Must have columns called xpredict and ypredict (as one gets from casu_getstds).
sradA search radius in pixels. This helps to define the number of points that are used in the grid search
outtabThe returned output table with both sets of cartesian coordinates plus any extra information that appears in the standards table.
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKIf everything succeeded.
CASU_WARNIf either table has no rows.
CASU_FATALIf either table is missing one of the required columns
QC headers:
None
DRS headers:
None
Author
Jim Lewis, CASU

Definition at line 300 of file casu_match.c.

References casu_fndmatch(), and casu_medmad().

Referenced by vircam_jmp_illum(), and vircam_jmp_matched_stds().

◆ casu_matchxy()

int casu_matchxy ( cpl_table *  progtab,
cpl_table *  template,
float  srad,
float *  xoffset,
float *  yoffset,
int *  nm,
cpl_table **  outtab,
int *  status 
)

Match two lists of x,y coordinates from two tables to find the cartesian offset between them.

Name:
casu_matchxy
Purpose:
Match two lists of x,y coordinates from two tables to find the cartesian offset between them
Description:
A program and a template table are given. The x,y coordinates of each are searched to find the offsets that maximises the number of matched objects. These offsets are returned along with the number of matches. The offsets are in the sense: xoffset = x_template - x_programme
Language:
C
Parameters
progtabThe input table with the programme objects. Must have columns called X_coordinate and Y_coordinate.
templateThe input table with the template objects. Must have columns called X_coordinate and Y_coordinate.
sradA search radius in pixels. This helps to define the number of points that are used in the grid search
xoffsetThe returned x offset
yoffsetThe returned y offset
nmThe returned number of matches
outtabThe returned table of matched objects.
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKIf everything succeeded.
CASU_WARNIf either table has no rows.
CASU_FATALIf either table is missing one of the required columns
QC headers:
None
DRS headers:
None
Author
Jim Lewis, CASU

Definition at line 105 of file casu_match.c.

References casu_fndmatch(), and casu_med().

Referenced by casu_imstack(), and vircam_jmp_dither_offsets().

◆ casu_mkconf()

int casu_mkconf ( cpl_image *  flat,
char *  flatfile,
casu_mask *  bpm,
cpl_image **  outconf,
cpl_propertylist **  drs,
int *  status 
)

Create a confidence map.

Name:
vircam_mkconf
Purpose:
Create a confidence map
Description:
Create a confidence map from a given flat image and a bad pixel mask. The confidence is defined as 100 times the normalised flat field. Any pixels that are flagged as bad will have a value of 0 confidence.
Language:
C
Parameters
flatThe input flat field data image
flatfileThe input flat field file name.
bpmThe input mask image
outconfThe ouput confidence map image
drsA propertylist with entries for the drs header block
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_FATALif image data fails to load or the dimensionality of the input images don't match.
QC headers:
None
DRS headers:
The following DRS keywords are written to the drs propertylist
  • FLATIN The name of the originating FITS file for the flat image
  • BPMIN: The name of the originating FITS file for the BPM image
Author
Jim Lewis, CASU

Definition at line 87 of file casu_mkconf.c.

References casu_mask_get_data(), casu_mask_get_filename(), casu_mask_get_size_x(), casu_mask_get_size_y(), casu_mask_get_type(), and casu_mean().

◆ casu_nditcor()

int casu_nditcor ( casu_fits *  infile,
int  ndit,
const char *  expkey,
int *  status 
)

Correct input data for number of dits.

Name:
casu_nditcor
Purpose:
Correct input data for multiple dits.
Description:
Divide the input data by the number of dits. This is so that all images are scaled the same way. The result overwrites the input data array. The header exposure time is also modified.
Language:
C
Parameters
infileThe input data image (overwritten by result).
nditThe number of dits in the observation
expkeyThe FITS keyword for the exposure time
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_FATALif image data fails to load
QC headers:
None
DRS headers:
The following DRS keywords are written to the infile extension header
  • NDITCOR A logical keyword to say that this correction has been applied
Main headers:
The following keywords in the non-hierarchical part of the headers have been modified:
  • expkey The exposure time on entry is divided by the number of DITs. This is done both in the extension and the primary header.
Author
Jim Lewis, CASU

Definition at line 85 of file casu_nditcor.c.

References casu_fits_get_ehu(), casu_fits_get_image(), and casu_fits_get_phu().

◆ casu_nebuliser()

int casu_nebuliser ( casu_fits *  infile,
casu_fits *  inconf,
int  medfilt,
int  linfilt,
int  niter,
int  axis,
int  twod,
int  takeout_sky,
int  norm,
int  wantback,
float  signeg,
float  sigpos,
casu_fits **  backmap,
int *  status 
)

Remove small scale background variations.

Name:
casu_nebuliser
Purpose:
Remove small scale background variations
Description:
An input image is smoothed using an unsharp masking algorithm. The smoothed image is subtracted which should leave an image with minimal background variation.
Language:
C
Parameters
infileThe input image to be smoothed
inconfThe relevant confidence map. If this is NULL, then all pixels will be considered good.
medfiltThe size in pixels of the median filter box
linfiltThe size in pixels of the linear filter box
niterThe number of rejection iterations to use
axisIn the case of a 1d smooth, which axis to do first (1 => X, 2 => Y)
twodIf set, then a full 2d smooth is done. Otherwise it is a combination of 2 1d smoothing operations
takeout_skyIf set then the output median background will be zero
normIf set, then the output is the input divided by the smoothed image
wantbackIf set, then we want to have an output image of the background map
signegThe low clipping threshold
sigposThe high clipping threshold
backmapThe output background map, if requested. Otherwise set to NULL
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_FATALif image and confidence maps don't have the same dimensionality
QC headers:
None
DRS headers:
The following DRS keywords are written to the input file's extension header:
  • NEBULISED A boolean flag to say that the image has been nebulised
Author
Jim Lewis, CASU

Definition at line 154 of file casu_nebuliser.c.

References casu_fits_duplicate(), casu_fits_get_ehu(), and casu_fits_get_image().

◆ casu_opm()

int casu_opm ( casu_fits *  infile,
casu_fits *  conf,
int  ipix,
float  threshold,
int  nbsize,
float  filtfwhm,
int  niter,
int *  status 
)

Generate an object mask from an input image.

Name:
casu_opm
Purpose:
Generate an object mask from an input image
Description:
A frame and its confidence map are given. Detection thresholds and various other parameters are also given. Output is an object mask of the extracted objects. The result is written to the input cpl_image bad pixel mask.
Language:
C
Parameters
infileThe input frame with the image to be analysed
confThe input frame with the confidence map
ipixThe minimum allowable size of an object
thresholdThe detection threshold in sigma above sky
nbsizeThe smoothing box size for background map estimation
filtfwhmThe FWHM of the smoothing kernel in the detection algorithm
niterThe number of detection iterations to be done
statusThe input/output status that has the same return value a below
Return values
CASU_OKif everything is ok
CASU_WARN,CASU_FATALerrors in the called routines
DRS headers:
The following values will go into the extension propertylist
  • SKYLEVEL Mean sky brightness in ADU
  • SKYNOISE Pixel noise at sky level in ADU
Author
Jim Lewis, CASU

Definition at line 90 of file casu_opm.c.

References casu_fits_delete(), casu_fits_duplicate(), casu_fits_get_image(), and imcore_opm().

Referenced by casu_pawsky_mask(), and casu_simplesky_mask().

◆ casu_pawsky_mask()

int casu_pawsky_mask ( casu_fits **  inlist,
casu_fits **  invar,
int  nfiles,
casu_fits *  conf,
casu_mask *  mask,
casu_fits **  skyout,
casu_fits **  skyvar,
int  niter,
int  ipix,
float  thresh,
int  nbsize,
float  smkern,
int *  status 
)

Work out a masked sky estimate from an input jitter series.

Name:
casu_pawsky_mask
Purpose:
Work out a masked sky estimate from an input jitter series
Description:
Given an input jitter series stars are iteratively masked and clipped to form a final sky estimate.
Language:
C
Parameters
inlistThe input jitter series
invarThe variance maps for the input jitter series
nfilesThe number of images in the jitter series
confThe input confidence map for the jitter series
maskThe bad pixel mask derived from the confidence map.
skyoutThe output sky map
skyvarThe output sky variance map
niterThe number of masking and clipping iterations to do
ipixThe minimum object size for masking
threshThe threshold in sigma above sky for the object detection alrorithm
nbsizeThe cell size for the background following part of the object detection algorithm
smkernThe size in pixels of the smoothing kernal for the object detection algorithm
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_FATALif something went wrong. An error message will appear.
DRS headers:
The following values will go into the extension propertylist
  • SKYALGO The sky estimation algorithm used
Author
Jim Lewis, CASU

Definition at line 110 of file casu_sky.c.

References casu_dummy_image(), casu_dummy_property(), casu_fits_delete(), casu_fits_get_ehu(), casu_fits_get_image(), casu_fits_get_status(), casu_fits_set_status(), casu_fits_wrap(), casu_imcombine(), casu_imdither(), casu_inpaint(), casu_mask_get_data(), casu_mask_get_size_x(), casu_mask_get_size_y(), and casu_opm().

◆ casu_pawsky_mask_pre()

int casu_pawsky_mask_pre ( casu_fits **  inlist,
casu_fits **  invar,
int  nfiles,
casu_mask *  mask,
casu_fits *  objmask,
int  nbsize,
casu_fits **  skyout,
casu_fits **  skyvar,
int *  status 
)

Work out a sky estimate from an input jitter series and a pre-existing object mask.

Name:
casu_pawsky_mask_pre
Purpose:
Work out a sky estimate from an input jitter series and a pre-existing object mask.
Description:
Given an input jitter series and an object mask, the mask is partitioned to the regions covered by each input image. These are used to mask out objects during the stack to find the background map.
Language:
C
Parameters
inlistThe input jitter series
invarThe input jitter series variance maps
nfilesThe number of images in the jitter series
maskThe bad pixel mask derived from the confidence map.
objmaskThe input object mask
nbsizeThe cell size for the background following
skyoutThe output sky map
skyvarThe output sky variance map
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_FATALif something went wrong. An error message will appear.
DRS headers:
The following values will go into the extension propertylist
  • SKYALGO The sky estimation algorithm used
  • MASKUSED The object mask used
Author
Jim Lewis, CASU

Definition at line 412 of file casu_sky.c.

References casu_dummy_image(), casu_dummy_property(), casu_fits_get_ehu(), casu_fits_get_filename(), casu_fits_get_image(), casu_fits_get_status(), casu_fits_set_status(), casu_fits_wrap(), casu_imcombine(), casu_inpaint(), casu_mask_get_data(), casu_mask_get_size_x(), and casu_mask_get_size_y().

◆ casu_pawsky_minus()

int casu_pawsky_minus ( casu_fits **  infiles,
casu_fits **  invar,
casu_fits *  conf,
casu_fits *  objmaskfits,
int  nfiles,
casu_fits **  skyout,
casu_fits **  skyvar,
int *  status 
)

Background correct images using pawsky_minus algorithm.

Name:
casu_pawsky_minus
Purpose:
Use the pawsky_minus algorithm to background correct a list of images
Description:
The pawsky_minus algorithm is employed to work out a background estimate for each image in a list. A single representative sky is output, but it is not a sky that has been used to correct any of the input images.
Language:
C
Parameters
infilesThe input image list
invarThe input variance image list
confThe input master confidence map
objmaskfitsThe input object mask.
nfilesThe number of input images to be corrected
skyoutAn output representative sky map.
skyvarAn output representative sky variance map.
statusAn input/output status.
Return values
CASU_OKif everything is ok
CASU_WARNif all images have been flagged as bad
QC headers:
None
DRS headers:
The following DRS keywords are written to the infile extension
  • MASKUSED The name of the FITS file containing the object mask used.
  • SKYALGO The name of the sky correction algorithm
  • SKYSUB A keyword used to flag whether sky subtraction has been done
Author
Jim Lewis, CASU

Definition at line 112 of file casu_pawsky_minus.c.

References casu_dummy_image(), casu_dummy_property(), casu_fits_get_ehu(), casu_fits_get_filename(), casu_fits_get_image(), casu_fits_get_status(), casu_fits_set_status(), casu_fits_wrap(), casu_inpaint(), casu_prov(), casu_qmedsig(), and casu_xytoxy_list().

◆ casu_photcal_extinct()

int casu_photcal_extinct ( casu_fits **  images,
casu_tfits **  mstds,
casu_tfits **  cats,
int  nimages,
char *  filt,
cpl_table *  phottab,
int  minstars,
cpl_frame *  schlf_n,
cpl_frame *  schlf_s,
const char *  expkey,
const char *  amkey,
float  magerrcut,
int *  status 
)

Do photometric calibration.

Name:
casu_photcal_extinct
Purpose:
Do photometric calibration of a pawprint or tile
Description:
A photometric calibration calculation is done for either a tile or a pawprint. The input matched standards catalogue will be modified to include information on galactic extinction. Fluxes will also be modified by the camera distortion implied by the WCS.
Language:
C
Parameters
imagesThe input image list
mstdsThe matched standards tables list
catsThe list of source catalogues
nimagesThe number of input images
filtThe name of the filter for the observation
phottabThe relevant table for photometric calibration for a given standard source
minstarsThe minimum number of stars for the solution
schlf_nThe Schlegel map for the northern hemisphere
schlf_sThe Schlegel map for the southern hemisphere
expkeyThe FITS header keyword for the exposure time
amkeyThe FITS header keyword for the airmass
statusAn input/output status
Return values
CASU_OKif everything is ok
CASU_WARNif there are no images or images fail to load
QC headers:
  • MAGZPT The zeropoint calculated through aperture 3 using only objects from the current image
  • MAGZERR The zeropoint sigma calculated through aperture 3 using only objects from the current image.
  • MAGNZPT The number of objects used to calculate the zeropoint.
  • LIMITING_MAG The 5 sigma limiting magnitude through aperture 3.
  • SKYBRIGHT The sky brightness in mag/sq-arcsec
DRS headers:
The following DRS keywords are written to the infile extension header
  • MAGNZPTIM The number of objects used to calculate the zeropoint for the current image.
  • ZPIM1 The zeropoint calculated through 1*rcore using only objects from the current image.
  • ZPSIGIM1 The zeropoint sigma calculated through 1*rcore using only objects from the current image.
  • LIMIT_MAG1 The 5 sigma limiting magnitude for this image in 1*rcore
  • ZPIM2 The zeropoint calculated through 2*rcore using only objects from the current image.
  • ZPSIGIM2 The zeropoint sigma calculated through 2*rcore using only objects from the current image.
  • LIMIT_MAG2 The 5 sigma limiting magnitude for this image in 2*rcore
  • MAGNZPTALL The number of objects on all images used to calculate the zeropoint.
  • ZPALL1 The zeropoint calculated through 1*rcore using all objects from all images in the list.
  • ZPSIGALL1 The zeropoint sigma calculated through 1*rcore using all objects from all images in the list
  • ZPALL2 The zeropoint calculated through 2*rcore using all objects from all images in the list.
  • ZPSIGALL2 The zeropoint sigma calculated through 2*rcore using all objects from all images in the list
  • MEDEBV The median colour excess calculated from the Schlegel maps
  • SIGDET1 The detector-level dispersion in the 1*rcore aperture
  • SIGDET2 The detector-level dispersion in the 2*rcore aperture
  • SKYBRIGHT The sky brightness in mag/sq-arcsec
  • EXTINCT The assumed atmospheric extinction
Author
Jim Lewis, CASU

Definition at line 198 of file casu_photcal_extinct.c.

References casu_fits_get_ehu(), casu_fits_get_fullname(), casu_fits_get_phu(), casu_fits_get_status(), casu_medmad(), casu_tfits_get_ehu(), casu_tfits_get_phu(), and casu_tfits_get_table().

Referenced by vircam_jmp_photcal().

◆ casu_platesol()

int casu_platesol ( cpl_propertylist *  plist,
cpl_propertylist *  tlist,
cpl_table *  matchedstds,
int  nconst,
int  shiftan,
int *  status 
)

Work out a WCS for an image.

Name:
casu_platesol
Purpose:
Work out a WCS for an image
Description:
Given a matched standards table (a table of astrometric standards matched with objects on an image), work out a world coordinate system for the image. A full 6 constant plate solution (two zero points, two scales and two rotations) or a more restricted 4 constant solution (two zero points, one scale and one rotation) can be fit.
Language:
C
Parameters
plistThe propertylist which represents the FITS header for an input image. Must have a rough FITS WCS if the tangent point is going to be repositioned.
tlistThe propertylist which represents the FITS header for the input catalogue that went into the matched standards table. This is needed so that the catalogue header can be updated with the new WCS values. If it is NULL, then obviously no updating with be done
matchedstdsA matched standards table containing at least the following columns: X_coordinate, Y_coordinate, xpredict, ypredict, ra, dec.
nconstThe number of plate constants for the fit. The allowed values are 4 and 6 (4 constants or 6 constants).
shiftanIf set, then the difference between the predicted and true cartesian coordinates are used to redefine the equatorial coordinates of the pole of the WCS.
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_FATALif the plate solution has failed, there aren't enough standards or the requested number of constants is neither 4 nor 6.
QC headers:
The following QC keywords are written to the plist propertylist
  • WCS_DCRVAL1 Change in crval1 (degrees)
  • WCS_DCRVAL2 Change in crval2 (degrees)
  • WCS_DTHETA Change in rotation (degrees)
  • WCS_SCALE The mean plate scale (arcsec/pixel)
  • WCS_SHEAR Shear in the WCS solution (degrees)
  • WCS_RMS Average error in WCS fit in (arcsec)
DRS headers:
The following DRS keywords are written to the plist propertylist
  • NUMBRMS The number of stars in the WCS fit
  • STDCRMS The average error in the WCS fit (arcsec)
  • WCSRAOFF Central pixel RA_after - RA_before (arcsec)
  • WCSDECOFF Central pixel Dec_after - Dec_before (arcsec)
Other headers:
The input FITS WCS keywords are overwritten by updated values
Author
Jim Lewis, CASU

Definition at line 126 of file casu_platesol.c.

References casu_dmed(), casu_findcol(), casu_propertylist_update_double(), casu_radectoxieta(), and casu_xytoradec().

Referenced by vircam_jmp_wcsfit().

◆ casu_platexy()

int casu_platexy ( cpl_table *  matchedxy,
int  nconst,
cpl_array **  coefs,
int *  status 
)

Work out an xy transformation for two coodinate lists.

Name:
casu_platexy
Purpose:
Work out an xy transformation for two coordinate lists
Description:
Given a matched xy table (a table of objects with two sets of xy coordinates), work out a linear transformation between the coordinate sets. A full 6 constant plate solution (two zero points, two scales and two rotations) or a more restricted 4 constant solution (two zero points, one scale and one rotation) can be fit.
Language:
C
Parameters
matchedxyA matchedxy table. Must contain the following columns: X_coordinate_1, Y_coordinate_1, X_coordinate_2, Y_coordinate_2. The transformation will be done in the sense of transforming from frame 2 to frame 1.
nconstThe number of plate constants for the fit. The allowed values are 4 and 6 (4 constants or 6 constants).
coefsAn array of coefs.
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_FATALif the plate solution has failed, there aren't enough standards or the requested number of constants is neither 4 nor 6.
QC headers:
None
DRS headers:
None
Author
Jim Lewis, CASU

Definition at line 569 of file casu_platesol.c.

References casu_dmed().

Referenced by casu_imstack().

◆ casu_simplesky_mask()

int casu_simplesky_mask ( casu_fits **  inlist,
casu_fits **  invar,
int  nfiles,
casu_fits *  conf,
casu_mask *  mask,
casu_fits **  skyout,
casu_fits **  skyvar,
int  niter,
int  ipix,
float  thresh,
int  nbsize,
float  smkern,
int *  status 
)

Work out a masked sky estimate from a jitter series with large offsets.

Name:
casu_simplesky_mask
Purpose:
Work out a masked sky estimate from a jitter series with large offsets
Description:
Given an input jitter series stars are iteratively masked and clipped to form a final sky estimate.
Language:
C
Parameters
inlistThe input jitter series
invarThe input jitter series variance maps
nfilesThe number of images in the jitter series
confThe input confidence map for the jitter series
maskThe bad pixel mask derived from the confidence map.
skyoutThe output sky map
skyvarThe output sky variance map
niterThe number of masking and clipping iterations to do
ipixThe minimum object size for masking
threshThe threshold in sigma above sky for the object detection alrorithm
nbsizeThe cell size for the background following part of the object detection algorithm
smkernThe size in pixels of the smoothing kernal for the object detection algorithm
statusAn input/output status that is the same as the returned values below.
Return values
CASU_OKif everything is ok
CASU_FATALif something went wrong. An error message will appear.
DRS headers:
The following values will go into the extension propertylist
  • SKYALGO The sky estimation algorithm used
Author
Jim Lewis, CASU

Definition at line 643 of file casu_sky.c.

References casu_dummy_image(), casu_dummy_property(), casu_fits_get_ehu(), casu_fits_get_image(), casu_fits_get_status(), casu_fits_set_status(), casu_fits_wrap(), casu_imcombine(), casu_inpaint(), casu_mask_get_data(), casu_mask_get_size_x(), casu_mask_get_size_y(), and casu_opm().