MUSE Pipeline Reference Manual  1.0.2
muse_scipost_z.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 /* This file was automatically generated */
23 
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 
28 /*----------------------------------------------------------------------------*
29  * Includes *
30  *----------------------------------------------------------------------------*/
31 #include <string.h> /* strcmp(), strstr() */
32 #include <strings.h> /* strcasecmp() */
33 #include <cpl.h>
34 
35 #include "muse_scipost_z.h" /* in turn includes muse.h */
36 
37 /*----------------------------------------------------------------------------*/
80 /*----------------------------------------------------------------------------*/
83 /*----------------------------------------------------------------------------*
84  * Static variables *
85  *----------------------------------------------------------------------------*/
86 static const char *muse_scipost_help =
87  "Sort input pixel tables into lists of files per exposure, merge pixel tables from all IFUs of each exposure. Correct each exposure for differential atmopheric refraction (unless --lambdaraf is far outside the MUSE wavelength range). Then the flux calibration is carried out, if a respnse curve was given in the input; it includes a correction of telluric absorption, if a telluric absorptin correction file was given. Then the sky subtraction is carried out(unless --skymethod=&none&), either directly subtracting an input sky continuum and an input sky emission lines (for --skymethod=&subtract-model&), or (--skymethod=&model&) create a sky spectrum from the darkest fraction (--skymodel_fraction) of the field of view, then fitting and subtracting sky emission lines using an initial estimate of the input sky lines; then the continuum (residuals after subtracting the sky lines from the sky spectrum) is subtracted as well. If --save contains &skymodel&, all sky-related products are saved for each exposure. Afterwards the data is corrected for the radial velocity of the observer (--rvcorr), before the input (or a default) astrometric solution is applied. Now each individual exposure is fully reduced; the pixel tables at this stage can be saved by setting &individual& in --save. If multiple exposures were given, they are then combined. If --save contains &combined&, this final merged pixel table is saved. Finally (if --save contains &cube&), the data is resampled into a datacube, using all parameters given to the recipe. The extent and orientation of the cube is normally computed from the data itself, but this can be overridden by passing a file with the output world coordinate system (OUTPUT_WCS), for example a MUSE cube. This can also be used to sample the wavelength axis logorithmically (in that file set &CTYPE3='AWAV-LOG'&). As a last step, the computed cube is integrated over all filter functions given (--filter) that are also present in the input filter list table.";
88 
89 static const char *muse_scipost_help_esorex =
90  "\n\nInput frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
91  "\n Frame tag Type Req #Fr Description"
92  "\n -------------------- ---- --- --- ------------"
93  "\n PIXTABLE_OBJECT raw Y Pixel table of a science object"
94  "\n EXTINCT_TABLE calib Y 1 Atmospheric extinction table"
95  "\n STD_RESPONSE calib Y 1 Response curve as derived from standard star(s)"
96  "\n STD_TELLURIC calib . 1 Telluric absorption correction as derived from standard star(s)"
97  "\n ASTROMETRY_WCS calib . 1 Astrometric solution derived from astrometric science frame"
98  "\n FILTER_LIST calib . 1 File to be used to create field-of-view images."
99  "\n OUTPUT_WCS calib . 1 WCS to override output cube location / dimensions"
100  "\n SKY_LINES calib . 1 List of OH transitions and other sky lines"
101  "\n SKY_CONTINUUM calib . 1 Sky continuum to use"
102  "\n LSF_PROFILE calib . Slice specific LSF parameters"
103  "\n SKY_MASK calib . 1 Sky mask to use"
104  "\n\nProduct frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
105  "\n Frame tag Level Description"
106  "\n -------------------- -------- ------------"
107  "\n DATACUBE_FINAL final Output datacube"
108  "\n IMAGE_FOV final Field-of-view images corresponding to the \"filter\" parameter."
109  "\n OBJECT_RESAMPLED final Stacked image (if --save contains \"stacked\")"
110  "\n PIXTABLE_REDUCED intermed Fully reduced pixel tables for each exposure (if --save contains \"ptindividual\")"
111  "\n PIXTABLE_POSITIONED intermed Fully reduced and positioned pixel table for each individual exposure (if --save contains \"ptpositioned\")"
112  "\n PIXTABLE_COMBINED intermed Fully reduced and combined pixel table for the full set of exposures (if --save contains \"ptcombined\")"
113  "\n SKY_MASK intermed Created sky mask (if --skymethod=model and --save contains \"skymodel\")"
114  "\n SKY_SPECTRUM intermed Sky spectrum within the sky mask (if --skymethod=model and --save contains \"skymodel\")"
115  "\n SKY_LINES final Estimated sky line flux table (if --skymethod=model and --save contains \"skymodel\")"
116  "\n SKY_CONTINUUM final Estimated continuum flux spectrum (if --skymethod=model and --save contains \"skymodel\")";
117 
118 /*----------------------------------------------------------------------------*/
126 /*----------------------------------------------------------------------------*/
127 static cpl_recipeconfig *
128 muse_scipost_new_recipeconfig(void)
129 {
130  cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
131  const char *tag;
132 
133  tag = "PIXTABLE_OBJECT";
134  cpl_recipeconfig_set_tag(recipeconfig, tag, 1, -1);
135  cpl_recipeconfig_set_input(recipeconfig, tag, "EXTINCT_TABLE", 1, 1);
136  cpl_recipeconfig_set_input(recipeconfig, tag, "STD_RESPONSE", 1, 1);
137  cpl_recipeconfig_set_input(recipeconfig, tag, "STD_TELLURIC", -1, 1);
138  cpl_recipeconfig_set_input(recipeconfig, tag, "ASTROMETRY_WCS", -1, 1);
139  cpl_recipeconfig_set_input(recipeconfig, tag, "FILTER_LIST", -1, 1);
140  cpl_recipeconfig_set_input(recipeconfig, tag, "OUTPUT_WCS", -1, 1);
141  cpl_recipeconfig_set_input(recipeconfig, tag, "SKY_LINES", 0, 1);
142  cpl_recipeconfig_set_input(recipeconfig, tag, "SKY_CONTINUUM", 0, 1);
143  cpl_recipeconfig_set_input(recipeconfig, tag, "LSF_PROFILE", 0, -1);
144  cpl_recipeconfig_set_input(recipeconfig, tag, "SKY_MASK", 0, 1);
145  cpl_recipeconfig_set_output(recipeconfig, tag, "DATACUBE_FINAL");
146  cpl_recipeconfig_set_output(recipeconfig, tag, "IMAGE_FOV");
147  cpl_recipeconfig_set_output(recipeconfig, tag, "OBJECT_RESAMPLED");
148  cpl_recipeconfig_set_output(recipeconfig, tag, "PIXTABLE_REDUCED");
149  cpl_recipeconfig_set_output(recipeconfig, tag, "PIXTABLE_POSITIONED");
150  cpl_recipeconfig_set_output(recipeconfig, tag, "PIXTABLE_COMBINED");
151  cpl_recipeconfig_set_output(recipeconfig, tag, "SKY_MASK");
152  cpl_recipeconfig_set_output(recipeconfig, tag, "SKY_SPECTRUM");
153  cpl_recipeconfig_set_output(recipeconfig, tag, "SKY_LINES");
154  cpl_recipeconfig_set_output(recipeconfig, tag, "SKY_CONTINUUM");
155 
156  return recipeconfig;
157 } /* muse_scipost_new_recipeconfig() */
158 
159 /*----------------------------------------------------------------------------*/
169 /*----------------------------------------------------------------------------*/
170 static cpl_error_code
171 muse_scipost_prepare_header(const char *aFrametag, cpl_propertylist *aHeader)
172 {
173  cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
174  cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
175  if (!strcmp(aFrametag, "DATACUBE_FINAL")) {
176  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST POS[0-9]+ X",
177  CPL_TYPE_FLOAT,
178  "[pix] Position of source k in x-direction in combined frame");
179  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST POS[0-9]+ Y",
180  CPL_TYPE_FLOAT,
181  "[pix] Position of source k in y-direction in combined frame");
182  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST FWHM[0-9]+ X",
183  CPL_TYPE_FLOAT,
184  "[arcsec] FWHM of source k in x-direction in combined frame");
185  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST FWHM[0-9]+ Y",
186  CPL_TYPE_FLOAT,
187  "[arcsec] FWHM of source k in y-direction in combined frame");
188  } else if (!strcmp(aFrametag, "IMAGE_FOV")) {
189  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST POS[0-9]+ X",
190  CPL_TYPE_FLOAT,
191  "[pix] Position of source k in x-direction in combined frame");
192  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST POS[0-9]+ Y",
193  CPL_TYPE_FLOAT,
194  "[pix] Position of source k in y-direction in combined frame");
195  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST FWHM[0-9]+ X",
196  CPL_TYPE_FLOAT,
197  "[arcsec] FWHM of source k in x-direction in combined frame");
198  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST FWHM[0-9]+ Y",
199  CPL_TYPE_FLOAT,
200  "[arcsec] FWHM of source k in y-direction in combined frame");
201  } else if (!strcmp(aFrametag, "OBJECT_RESAMPLED")) {
202  } else if (!strcmp(aFrametag, "PIXTABLE_REDUCED")) {
203  } else if (!strcmp(aFrametag, "PIXTABLE_POSITIONED")) {
204  } else if (!strcmp(aFrametag, "PIXTABLE_COMBINED")) {
205  } else if (!strcmp(aFrametag, "SKY_MASK")) {
206  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST THRESHOLD",
207  CPL_TYPE_DOUBLE,
208  "Threshold in the white light considered as sky, used to create this mask");
209  } else if (!strcmp(aFrametag, "SKY_SPECTRUM")) {
210  } else if (!strcmp(aFrametag, "SKY_LINES")) {
211  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST LINE[0-9]+ NAME",
212  CPL_TYPE_STRING,
213  "Name of the strongest line in group l");
214  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST LINE[0-9]+ AWAV",
215  CPL_TYPE_DOUBLE,
216  "[Angstrom] Wavelength (air) of the strongest line of group l");
217  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST LINE[0-9]+ FLUX",
218  CPL_TYPE_DOUBLE,
219  "[erg/(s cm2 arcsec2)] Flux of the strongest line of group l");
220  } else if (!strcmp(aFrametag, "SKY_CONTINUUM")) {
221  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST CONT FLUX",
222  CPL_TYPE_DOUBLE,
223  "[erg/(s cm2 arcsec2)] Total flux of the continuum");
224  muse_processing_prepare_property(aHeader, "ESO QC SCIPOST CONT MAXDEV",
225  CPL_TYPE_DOUBLE,
226  "[erg/(s cm2 arcsec2 Angstrom)] Maximum (absolute value) of the derivative of the continuum spectrum");
227  } else {
228  cpl_msg_warning(__func__, "Frame tag %s is not defined", aFrametag);
229  return CPL_ERROR_ILLEGAL_INPUT;
230  }
231  return CPL_ERROR_NONE;
232 } /* muse_scipost_prepare_header() */
233 
234 /*----------------------------------------------------------------------------*/
243 /*----------------------------------------------------------------------------*/
244 static cpl_frame_level
245 muse_scipost_get_frame_level(const char *aFrametag)
246 {
247  if (!aFrametag) {
248  return CPL_FRAME_LEVEL_NONE;
249  }
250  if (!strcmp(aFrametag, "DATACUBE_FINAL")) {
251  return CPL_FRAME_LEVEL_FINAL;
252  }
253  if (!strcmp(aFrametag, "IMAGE_FOV")) {
254  return CPL_FRAME_LEVEL_FINAL;
255  }
256  if (!strcmp(aFrametag, "OBJECT_RESAMPLED")) {
257  return CPL_FRAME_LEVEL_FINAL;
258  }
259  if (!strcmp(aFrametag, "PIXTABLE_REDUCED")) {
260  return CPL_FRAME_LEVEL_INTERMEDIATE;
261  }
262  if (!strcmp(aFrametag, "PIXTABLE_POSITIONED")) {
263  return CPL_FRAME_LEVEL_INTERMEDIATE;
264  }
265  if (!strcmp(aFrametag, "PIXTABLE_COMBINED")) {
266  return CPL_FRAME_LEVEL_INTERMEDIATE;
267  }
268  if (!strcmp(aFrametag, "SKY_MASK")) {
269  return CPL_FRAME_LEVEL_INTERMEDIATE;
270  }
271  if (!strcmp(aFrametag, "SKY_SPECTRUM")) {
272  return CPL_FRAME_LEVEL_INTERMEDIATE;
273  }
274  if (!strcmp(aFrametag, "SKY_LINES")) {
275  return CPL_FRAME_LEVEL_FINAL;
276  }
277  if (!strcmp(aFrametag, "SKY_CONTINUUM")) {
278  return CPL_FRAME_LEVEL_FINAL;
279  }
280  return CPL_FRAME_LEVEL_NONE;
281 } /* muse_scipost_get_frame_level() */
282 
283 /*----------------------------------------------------------------------------*/
292 /*----------------------------------------------------------------------------*/
293 static muse_frame_mode
294 muse_scipost_get_frame_mode(const char *aFrametag)
295 {
296  if (!aFrametag) {
297  return MUSE_FRAME_MODE_ALL;
298  }
299  if (!strcmp(aFrametag, "DATACUBE_FINAL")) {
300  return MUSE_FRAME_MODE_MASTER;
301  }
302  if (!strcmp(aFrametag, "IMAGE_FOV")) {
304  }
305  if (!strcmp(aFrametag, "OBJECT_RESAMPLED")) {
306  return MUSE_FRAME_MODE_MASTER;
307  }
308  if (!strcmp(aFrametag, "PIXTABLE_REDUCED")) {
310  }
311  if (!strcmp(aFrametag, "PIXTABLE_POSITIONED")) {
313  }
314  if (!strcmp(aFrametag, "PIXTABLE_COMBINED")) {
315  return MUSE_FRAME_MODE_MASTER;
316  }
317  if (!strcmp(aFrametag, "SKY_MASK")) {
319  }
320  if (!strcmp(aFrametag, "SKY_SPECTRUM")) {
322  }
323  if (!strcmp(aFrametag, "SKY_LINES")) {
325  }
326  if (!strcmp(aFrametag, "SKY_CONTINUUM")) {
328  }
329  return MUSE_FRAME_MODE_ALL;
330 } /* muse_scipost_get_frame_mode() */
331 
332 /*----------------------------------------------------------------------------*/
342 /*----------------------------------------------------------------------------*/
343 static int
344 muse_scipost_create(cpl_plugin *aPlugin)
345 {
346  /* Check that the plugin is part of a valid recipe */
347  cpl_recipe *recipe;
348  if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
349  recipe = (cpl_recipe *)aPlugin;
350  } else {
351  return -1;
352  }
353 
354  /* register the extended processing information (new FITS header creation, *
355  * getting of the frame level for a certain tag) */
357  muse_scipost_new_recipeconfig(),
358  muse_scipost_prepare_header,
359  muse_scipost_get_frame_level,
360  muse_scipost_get_frame_mode);
361 
362  /* XXX initialize timing in messages *
363  * since at least esorex is too stupid to turn it on, we have to do it */
365  cpl_msg_set_time_on();
366  }
367 
368  /* Create the parameter list in the cpl_recipe object */
369  recipe->parameters = cpl_parameterlist_new();
370  /* Fill the parameters list */
371  cpl_parameter *p;
372 
373  /* --save: Select output product(s) to save. Can contain one or more of "cube", "skymodel", "individual", "positioned", "combined", and "stacked". If several options are given, they have to be comma-separated.
374  ("cube": output cube and associated images, if this is not given, no final resampling is done at all --
375  "skymodel": up to four additional output products about the effectively used sky that was subtracted with the "model" method --
376  "individual": fully reduced pixel table for each individual exposure --
377  "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 --
378  "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 --
379  "stacked": an additional output file in form of a 2D column-stacked image, i.e. x direction is pseudo-spatial, y direction is wavelength.)
380  */
381  p = cpl_parameter_new_value("muse.muse_scipost.save",
382  CPL_TYPE_STRING,
383  "Select output product(s) to save. Can contain one or more of \"cube\", \"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 -- \"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.)",
384  "muse.muse_scipost",
385  (const char *)"cube,skymodel");
386  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "save");
387  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "save");
388 
389  cpl_parameterlist_append(recipe->parameters, p);
390 
391  /* --resample: The resampling technique to use for the final output cube. */
392  p = cpl_parameter_new_enum("muse.muse_scipost.resample",
393  CPL_TYPE_STRING,
394  "The resampling technique to use for the final output cube.",
395  "muse.muse_scipost",
396  (const char *)"drizzle",
397  6,
398  (const char *)"nearest",
399  (const char *)"linear",
400  (const char *)"quadratic",
401  (const char *)"renka",
402  (const char *)"drizzle",
403  (const char *)"lanczos");
404  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "resample");
405  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "resample");
406 
407  cpl_parameterlist_append(recipe->parameters, p);
408 
409  /* --dx: Horizontal step size for resampling (in arcsec or pixel). The following defaults are taken when this value is set to 0.0: 0.2'' for WFM, 0.075'' for NFM, 1.0 if data is in pixel units. */
410  p = cpl_parameter_new_value("muse.muse_scipost.dx",
411  CPL_TYPE_DOUBLE,
412  "Horizontal step size for resampling (in arcsec or pixel). The following defaults are taken when this value is set to 0.0: 0.2'' for WFM, 0.075'' for NFM, 1.0 if data is in pixel units.",
413  "muse.muse_scipost",
414  (double)0.0);
415  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "dx");
416  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dx");
417 
418  cpl_parameterlist_append(recipe->parameters, p);
419 
420  /* --dy: Vertical step size for resampling (in arcsec or pixel). The following defaults are taken when this value is set to 0.0: 0.2'' for WFM, 0.075'' for NFM, 1.0 if data is in pixel units. */
421  p = cpl_parameter_new_value("muse.muse_scipost.dy",
422  CPL_TYPE_DOUBLE,
423  "Vertical step size for resampling (in arcsec or pixel). The following defaults are taken when this value is set to 0.0: 0.2'' for WFM, 0.075'' for NFM, 1.0 if data is in pixel units.",
424  "muse.muse_scipost",
425  (double)0.0);
426  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "dy");
427  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dy");
428 
429  cpl_parameterlist_append(recipe->parameters, p);
430 
431  /* --dlambda: Wavelength step size (in Angstrom). Natural instrument sampling is used, if this is 0.0 */
432  p = cpl_parameter_new_value("muse.muse_scipost.dlambda",
433  CPL_TYPE_DOUBLE,
434  "Wavelength step size (in Angstrom). Natural instrument sampling is used, if this is 0.0",
435  "muse.muse_scipost",
436  (double)0.0);
437  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "dlambda");
438  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dlambda");
439 
440  cpl_parameterlist_append(recipe->parameters, p);
441 
442  /* --crtype: Type of statistics used for detection of cosmic rays during final resampling. "iraf" uses the variance information, "mean" uses standard (mean/stdev) statistics, "median" uses median and the median median of the absolute median deviation. */
443  p = cpl_parameter_new_enum("muse.muse_scipost.crtype",
444  CPL_TYPE_STRING,
445  "Type of statistics used for detection of cosmic rays during final resampling. \"iraf\" uses the variance information, \"mean\" uses standard (mean/stdev) statistics, \"median\" uses median and the median median of the absolute median deviation.",
446  "muse.muse_scipost",
447  (const char *)"median",
448  3,
449  (const char *)"iraf",
450  (const char *)"mean",
451  (const char *)"median");
452  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "crtype");
453  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "crtype");
454 
455  cpl_parameterlist_append(recipe->parameters, p);
456 
457  /* --crsigma: Sigma rejection factor to use for cosmic ray rejection during final resampling. A zero or negative value switches cosmic ray rejection off. */
458  p = cpl_parameter_new_value("muse.muse_scipost.crsigma",
459  CPL_TYPE_DOUBLE,
460  "Sigma rejection factor to use for cosmic ray rejection during final resampling. A zero or negative value switches cosmic ray rejection off.",
461  "muse.muse_scipost",
462  (double)15.);
463  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "crsigma");
464  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "crsigma");
465 
466  cpl_parameterlist_append(recipe->parameters, p);
467 
468  /* --rc: Critical radius for the "renka" resampling method. */
469  p = cpl_parameter_new_value("muse.muse_scipost.rc",
470  CPL_TYPE_DOUBLE,
471  "Critical radius for the \"renka\" resampling method.",
472  "muse.muse_scipost",
473  (double)1.25);
474  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "rc");
475  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "rc");
476 
477  cpl_parameterlist_append(recipe->parameters, p);
478 
479  /* --pixfrac: Pixel down-scaling factor for the "drizzle" resampling method. */
480  p = cpl_parameter_new_value("muse.muse_scipost.pixfrac",
481  CPL_TYPE_DOUBLE,
482  "Pixel down-scaling factor for the \"drizzle\" resampling method.",
483  "muse.muse_scipost",
484  (double)0.8);
485  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "pixfrac");
486  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "pixfrac");
487 
488  cpl_parameterlist_append(recipe->parameters, p);
489 
490  /* --ld: Number of adjacent pixels to take into account during resampling in all three directions (loop distance); this affects all resampling methods except "nearest". */
491  p = cpl_parameter_new_value("muse.muse_scipost.ld",
492  CPL_TYPE_INT,
493  "Number of adjacent pixels to take into account during resampling in all three directions (loop distance); this affects all resampling methods except \"nearest\".",
494  "muse.muse_scipost",
495  (int)1);
496  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "ld");
497  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ld");
498 
499  cpl_parameterlist_append(recipe->parameters, p);
500 
501  /* --format: Type of output file format, "Cube" is a standard FITS cube with NAXIS=3 and multiple extensions (for data and variance). The extended "x" formats include the reconstructed image(s) in FITS image extensions within the same file. */
502  p = cpl_parameter_new_enum("muse.muse_scipost.format",
503  CPL_TYPE_STRING,
504  "Type of output file format, \"Cube\" is a standard FITS cube with NAXIS=3 and multiple extensions (for data and variance). The extended \"x\" formats include the reconstructed image(s) in FITS image extensions within the same file.",
505  "muse.muse_scipost",
506  (const char *)"Cube",
507  4,
508  (const char *)"Cube",
509  (const char *)"Euro3D",
510  (const char *)"xCube",
511  (const char *)"xEuro3D");
512  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "format");
513  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "format");
514 
515  cpl_parameterlist_append(recipe->parameters, p);
516 
517  /* --weight: Type of weighting scheme to use when combining multiple exposures. "exptime" just uses the exposure time to weight the exposures, "fwhm" uses the DIMM information in the header as well, "none" preserves an existing weight column in the input pixel tables without changes. */
518  p = cpl_parameter_new_enum("muse.muse_scipost.weight",
519  CPL_TYPE_STRING,
520  "Type of weighting scheme to use when combining multiple exposures. \"exptime\" just uses the exposure time to weight the exposures, \"fwhm\" uses the DIMM information in the header as well, \"none\" preserves an existing weight column in the input pixel tables without changes.",
521  "muse.muse_scipost",
522  (const char *)"exptime",
523  3,
524  (const char *)"exptime",
525  (const char *)"fwhm",
526  (const char *)"none");
527  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "weight");
528  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "weight");
529 
530  cpl_parameterlist_append(recipe->parameters, p);
531 
532  /* --filter: The filter name(s) to be used for the output field-of-view image. Each name has to correspond to an EXTNAME in an extension of the FILTER_LIST file. If an unsupported filter name is given, creation of the respective image is omitted. If multiple filter names are given, they have to be comma separated. */
533  p = cpl_parameter_new_value("muse.muse_scipost.filter",
534  CPL_TYPE_STRING,
535  "The filter name(s) to be used for the output field-of-view image. Each name has to correspond to an EXTNAME in an extension of the FILTER_LIST file. If an unsupported filter name is given, creation of the respective image is omitted. If multiple filter names are given, they have to be comma separated.",
536  "muse.muse_scipost",
537  (const char *)"white");
538  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "filter");
539  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "filter");
540 
541  cpl_parameterlist_append(recipe->parameters, p);
542 
543  /* --skymethod: The method used to subtract the sky background. "model" should work in all cases, it uses a global sky spectrum model with a local LSF. If "model" is selected, calibration frames for SKY_LINES and LSF_PROFILE must be set; SKY_CONTINUUM and SKY_MASK are optional. If "subtract-model" is selected, precalculated sky lines and continuum are subtracted if specified by SKY_LINES and SKY_CONTINUUM. An LSF_PROFILE is necessary for the two model-based methods. */
544  p = cpl_parameter_new_enum("muse.muse_scipost.skymethod",
545  CPL_TYPE_STRING,
546  "The method used to subtract the sky background. \"model\" should work in all cases, it uses a global sky spectrum model with a local LSF. If \"model\" is selected, calibration frames for SKY_LINES and LSF_PROFILE must be set; SKY_CONTINUUM and SKY_MASK are optional. If \"subtract-model\" is selected, precalculated sky lines and continuum are subtracted if specified by SKY_LINES and SKY_CONTINUUM. An LSF_PROFILE is necessary for the two model-based methods.",
547  "muse.muse_scipost",
548  (const char *)"model",
549  3,
550  (const char *)"none",
551  (const char *)"subtract-model",
552  (const char *)"model");
553  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "skymethod");
554  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "skymethod");
555 
556  cpl_parameterlist_append(recipe->parameters, p);
557 
558  /* --lambdamin: Cut off the data below this wavelength after loading the pixel table(s). */
559  p = cpl_parameter_new_value("muse.muse_scipost.lambdamin",
560  CPL_TYPE_DOUBLE,
561  "Cut off the data below this wavelength after loading the pixel table(s).",
562  "muse.muse_scipost",
563  (double)4000.);
564  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "lambdamin");
565  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "lambdamin");
566 
567  cpl_parameterlist_append(recipe->parameters, p);
568 
569  /* --lambdamax: Cut off the data above this wavelength after loading the pixel table(s). */
570  p = cpl_parameter_new_value("muse.muse_scipost.lambdamax",
571  CPL_TYPE_DOUBLE,
572  "Cut off the data above this wavelength after loading the pixel table(s).",
573  "muse.muse_scipost",
574  (double)10000.);
575  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "lambdamax");
576  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "lambdamax");
577 
578  cpl_parameterlist_append(recipe->parameters, p);
579 
580  /* --lambdaref: Reference wavelength used for correction of differential atmospheric refraction. The R-band (peak wavelength ~7000 Angstrom) that is usually used for guiding, is close to the central wavelength of MUSE, so a value of 7000.0 Angstrom should be used if nothing else is known. A value less than zero switches DAR correction off. */
581  p = cpl_parameter_new_value("muse.muse_scipost.lambdaref",
582  CPL_TYPE_DOUBLE,
583  "Reference wavelength used for correction of differential atmospheric refraction. The R-band (peak wavelength ~7000 Angstrom) that is usually used for guiding, is close to the central wavelength of MUSE, so a value of 7000.0 Angstrom should be used if nothing else is known. A value less than zero switches DAR correction off.",
584  "muse.muse_scipost",
585  (double)7000.);
586  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "lambdaref");
587  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "lambdaref");
588 
589  cpl_parameterlist_append(recipe->parameters, p);
590 
591  /* --darcheck: Carry out a check of the theoretical DAR correction using source centroiding. If "correct" it will also apply an empirical correction. */
592  p = cpl_parameter_new_enum("muse.muse_scipost.darcheck",
593  CPL_TYPE_STRING,
594  "Carry out a check of the theoretical DAR correction using source centroiding. If \"correct\" it will also apply an empirical correction.",
595  "muse.muse_scipost",
596  (const char *)"none",
597  3,
598  (const char *)"none",
599  (const char *)"check",
600  (const char *)"correct");
601  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "darcheck");
602  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "darcheck");
603 
604  cpl_parameterlist_append(recipe->parameters, p);
605 
606  /* --skymodel_fraction: Fraction of the image to be considered as sky. If an input sky mask is provided, the fraction is applied to the regions within the mask. If the whole sky mask should be used, set this parameter to 1. */
607  p = cpl_parameter_new_value("muse.muse_scipost.skymodel_fraction",
608  CPL_TYPE_DOUBLE,
609  "Fraction of the image to be considered as sky. If an input sky mask is provided, the fraction is applied to the regions within the mask. If the whole sky mask should be used, set this parameter to 1.",
610  "muse.muse_scipost",
611  (double)0.05);
612  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "skymodel_fraction");
613  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "skymodel_fraction");
614 
615  cpl_parameterlist_append(recipe->parameters, p);
616 
617  /* --skymodel_sampling: Spectral sampling of the sky spectrum [Angstrom]. */
618  p = cpl_parameter_new_value("muse.muse_scipost.skymodel_sampling",
619  CPL_TYPE_DOUBLE,
620  "Spectral sampling of the sky spectrum [Angstrom].",
621  "muse.muse_scipost",
622  (double)1.25);
623  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "skymodel_sampling");
624  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "skymodel_sampling");
625 
626  cpl_parameterlist_append(recipe->parameters, p);
627 
628  /* --skymodel_csampling: Spectral sampling of the continuum spectrum [Angstrom]. */
629  p = cpl_parameter_new_value("muse.muse_scipost.skymodel_csampling",
630  CPL_TYPE_DOUBLE,
631  "Spectral sampling of the continuum spectrum [Angstrom].",
632  "muse.muse_scipost",
633  (double)1.25);
634  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "skymodel_csampling");
635  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "skymodel_csampling");
636 
637  cpl_parameterlist_append(recipe->parameters, p);
638 
639  /* --rvcorr: Correct the radial velocity of the telescope with reference to either the barycenter of the Solar System (bary), the center of the Sun (helio), or to the center of the Earth (geo). */
640  p = cpl_parameter_new_enum("muse.muse_scipost.rvcorr",
641  CPL_TYPE_STRING,
642  "Correct the radial velocity of the telescope with reference to either the barycenter of the Solar System (bary), the center of the Sun (helio), or to the center of the Earth (geo).",
643  "muse.muse_scipost",
644  (const char *)"bary",
645  4,
646  (const char *)"bary",
647  (const char *)"helio",
648  (const char *)"geo",
649  (const char *)"none");
650  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "rvcorr");
651  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "rvcorr");
652 
653  cpl_parameterlist_append(recipe->parameters, p);
654 
655  /* --astrometry: If false, skip any astrometric calibration, even if one was passed in the input set of files. This causes creation of an output cube with a linear WCS and may result in errors. If you want to use a sensible default, leave this true but do not pass an ASTROMETRY_WCS. */
656  p = cpl_parameter_new_value("muse.muse_scipost.astrometry",
657  CPL_TYPE_BOOL,
658  "If false, skip any astrometric calibration, even if one was passed in the input set of files. This causes creation of an output cube with a linear WCS and may result in errors. If you want to use a sensible default, leave this true but do not pass an ASTROMETRY_WCS.",
659  "muse.muse_scipost",
660  (int)TRUE);
661  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "astrometry");
662  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "astrometry");
663 
664  cpl_parameterlist_append(recipe->parameters, p);
665 
666  return 0;
667 } /* muse_scipost_create() */
668 
669 /*----------------------------------------------------------------------------*/
680 /*----------------------------------------------------------------------------*/
681 static int
682 muse_scipost_params_fill(muse_scipost_params_t *aParams, cpl_parameterlist *aParameters)
683 {
684  cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
685  cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
686  cpl_parameter *p;
687 
688  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.save");
689  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
690  aParams->save = cpl_parameter_get_string(p);
691 
692  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.resample");
693  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
694  aParams->resample_s = cpl_parameter_get_string(p);
695  aParams->resample =
696  (!strcasecmp(aParams->resample_s, "nearest")) ? MUSE_SCIPOST_PARAM_RESAMPLE_NEAREST :
697  (!strcasecmp(aParams->resample_s, "linear")) ? MUSE_SCIPOST_PARAM_RESAMPLE_LINEAR :
698  (!strcasecmp(aParams->resample_s, "quadratic")) ? MUSE_SCIPOST_PARAM_RESAMPLE_QUADRATIC :
699  (!strcasecmp(aParams->resample_s, "renka")) ? MUSE_SCIPOST_PARAM_RESAMPLE_RENKA :
700  (!strcasecmp(aParams->resample_s, "drizzle")) ? MUSE_SCIPOST_PARAM_RESAMPLE_DRIZZLE :
701  (!strcasecmp(aParams->resample_s, "lanczos")) ? MUSE_SCIPOST_PARAM_RESAMPLE_LANCZOS :
702  MUSE_SCIPOST_PARAM_RESAMPLE_INVALID_VALUE;
703  cpl_ensure_code(aParams->resample != MUSE_SCIPOST_PARAM_RESAMPLE_INVALID_VALUE,
704  CPL_ERROR_ILLEGAL_INPUT);
705 
706  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.dx");
707  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
708  aParams->dx = cpl_parameter_get_double(p);
709 
710  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.dy");
711  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
712  aParams->dy = cpl_parameter_get_double(p);
713 
714  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.dlambda");
715  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
716  aParams->dlambda = cpl_parameter_get_double(p);
717 
718  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.crtype");
719  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
720  aParams->crtype_s = cpl_parameter_get_string(p);
721  aParams->crtype =
722  (!strcasecmp(aParams->crtype_s, "iraf")) ? MUSE_SCIPOST_PARAM_CRTYPE_IRAF :
723  (!strcasecmp(aParams->crtype_s, "mean")) ? MUSE_SCIPOST_PARAM_CRTYPE_MEAN :
724  (!strcasecmp(aParams->crtype_s, "median")) ? MUSE_SCIPOST_PARAM_CRTYPE_MEDIAN :
725  MUSE_SCIPOST_PARAM_CRTYPE_INVALID_VALUE;
726  cpl_ensure_code(aParams->crtype != MUSE_SCIPOST_PARAM_CRTYPE_INVALID_VALUE,
727  CPL_ERROR_ILLEGAL_INPUT);
728 
729  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.crsigma");
730  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
731  aParams->crsigma = cpl_parameter_get_double(p);
732 
733  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.rc");
734  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
735  aParams->rc = cpl_parameter_get_double(p);
736 
737  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.pixfrac");
738  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
739  aParams->pixfrac = cpl_parameter_get_double(p);
740 
741  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.ld");
742  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
743  aParams->ld = cpl_parameter_get_int(p);
744 
745  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.format");
746  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
747  aParams->format_s = cpl_parameter_get_string(p);
748  aParams->format =
749  (!strcasecmp(aParams->format_s, "Cube")) ? MUSE_SCIPOST_PARAM_FORMAT_CUBE :
750  (!strcasecmp(aParams->format_s, "Euro3D")) ? MUSE_SCIPOST_PARAM_FORMAT_EURO3D :
751  (!strcasecmp(aParams->format_s, "xCube")) ? MUSE_SCIPOST_PARAM_FORMAT_XCUBE :
752  (!strcasecmp(aParams->format_s, "xEuro3D")) ? MUSE_SCIPOST_PARAM_FORMAT_XEURO3D :
753  MUSE_SCIPOST_PARAM_FORMAT_INVALID_VALUE;
754  cpl_ensure_code(aParams->format != MUSE_SCIPOST_PARAM_FORMAT_INVALID_VALUE,
755  CPL_ERROR_ILLEGAL_INPUT);
756 
757  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.weight");
758  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
759  aParams->weight_s = cpl_parameter_get_string(p);
760  aParams->weight =
761  (!strcasecmp(aParams->weight_s, "exptime")) ? MUSE_SCIPOST_PARAM_WEIGHT_EXPTIME :
762  (!strcasecmp(aParams->weight_s, "fwhm")) ? MUSE_SCIPOST_PARAM_WEIGHT_FWHM :
763  (!strcasecmp(aParams->weight_s, "none")) ? MUSE_SCIPOST_PARAM_WEIGHT_NONE :
764  MUSE_SCIPOST_PARAM_WEIGHT_INVALID_VALUE;
765  cpl_ensure_code(aParams->weight != MUSE_SCIPOST_PARAM_WEIGHT_INVALID_VALUE,
766  CPL_ERROR_ILLEGAL_INPUT);
767 
768  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.filter");
769  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
770  aParams->filter = cpl_parameter_get_string(p);
771 
772  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.skymethod");
773  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
774  aParams->skymethod_s = cpl_parameter_get_string(p);
775  aParams->skymethod =
776  (!strcasecmp(aParams->skymethod_s, "none")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_NONE :
777  (!strcasecmp(aParams->skymethod_s, "subtract-model")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_SUBTRACT_MODEL :
778  (!strcasecmp(aParams->skymethod_s, "model")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_MODEL :
779  MUSE_SCIPOST_PARAM_SKYMETHOD_INVALID_VALUE;
780  cpl_ensure_code(aParams->skymethod != MUSE_SCIPOST_PARAM_SKYMETHOD_INVALID_VALUE,
781  CPL_ERROR_ILLEGAL_INPUT);
782 
783  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.lambdamin");
784  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
785  aParams->lambdamin = cpl_parameter_get_double(p);
786 
787  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.lambdamax");
788  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
789  aParams->lambdamax = cpl_parameter_get_double(p);
790 
791  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.lambdaref");
792  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
793  aParams->lambdaref = cpl_parameter_get_double(p);
794 
795  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.darcheck");
796  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
797  aParams->darcheck_s = cpl_parameter_get_string(p);
798  aParams->darcheck =
799  (!strcasecmp(aParams->darcheck_s, "none")) ? MUSE_SCIPOST_PARAM_DARCHECK_NONE :
800  (!strcasecmp(aParams->darcheck_s, "check")) ? MUSE_SCIPOST_PARAM_DARCHECK_CHECK :
801  (!strcasecmp(aParams->darcheck_s, "correct")) ? MUSE_SCIPOST_PARAM_DARCHECK_CORRECT :
802  MUSE_SCIPOST_PARAM_DARCHECK_INVALID_VALUE;
803  cpl_ensure_code(aParams->darcheck != MUSE_SCIPOST_PARAM_DARCHECK_INVALID_VALUE,
804  CPL_ERROR_ILLEGAL_INPUT);
805 
806  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.skymodel_fraction");
807  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
808  aParams->skymodel_fraction = cpl_parameter_get_double(p);
809 
810  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.skymodel_sampling");
811  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
812  aParams->skymodel_sampling = cpl_parameter_get_double(p);
813 
814  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.skymodel_csampling");
815  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
816  aParams->skymodel_csampling = cpl_parameter_get_double(p);
817 
818  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.rvcorr");
819  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
820  aParams->rvcorr_s = cpl_parameter_get_string(p);
821  aParams->rvcorr =
822  (!strcasecmp(aParams->rvcorr_s, "bary")) ? MUSE_SCIPOST_PARAM_RVCORR_BARY :
823  (!strcasecmp(aParams->rvcorr_s, "helio")) ? MUSE_SCIPOST_PARAM_RVCORR_HELIO :
824  (!strcasecmp(aParams->rvcorr_s, "geo")) ? MUSE_SCIPOST_PARAM_RVCORR_GEO :
825  (!strcasecmp(aParams->rvcorr_s, "none")) ? MUSE_SCIPOST_PARAM_RVCORR_NONE :
826  MUSE_SCIPOST_PARAM_RVCORR_INVALID_VALUE;
827  cpl_ensure_code(aParams->rvcorr != MUSE_SCIPOST_PARAM_RVCORR_INVALID_VALUE,
828  CPL_ERROR_ILLEGAL_INPUT);
829 
830  p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.astrometry");
831  cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
832  aParams->astrometry = cpl_parameter_get_bool(p);
833 
834  return 0;
835 } /* muse_scipost_params_fill() */
836 
837 /*----------------------------------------------------------------------------*/
844 /*----------------------------------------------------------------------------*/
845 static int
846 muse_scipost_exec(cpl_plugin *aPlugin)
847 {
848  if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
849  return -1;
850  }
851  cpl_recipe *recipe = (cpl_recipe *)aPlugin;
852  cpl_msg_set_threadid_on();
853 
854  cpl_frameset *usedframes = cpl_frameset_new(),
855  *outframes = cpl_frameset_new();
856  muse_scipost_params_t params;
857  muse_scipost_params_fill(&params, recipe->parameters);
858 
859  cpl_errorstate prestate = cpl_errorstate_get();
860 
861  muse_processing *proc = muse_processing_new("muse_scipost",
862  recipe);
863  int rc = muse_scipost_compute(proc, &params);
864  cpl_frameset_join(usedframes, proc->usedframes);
865  cpl_frameset_join(outframes, proc->outframes);
867 
868  if (!cpl_errorstate_is_equal(prestate)) {
869  /* dump all errors from this recipe in chronological order */
870  cpl_errorstate_dump(prestate, CPL_FALSE, muse_cplerrorstate_dump_some);
871  /* reset message level to not get the same errors displayed again by esorex */
872  cpl_msg_set_level(CPL_MSG_INFO);
873  }
874  /* clean up duplicates in framesets of used and output frames */
877 
878  /* to get esorex to see our classification (frame groups etc.), *
879  * replace the original frameset with the list of used frames *
880  * before appending product output frames */
881  /* keep the same pointer, so just erase all frames, not delete the frameset */
882  muse_cplframeset_erase_all(recipe->frames);
883  cpl_frameset_join(recipe->frames, usedframes);
884  cpl_frameset_join(recipe->frames, outframes);
885  cpl_frameset_delete(usedframes);
886  cpl_frameset_delete(outframes);
887  return rc;
888 } /* muse_scipost_exec() */
889 
890 /*----------------------------------------------------------------------------*/
897 /*----------------------------------------------------------------------------*/
898 static int
899 muse_scipost_destroy(cpl_plugin *aPlugin)
900 {
901  /* Get the recipe from the plugin */
902  cpl_recipe *recipe;
903  if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
904  recipe = (cpl_recipe *)aPlugin;
905  } else {
906  return -1;
907  }
908 
909  /* Clean up */
910  cpl_parameterlist_delete(recipe->parameters);
912  return 0;
913 } /* muse_scipost_destroy() */
914 
915 /*----------------------------------------------------------------------------*/
925 /*----------------------------------------------------------------------------*/
926 int
927 cpl_plugin_get_info(cpl_pluginlist *aList)
928 {
929  cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
930  cpl_plugin *plugin = &recipe->interface;
931 
932  char *helptext;
934  helptext = cpl_sprintf("%s%s", muse_scipost_help,
935  muse_scipost_help_esorex);
936  } else {
937  helptext = cpl_sprintf("%s", muse_scipost_help);
938  }
939 
940  /* Initialize the CPL plugin stuff for this module */
941  cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
942  CPL_PLUGIN_TYPE_RECIPE,
943  "muse_scipost",
944  "Prepare reduced and combined science products.",
945  helptext,
946  "Peter Weilbacher",
947  "usd-help@eso.org",
949  muse_scipost_create,
950  muse_scipost_exec,
951  muse_scipost_destroy);
952  cpl_pluginlist_append(aList, plugin);
953  cpl_free(helptext);
954 
955  return 0;
956 } /* cpl_plugin_get_info() */
957 
void muse_processing_delete(muse_processing *aProcessing)
Free the muse_processing structure.
int rvcorr
Correct the radial velocity of the telescope with reference to either the barycenter of the Solar Sys...
double lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
const char * skymethod_s
The method used to subtract the sky background. "model" should work in all cases, it uses a global sk...
const char * darcheck_s
Carry out a check of the theoretical DAR correction using source centroiding. If "correct" it will al...
muse_cplframework_type muse_cplframework(void)
Return the CPL framework the recipe is run under.
int ld
Number of adjacent pixels to take into account during resampling in all three directions (loop distan...
const char * rvcorr_s
Correct the radial velocity of the telescope with reference to either the barycenter of the Solar Sys...
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...
cpl_frameset * usedframes
muse_processing * muse_processing_new(const char *aName, cpl_recipe *aRecipe)
Create a new processing structure.
const char * weight_s
Type of weighting scheme to use when combining multiple exposures. "exptime" just uses the exposure t...
const char * muse_get_license(void)
Get the pipeline copyright and license.
Definition: muse_utils.c:84
muse_frame_mode
double dy
Vertical step size for resampling (in arcsec or pixel). The following defaults are taken when this va...
cpl_frameset * outframes
double pixfrac
Pixel down-scaling factor for the "drizzle" resampling method.
double lambdaref
Reference wavelength used for correction of differential atmospheric refraction. The R-band (peak wav...
double rc
Critical radius for the "renka" resampling method.
double skymodel_fraction
Fraction of the image to be considered as sky. If an input sky mask is provided, the fraction is appl...
void muse_cplerrorstate_dump_some(unsigned aCurrent, unsigned aFirst, unsigned aLast)
Dump some CPL errors.
const char * crtype_s
Type of statistics used for detection of cosmic rays during final resampling. "iraf" uses the varianc...
void muse_processinginfo_delete(cpl_recipe *)
Clear all information from the processing info and from the recipe config.
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].
int astrometry
If false, skip any astrometric calibration, even if one was passed in the input set of files...
double skymodel_csampling
Spectral sampling of the continuum spectrum [Angstrom].
int weight
Type of weighting scheme to use when combining multiple exposures. "exptime" just uses the exposure t...
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).
cpl_error_code muse_cplframeset_erase_duplicate(cpl_frameset *aFrames)
Erase all duplicate frames from a frameset.
double dx
Horizontal step size for resampling (in arcsec or pixel). The following defaults are taken when this ...
cpl_error_code muse_cplframeset_erase_all(cpl_frameset *aFrames)
Erase all frames in a frameset.
int skymethod
The method used to subtract the sky background. "model" should work in all cases, it uses a global sk...
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...
int resample
The resampling technique to use for the final output cube.
void muse_processinginfo_register(cpl_recipe *, cpl_recipeconfig *, muse_processing_prepare_header_func *, muse_processing_get_frame_level_func *, muse_processing_get_frame_mode_func *)
Register extended functionalities for MUSE recipes.
double dlambda
Wavelength step size (in Angstrom). Natural instrument sampling is used, if this is 0...
int format
Type of output file format, "Cube" is a standard FITS cube with NAXIS=3 and multiple extensions (for ...
const char * resample_s
The resampling technique to use for the final output cube. (as string)
int crtype
Type of statistics used for detection of cosmic rays during final resampling. "iraf" uses the varianc...
cpl_error_code muse_processing_prepare_property(cpl_propertylist *, const char *, cpl_type, const char *)
Prepare and check the specified property.
const char * save
Select output product(s) to save. Can contain one or more of "cube", "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 – "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.)