MUSE Pipeline Reference Manual  2.1.1
muse_scipost_make_cube.c
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set sw=2 sts=2 et cin: */
3 /*
4  * This file is part of the MUSE Instrument Pipeline
5  * Copyright (C) 2005-2014 European Southern Observatory
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  */
21 
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25 
26 /*---------------------------------------------------------------------------*
27  * Includes *
28  *---------------------------------------------------------------------------*/
29 #include <muse.h>
30 #include "muse_scipost_make_cube_z.h"
31 
32 /*---------------------------------------------------------------------------*
33  * Functions code *
34  *---------------------------------------------------------------------------*/
35 
36 /*----------------------------------------------------------------------------*/
43 /*----------------------------------------------------------------------------*/
44 int
45 muse_scipost_make_cube_compute(muse_processing *aProcessing,
47 {
48  cpl_frameset *inframes = muse_frameset_find_tags(aProcessing->inframes,
49  aProcessing->intags, 0,
50  CPL_FALSE);
51  cpl_frame *frame = cpl_frameset_get_position(inframes, 0);
52  char *fn = cpl_strdup(cpl_frame_get_filename(frame));
54  aParams->lambdamin,
55  aParams->lambdamax);
56  muse_processing_append_used(aProcessing, frame, CPL_FRAME_GROUP_RAW, 1);
57  cpl_frameset_delete(inframes);
58  if (!pixtable) {
59  cpl_msg_error(__func__, "NULL pixel table for %s", fn);
60  cpl_free(fn);
61  return -1;
62  }
63  cpl_free(fn);
64  /* erase pre-existing QC parameters */
65  cpl_propertylist_erase_regexp(pixtable->header, "ESO QC ", 0);
66  muse_pixtable_wcs wcstype = muse_pixtable_wcs_check(pixtable);
67  if (wcstype == MUSE_PIXTABLE_WCS_NATSPH) {
69  muse_pfits_get_ra(pixtable->header),
70  muse_pfits_get_dec(pixtable->header));
71  }
72  muse_resampling_type resample
75  rp->dx = aParams->dx;
76  rp->dy = aParams->dy;
77  rp->dlambda = aParams->dlambda;
79  rp->crsigma = aParams->crsigma;
80  rp->ld = aParams->ld;
81  rp->rc = aParams->rc;
83  cpl_propertylist *outwcs = muse_postproc_cube_load_output_wcs(aProcessing);
85  cpl_propertylist_delete(outwcs);
87  cpl_error_code rc = muse_postproc_cube_resample_and_collapse(aProcessing,
88  pixtable,
89  format, rp,
90  aParams->filter);
92  if (aParams->stacked) {
93  cpl_msg_debug(__func__, "additional output as column-stacked image");
94  muse_image *img = muse_resampling_image(pixtable,
96  aParams->dx, aParams->dlambda);
97  muse_processing_save_image(aProcessing, -1, img, MUSE_TAG_OBJECT_RESAMPLED);
98  muse_image_delete(img);
99  }
100  muse_pixtable_delete(pixtable);
101  return rc == CPL_ERROR_NONE ? 0 : -1;
102 } /* muse_scipost_make_cube_compute() */
muse_pixtable_wcs
State of the astrometric calibration of a MUSE pixel table.
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.
cpl_propertylist * muse_postproc_cube_load_output_wcs(muse_processing *aProcessing)
Find a file with a usable output WCS in the input frameset.
void muse_image_delete(muse_image *aImage)
Deallocate memory associated to a muse_image object.
Definition: muse_image.c:85
double muse_pfits_get_ra(const cpl_propertylist *aHeaders)
find out the right ascension
Definition: muse_pfits.c:267
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.
const char * filter
The filter name(s) to be used for the output field-of-view image. Each name has to correspond to an E...
const char * resample_s
The resampling technique to use for the final output cube. (as string)
muse_resampling_crstats_type muse_postproc_get_cr_type(const char *aCRTypeString)
Select correct cosmic ray rejection type for crtype string.
Structure definition of MUSE three extension FITS file.
Definition: muse_image.h:40
double crsigma
Sigma rejection factor to use for cosmic ray rejection during final resampling. A zero or negative va...
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 ...
int ld
Number of adjacent pixels to take into account during resampling in all three directions (loop distan...
muse_resampling_crstats_type crtype
Structure definition of MUSE pixel table.
muse_cube_type muse_postproc_get_cube_format(const char *aFormatString)
Select correct cube format for format string.
muse_pixtable_wcs muse_pixtable_wcs_check(muse_pixtable *aPixtable)
Check the state of the world coordinate system of a pixel table.
double lambdamax
Cut off the data above this wavelength after loading the pixel table(s).
int stacked
If true, write an additional output file in form of a 2D stacked image (x direction is pseudo-spatial...
muse_resampling_params * muse_resampling_params_new(muse_resampling_type aMethod)
Create the resampling parameters structure.
muse_cube_type
double muse_pfits_get_dec(const cpl_propertylist *aHeaders)
find out the declination
Definition: muse_pfits.c:285
void muse_processing_append_used(muse_processing *aProcessing, cpl_frame *aFrame, cpl_frame_group aGroup, int aDuplicate)
Add a frame to the set of used frames.
double dx
Horizontal step size for resampling (in arcsec or pixel). The following defaults are taken when this ...
double rc
Critical radius for the "renka" resampling method.
muse_pixtable * muse_pixtable_load_restricted_wavelength(const char *aFilename, double aLambdaMin, double aLambdaMax)
Load a pixel table from file and cut down the wavelength range.
cpl_error_code muse_resampling_params_set_pixfrac(muse_resampling_params *aParams, const char *aString)
Set resampling pixfrac given a string that can contain up to three floating-point values...
int muse_processing_save_image(muse_processing *aProcessing, int aIFU, muse_image *aImage, const char *aTag)
Save a computed MUSE image to disk.
muse_resampling_type muse_postproc_get_resampling_type(const char *aResampleString)
Select correct resampling type for resample string.
Structure to hold the parameters of the muse_scipost_make_cube recipe.
const char * crtype_s
Type of statistics used for detection of cosmic rays during final resampling. "iraf" uses the varianc...
cpl_array * intags
double lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
cpl_frameset * inframes
double dy
Vertical step size for resampling (in arcsec or pixel). The following defaults are taken when this va...
muse_resampling_type
Resampling types.
const char * pixfrac
Pixel down-scaling factor for the "drizzle" resampling method. Up to three, comma-separated, floating-point values can be given. If only one value is given, it applies to all dimensions, two values are interpreted as spatial and spectral direction, respectively, while three are taken as horizontal, vertical, and spectral.
Resampling parameters.
void muse_resampling_params_delete(muse_resampling_params *aParams)
Delete a resampling parameters structure.
cpl_error_code muse_wcs_position_celestial(muse_pixtable *aPixtable, double aRA, double aDEC)
Convert native to celestial spherical coordinates in a pixel table.
Definition: muse_wcs.c:1466
double dlambda
Wavelength step size (in Angstrom). Natural instrument sampling is used, if this is 0...
void muse_pixtable_delete(muse_pixtable *aPixtable)
Deallocate memory associated to a pixel table object.
cpl_propertylist * header
The FITS header.
cpl_frameset * muse_frameset_find_tags(const cpl_frameset *aFrames, const cpl_array *aTags, unsigned char aIFU, cpl_boolean aInvert)
return frameset containing data from an IFU/channel with the given tag(s)
Definition: muse_utils.c:253
const char * format_s
Type of output file format, "Cube" is a standard FITS cube with NAXIS=3 and multiple extensions (for ...