Resampling

Data Structures

struct  muse_datacube
 Structure definition of a MUSE datacube. More...
struct  muse_euro3dcube
 Structure definition of a Euro3D datacube. More...
struct  muse_resampling_params
 Resampling parameters. More...

Enumerations

enum  muse_resampling_type {
  MUSE_RESAMPLE_NEAREST = 0, MUSE_RESAMPLE_WEIGHTED_RENKA = 1, MUSE_RESAMPLE_WEIGHTED_LINEAR, MUSE_RESAMPLE_WEIGHTED_QUADRATIC,
  MUSE_RESAMPLE_WEIGHTED_DRIZZLE, MUSE_RESAMPLE_WEIGHTED_LANCZOS, MUSE_RESAMPLE_NONE
}
 

Resampling types.

More...
enum  muse_resampling_crstats_type { MUSE_RESAMPLING_CRSTATS_IRAF = 0, MUSE_RESAMPLING_CRSTATS_MEAN = 1, MUSE_RESAMPLING_CRSTATS_MEDIAN = 2 }
 

Cosmic ray rejection statistics type.

More...
enum  muse_resampling_dispersion_type { MUSE_RESAMPLING_DISP_AWAV = 0, MUSE_RESAMPLING_DISP_AWAV_LOG = 1, MUSE_RESAMPLING_DISP_WAVE, MUSE_RESAMPLING_DISP_WAVE_LOG }

Functions

muse_resampling_paramsmuse_resampling_params_new (muse_resampling_type aMethod)
 Create the resampling parameters structure.
cpl_error_code muse_resampling_params_set_wcs (muse_resampling_params *aParams, const cpl_propertylist *aWCS)
 Set an output WCS (and wavelength scale) in the resampling parameters.
void muse_resampling_params_delete (muse_resampling_params *aParams)
 Delete a resampling parameters structure.
muse_euro3dcubemuse_resampling_euro3d (muse_pixtable *aPixtable, muse_resampling_params *aParams)
 Resample a pixel table onto a regular grid structure representing a Euro3D format file.
muse_datacubemuse_resampling_cube (muse_pixtable *aPixtable, muse_resampling_params *aParams, muse_pixgrid **aPixgrid)
 Resample a pixel table onto a regular grid structure representing a FITS NAXIS=3 datacube.
muse_imagemuse_resampling_collapse_pixgrid (muse_pixtable *aPixtable, muse_pixgrid *aPixgrid, muse_datacube *aCube, cpl_table *aFilter, muse_resampling_params *aParams)
 Integrate a pixel table / pixel grid along the wavelength direction.
muse_imagemuse_resampling_image (muse_pixtable *aPixtable, muse_resampling_type aMethod, double aDX, double aDLambda)
 Resample a pixel table onto a two-dimensional regular grid.
cpl_table * muse_resampling_spectrum (muse_pixtable *aPixtable, double aBinwidth)
 Resample the selected pixels of a pixel table into a spectrum.
cpl_table * muse_resampling_spectrum_iterate (muse_pixtable *aPixtable, double aBinwidth, float aLo, float aHi, unsigned char aIter)
 Iteratively resample selected pixels of a pixel table into spectrum.

Detailed Description


Enumeration Type Documentation

Cosmic ray rejection statistics type.

Enumerator:
MUSE_RESAMPLING_CRSTATS_IRAF 

IRAF-like statistics for cosmic ray rejection, * using mean and the data variance

MUSE_RESAMPLING_CRSTATS_MEAN 

Mean/standard deviation statistics for cosmic ray rejection

MUSE_RESAMPLING_CRSTATS_MEDIAN 

Median/MAD statistics for cosmic ray rejection

Definition at line 71 of file muse_resampling.h.

Enumerator:
MUSE_RESAMPLING_DISP_AWAV 

linear air-wavelength (CTYPEj="AWAV")

MUSE_RESAMPLING_DISP_AWAV_LOG 

logarithmic air-wavelength (CTYPEj="AWAV-LOG")

MUSE_RESAMPLING_DISP_WAVE 

linear vacuum-wavelength (CTYPEj="WAVE")

MUSE_RESAMPLING_DISP_WAVE_LOG 

logarithmic vacuum-wavelength (CTYPEj="WAVE-LOG")

Definition at line 81 of file muse_resampling.h.

Resampling types.

Enumerator:
MUSE_RESAMPLE_NEAREST 

Nearest neighbor resampling

MUSE_RESAMPLE_WEIGHTED_RENKA 

Weighted resampling using Renka weighting function

MUSE_RESAMPLE_WEIGHTED_LINEAR 

Weighted resampling using inverse distance weighting function

MUSE_RESAMPLE_WEIGHTED_QUADRATIC 

Weighted resampling using quadratic inverse distance weighting function

MUSE_RESAMPLE_WEIGHTED_DRIZZLE 

Weighted resampling using a drizzle-like weighting scheme

MUSE_RESAMPLE_WEIGHTED_LANCZOS 

Weighted resampling using a lanczos-like restricted sinc for weighting

MUSE_RESAMPLE_NONE 

No resampling, just create pixel grid; last value, can be used for range checking

Definition at line 48 of file muse_resampling.h.


Function Documentation

muse_image* muse_resampling_collapse_pixgrid ( muse_pixtable aPixtable,
muse_pixgrid aPixgrid,
muse_datacube aCube,
cpl_table *  aFilter,
muse_resampling_params aParams 
)

Integrate a pixel table / pixel grid along the wavelength direction.

Parameters:
aPixtable the input pixel table
aPixgrid the input pixel grid
aCube the datacube (only the header component is used)
aFilter the filter response curve
aParams the structure of resampling parameters
Returns:
A muse_image * of the field of view or NULL on error.

Loop through all pixels of the output image and integrate along the wavelength direction, using the requested resampling scheme to interpolate pixels of all wavelengths onto the output 2D image. The filter response curve is used weight the pixel data values according to their wavelength.

Note:
Only weighted resampling types are allowed, MUSE_RESAMPLE_NEAREST is not supported.

Optionally, if the environment variable MUSE_COLLAPSE_USE_VARIANCE is set to something positive, the variance information in the input pixel table will be used to weight the data according to their S/N.

XXX this function copies large parts of muse_resampling_cube_weighted().

Exceptions:
set CPL_ERROR_NULL_INPUT, return NULL aPixtable, its table component, aPixgrid, aCube, its header component, or aParams are NULL
set CPL_ERROR_ILLEGAL_INPUT, return NULL the resampling method passed in aParams is MUSE_RESAMPLE_NEAREST or unknown
integrate over the whole wavelength range aFilter is NULL

Definition at line 2108 of file muse_resampling.c.

References muse_wcs::cd22, muse_image::data, muse_image::dq, muse_image::header, muse_pixtable::header, muse_datacube::header, muse_wcs::iscelsph, muse_resampling_params::ld, muse_resampling_params::method, MUSE_FLUX_RESP_FILTER, muse_flux_response_interpolate(), MUSE_HDR_PT_LHI, MUSE_HDR_PT_LLO, muse_image_new(), muse_pfits_get_crval(), muse_pixgrid_get_count(), muse_pixgrid_get_index(), muse_pixgrid_get_rows(), MUSE_PIXTABLE_WCS_CELSPH, muse_pixtable_wcs_check(), MUSE_RESAMPLE_NEAREST, MUSE_RESAMPLE_NONE, MUSE_RESAMPLE_WEIGHTED_DRIZZLE, MUSE_RESAMPLE_WEIGHTED_LANCZOS, MUSE_RESAMPLE_WEIGHTED_LINEAR, MUSE_RESAMPLE_WEIGHTED_QUADRATIC, MUSE_RESAMPLE_WEIGHTED_RENKA, muse_wcs_celestial_from_pixel_fast(), muse_wcs_get_scales(), muse_wcs_new(), muse_wcs_projplane_from_pixel_fast(), muse_resampling_params::pfx, muse_resampling_params::rc, muse_image::stat, and muse_pixtable::table.

Referenced by muse_postproc_cube_resample_and_collapse().

muse_datacube* muse_resampling_cube ( muse_pixtable aPixtable,
muse_resampling_params aParams,
muse_pixgrid **  aPixgrid 
)

Resample a pixel table onto a regular grid structure representing a FITS NAXIS=3 datacube.

Parameters:
aPixtable the MUSE pixel table to resample
aParams the structure of resampling parameters
aPixgrid if not NULL, use it to store the pixel grid pointer
Returns:
A muse_datacube * for the output FITS datacube (and its bad pixels, variance and headers) or NULL on error.

This function implements the resampling scheme discussed in Sect. 2.2 of the DRLDesign document: First, convert the input pixel table into a regular grid of cells, storing the input pixels in their nearest cell. To resample, then loop through all cells, sampling surrounding pixels depending on the requested method. Values that rise aHSigma above the surrounding values, i.e. cosmic rays, are removed at this stage. Store the output pixels (their values, bad pixel status, and variance) in a muse_datacube structure to be used to store 3xFITS_NAXIS=3 files.

Note:
This function changes some of the components of aParams. Specifically, dx, dy, and dlambda may be changed after calling this function!
Quality Assessment:
Using the INM, different astronomical scenes can be created to be used for quality checks. When creating a scene with a few well separated point sources, one knows the flux of each source at each wavelength. If this function works correctly, the flux should be conserved and can be compared to the expected value (using some tolerance). If using a scene with sky emission lines, one can measure the wavelengths and dispersions in a few of the sky lines. They should be at the same wavelength for all spaxels and this position should agree with the position determined from the INM-created data. Additionally, a (visual) comparison of monochromatic maps created from INM input frames can be compared to maps derived from output cubes created by this routine. If all intermediate calibrations were derived correctly, both should look similar.
Exceptions:
set CPL_ERROR_NULL_INPUT, return NULL the input pixel table or input param structure are NULL
set CPL_ERROR_ILLEGAL_INPUT, return NULL the input pixel table does not contain full geometry information
set CPL_ERROR_UNSUPPORTED_MODE, return NULL the WCS in the pixel table is neither in pixels nor degrees
set CPL_ERROR_ILLEGAL_OUTPUT, return NULL computed output size in at least one coordinate is not positive
just create empty datacube and possibly return pixel grid given method is MUSE_RESAMPLE_NONE
set CPL_ERROR_UNSUPPORTED_MODE, return NULL given method is unknown
return NULL, propagate error code resampling fails

Definition at line 1854 of file muse_resampling.c.

References muse_resampling_params::crsigma, muse_resampling_params::crtype, muse_datacube::data, muse_datacube::dq, muse_resampling_params::dx, muse_pixtable::header, muse_datacube::header, muse_resampling_params::ld, muse_resampling_params::method, muse_datacube_delete(), MUSE_HDR_PT_LLO, MUSE_HDR_PT_XLO, MUSE_HDR_PT_YLO, muse_pfits_get_crpix(), muse_pixgrid_create(), muse_pixgrid_delete(), muse_pixtable_get_type(), MUSE_PIXTABLE_TYPE_FULL, MUSE_PIXTABLE_WCS_CELSPH, muse_pixtable_wcs_check(), MUSE_PIXTABLE_WCS_PIXEL, MUSE_RESAMPLE_NEAREST, MUSE_RESAMPLE_NONE, MUSE_RESAMPLE_WEIGHTED_DRIZZLE, MUSE_RESAMPLE_WEIGHTED_LANCZOS, MUSE_RESAMPLE_WEIGHTED_LINEAR, MUSE_RESAMPLE_WEIGHTED_QUADRATIC, MUSE_RESAMPLE_WEIGHTED_RENKA, MUSE_RESAMPLING_DISP_AWAV, MUSE_RESAMPLING_DISP_AWAV_LOG, MUSE_RESAMPLING_DISP_WAVE, MUSE_RESAMPLING_DISP_WAVE_LOG, muse_utils_memory_dump(), MUSE_WCS_KEYS, muse_resampling_params::pfx, muse_resampling_params::rc, muse_datacube::stat, muse_pixtable::table, and muse_resampling_params::tlambda.

Referenced by muse_dar_check(), muse_flux_integrate_std(), muse_postproc_cube_resample_and_collapse(), muse_postproc_process_exposure(), muse_resampling_euro3d(), and muse_wcs_locate_sources().

muse_euro3dcube* muse_resampling_euro3d ( muse_pixtable aPixtable,
muse_resampling_params aParams 
)

Resample a pixel table onto a regular grid structure representing a Euro3D format file.

Parameters:
aPixtable the MUSE pixel table to resample
aParams the structure of resampling parameters
Returns:
a muse_euro3dcube * for the output Euro3D data or NULL on error

See muse_resampling_cube() for the description of the algorithm. This function uses that output cube and converts it into a Euro3D table structure.

This function decides from the FITS keywords available in the pixel table header if the data was corrected for DAR and which reference wavelength was used, see muse_dar_correct().

Quality Assessment:
See muse_resampling_cube().
Exceptions:
set CPL_ERROR_NULL_INPUT, return NULL aParams is NULL
set CPL_ERROR_ILLEGAL_INPUT, return NULL aParams->method is not a real resampling type
return NULL, propagate error code of muse_resampling_cube() resampling fails

Definition at line 1567 of file muse_resampling.c.

References muse_datacube::data, muse_datacube::dq, muse_euro3dcube::dtable, muse_resampling_params::dx, muse_euro3dcube::gtable, muse_euro3dcube::hdata, muse_datacube::header, muse_euro3dcube::header, muse_euro3dcube::hgroup, muse_wcs::iscelsph, muse_resampling_params::method, muse_astro_airmass(), muse_astro_parangle(), muse_cpltable_new(), muse_datacube_delete(), muse_euro3dcube_e3d_data_def, muse_euro3dcube_e3d_grp_def, MUSE_HDR_PT_DAR_NAME, muse_pfits_get_cd(), muse_pfits_get_crval(), muse_pfits_get_ctype(), muse_pfits_get_cunit(), muse_pfits_get_pres_start(), muse_pfits_get_rhum(), muse_pfits_get_temp(), MUSE_PIXTABLE_WCS_CELSPH, muse_pixtable_wcs_check(), MUSE_RESAMPLE_NONE, muse_resampling_cube(), muse_wcs_celestial_from_pixel_fast(), muse_wcs_new(), muse_wcs_projplane_from_pixel_fast(), muse_datacube::stat, and muse_pixtable::table.

Referenced by muse_postproc_cube_resample_and_collapse().

muse_image* muse_resampling_image ( muse_pixtable aPixtable,
muse_resampling_type  aMethod,
double  aDX,
double  aDLambda 
)

Resample a pixel table onto a two-dimensional regular grid.

Parameters:
aPixtable the MUSE pixel table to resample
aMethod the value corresponding to a resampling method
aDX Step size in pixel direction
aDLambda the step size in wavelength direction (in Angstrom)
Returns:
a muse_image * on success or NULL on error
Remarks:
This function can be used instead of muse_resampling_cube() or muse_resampling_euro3d() for visual assessment of the wavelength calibration quality in the muse_wavecal recipe or for sky subtraction during post-processing.
The output is an image in which the y-axis is the wavelength direction and the x-axis represents the spatial domain within the slices, with all slices placed adjacent.
aMethod can be either MUSE_RESAMPLE_WEIGHTED_RENKA or MUSE_RESAMPLE_NEAREST (see Sect. 2.2.2 and 2.2.4 of the DRLDesign document). Other interpolation methods are not supported.
No horizontal interpolation (in cross-dispersion direction) is done. These resampling methods only use information in the wavelength direction to find the output value, as it is not clear what the real spatial relationship of neighboring grid points is when stored in a 2D grid.

Loop through all the pixels in the regular output grid and interpolate as discussed in DRLDesign document (2.2). The result is stored in a muse_image structure, so that the headers and the data component of this image can be saved as a FITS NAXIS=2 image.

Quality Assessment:
This method is only used for quick visual check, good quality is not expected.
Exceptions:
set CPL_ERROR_NULL_INPUT, return NULL the input pixel table is NULL
set CPL_ERROR_UNSUPPORTED_MODE, return NULL the WCS in the pixel table is neither in pixels nor degrees
set CPL_ERROR_UNSUPPORTED_MODE, return NULL given method is unknown
set CPL_ERROR_ILLEGAL_OUTPUT, return NULL computed output size in at least one coordinate is not positive
return NULL, propagate error code resampling fails

Definition at line 2668 of file muse_resampling.c.

References muse_image::data, muse_image::dq, muse_image::header, muse_pixtable::header, muse_cplimage_concat_x(), MUSE_HDR_PT_LHI, MUSE_HDR_PT_LLO, muse_image_delete(), muse_image_new(), muse_pixtable_extracted_delete(), muse_pixtable_extracted_get_size(), muse_pixtable_extracted_get_slices(), muse_pixtable_get_nrow(), muse_pixtable_get_type(), MUSE_PIXTABLE_TYPE_SIMPLE, MUSE_PIXTABLE_WCS_CELSPH, muse_pixtable_wcs_check(), MUSE_PIXTABLE_WCS_PIXEL, MUSE_RESAMPLE_NEAREST, MUSE_RESAMPLE_WEIGHTED_RENKA, muse_wcs_get_scales(), muse_image::stat, and muse_pixtable::table.

void muse_resampling_params_delete ( muse_resampling_params aParams  ) 

Delete a resampling parameters structure.

Parameters:
aParams Pointer to the structure.

This only calls cpl_free, but it's nice to have a function that reverses muse_resampling_params_new().

Definition at line 168 of file muse_resampling.c.

References muse_resampling_params::wcs.

Referenced by muse_dar_check(), muse_flux_integrate_std(), muse_postproc_process_exposure(), and muse_wcs_locate_sources().

muse_resampling_params* muse_resampling_params_new ( muse_resampling_type  aMethod  ) 

Create the resampling parameters structure.

Parameters:
aMethod the resampling type/method to set
Returns:
Pointer to the newly created structure or NULL on error.

Passing MUSE_RESAMPLE_NONE is allowed; it signifies to create an empty datacube but cannot be used to resample to Euro3D.

Exceptions:
set CPL_ERROR_ILLEGAL_INPUT, return NULL an illegal method was given
wcs component is left NULL, so it triggers valid defaults later aWCS is NULL

Definition at line 81 of file muse_resampling.c.

References muse_resampling_params::ld, muse_resampling_params::method, MUSE_RESAMPLE_NONE, muse_resampling_params::pfx, and muse_resampling_params::rc.

Referenced by muse_dar_check(), muse_flux_integrate_std(), muse_postproc_process_exposure(), and muse_wcs_locate_sources().

cpl_error_code muse_resampling_params_set_wcs ( muse_resampling_params aParams,
const cpl_propertylist *  aWCS 
)

Set an output WCS (and wavelength scale) in the resampling parameters.

Parameters:
aParams the resampling parameters
aWCS propertylist with a WCS
Returns:
CPL_ERROR_NONE on success, another CPL error code on failure.

Passing aWCS as NULL is allowed, it signifies to free and NULL out an existing WCS, the tlambda component is then set to MUSE_RESAMPLING_DISP_AWAV. Otherwise, tlambda is set to MUSE_RESAMPLING_DISP_AWAV (as default) or another valid muse_resampling_dispersion_type, and wcs is filled using cpl_wcs_new_from_propertylist().

Exceptions:
return CPL_ERROR_NULL_INPUT aParams is NULL
wcs component is left NULL, so it triggers valid defaults later aWCS is NULL
wcs component is set to NULL, return code is propagated cpl_wcs_new_from_propertylist() fails

Definition at line 119 of file muse_resampling.c.

References muse_pfits_get_ctype(), MUSE_RESAMPLING_DISP_AWAV, MUSE_RESAMPLING_DISP_AWAV_LOG, MUSE_RESAMPLING_DISP_WAVE, MUSE_RESAMPLING_DISP_WAVE_LOG, muse_resampling_params::tlambda, and muse_resampling_params::wcs.

cpl_table* muse_resampling_spectrum ( muse_pixtable aPixtable,
double  aBinwidth 
)

Resample the selected pixels of a pixel table into a spectrum.

Parameters:
aPixtable The MUSE pixel table to resample
aBinwidth The bin width to use.
Returns:
A table with a spectrum or NULL on error.

This function carries out a linear interpolation of all selected pixels of a pixel table into a 1D spectrum. The output spectrum is represented as a table and may not be contiguous.

Exceptions:
set CPL_ERROR_NULL_INPUT, return NULL aPixtable or one of its components is NULL
set CPL_ERROR_ILLEGAL_INPUT, return NULL aPixtable does not match the definition of a pixel table

Definition at line 2805 of file muse_resampling.c.

References muse_pixtable::header, muse_cpltable_check(), muse_cpltable_new(), muse_dataspectrum_def, MUSE_HDR_PT_LHI, MUSE_HDR_PT_LLO, muse_pixtable_def, and muse_pixtable::table.

Referenced by muse_postproc_process_exposure(), and muse_resampling_spectrum_iterate().

cpl_table* muse_resampling_spectrum_iterate ( muse_pixtable aPixtable,
double  aBinwidth,
float  aLo,
float  aHi,
unsigned char  aIter 
)

Iteratively resample selected pixels of a pixel table into spectrum.

Parameters:
aPixtable The MUSE pixel table to resample
aBinwidth The bin width to use.
aLo Low rejection sigma limit, use 0. to ignore low outliers
aHi High rejection sigma limit, use 0. to ignore high outliers
aIter The number of iterations to use
Returns:
A table with a spectrum or NULL on error.

This function carries out a linear interpolation of all selected pixels of a pixel table into a 1D spectrum, using muse_resampling_spectrum().

This function uses the first version of the spectrum is checked against the original pixels in each spectral bin, to reject outliers outside the ranges spectrum - aLo * stddev and spectrum + aHi * stddev. The flagged pixel table is then used to compute another version of the spectrum, until aIter is reached. Before exiting the function, the flags are removed again from the original pixel table.

Note that this works well for regions where the spectrum changes very little (i.e. the sky background), but it is likely to reject science content in areas covered by objects.

The output spectrum is represented as a table and may not be contiguous.

Exceptions:
set CPL_ERROR_NULL_INPUT, return NULL aPixtable or one of its components is NULL
set CPL_ERROR_ILLEGAL_INPUT, return NULL aPixtable does not match the definition of a pixel table

Definition at line 2935 of file muse_resampling.c.

References muse_pixtable::header, muse_cpltable_check(), muse_cpltable_find_sorted(), muse_pixtable_def, muse_pixtable_reset_dq(), muse_resampling_spectrum(), and muse_pixtable::table.

Referenced by muse_postproc_process_exposure(), and muse_utils_pixtable_fit_line_gaussian().


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