MUSE Pipeline Reference Manual  2.5.2
muse_scipost.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-2017 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 <string.h>
30 
31 #include <muse.h>
32 #include "muse_scipost_z.h"
33 
34 /*---------------------------------------------------------------------------*
35  * Functions code *
36  *---------------------------------------------------------------------------*/
37 
38 /*----------------------------------------------------------------------------*/
54 /*----------------------------------------------------------------------------*/
55 int
56 muse_scipost_compute(muse_processing *aProcessing,
57  muse_scipost_params_t *aParams)
58 {
59  const char *savevalid = "cube,autocal,raman,skymodel,individual,positioned,"
60  "combined,stacked";
61  if (!muse_postproc_check_save_param(aParams->save, savevalid)) {
62  return -1;
63  }
64  muse_postproc_properties *prop = muse_postproc_properties_new(MUSE_POSTPROC_SCIPOST);
65  /* per-exposure parameters */
66  prop->lambdamin = aParams->lambdamin;
67  prop->lambdamax = aParams->lambdamax;
68  prop->lambdaref = aParams->lambdaref;
69  prop->darcheck = MUSE_POSTPROC_DARCHECK_NONE;
70  if (aParams->darcheck == MUSE_SCIPOST_PARAM_DARCHECK_CHECK) {
71  prop->darcheck = MUSE_POSTPROC_DARCHECK_CHECK;
72  } else if (aParams->darcheck == MUSE_SCIPOST_PARAM_DARCHECK_CORRECT) {
73  prop->darcheck = MUSE_POSTPROC_DARCHECK_CORRECT;
74  }
75  prop->rvtype = muse_rvcorrect_select_type(aParams->rvcorr_s);
76  /* flux calibration */
77  prop->response = muse_processing_load_table(aProcessing,
78  MUSE_TAG_STD_RESPONSE, 0);
79  prop->telluric = muse_processing_load_table(aProcessing,
80  MUSE_TAG_STD_TELLURIC, 0);
81  prop->extinction = muse_processing_load_ctable(aProcessing,
82  MUSE_TAG_EXTINCT_TABLE, 0);
83  /* astrometric correction */
84  prop->astrometry = aParams->astrometry;
85  if (aParams->astrometry) {
86  prop->wcs = muse_processing_load_header(aProcessing, MUSE_TAG_ASTROMETRY_WCS);
87  }
88  /* self calibration */
89  prop->autocalib = MUSE_POSTPROC_AUTOCALIB_NONE;
90  if (aParams->autocalib == MUSE_SCIPOST_PARAM_AUTOCALIB_DEEPFIELD) {
91  prop->autocalib = MUSE_POSTPROC_AUTOCALIB_DEEPFIELD;
92  }
93  /* Raman emission handling */
94  prop->raman_width = aParams->raman_width;
95  prop->raman_lines = muse_raman_lines_load(aProcessing);
96  /* sky subtraction methods and parameters */
97  const struct {
98  int par;
99  muse_postproc_skymethod postproc;
100  } skymethod[] = {
101  { MUSE_SCIPOST_PARAM_SKYMETHOD_NONE, MUSE_POSTPROC_SKYMETHOD_NONE },
102  { MUSE_SCIPOST_PARAM_SKYMETHOD_SUBTRACT_MODEL, MUSE_POSTPROC_SKYMETHOD_NONE }, /* sic! */
103  { MUSE_SCIPOST_PARAM_SKYMETHOD_MODEL, MUSE_POSTPROC_SKYMETHOD_MODEL },
104  { MUSE_SCIPOST_PARAM_SKYMETHOD_SIMPLE, MUSE_POSTPROC_SKYMETHOD_SIMPLE },
105  { MUSE_SCIPOST_PARAM_SKYMETHOD_INVALID_VALUE, MUSE_POSTPROC_SKYMETHOD_MODEL },
106  };
107  prop->skymethod = MUSE_POSTPROC_SKYMETHOD_MODEL;
108  int i_method;
109  for (i_method = 0;
110  skymethod[i_method].par != MUSE_SCIPOST_PARAM_SKYMETHOD_INVALID_VALUE;
111  i_method++) {
112  if (skymethod[i_method].par == aParams->skymethod) {
113  prop->skymethod = skymethod[i_method].postproc;
114  break;
115  }
116  }
117  prop->skymodel_params.fraction = aParams->skymodel_fraction;
118  prop->skymodel_params.ignore = aParams->skymodel_ignore;
119  prop->skymodel_params.sampling = aParams->skymodel_sampling;
120  prop->skymodel_params.csampling = aParams->skymodel_csampling;
121  /* CR rejection sigmas */
122  cpl_array *crarray = muse_cplarray_new_from_delimited_string(aParams->sky_crsigma, ",");
123  if (cpl_array_get_size(crarray) < 2) {
124  prop->skymodel_params.crsigmac = 15.;
125  prop->skymodel_params.crsigmas = 0.;
126  cpl_msg_warning(__func__, "Less than two values given by sky_crsigma "
127  "parameter, using defaults (%.3f.,%.3f)!",
128  prop->skymodel_params.crsigmac, prop->skymodel_params.crsigmas);
129  } else {
130  prop->skymodel_params.crsigmac = cpl_array_get_string(crarray, 0)
131  ? atof(cpl_array_get_string(crarray, 0)) : 15.;
132  prop->skymodel_params.crsigmas = cpl_array_get_string(crarray, 1)
133  ? atof(cpl_array_get_string(crarray, 1)) : 0.;
134  }
135  cpl_array_delete(crarray);
136 
137  /* further setup for sky subtraction */
138 #ifdef USE_LSF_PARAMS
139  cpl_errorstate prestate = cpl_errorstate_get();
140 #endif
141  if (aParams->skymethod == MUSE_SCIPOST_PARAM_SKYMETHOD_SUBTRACT_MODEL) {
142  prop->lsf_cube = muse_lsf_cube_load_all(aProcessing);
143  if (prop->lsf_cube != NULL) {
144  prop->sky_lines = muse_sky_lines_load(aProcessing);
145 #ifdef USE_LSF_PARAMS
146  } else {
147  prop-> lsf_params = muse_processing_lsf_params_load(aProcessing, 0);
148  if (prop->lsf_params != NULL) { // Old LSF params code
149  cpl_errorstate_set(prestate);
150  prop->sky_lines = muse_sky_lines_load(aProcessing);
151  }
152 #endif
153  }
154  prop->sky_continuum = muse_sky_continuum_load(aProcessing);
155  } else if (aParams->skymethod == MUSE_SCIPOST_PARAM_SKYMETHOD_MODEL) {
156  prop->lsf_cube = muse_lsf_cube_load_all(aProcessing);
157  if (prop->lsf_cube == NULL) {
158 #ifdef USE_LSF_PARAMS
159  prop->lsf_params = muse_processing_lsf_params_load(aProcessing, 0);
160  if (prop->lsf_params != NULL) { // Old LSF params code
161  cpl_errorstate_set(prestate);
162  } else {
163 #endif
164  cpl_msg_error(__func__, "Missing required LSF frames for sky model");
165 #ifdef USE_LSF_PARAMS
166  }
167 #endif
168  }
169  prop->sky_lines = muse_sky_lines_load(aProcessing);
170  if (prop->sky_lines == NULL) {
171  cpl_msg_error(__func__, "Missing required sky lines frame for sky model");
172  }
173  if (((prop->lsf_cube == NULL)
174 #ifdef USE_LSF_PARAMS
175  && (prop->lsf_params == NULL)
176 #endif
177  )
178  || (prop->sky_lines == NULL)) {
180  return -1;
181  }
182  prop->sky_continuum = muse_sky_continuum_load(aProcessing);
183  prop->sky_mask = muse_processing_load_mask(aProcessing, MUSE_TAG_SKY_MASK);
184  } else if (aParams->skymethod == MUSE_SCIPOST_PARAM_SKYMETHOD_SIMPLE) {
185  /* a mask could help for the simple sky subtraction */
186  prop->sky_mask = muse_processing_load_mask(aProcessing, MUSE_TAG_SKY_MASK);
187  }
188 
189  /* warn about bad combinations of inputs regarding Raman correction */
190  if (prop->raman_lines) {
191  cpl_msg_debug(__func__, "Raman 2D correction wanted (%s given)...",
192  MUSE_TAG_RAMAN_LINES);
193  if (prop->sky_continuum) {
194  cpl_msg_warning(__func__, "Using a %s together with Raman correction (%s)"
195  " is unlikely to give good results!", MUSE_TAG_SKY_CONT,
196  MUSE_TAG_RAMAN_LINES);
197  }
198  if (prop->skymodel_params.fraction < 0.5) {
199  cpl_msg_warning(__func__, "Using a small sky fraction (%.2f) together "
200  "with Raman correction (%s) is unlikely to give good "
201  "results!", prop->skymodel_params.fraction,
202  MUSE_TAG_RAMAN_LINES);
203  }
204  }
205 
206  /* also load the LSF, if we need it for Raman correction */
207  if (prop->raman_lines && !prop->lsf_cube) {
208  prop->lsf_cube = muse_lsf_cube_load_all(aProcessing);
209  }
210 
211  /* sort input pixel tables into different exposures */
212  prop->exposures = muse_processing_sort_exposures(aProcessing);
213  if (!prop->exposures) {
214  cpl_msg_error(__func__, "no science exposures found in input");
216  return -1;
217  }
218  int nexposures = cpl_table_get_nrow(prop->exposures);
219 
220  /* load optional offsets */
221  cpl_table *offsets = muse_processing_load_ctable(aProcessing, MUSE_TAG_OFFSET_LIST, 0);
222  if (offsets && muse_cpltable_check(offsets, muse_offset_list_def) != CPL_ERROR_NONE) {
223  cpl_msg_warning(__func__, "Input %s has unexpected format, proceeding "
224  "without offset and flux scales!", MUSE_TAG_OFFSET_LIST);
225  cpl_table_delete(offsets);
226  offsets = NULL;
227  } /* if offsets have wrong format */
228 
229  /* now process all the pixel tables, do it separately for each exposure */
230  /* allocate one additional element for NULL termination */
231  muse_pixtable **pixtables = cpl_calloc(nexposures + 1, sizeof(muse_pixtable *));
232  int i;
233  for (i = 0; i < nexposures; i++) {
235  = cpl_calloc(1, sizeof(muse_postproc_autocal_outputs));
236  muse_datacube *ramancube = NULL;
238  = cpl_calloc(1, sizeof(muse_postproc_sky_outputs));
239  pixtables[i] = muse_postproc_process_exposure(prop, i, autocal, &ramancube,
240  skyout, offsets);
241  if (!pixtables[i]) {
242  int i2;
243  for (i2 = 0; i2 <= i; i2++) {
244  muse_pixtable_delete(pixtables[i2]);
245  } /* for i2 */
246  cpl_free(pixtables);
248  cpl_table_delete(offsets);
249  muse_mask_delete(autocal->mask);
250  muse_table_delete(autocal->table);
251  cpl_free(autocal);
252  muse_datacube_delete(ramancube);
253  muse_image_delete(skyout->image);
254  muse_mask_delete(skyout->mask);
255  cpl_table_delete(skyout->spectrum);
256  cpl_table_delete(skyout->lines);
257  cpl_table_delete(skyout->continuum);
258  cpl_free(skyout);
259  return -1; /* enough error messages, just return */
260  } /* if !pixtable */
261 
262  /* save the autocalibration products, if requested */
263  if (strstr(aParams->save, "autocal")) {
264  if (autocal->mask) {
265  muse_processing_save_mask(aProcessing, -1, autocal->mask,
266  MUSE_TAG_ACAL_MASK);
267  }
268  if (autocal->table) {
269  muse_processing_save_table(aProcessing, -1, autocal->table, NULL,
270  MUSE_TAG_ACAL_FACTORS, MUSE_TABLE_TYPE_MUSE);
271  }
272  } /* if save autocal */
273  muse_mask_delete(autocal->mask);
274  muse_table_delete(autocal->table);
275  cpl_free(autocal);
276 
277  /* save the Raman product, if requested */
278  if (strstr(aParams->save, "raman") && ramancube) {
279  muse_processing_save_cube(aProcessing, -1, ramancube,
280  MUSE_TAG_RAMAN_IMAGES, MUSE_CUBE_TYPE_FITS);
281  muse_datacube_delete(ramancube);
282  } /* if save Raman outputs */
283 
284  /* save the effectively used sky products, if requested */
285  if (strstr(aParams->save, "skymodel")) {
286  if (skyout->image) {
287  muse_processing_save_image(aProcessing, -1, skyout->image, MUSE_TAG_SKY_IMAGE);
288  }
289  if (skyout->mask) {
290  muse_processing_save_mask(aProcessing, -1, skyout->mask, MUSE_TAG_SKY_MASK);
291  }
292  if (skyout->spectrum) {
293  cpl_propertylist *header = cpl_propertylist_duplicate(pixtables[i]->header);
294  cpl_propertylist_erase_regexp(header, MUSE_HDR_PT_REGEXP, 0);
295  muse_processing_save_table(aProcessing, -1, skyout->spectrum, header,
296  MUSE_TAG_SKY_SPECTRUM, MUSE_TABLE_TYPE_CPL);
297  cpl_propertylist_delete(header);
298  }
299  if (skyout->lines) {
300  cpl_propertylist *header = cpl_propertylist_duplicate(pixtables[i]->header);
301  cpl_propertylist_erase_regexp(header, MUSE_HDR_PT_REGEXP, 0);
302  muse_sky_qc_lines(header, skyout->lines, "ESO QC SCIPOST");
303  muse_sky_lines_save(aProcessing, skyout->lines, header);
304  cpl_propertylist_delete(header);
305  }
306  if (skyout->continuum) {
307  cpl_propertylist *header = cpl_propertylist_duplicate(pixtables[i]->header);
308  cpl_propertylist_erase_regexp(header, MUSE_HDR_PT_REGEXP, 0);
309  muse_sky_qc_continuum(header, skyout->continuum, "ESO QC SCIPOST");
310  muse_sky_save_continuum(aProcessing, skyout->continuum, header);
311  cpl_propertylist_delete(header);
312  }
313  } /* if save skymodel */
314  muse_image_delete(skyout->image);
315  muse_mask_delete(skyout->mask);
316  cpl_table_delete(skyout->spectrum);
317  cpl_table_delete(skyout->lines);
318  cpl_table_delete(skyout->continuum);
319  cpl_free(skyout);
320 
321  if (strstr(aParams->save, "individual")) {
322  muse_processing_save_table(aProcessing, -1, pixtables[i], NULL,
323  MUSE_TAG_PIXTABLE_REDUCED,
325  }
326  if (strstr(aParams->save, "positioned")) {
327  /* duplicate table to not mess with the coordinates in the individual *
328  * pixel tables, which are still needed when combining the exposures */
329  muse_pixtable *pt = muse_pixtable_duplicate(pixtables[i]);
330  /* since after positioning it is too late to *
331  * adapt the reference position, do it now */
332  muse_postproc_offsets_scale(pt, offsets,
333  "positioned pixel table for saving");
336  muse_processing_save_table(aProcessing, -1, pt, NULL,
337  MUSE_TAG_PIXTABLE_POSITIONED,
340  }
341  } /* for i (exposures) */
343 
344  /* now combine the possibly more than one exposures */
345  muse_pixtable *bigpixtable = NULL;
346  if (nexposures > 1) {
348  cpl_error_code rc = muse_xcombine_weights(pixtables, weight);
349  if (rc != CPL_ERROR_NONE) {
350  cpl_msg_error(__func__, "weighting the pixel tables didn't work: %s",
351  cpl_error_get_message());
352  for (i = 0; i < nexposures; i++) {
353  muse_pixtable_delete(pixtables[i]);
354  } /* for i (exposures) */
355  cpl_free(pixtables);
356  cpl_table_delete(offsets);
357  return -1;
358  }
359  /* combine individual pixel tables and delete them */
360  bigpixtable = muse_xcombine_tables(pixtables, offsets);
361  if (!bigpixtable) {
362  cpl_msg_error(__func__, "combining the pixel tables didn't work: %s",
363  cpl_error_get_message());
364  for (i = 0; i < nexposures; i++) {
365  muse_pixtable_delete(pixtables[i]);
366  } /* for i (exposures) */
367  cpl_free(pixtables);
368  cpl_table_delete(offsets);
369  return -1;
370  }
371  } else {
372  bigpixtable = pixtables[0];
373  /* if there is only one pixel table, apply the offset for that */
374  cpl_msg_indent_more();
375  muse_postproc_offsets_scale(bigpixtable, offsets,
376  "single pixel table for resampling");
377  cpl_msg_indent_less();
378  muse_wcs_position_celestial(bigpixtable,
379  muse_pfits_get_ra(bigpixtable->header),
380  muse_pfits_get_dec(bigpixtable->header));
381  }
382  cpl_free(pixtables);
383  cpl_table_delete(offsets);
384 
385  cpl_error_code rc = CPL_ERROR_NONE;
386  if (strstr(aParams->save, "cube")) {
387  muse_resampling_type resample
390  rp->dx = aParams->dx;
391  rp->dy = aParams->dy;
392  rp->dlambda = aParams->dlambda;
393  rp->crtype = muse_postproc_get_cr_type(aParams->crtype_s);
394  rp->crsigma = aParams->crsigma;
395  rp->ld = aParams->ld;
396  rp->rc = aParams->rc;
398  cpl_propertylist *outwcs = muse_postproc_cube_load_output_wcs(aProcessing);
399  muse_resampling_params_set_wcs(rp, outwcs);
400  cpl_propertylist_delete(outwcs);
402  rc = muse_postproc_cube_resample_and_collapse(aProcessing, bigpixtable,
403  format, rp, aParams->filter);
405  } /* if save contains cube */
406  if (strstr(aParams->save, "combined")) {
407  muse_processing_save_table(aProcessing, -1, bigpixtable, NULL,
408  MUSE_TAG_PIXTABLE_COMBINED,
410  }
411  if (strstr(aParams->save, "stacked")) {
412  cpl_msg_debug(__func__, "additional output as column-stacked image");
413  muse_image *img = muse_resampling_image(bigpixtable,
415  aParams->dx, aParams->dlambda);
416  muse_processing_save_image(aProcessing, -1, img, MUSE_TAG_OBJECT_RESAMPLED);
417  muse_image_delete(img);
418  }
419 
420  muse_pixtable_delete(bigpixtable);
421 
422  /* the cube is normally the main output, check only its return code */
423  return rc == CPL_ERROR_NONE ? 0 : -1;
424 } /* muse_scipost_compute() */
Structure definition of a MUSE datacube.
Definition: muse_datacube.h:48
muse_rvcorrect_type rvtype
Definition: muse_postproc.h:99
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.
muse_autocalib_type autocalib
muse_postproc_properties * muse_postproc_properties_new(muse_postproc_type aType)
Create a post-processing properties object.
Definition: muse_postproc.c:76
muse_postproc_skymethod
Method of sky subtraction to apply.
Definition: muse_postproc.h:70
void muse_image_delete(muse_image *aImage)
Deallocate memory associated to a muse_image object.
Definition: muse_image.c:85
double lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
muse_pixtable * muse_pixtable_duplicate(muse_pixtable *aPixtable)
Make a copy of the pixtanle.
int muse_processing_save_mask(muse_processing *aProcessing, int aIFU, muse_mask *aMask, const char *aTag)
Save a computed MUSE mask to disk.
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.
cpl_error_code muse_sky_lines_save(muse_processing *, const cpl_table *, cpl_propertylist *)
Save sky lines table to file.
void muse_postproc_offsets_scale(muse_pixtable *aPT, const cpl_table *aOffsets, const char *aPurpose)
Apply spatial offsets and flux scale to a pixel table (of a single exposure)
void muse_mask_delete(muse_mask *aMask)
Deallocate memory associated to a muse_mask object.
Definition: muse_mask.c:78
muse_xcombine_types muse_postproc_get_weight_type(const char *aWeightString)
Select correct weighting type for weight string.
double skymodel_ignore
Fraction of the image to be ignored. If an input sky mask is provided, the fraction is applied to the...
cpl_table * muse_sky_lines_load(muse_processing *)
Load the sky data files.
muse_resampling_crstats_type muse_postproc_get_cr_type(const char *aCRTypeString)
Select correct cosmic ray rejection type for crtype string.
int ld
Number of adjacent pixels to take into account during resampling in all three directions (loop distan...
cpl_table * muse_raman_lines_load(muse_processing *aProcessing)
Load the raman lines file.
Definition: muse_raman.c:48
const muse_cpltable_def muse_offset_list_def[]
void muse_datacube_delete(muse_datacube *aCube)
Deallocate memory associated to a muse_datacube object.
const char * rvcorr_s
Correct the radial velocity of the telescope with reference to either the barycenter of the Solar Sys...
muse_rvcorrect_type muse_rvcorrect_select_type(const char *aTypeString)
Select type of radial velocity correction to be done from type string.
void muse_sky_qc_lines(cpl_propertylist *, cpl_table *, const char *)
Fill a header with the QC parameters for the sky lines.
Definition: muse_sky_qc.c:46
Structure definition of MUSE three extension FITS file.
Definition: muse_image.h:40
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.
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 ...
cpl_error_code muse_xcombine_weights(muse_pixtable **aPixtables, muse_xcombine_types aWeighting)
compute the weights for combination of two or more exposures
muse_postproc_skymethod skymethod
muse_lsf_params ** lsf_params
cpl_error_code muse_cpltable_check(const cpl_table *aTable, const muse_cpltable_def *aDef)
Check whether the table contains the fields of the definition.
const char * sky_crsigma
Sigma level clipping for cube-based and spectrum-based CR rejection when creating the sky spectrum...
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...
muse_resampling_crstats_type crtype
void muse_sky_qc_continuum(cpl_propertylist *, cpl_table *, const char *)
Fill a header with the QC parameters for the sky continuum.
Definition: muse_sky_qc.c:102
const char * weight_s
Type of weighting scheme to use when combining multiple exposures. "exptime" just uses the exposure t...
cpl_table * muse_sky_continuum_load(muse_processing *)
Load the sky continuum.
cpl_array * muse_cplarray_new_from_delimited_string(const char *aString, const char *aDelim)
Convert a delimited string into an array of strings.
Structure definition of MUSE pixel table.
muse_cube_type muse_postproc_get_cube_format(const char *aFormatString)
Select correct cube format for format string.
double dy
Vertical step size for resampling (in arcsec or pixel). The following defaults are taken when this va...
cpl_boolean muse_postproc_check_save_param(const char *aSave, const char *aValid)
Check the –save parameter contents against allowed options.
muse_resampling_params * muse_resampling_params_new(muse_resampling_type aMethod)
Create the resampling parameters structure.
double lambdaref
Reference wavelength used for correction of differential atmospheric refraction. The R-band (peak wav...
cpl_error_code muse_processing_save_cube(muse_processing *aProcessing, int aIFU, void *aCube, const char *aTag, muse_cube_type aType)
Save a MUSE datacube to disk.
double rc
Critical radius for the "renka" resampling method.
muse_lsf_cube ** muse_lsf_cube_load_all(muse_processing *aProcessing)
Load all LSF cubes for all IFUs into an array.
muse_pixtable * muse_xcombine_tables(muse_pixtable **aPixtables, const cpl_table *aOffsets)
combine the pixel tables of several exposures into one
muse_table * muse_processing_load_table(muse_processing *aProcessing, const char *aTag, unsigned char aIFU)
Load a MUSE table according to its tag and IFU/channel number.
muse_cube_type
cpl_propertylist * wcs
Structure definition of the post-processing properties.
Definition: muse_postproc.h:92
double skymodel_fraction
Fraction of the image (without the ignored part) to be considered as sky. If an input sky mask is pro...
void muse_postproc_properties_delete(muse_postproc_properties *aProp)
Free memory taken by a post-processing properties object and all its components.
const char * crtype_s
Type of statistics used for detection of cosmic rays during final resampling. "iraf" uses the varianc...
int darcheck
Carry out a check of the theoretical DAR correction using source centroiding. If "correct" it will al...
double skymodel_sampling
Spectral sampling of the sky spectrum [Angstrom].
double muse_pfits_get_dec(const cpl_propertylist *aHeaders)
find out the declination
Definition: muse_pfits.c:285
int astrometry
If false, skip any astrometric calibration, even if one was passed in the input set of files...
muse_mask * muse_processing_load_mask(muse_processing *aProcessing, const char *aTag)
Load a mask file and its FITS header.
void muse_table_delete(muse_table *aTable)
Deallocate memory associated to a muse_table object.
Definition: muse_table.c:80
double skymodel_csampling
Spectral sampling of the continuum spectrum [Angstrom].
muse_lsf_cube ** lsf_cube
void * muse_postproc_process_exposure(muse_postproc_properties *aProp, unsigned int aIndex, muse_postproc_autocal_outputs *aACalOut, muse_datacube **aRamanCube, muse_postproc_sky_outputs *aSkyOut, const cpl_table *aOffsets)
Merge and process pixel tables from one exposure.
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...
const char * format_s
Type of output file format, "Cube" is a standard FITS cube with NAXIS=3 and multiple extensions (for ...
double lambdamax
Cut off the data above this wavelength after loading the pixel table(s).
int muse_processing_save_image(muse_processing *aProcessing, int aIFU, muse_image *aImage, const char *aTag)
Save a computed MUSE image to disk.
cpl_table * muse_processing_load_ctable(muse_processing *aProcessing, const char *aTag, unsigned char aIFU)
Load a CPL table according to its tag and IFU/channel number.
muse_resampling_type muse_postproc_get_resampling_type(const char *aResampleString)
Select correct resampling type for resample string.
double dx
Horizontal step size for resampling (in arcsec or pixel). The following defaults are taken when this ...
double raman_width
Wavelength range around Raman lines [Angstrom].
int skymethod
The method used to subtract the sky background (spectrum). Option "model" should work in all kinds of...
Structure to hold the parameters of the muse_scipost recipe.
double crsigma
Sigma rejection factor to use for cosmic ray rejection during final resampling. A zero or negative va...
cpl_error_code muse_processing_save_table(muse_processing *aProcessing, int aIFU, void *aTable, cpl_propertylist *aHeader, const char *aTag, muse_table_type aType)
Save a computed table to disk.
muse_resampling_type
Resampling types.
Resampling parameters.
Structure definition of the post-processing output sky data.
void muse_resampling_params_delete(muse_resampling_params *aParams)
Delete a resampling parameters structure.
muse_lsf_params ** muse_processing_lsf_params_load(muse_processing *aProcessing, int aIFU)
Load slice LSF parameters.
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:1493
Structure definition of the post-processing output auto-calibration.
muse_sky_params skymodel_params
cpl_table * muse_processing_sort_exposures(muse_processing *aProcessing)
Sort input frames (containing lists of pixel table filenames) into different exposures.
void muse_pixtable_delete(muse_pixtable *aPixtable)
Deallocate memory associated to a pixel table object.
cpl_propertylist * muse_processing_load_header(muse_processing *aProcessing, const char *aTag)
load a header according to its tag
muse_postproc_darcheck darcheck
Definition: muse_postproc.h:98
muse_xcombine_types
Xposure combination types.
Definition: muse_xcombine.h:44
double dlambda
Wavelength step size (in Angstrom). Natural instrument sampling is used, if this is 0...
const char * resample_s
The resampling technique to use for the final output cube. (as string)
cpl_propertylist * header
The FITS header.
int autocalib
The type of autocalibration to use. "none" switches it off, "deepfield" uses the revised MPDAF method...
const char * save
Select output product(s) to save. Can contain one or more of "cube", "autocal", "skymodel", "individual", "positioned", "combined", and "stacked". If several options are given, they have to be comma-separated. ("cube": output cube and associated images, if this is not given, no final resampling is done at all – "autocal": up to two additional output products related to the slice autocalibration – "raman": up to four additional output products about the Raman light distribution for AO observations – "skymodel": up to four additional output products about the effectively used sky that was subtracted with the "model" method – "individual": fully reduced pixel table for each individual exposure – "positioned": fully reduced and positioned pixel table for each individual exposure, the difference to "individual" is that here, the output pixel tables have coordinates in RA and DEC; this is only useful, if both the relative exposure weighting and the final resampling are to be done externally – "combined": fully reduced and combined pixel table for the full set of exposures, the difference to "positioned" is that all pixel tables are combined into one, with an added weight column; this is useful, if only the final resampling step is to be done separately – "stacked": an additional output file in form of a 2D column-stacked image, i.e. x direction is pseudo-spatial, y direction is wavelength.)
cpl_error_code muse_sky_save_continuum(muse_processing *, const cpl_table *, cpl_propertylist *)
Save sky continuum table to file.