Post-processing functions

Data Structures

struct  muse_postproc_properties
 Structure definition of the post-processing properties. More...
struct  muse_postproc_sky_outputs
 Structure definition of the post-processing output sky data. More...

Enumerations

enum  muse_postproc_type
 

Type of per-exposure processing to run.


enum  muse_postproc_skymethod
 

Method of sky subtraction to apply.


enum  muse_postproc_darcheck
 

Method of DAR checking/correction to do.


Functions

muse_postproc_propertiesmuse_postproc_properties_new (muse_postproc_type aType)
 Create a post-processing properties object.
void muse_postproc_properties_delete (muse_postproc_properties *aProp)
 Free memory taken by a post-processing properties object and all its components.
cpl_boolean muse_postproc_check_save_param (const char *aSave, const char *aValid)
 Check the --save parameter contents against allowed options.
muse_resampling_type muse_postproc_get_resampling_type (const char *aResampleString)
 Select correct resampling type for resample string.
muse_resampling_crstats_type muse_postproc_get_cr_type (const char *aCRTypeString)
 Select correct cosmic ray rejection type for crtype string.
muse_cube_type muse_postproc_get_cube_format (const char *aFormatString)
 Select correct cube format for format string.
muse_xcombine_types muse_postproc_get_weight_type (const char *aWeightString)
 Select correct weighting type for weight string.
cpl_table * muse_postproc_load_nearest (const cpl_propertylist *aHeader, const cpl_frame *aFrame, float aWarnLimit, float aErrLimit, double *aRA, double *aDEC)
 Load the calibration from a multi-table FITS file that is nearest on the sky.
void * muse_postproc_process_exposure (muse_postproc_properties *aProp, unsigned int aIndex, muse_postproc_sky_outputs *aSkyOut)
 Merge and process pixel tables from one exposure.
cpl_propertylist * muse_postproc_cube_load_output_wcs (muse_processing *aProcessing)
 Find a file with a usable output WCS in the input frameset.
cpl_error_code muse_postproc_cube_resample_and_collapse (muse_processing *aProcessing, muse_pixtable *aPixtable, muse_cube_type aFormat, muse_resampling_params *aParams, const char *aFilter)
 High level function to resample to a datacube and collapse that to an image of the field of view and save both objects.
cpl_error_code muse_postproc_qc_fwhm (muse_processing *aProcessing, muse_datacube *aCube)
 Compute QC1 parameters for datacubes and save them in the FITS header.

Detailed Description

This group contains functions that are common to some post-processing recipes.


Function Documentation

cpl_boolean muse_postproc_check_save_param ( const char *  aSave,
const char *  aValid 
)

Check the --save parameter contents against allowed options.

Parameters:
aSave --save parameter string constant
aValid comma-delimited string of all valid options
Returns:
CPL_TRUE if everything is ok, CPL_FALSE something went wrong.

Definition at line 134 of file muse_postproc.c.

References muse_cplarray_new_from_delimited_string().

cpl_propertylist* muse_postproc_cube_load_output_wcs ( muse_processing aProcessing  ) 

Find a file with a usable output WCS in the input frameset.

Parameters:
aProcessing the processing structure
Returns:
A cpl_propertylist with the WCS or NULL on failure

The file to search should be tagged as MUSE_TAG_OUTPUT_WCS in the input aProcessing->inFrames. This function then takes the header of the first extension that has NAXIS=2 or 3 (or WCSAXES=2 or 3) and supported CTYPEi entries for all relevant axes (supported are RA---TAN for axis1, DEC--TAN for axis 2, and AWAV and AWAV-LOG for axis 3). If aProcessing->inFrames contains multiple files with the required tag, only the first one is taken into account.

Exceptions:
set CPL_ERROR_NULL_INPUT, return NULL aProcessing is NULL
set CPL_ERROR_NONE, return NULL no file tagged MUSE_TAG_OUTPUT_WCS was found

Definition at line 802 of file muse_postproc.c.

References muse_processing::inframes, muse_frameset_find(), and muse_processing_append_used().

cpl_error_code muse_postproc_cube_resample_and_collapse ( muse_processing aProcessing,
muse_pixtable aPixtable,
muse_cube_type  aFormat,
muse_resampling_params aParams,
const char *  aFilter 
)

High level function to resample to a datacube and collapse that to an image of the field of view and save both objects.

Parameters:
aProcessing the processing structure
aPixtable the MUSE pixel table to resample
aFormat the output format of the datacube
aParams the structure of resampling parameters
aFilter the string with comma-separated filter names to load
Returns:
CPL_ERROR_NONE on success or a cpl_error_code on failure
Exceptions:
return CPL_ERROR_NULL_INPUT aProcessing, aPixtable, or aParams are NULL
return CPL_ERROR_ILLEGAL_INPUT aFormat contains an invalid format ID
propagate error code of muse_resampling_<format> resampling to cube fails
propagate error code of muse_processing_save_cube() saving cube fails

Definition at line 892 of file muse_postproc.c.

References muse_image::header, muse_cplarray_new_from_delimited_string(), MUSE_CUBE_TYPE_EURO3D, MUSE_CUBE_TYPE_EURO3D_X, MUSE_CUBE_TYPE_FITS, MUSE_CUBE_TYPE_FITS_X, MUSE_CUBE_TYPE_SDP, muse_datacube_collapse(), muse_datacube_convert_dq(), muse_datacube_delete(), muse_euro3dcube_collapse(), muse_euro3dcube_delete(), muse_image_delete(), muse_image_dq_to_nan(), muse_imagelist_get_size(), muse_imagelist_new(), muse_imagelist_set(), MUSE_PHYS_AIR_STANDARD, muse_phys_air_to_vacuum(), muse_pixgrid_delete(), muse_postproc_qc_fwhm(), muse_processing_save_cube(), muse_processing_save_image(), muse_resampling_collapse_pixgrid(), muse_resampling_cube(), MUSE_RESAMPLING_DISP_WAVE, MUSE_RESAMPLING_DISP_WAVE_LOG, muse_resampling_euro3d(), muse_table_load_filter(), muse_utils_copy_modified_header(), and muse_resampling_params::tlambda.

muse_resampling_crstats_type muse_postproc_get_cr_type ( const char *  aCRTypeString  ) 

Select correct cosmic ray rejection type for crtype string.

Parameters:
aCRTypeString the format string from the recipe parameters
Returns:
The respective cosmic ray rejection type as muse_resampling_crstats_type or MUSE_RESAMPLING_CRSTATS_MEDIAN on error.

The framework in principle ensures that no unsupported/unknown crtypes arrive here but nevertheless fall back to MUSE_RESAMPLING_CRSTATS_MEDIAN as the default in case something really weird happens.

Exceptions:
set CPL_ERROR_NULL_INPUT, return MUSE_RESAMPLING_CRSTATS_MEDIAN aCRTypeString is NULL

Definition at line 227 of file muse_postproc.c.

References MUSE_RESAMPLING_CRSTATS_IRAF, MUSE_RESAMPLING_CRSTATS_MEAN, and MUSE_RESAMPLING_CRSTATS_MEDIAN.

muse_cube_type muse_postproc_get_cube_format ( const char *  aFormatString  ) 

Select correct cube format for format string.

Parameters:
aFormatString the format string from the recipe parameters
Returns:
The respective cube format as muse_cube_type or MUSE_CUBE_TYPE_FITS on error.

The framework in principle ensures that no unsupported/unknown formats arrive here but nevertheless fall back to MUSE_CUBE_TYPE_FITS as the default in case something really weird happens.

Exceptions:
set CPL_ERROR_NULL_INPUT, return MUSE_CUBE_TYPE_FITS aFormatString is NULL

Definition at line 258 of file muse_postproc.c.

References MUSE_CUBE_TYPE_EURO3D, MUSE_CUBE_TYPE_EURO3D_X, MUSE_CUBE_TYPE_FITS, MUSE_CUBE_TYPE_FITS_X, and MUSE_CUBE_TYPE_SDP.

muse_resampling_type muse_postproc_get_resampling_type ( const char *  aResampleString  ) 

Select correct resampling type for resample string.

Parameters:
aResampleString the format string from the recipe parameters
Returns:
The respective resampling type as muse_resampling_type or MUSE_RESAMPLE_WEIGHTED_DRIZZLE on error.

The framework in principle ensures that no unsupported/unknown resampling types arrive here but nevertheless fall back to MUSE_RESAMPLE_WEIGHTED_DRIZZLE as the default in case something really weird happens.

Exceptions:
set CPL_ERROR_NULL_INPUT, return MUSE_RESAMPLE_WEIGHTED_DRIZZLE aResampleString is NULL

Definition at line 186 of file muse_postproc.c.

References MUSE_RESAMPLE_NEAREST, MUSE_RESAMPLE_WEIGHTED_DRIZZLE, MUSE_RESAMPLE_WEIGHTED_LANCZOS, MUSE_RESAMPLE_WEIGHTED_LINEAR, MUSE_RESAMPLE_WEIGHTED_QUADRATIC, and MUSE_RESAMPLE_WEIGHTED_RENKA.

muse_xcombine_types muse_postproc_get_weight_type ( const char *  aWeightString  ) 

Select correct weighting type for weight string.

Parameters:
aWeightString the weight string from the recipe parameters
Returns:
The respective weighting type as muse_xcombine_types or MUSE_XCOMBINE_EXPTIME on error.

The framework in principle ensures that no unsupported/unknown weight types arrive here but nevertheless fall back to MUSE_XCOMBINE_EXPTIME as the default in case something really weird happens.

Exceptions:
set CPL_ERROR_NULL_INPUT, return MUSE_XCOMBINE_EXPTIME aWeightString is NULL

Definition at line 295 of file muse_postproc.c.

References MUSE_XCOMBINE_EXPTIME, MUSE_XCOMBINE_FWHM, and MUSE_XCOMBINE_NONE.

cpl_table* muse_postproc_load_nearest ( const cpl_propertylist *  aHeader,
const cpl_frame *  aFrame,
float  aWarnLimit,
float  aErrLimit,
double *  aRA,
double *  aDEC 
)

Load the calibration from a multi-table FITS file that is nearest on the sky.

Parameters:
aHeader the FITS header with the reference position (RA, DEC)
aFrame the frame containing the multi-table file information
aWarnLimit minimum distance in arcsec before warning is given
aErrLimit minimum distance in arcsec before failing
aRA RA of reference source to return (can be NULL)
aDEC DEC of reference source to return (can be NULL)
Returns:
a table selected to be nearest on the sky or NULL on error

This loops through all FITS extensions present in the file in aFrame and computes the distance on the sky relative to the position taken from aHeader. The table from the extension with the nearest distance is then loaded.

A warning is output if the distance is larger than half the MUSE field size, i.e. more than aWarnLimit arcsec.

Exceptions:
set CPL_ERROR_NULL_INPUT, return NULL aHeader and/or aFrame are NULL
set CPL_ERROR_DATA_NOT_FOUND, return NULL aHeader does not contain RA and/or DEC
set CPL_ERROR_INCOMPATIBLE_INPUT, return NULL position in aHeader is more than aErrLimit away from all reference sources

Definition at line 337 of file muse_postproc.c.

References muse_astro_angular_distance(), muse_pfits_get_dec(), and muse_pfits_get_ra().

Referenced by muse_postproc_process_exposure().

void* muse_postproc_process_exposure ( muse_postproc_properties aProp,
unsigned int  aIndex,
muse_postproc_sky_outputs aSkyOut 
)

Merge and process pixel tables from one exposure.

Parameters:
aProp the post-processing properties object
aIndex index of the exposure (starting with 0)
aSkyOut sky output structure
Returns:
a valid pointer representing the object expected by the calling recipe or NULL on error

Depending on processing type requested in the properties object, either apply all calibrations (and return a pixel table), or derive the flux response (and return a response table plus a telluric correction table), or derive an astrometric calibration (and return it).

On output, the components of the aSkyOut structure may have been filled (depending on the inputs and parameters given in aProp). Then, they need to be deallocated with the respective functions.

Pseudo code:
  pixeltable = muse_pixtable_load_merge_channels()
  if not standard:
    muse_flux_calibrate()
  muse_sky_subtract_pixtable(pixeltable)
  if WFM:
    muse_dar_correct()
    muse_dar_check()
  if standard:
    muse_flux_integrate_std()
    muse_flux_response_compute()
    muse_flux_get_response_table()
    muse_flux_get_telluric_table()
    return
  if astrometry:
    muse_wcs_locate_sources()
    muse_wcs_solve()
    return
  muse_wcs_project_tan()
Exceptions:
set CPL_ERROR_NULL_INPUT, return NULL aProp or aProp->exposures are NULL
set CPL_ERROR_ILLEGAL_INPUT, return NULL aIndex is larger than the last index in the aProp->exposures table

Definition at line 442 of file muse_postproc.c.

References muse_postproc_properties::centroid, muse_postproc_sky_outputs::continuum, muse_postproc_properties::crpix2, muse_resampling_params::crsigma, muse_resampling_params::crtype, muse_postproc_properties::darcheck, muse_image::data, muse_flux_object::decref, muse_postproc_properties::detsigma, muse_postproc_properties::exposures, muse_postproc_properties::extinction, muse_postproc_properties::faccuracy, muse_pixtable::header, muse_flux_object::intimage, muse_postproc_properties::lambdamax, muse_postproc_properties::lambdamin, muse_postproc_properties::lambdaref, muse_postproc_sky_outputs::lines, muse_postproc_properties::lsf_cube, muse_postproc_properties::lsf_params, muse_postproc_sky_outputs::mask, muse_astro_airmass(), muse_cplerrorstate_dump_some(), muse_cpltable_extract_column(), muse_dar_check(), muse_dar_correct(), muse_datacube_collapse(), muse_datacube_delete(), muse_flux_calibrate(), muse_flux_get_response_table(), muse_flux_get_telluric_table(), muse_flux_integrate_std(), muse_flux_object_new(), muse_flux_reference_table_check(), muse_flux_response_compute(), muse_image_delete(), muse_lsf_average_cube_all(), muse_lsf_fold_rectangle(), muse_mask_delete(), muse_pfits_get_dec(), muse_pfits_get_mode(), muse_pfits_get_ra(), muse_pixtable_and_selected_mask(), muse_pixtable_delete(), muse_pixtable_duplicate(), muse_pixtable_load_merge_channels(), muse_postproc_load_nearest(), MUSE_RESAMPLE_WEIGHTED_DRIZZLE, MUSE_RESAMPLING_CRSTATS_MEDIAN, muse_resampling_cube(), muse_resampling_params_delete(), muse_resampling_params_new(), muse_resampling_spectrum(), muse_resampling_spectrum_iterate(), muse_rvcorrect(), muse_sky_continuum_create(), muse_sky_create_skymask(), muse_sky_lines_fit(), muse_sky_lines_fit_old(), muse_sky_lines_set_range(), muse_sky_subtract_continuum(), muse_sky_subtract_lines(), muse_sky_subtract_lines_old(), muse_table_load_filter(), muse_wcs_locate_sources(), muse_wcs_object_new(), muse_wcs_optimize_solution(), muse_wcs_project_tan(), muse_wcs_solve(), muse_postproc_properties::niter, muse_postproc_properties::profile, muse_postproc_properties::radius, muse_flux_object::raref, muse_postproc_properties::refframe, muse_postproc_properties::rejsigma, muse_postproc_properties::response, muse_postproc_properties::rvtype, muse_postproc_properties::select, muse_postproc_properties::sky_continuum, muse_postproc_properties::sky_lines, muse_postproc_properties::sky_mask, muse_postproc_properties::skymethod, muse_postproc_properties::skymodel_params, muse_postproc_properties::smooth, muse_postproc_sky_outputs::spectrum, muse_pixtable::table, muse_postproc_properties::tellregions, muse_postproc_properties::telluric, muse_postproc_properties::type, and muse_postproc_properties::wcs.

void muse_postproc_properties_delete ( muse_postproc_properties aProp  ) 
muse_postproc_properties* muse_postproc_properties_new ( muse_postproc_type  aType  ) 

Create a post-processing properties object.

Parameters:
aType the type of processing to set
Returns:
the post-processing properties object or NULL on error

In the returned structure, all pointer objects are NULL. The sky subtraction method is set to MUSE_POSTPROC_SKYMETHOD_NONE.

Exceptions:
set CPL_ERROR_ILLEGAL_INPUT, return NULL unsupported aType is given

Definition at line 76 of file muse_postproc.c.

References muse_postproc_properties::type.

cpl_error_code muse_postproc_qc_fwhm ( muse_processing aProcessing,
muse_datacube aCube 
)

Compute QC1 parameters for datacubes and save them in the FITS header.

Parameters:
aProcessing the processing structure
aCube the datacube
Returns:
CPL_ERROR_NONE on success or a cpl_error_code on failure

The prefix of the generated QC1 FITS keywords is set depending on the recipe name in the aProcessing structure.

XXX Part of this is copied in the image_fwhm tool.

Algorithm:
This function detects objects in the central wavelength plane of the input datacube, derives the FWHM for each source in x- and y-direction, and converts the FWHM from pixel scale to arcsec units which are saved in the header of the input cube.
Exceptions:
return CPL_ERROR_NULL_INPUT aProcessing or aCube are NULL
return CPL_ERROR_DATA_NOT_FOUND no sources were detected
output info message, return CPL_ERROR_NONE unknown recipe called this function

Definition at line 1060 of file muse_postproc.c.

References muse_datacube::data, muse_datacube::header, muse_pfits_get_cd(), muse_pfits_get_crpix(), muse_pfits_get_crval(), muse_pfits_get_ctype(), muse_pfits_get_mode(), and muse_processing::name.

Referenced by muse_postproc_cube_resample_and_collapse().


Generated on 26 Jan 2017 for MUSE Pipeline Reference Manual by  doxygen 1.6.1