00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027
00028
00029
00030
00031 #include <string.h>
00032 #include <strings.h>
00033 #include <cpl.h>
00034
00035 #include "muse_scipost_z.h"
00036
00037
00081
00084
00085
00086
00087 static const char *muse_scipost_help =
00088 "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 absorption 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, after ignoring the lowest --skymodel_ignore as artifacts) 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.";
00089
00090 static const char *muse_scipost_help_esorex =
00091 "\n\nInput frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
00092 "\n Frame tag Type Req #Fr Description"
00093 "\n -------------------- ---- --- --- ------------"
00094 "\n PIXTABLE_OBJECT raw Y Pixel table of a science object"
00095 "\n EXTINCT_TABLE calib Y 1 Atmospheric extinction table"
00096 "\n STD_RESPONSE calib Y 1 Response curve as derived from standard star(s)"
00097 "\n STD_TELLURIC calib . 1 Telluric absorption correction as derived from standard star(s)"
00098 "\n ASTROMETRY_WCS calib . 1 Astrometric solution derived from astrometric science frame"
00099 "\n OFFSET_LIST calib . 1 List of coordinate offsets (and optional flux scale factors)"
00100 "\n FILTER_LIST calib . 1 File to be used to create field-of-view images."
00101 "\n OUTPUT_WCS calib . 1 WCS to override output cube location / dimensions"
00102 "\n SKY_LINES calib . 1 List of OH transitions and other sky lines"
00103 "\n SKY_CONTINUUM calib . 1 Sky continuum to use"
00104 "\n LSF_PROFILE calib . Slice specific LSF parameters."
00105 "\n SKY_MASK calib . 1 Sky mask to use"
00106 "\n\nProduct frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
00107 "\n Frame tag Level Description"
00108 "\n -------------------- -------- ------------"
00109 "\n DATACUBE_FINAL final Output datacube"
00110 "\n IMAGE_FOV final Field-of-view images corresponding to the \"filter\" parameter."
00111 "\n OBJECT_RESAMPLED final Stacked image (if --save contains \"stacked\")"
00112 "\n PIXTABLE_REDUCED intermed Fully reduced pixel tables for each exposure (if --save contains \"individual\")"
00113 "\n PIXTABLE_POSITIONED intermed Fully reduced and positioned pixel table for each individual exposure (if --save contains \"positioned\")"
00114 "\n PIXTABLE_COMBINED intermed Fully reduced and combined pixel table for the full set of exposures (if --save contains \"combined\")"
00115 "\n SKY_MASK intermed Created sky mask (if --skymethod=model and --save contains \"skymodel\")"
00116 "\n SKY_SPECTRUM intermed Sky spectrum within the sky mask (if --skymethod=model and --save contains \"skymodel\")"
00117 "\n SKY_LINES final Estimated sky line flux table (if --skymethod=model and --save contains \"skymodel\")"
00118 "\n SKY_CONTINUUM final Estimated continuum flux spectrum (if --skymethod=model and --save contains \"skymodel\")";
00119
00120
00128
00129 static cpl_recipeconfig *
00130 muse_scipost_new_recipeconfig(void)
00131 {
00132 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
00133
00134 cpl_recipeconfig_set_tag(recipeconfig, "PIXTABLE_OBJECT", 1, -1);
00135 cpl_recipeconfig_set_input(recipeconfig, "PIXTABLE_OBJECT", "EXTINCT_TABLE", 1, 1);
00136 cpl_recipeconfig_set_input(recipeconfig, "PIXTABLE_OBJECT", "STD_RESPONSE", 1, 1);
00137 cpl_recipeconfig_set_input(recipeconfig, "PIXTABLE_OBJECT", "STD_TELLURIC", -1, 1);
00138 cpl_recipeconfig_set_input(recipeconfig, "PIXTABLE_OBJECT", "ASTROMETRY_WCS", -1, 1);
00139 cpl_recipeconfig_set_input(recipeconfig, "PIXTABLE_OBJECT", "OFFSET_LIST", -1, 1);
00140 cpl_recipeconfig_set_input(recipeconfig, "PIXTABLE_OBJECT", "FILTER_LIST", -1, 1);
00141 cpl_recipeconfig_set_input(recipeconfig, "PIXTABLE_OBJECT", "OUTPUT_WCS", -1, 1);
00142 cpl_recipeconfig_set_input(recipeconfig, "PIXTABLE_OBJECT", "SKY_LINES", 0, 1);
00143 cpl_recipeconfig_set_input(recipeconfig, "PIXTABLE_OBJECT", "SKY_CONTINUUM", 0, 1);
00144 cpl_recipeconfig_set_input(recipeconfig, "PIXTABLE_OBJECT", "LSF_PROFILE", 0, -1);
00145 cpl_recipeconfig_set_input(recipeconfig, "PIXTABLE_OBJECT", "SKY_MASK", 0, 1);
00146 cpl_recipeconfig_set_output(recipeconfig, "PIXTABLE_OBJECT", "SKY_MASK");
00147 cpl_recipeconfig_set_output(recipeconfig, "PIXTABLE_OBJECT", "SKY_SPECTRUM");
00148 cpl_recipeconfig_set_output(recipeconfig, "PIXTABLE_OBJECT", "SKY_LINES");
00149 cpl_recipeconfig_set_output(recipeconfig, "PIXTABLE_OBJECT", "SKY_CONTINUUM");
00150
00151 return recipeconfig;
00152 }
00153
00154
00164
00165 static cpl_error_code
00166 muse_scipost_prepare_header(const char *aFrametag, cpl_propertylist *aHeader)
00167 {
00168 cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
00169 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
00170 if (!strcmp(aFrametag, "DATACUBE_FINAL")) {
00171 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST NDET",
00172 CPL_TYPE_INT,
00173 "Number of detected sources in output cube.");
00174 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST LAMBDA",
00175 CPL_TYPE_FLOAT,
00176 "[Angstrom] Wavelength of plane in combined cube that was used for object detection.");
00177 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST POS[0-9]+ X",
00178 CPL_TYPE_FLOAT,
00179 "[pix] Position of source k in x-direction in output cube. If the FWHM measurement fails, this value will be -1.");
00180 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST POS[0-9]+ Y",
00181 CPL_TYPE_FLOAT,
00182 "[pix] Position of source k in y-direction in output cube. If the FWHM measurement fails, this value will be -1.");
00183 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST FWHM[0-9]+ X",
00184 CPL_TYPE_FLOAT,
00185 "[arcsec] FWHM of source k in x-direction in output cube. If the FWHM measurement fails, this value will be -1.");
00186 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST FWHM[0-9]+ Y",
00187 CPL_TYPE_FLOAT,
00188 "[arcsec] FWHM of source k in y-direction in output cube. If the FWHM measurement fails, this value will be -1.");
00189 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST FWHM NVALID",
00190 CPL_TYPE_INT,
00191 "Number of detected sources with valid FWHM in output cube.");
00192 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST FWHM MEDIAN",
00193 CPL_TYPE_FLOAT,
00194 "[arcsec] Median FWHM of all sources with valid FWHM measurement (in x- and y-direction) in output cube. If less than three sources with valid FWHM are detected, this value is zero.");
00195 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST FWHM MAD",
00196 CPL_TYPE_FLOAT,
00197 "[arcsec] Median absolute deviation of the FWHM of all sources with valid FWHM measurement (in x- and y-direction) in output cube. If less than three sources with valid FWHM are detected, this value is zero.");
00198 } else if (!strcmp(aFrametag, "IMAGE_FOV")) {
00199 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST POS[0-9]+ X",
00200 CPL_TYPE_FLOAT,
00201 "[pix] Position of source k in x-direction in combined frame");
00202 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST POS[0-9]+ Y",
00203 CPL_TYPE_FLOAT,
00204 "[pix] Position of source k in y-direction in combined frame");
00205 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST FWHM[0-9]+ X",
00206 CPL_TYPE_FLOAT,
00207 "[arcsec] FWHM of source k in x-direction in combined frame");
00208 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST FWHM[0-9]+ Y",
00209 CPL_TYPE_FLOAT,
00210 "[arcsec] FWHM of source k in y-direction in combined frame");
00211 } else if (!strcmp(aFrametag, "OBJECT_RESAMPLED")) {
00212 } else if (!strcmp(aFrametag, "PIXTABLE_REDUCED")) {
00213 } else if (!strcmp(aFrametag, "PIXTABLE_POSITIONED")) {
00214 } else if (!strcmp(aFrametag, "PIXTABLE_COMBINED")) {
00215 } else if (!strcmp(aFrametag, "SKY_MASK")) {
00216 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST THRESHOLD",
00217 CPL_TYPE_DOUBLE,
00218 "Threshold in the white light considered as sky, used to create this mask");
00219 } else if (!strcmp(aFrametag, "SKY_SPECTRUM")) {
00220 } else if (!strcmp(aFrametag, "SKY_LINES")) {
00221 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST LINE[0-9]+ NAME",
00222 CPL_TYPE_STRING,
00223 "Name of the strongest line in group l");
00224 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST LINE[0-9]+ AWAV",
00225 CPL_TYPE_DOUBLE,
00226 "[Angstrom] Wavelength (air) of the strongest line of group l");
00227 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST LINE[0-9]+ FLUX",
00228 CPL_TYPE_DOUBLE,
00229 "[erg/(s cm2 arcsec2)] Flux of the strongest line of group l");
00230 } else if (!strcmp(aFrametag, "SKY_CONTINUUM")) {
00231 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST CONT FLUX",
00232 CPL_TYPE_DOUBLE,
00233 "[erg/(s cm2 arcsec2)] Total flux of the continuum");
00234 muse_processing_prepare_property(aHeader, "ESO QC SCIPOST CONT MAXDEV",
00235 CPL_TYPE_DOUBLE,
00236 "[erg/(s cm2 arcsec2 Angstrom)] Maximum (absolute value) of the derivative of the continuum spectrum");
00237 } else {
00238 cpl_msg_warning(__func__, "Frame tag %s is not defined", aFrametag);
00239 return CPL_ERROR_ILLEGAL_INPUT;
00240 }
00241 return CPL_ERROR_NONE;
00242 }
00243
00244
00253
00254 static cpl_frame_level
00255 muse_scipost_get_frame_level(const char *aFrametag)
00256 {
00257 if (!aFrametag) {
00258 return CPL_FRAME_LEVEL_NONE;
00259 }
00260 if (!strcmp(aFrametag, "DATACUBE_FINAL")) {
00261 return CPL_FRAME_LEVEL_FINAL;
00262 }
00263 if (!strcmp(aFrametag, "IMAGE_FOV")) {
00264 return CPL_FRAME_LEVEL_FINAL;
00265 }
00266 if (!strcmp(aFrametag, "OBJECT_RESAMPLED")) {
00267 return CPL_FRAME_LEVEL_FINAL;
00268 }
00269 if (!strcmp(aFrametag, "PIXTABLE_REDUCED")) {
00270 return CPL_FRAME_LEVEL_INTERMEDIATE;
00271 }
00272 if (!strcmp(aFrametag, "PIXTABLE_POSITIONED")) {
00273 return CPL_FRAME_LEVEL_INTERMEDIATE;
00274 }
00275 if (!strcmp(aFrametag, "PIXTABLE_COMBINED")) {
00276 return CPL_FRAME_LEVEL_INTERMEDIATE;
00277 }
00278 if (!strcmp(aFrametag, "SKY_MASK")) {
00279 return CPL_FRAME_LEVEL_INTERMEDIATE;
00280 }
00281 if (!strcmp(aFrametag, "SKY_SPECTRUM")) {
00282 return CPL_FRAME_LEVEL_INTERMEDIATE;
00283 }
00284 if (!strcmp(aFrametag, "SKY_LINES")) {
00285 return CPL_FRAME_LEVEL_FINAL;
00286 }
00287 if (!strcmp(aFrametag, "SKY_CONTINUUM")) {
00288 return CPL_FRAME_LEVEL_FINAL;
00289 }
00290 return CPL_FRAME_LEVEL_NONE;
00291 }
00292
00293
00302
00303 static muse_frame_mode
00304 muse_scipost_get_frame_mode(const char *aFrametag)
00305 {
00306 if (!aFrametag) {
00307 return MUSE_FRAME_MODE_ALL;
00308 }
00309 if (!strcmp(aFrametag, "DATACUBE_FINAL")) {
00310 return MUSE_FRAME_MODE_MASTER;
00311 }
00312 if (!strcmp(aFrametag, "IMAGE_FOV")) {
00313 return MUSE_FRAME_MODE_SEQUENCE;
00314 }
00315 if (!strcmp(aFrametag, "OBJECT_RESAMPLED")) {
00316 return MUSE_FRAME_MODE_MASTER;
00317 }
00318 if (!strcmp(aFrametag, "PIXTABLE_REDUCED")) {
00319 return MUSE_FRAME_MODE_DATEOBS;
00320 }
00321 if (!strcmp(aFrametag, "PIXTABLE_POSITIONED")) {
00322 return MUSE_FRAME_MODE_DATEOBS;
00323 }
00324 if (!strcmp(aFrametag, "PIXTABLE_COMBINED")) {
00325 return MUSE_FRAME_MODE_MASTER;
00326 }
00327 if (!strcmp(aFrametag, "SKY_MASK")) {
00328 return MUSE_FRAME_MODE_DATEOBS;
00329 }
00330 if (!strcmp(aFrametag, "SKY_SPECTRUM")) {
00331 return MUSE_FRAME_MODE_DATEOBS;
00332 }
00333 if (!strcmp(aFrametag, "SKY_LINES")) {
00334 return MUSE_FRAME_MODE_DATEOBS;
00335 }
00336 if (!strcmp(aFrametag, "SKY_CONTINUUM")) {
00337 return MUSE_FRAME_MODE_DATEOBS;
00338 }
00339 return MUSE_FRAME_MODE_ALL;
00340 }
00341
00342
00352
00353 static int
00354 muse_scipost_create(cpl_plugin *aPlugin)
00355 {
00356
00357 cpl_recipe *recipe;
00358 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
00359 recipe = (cpl_recipe *)aPlugin;
00360 } else {
00361 return -1;
00362 }
00363
00364
00365
00366 muse_processinginfo_register(recipe,
00367 muse_scipost_new_recipeconfig(),
00368 muse_scipost_prepare_header,
00369 muse_scipost_get_frame_level,
00370 muse_scipost_get_frame_mode);
00371
00372
00373
00374 if (muse_cplframework() == MUSE_CPLFRAMEWORK_ESOREX) {
00375 cpl_msg_set_time_on();
00376 }
00377
00378
00379 recipe->parameters = cpl_parameterlist_new();
00380
00381 cpl_parameter *p;
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391 p = cpl_parameter_new_value("muse.muse_scipost.save",
00392 CPL_TYPE_STRING,
00393 "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.)",
00394 "muse.muse_scipost",
00395 (const char *)"cube,skymodel");
00396 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "save");
00397 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "save");
00398
00399 cpl_parameterlist_append(recipe->parameters, p);
00400
00401
00402 p = cpl_parameter_new_enum("muse.muse_scipost.resample",
00403 CPL_TYPE_STRING,
00404 "The resampling technique to use for the final output cube.",
00405 "muse.muse_scipost",
00406 (const char *)"drizzle",
00407 6,
00408 (const char *)"nearest",
00409 (const char *)"linear",
00410 (const char *)"quadratic",
00411 (const char *)"renka",
00412 (const char *)"drizzle",
00413 (const char *)"lanczos");
00414 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "resample");
00415 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "resample");
00416
00417 cpl_parameterlist_append(recipe->parameters, p);
00418
00419
00420 p = cpl_parameter_new_value("muse.muse_scipost.dx",
00421 CPL_TYPE_DOUBLE,
00422 "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.",
00423 "muse.muse_scipost",
00424 (double)0.0);
00425 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "dx");
00426 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dx");
00427
00428 cpl_parameterlist_append(recipe->parameters, p);
00429
00430
00431 p = cpl_parameter_new_value("muse.muse_scipost.dy",
00432 CPL_TYPE_DOUBLE,
00433 "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.",
00434 "muse.muse_scipost",
00435 (double)0.0);
00436 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "dy");
00437 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dy");
00438
00439 cpl_parameterlist_append(recipe->parameters, p);
00440
00441
00442 p = cpl_parameter_new_value("muse.muse_scipost.dlambda",
00443 CPL_TYPE_DOUBLE,
00444 "Wavelength step size (in Angstrom). Natural instrument sampling is used, if this is 0.0",
00445 "muse.muse_scipost",
00446 (double)0.0);
00447 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "dlambda");
00448 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dlambda");
00449
00450 cpl_parameterlist_append(recipe->parameters, p);
00451
00452
00453 p = cpl_parameter_new_enum("muse.muse_scipost.crtype",
00454 CPL_TYPE_STRING,
00455 "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.",
00456 "muse.muse_scipost",
00457 (const char *)"median",
00458 3,
00459 (const char *)"iraf",
00460 (const char *)"mean",
00461 (const char *)"median");
00462 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "crtype");
00463 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "crtype");
00464
00465 cpl_parameterlist_append(recipe->parameters, p);
00466
00467
00468 p = cpl_parameter_new_value("muse.muse_scipost.crsigma",
00469 CPL_TYPE_DOUBLE,
00470 "Sigma rejection factor to use for cosmic ray rejection during final resampling. A zero or negative value switches cosmic ray rejection off.",
00471 "muse.muse_scipost",
00472 (double)15.);
00473 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "crsigma");
00474 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "crsigma");
00475
00476 cpl_parameterlist_append(recipe->parameters, p);
00477
00478
00479 p = cpl_parameter_new_value("muse.muse_scipost.rc",
00480 CPL_TYPE_DOUBLE,
00481 "Critical radius for the \"renka\" resampling method.",
00482 "muse.muse_scipost",
00483 (double)1.25);
00484 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "rc");
00485 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "rc");
00486
00487 cpl_parameterlist_append(recipe->parameters, p);
00488
00489
00490 p = cpl_parameter_new_value("muse.muse_scipost.pixfrac",
00491 CPL_TYPE_DOUBLE,
00492 "Pixel down-scaling factor for the \"drizzle\" resampling method.",
00493 "muse.muse_scipost",
00494 (double)0.8);
00495 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "pixfrac");
00496 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "pixfrac");
00497
00498 cpl_parameterlist_append(recipe->parameters, p);
00499
00500
00501 p = cpl_parameter_new_value("muse.muse_scipost.ld",
00502 CPL_TYPE_INT,
00503 "Number of adjacent pixels to take into account during resampling in all three directions (loop distance); this affects all resampling methods except \"nearest\".",
00504 "muse.muse_scipost",
00505 (int)1);
00506 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "ld");
00507 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ld");
00508
00509 cpl_parameterlist_append(recipe->parameters, p);
00510
00511
00512 p = cpl_parameter_new_enum("muse.muse_scipost.format",
00513 CPL_TYPE_STRING,
00514 "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.",
00515 "muse.muse_scipost",
00516 (const char *)"Cube",
00517 5,
00518 (const char *)"Cube",
00519 (const char *)"Euro3D",
00520 (const char *)"xCube",
00521 (const char *)"xEuro3D",
00522 (const char *)"sdpCube");
00523 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "format");
00524 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "format");
00525
00526 cpl_parameterlist_append(recipe->parameters, p);
00527
00528
00529 p = cpl_parameter_new_enum("muse.muse_scipost.weight",
00530 CPL_TYPE_STRING,
00531 "Type of weighting scheme to use when combining multiple exposures. \"exptime\" just uses the exposure time to weight the exposures, \"fwhm\" uses the best available seeing information from the headers as well, \"none\" preserves an existing weight column in the input pixel tables without changes.",
00532 "muse.muse_scipost",
00533 (const char *)"exptime",
00534 3,
00535 (const char *)"exptime",
00536 (const char *)"fwhm",
00537 (const char *)"none");
00538 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "weight");
00539 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "weight");
00540
00541 cpl_parameterlist_append(recipe->parameters, p);
00542
00543
00544 p = cpl_parameter_new_value("muse.muse_scipost.filter",
00545 CPL_TYPE_STRING,
00546 "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.",
00547 "muse.muse_scipost",
00548 (const char *)"white");
00549 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "filter");
00550 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "filter");
00551
00552 cpl_parameterlist_append(recipe->parameters, p);
00553
00554
00555 p = cpl_parameter_new_enum("muse.muse_scipost.skymethod",
00556 CPL_TYPE_STRING,
00557 "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. \"simple\" directly subtracts a sky spectrum created from the data, without regard to LSF variations; it also works on data taht was not flux calibrated.",
00558 "muse.muse_scipost",
00559 (const char *)"model",
00560 4,
00561 (const char *)"none",
00562 (const char *)"subtract-model",
00563 (const char *)"model",
00564 (const char *)"simple");
00565 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "skymethod");
00566 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "skymethod");
00567
00568 cpl_parameterlist_append(recipe->parameters, p);
00569
00570
00571 p = cpl_parameter_new_value("muse.muse_scipost.lambdamin",
00572 CPL_TYPE_DOUBLE,
00573 "Cut off the data below this wavelength after loading the pixel table(s).",
00574 "muse.muse_scipost",
00575 (double)4000.);
00576 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "lambdamin");
00577 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "lambdamin");
00578
00579 cpl_parameterlist_append(recipe->parameters, p);
00580
00581
00582 p = cpl_parameter_new_value("muse.muse_scipost.lambdamax",
00583 CPL_TYPE_DOUBLE,
00584 "Cut off the data above this wavelength after loading the pixel table(s).",
00585 "muse.muse_scipost",
00586 (double)10000.);
00587 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "lambdamax");
00588 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "lambdamax");
00589
00590 cpl_parameterlist_append(recipe->parameters, p);
00591
00592
00593 p = cpl_parameter_new_value("muse.muse_scipost.lambdaref",
00594 CPL_TYPE_DOUBLE,
00595 "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.",
00596 "muse.muse_scipost",
00597 (double)7000.);
00598 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "lambdaref");
00599 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "lambdaref");
00600
00601 cpl_parameterlist_append(recipe->parameters, p);
00602
00603
00604 p = cpl_parameter_new_enum("muse.muse_scipost.darcheck",
00605 CPL_TYPE_STRING,
00606 "Carry out a check of the theoretical DAR correction using source centroiding. If \"correct\" it will also apply an empirical correction.",
00607 "muse.muse_scipost",
00608 (const char *)"none",
00609 3,
00610 (const char *)"none",
00611 (const char *)"check",
00612 (const char *)"correct");
00613 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "darcheck");
00614 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "darcheck");
00615
00616 cpl_parameterlist_append(recipe->parameters, p);
00617
00618
00619 p = cpl_parameter_new_value("muse.muse_scipost.skymodel_fraction",
00620 CPL_TYPE_DOUBLE,
00621 "Fraction of the image (without the ignored part) 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.",
00622 "muse.muse_scipost",
00623 (double)0.10);
00624 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "skymodel_fraction");
00625 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "skymodel_fraction");
00626
00627 cpl_parameterlist_append(recipe->parameters, p);
00628
00629
00630 p = cpl_parameter_new_value("muse.muse_scipost.skymodel_ignore",
00631 CPL_TYPE_DOUBLE,
00632 "Fraction of the image to be ignored. 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 0.",
00633 "muse.muse_scipost",
00634 (double)0.05);
00635 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "skymodel_ignore");
00636 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "skymodel_ignore");
00637
00638 cpl_parameterlist_append(recipe->parameters, p);
00639
00640
00641 p = cpl_parameter_new_value("muse.muse_scipost.skymodel_sampling",
00642 CPL_TYPE_DOUBLE,
00643 "Spectral sampling of the sky spectrum [Angstrom].",
00644 "muse.muse_scipost",
00645 (double)0.3125);
00646 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "skymodel_sampling");
00647 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "skymodel_sampling");
00648 if (!getenv("MUSE_EXPERT_USER")) {
00649 cpl_parameter_disable(p, CPL_PARAMETER_MODE_CLI);
00650 }
00651
00652 cpl_parameterlist_append(recipe->parameters, p);
00653
00654
00655 p = cpl_parameter_new_value("muse.muse_scipost.skymodel_csampling",
00656 CPL_TYPE_DOUBLE,
00657 "Spectral sampling of the continuum spectrum [Angstrom].",
00658 "muse.muse_scipost",
00659 (double)0.3125);
00660 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "skymodel_csampling");
00661 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "skymodel_csampling");
00662 if (!getenv("MUSE_EXPERT_USER")) {
00663 cpl_parameter_disable(p, CPL_PARAMETER_MODE_CLI);
00664 }
00665
00666 cpl_parameterlist_append(recipe->parameters, p);
00667
00668
00669 p = cpl_parameter_new_value("muse.muse_scipost.sky_crsigma",
00670 CPL_TYPE_STRING,
00671 "Sigma level clipping for cube-based and spectrum-based CR rejection when creating the sky spectrum. This has to be a string of two comma-separated floating-point numbers. The first value gives the sigma-level rejection for cube-based CR rejection (using \"median\"), the second value the sigma-level for spectrum-based CR cleaning. Both can be switched off, by passing zero or a negative value; by default, the spectrum-based rejection is switched off.",
00672 "muse.muse_scipost",
00673 (const char *)"15.,15.");
00674 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "sky_crsigma");
00675 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sky_crsigma");
00676 if (!getenv("MUSE_EXPERT_USER")) {
00677 cpl_parameter_disable(p, CPL_PARAMETER_MODE_CLI);
00678 }
00679
00680 cpl_parameterlist_append(recipe->parameters, p);
00681
00682
00683 p = cpl_parameter_new_enum("muse.muse_scipost.rvcorr",
00684 CPL_TYPE_STRING,
00685 "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).",
00686 "muse.muse_scipost",
00687 (const char *)"bary",
00688 4,
00689 (const char *)"bary",
00690 (const char *)"helio",
00691 (const char *)"geo",
00692 (const char *)"none");
00693 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "rvcorr");
00694 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "rvcorr");
00695
00696 cpl_parameterlist_append(recipe->parameters, p);
00697
00698
00699 p = cpl_parameter_new_value("muse.muse_scipost.astrometry",
00700 CPL_TYPE_BOOL,
00701 "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.",
00702 "muse.muse_scipost",
00703 (int)TRUE);
00704 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG, "astrometry");
00705 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "astrometry");
00706
00707 cpl_parameterlist_append(recipe->parameters, p);
00708
00709 return 0;
00710 }
00711
00712
00723
00724 static int
00725 muse_scipost_params_fill(muse_scipost_params_t *aParams, cpl_parameterlist *aParameters)
00726 {
00727 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
00728 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
00729 cpl_parameter *p;
00730
00731 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.save");
00732 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00733 aParams->save = cpl_parameter_get_string(p);
00734
00735 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.resample");
00736 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00737 aParams->resample_s = cpl_parameter_get_string(p);
00738 aParams->resample =
00739 (!strcasecmp(aParams->resample_s, "nearest")) ? MUSE_SCIPOST_PARAM_RESAMPLE_NEAREST :
00740 (!strcasecmp(aParams->resample_s, "linear")) ? MUSE_SCIPOST_PARAM_RESAMPLE_LINEAR :
00741 (!strcasecmp(aParams->resample_s, "quadratic")) ? MUSE_SCIPOST_PARAM_RESAMPLE_QUADRATIC :
00742 (!strcasecmp(aParams->resample_s, "renka")) ? MUSE_SCIPOST_PARAM_RESAMPLE_RENKA :
00743 (!strcasecmp(aParams->resample_s, "drizzle")) ? MUSE_SCIPOST_PARAM_RESAMPLE_DRIZZLE :
00744 (!strcasecmp(aParams->resample_s, "lanczos")) ? MUSE_SCIPOST_PARAM_RESAMPLE_LANCZOS :
00745 MUSE_SCIPOST_PARAM_RESAMPLE_INVALID_VALUE;
00746 cpl_ensure_code(aParams->resample != MUSE_SCIPOST_PARAM_RESAMPLE_INVALID_VALUE,
00747 CPL_ERROR_ILLEGAL_INPUT);
00748
00749 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.dx");
00750 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00751 aParams->dx = cpl_parameter_get_double(p);
00752
00753 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.dy");
00754 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00755 aParams->dy = cpl_parameter_get_double(p);
00756
00757 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.dlambda");
00758 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00759 aParams->dlambda = cpl_parameter_get_double(p);
00760
00761 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.crtype");
00762 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00763 aParams->crtype_s = cpl_parameter_get_string(p);
00764 aParams->crtype =
00765 (!strcasecmp(aParams->crtype_s, "iraf")) ? MUSE_SCIPOST_PARAM_CRTYPE_IRAF :
00766 (!strcasecmp(aParams->crtype_s, "mean")) ? MUSE_SCIPOST_PARAM_CRTYPE_MEAN :
00767 (!strcasecmp(aParams->crtype_s, "median")) ? MUSE_SCIPOST_PARAM_CRTYPE_MEDIAN :
00768 MUSE_SCIPOST_PARAM_CRTYPE_INVALID_VALUE;
00769 cpl_ensure_code(aParams->crtype != MUSE_SCIPOST_PARAM_CRTYPE_INVALID_VALUE,
00770 CPL_ERROR_ILLEGAL_INPUT);
00771
00772 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.crsigma");
00773 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00774 aParams->crsigma = cpl_parameter_get_double(p);
00775
00776 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.rc");
00777 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00778 aParams->rc = cpl_parameter_get_double(p);
00779
00780 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.pixfrac");
00781 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00782 aParams->pixfrac = cpl_parameter_get_double(p);
00783
00784 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.ld");
00785 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00786 aParams->ld = cpl_parameter_get_int(p);
00787
00788 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.format");
00789 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00790 aParams->format_s = cpl_parameter_get_string(p);
00791 aParams->format =
00792 (!strcasecmp(aParams->format_s, "Cube")) ? MUSE_SCIPOST_PARAM_FORMAT_CUBE :
00793 (!strcasecmp(aParams->format_s, "Euro3D")) ? MUSE_SCIPOST_PARAM_FORMAT_EURO3D :
00794 (!strcasecmp(aParams->format_s, "xCube")) ? MUSE_SCIPOST_PARAM_FORMAT_XCUBE :
00795 (!strcasecmp(aParams->format_s, "xEuro3D")) ? MUSE_SCIPOST_PARAM_FORMAT_XEURO3D :
00796 (!strcasecmp(aParams->format_s, "sdpCube")) ? MUSE_SCIPOST_PARAM_FORMAT_SDPCUBE :
00797 MUSE_SCIPOST_PARAM_FORMAT_INVALID_VALUE;
00798 cpl_ensure_code(aParams->format != MUSE_SCIPOST_PARAM_FORMAT_INVALID_VALUE,
00799 CPL_ERROR_ILLEGAL_INPUT);
00800
00801 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.weight");
00802 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00803 aParams->weight_s = cpl_parameter_get_string(p);
00804 aParams->weight =
00805 (!strcasecmp(aParams->weight_s, "exptime")) ? MUSE_SCIPOST_PARAM_WEIGHT_EXPTIME :
00806 (!strcasecmp(aParams->weight_s, "fwhm")) ? MUSE_SCIPOST_PARAM_WEIGHT_FWHM :
00807 (!strcasecmp(aParams->weight_s, "none")) ? MUSE_SCIPOST_PARAM_WEIGHT_NONE :
00808 MUSE_SCIPOST_PARAM_WEIGHT_INVALID_VALUE;
00809 cpl_ensure_code(aParams->weight != MUSE_SCIPOST_PARAM_WEIGHT_INVALID_VALUE,
00810 CPL_ERROR_ILLEGAL_INPUT);
00811
00812 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.filter");
00813 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00814 aParams->filter = cpl_parameter_get_string(p);
00815
00816 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.skymethod");
00817 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00818 aParams->skymethod_s = cpl_parameter_get_string(p);
00819 aParams->skymethod =
00820 (!strcasecmp(aParams->skymethod_s, "none")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_NONE :
00821 (!strcasecmp(aParams->skymethod_s, "subtract-model")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_SUBTRACT_MODEL :
00822 (!strcasecmp(aParams->skymethod_s, "model")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_MODEL :
00823 (!strcasecmp(aParams->skymethod_s, "simple")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_SIMPLE :
00824 MUSE_SCIPOST_PARAM_SKYMETHOD_INVALID_VALUE;
00825 cpl_ensure_code(aParams->skymethod != MUSE_SCIPOST_PARAM_SKYMETHOD_INVALID_VALUE,
00826 CPL_ERROR_ILLEGAL_INPUT);
00827
00828 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.lambdamin");
00829 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00830 aParams->lambdamin = cpl_parameter_get_double(p);
00831
00832 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.lambdamax");
00833 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00834 aParams->lambdamax = cpl_parameter_get_double(p);
00835
00836 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.lambdaref");
00837 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00838 aParams->lambdaref = cpl_parameter_get_double(p);
00839
00840 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.darcheck");
00841 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00842 aParams->darcheck_s = cpl_parameter_get_string(p);
00843 aParams->darcheck =
00844 (!strcasecmp(aParams->darcheck_s, "none")) ? MUSE_SCIPOST_PARAM_DARCHECK_NONE :
00845 (!strcasecmp(aParams->darcheck_s, "check")) ? MUSE_SCIPOST_PARAM_DARCHECK_CHECK :
00846 (!strcasecmp(aParams->darcheck_s, "correct")) ? MUSE_SCIPOST_PARAM_DARCHECK_CORRECT :
00847 MUSE_SCIPOST_PARAM_DARCHECK_INVALID_VALUE;
00848 cpl_ensure_code(aParams->darcheck != MUSE_SCIPOST_PARAM_DARCHECK_INVALID_VALUE,
00849 CPL_ERROR_ILLEGAL_INPUT);
00850
00851 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.skymodel_fraction");
00852 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00853 aParams->skymodel_fraction = cpl_parameter_get_double(p);
00854
00855 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.skymodel_ignore");
00856 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00857 aParams->skymodel_ignore = cpl_parameter_get_double(p);
00858
00859 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.skymodel_sampling");
00860 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00861 aParams->skymodel_sampling = cpl_parameter_get_double(p);
00862
00863 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.skymodel_csampling");
00864 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00865 aParams->skymodel_csampling = cpl_parameter_get_double(p);
00866
00867 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.sky_crsigma");
00868 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00869 aParams->sky_crsigma = cpl_parameter_get_string(p);
00870
00871 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.rvcorr");
00872 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00873 aParams->rvcorr_s = cpl_parameter_get_string(p);
00874 aParams->rvcorr =
00875 (!strcasecmp(aParams->rvcorr_s, "bary")) ? MUSE_SCIPOST_PARAM_RVCORR_BARY :
00876 (!strcasecmp(aParams->rvcorr_s, "helio")) ? MUSE_SCIPOST_PARAM_RVCORR_HELIO :
00877 (!strcasecmp(aParams->rvcorr_s, "geo")) ? MUSE_SCIPOST_PARAM_RVCORR_GEO :
00878 (!strcasecmp(aParams->rvcorr_s, "none")) ? MUSE_SCIPOST_PARAM_RVCORR_NONE :
00879 MUSE_SCIPOST_PARAM_RVCORR_INVALID_VALUE;
00880 cpl_ensure_code(aParams->rvcorr != MUSE_SCIPOST_PARAM_RVCORR_INVALID_VALUE,
00881 CPL_ERROR_ILLEGAL_INPUT);
00882
00883 p = cpl_parameterlist_find(aParameters, "muse.muse_scipost.astrometry");
00884 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
00885 aParams->astrometry = cpl_parameter_get_bool(p);
00886
00887 return 0;
00888 }
00889
00890
00897
00898 static int
00899 muse_scipost_exec(cpl_plugin *aPlugin)
00900 {
00901 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
00902 return -1;
00903 }
00904 muse_processing_recipeinfo(aPlugin);
00905 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
00906 cpl_msg_set_threadid_on();
00907
00908 cpl_frameset *usedframes = cpl_frameset_new(),
00909 *outframes = cpl_frameset_new();
00910 muse_scipost_params_t params;
00911 muse_scipost_params_fill(¶ms, recipe->parameters);
00912
00913 cpl_errorstate prestate = cpl_errorstate_get();
00914
00915 muse_processing *proc = muse_processing_new("muse_scipost",
00916 recipe);
00917 int rc = muse_scipost_compute(proc, ¶ms);
00918 cpl_frameset_join(usedframes, proc->usedframes);
00919 cpl_frameset_join(outframes, proc->outframes);
00920 muse_processing_delete(proc);
00921
00922 if (!cpl_errorstate_is_equal(prestate)) {
00923
00924 cpl_errorstate_dump(prestate, CPL_FALSE, muse_cplerrorstate_dump_some);
00925
00926 cpl_msg_set_level(CPL_MSG_INFO);
00927 }
00928
00929 muse_cplframeset_erase_duplicate(usedframes);
00930 muse_cplframeset_erase_duplicate(outframes);
00931
00932
00933
00934
00935
00936 muse_cplframeset_erase_all(recipe->frames);
00937 cpl_frameset_join(recipe->frames, usedframes);
00938 cpl_frameset_join(recipe->frames, outframes);
00939 cpl_frameset_delete(usedframes);
00940 cpl_frameset_delete(outframes);
00941 return rc;
00942 }
00943
00944
00951
00952 static int
00953 muse_scipost_destroy(cpl_plugin *aPlugin)
00954 {
00955
00956 cpl_recipe *recipe;
00957 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
00958 recipe = (cpl_recipe *)aPlugin;
00959 } else {
00960 return -1;
00961 }
00962
00963
00964 cpl_parameterlist_delete(recipe->parameters);
00965 muse_processinginfo_delete(recipe);
00966 return 0;
00967 }
00968
00969
00979
00980 int
00981 cpl_plugin_get_info(cpl_pluginlist *aList)
00982 {
00983 cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00984 cpl_plugin *plugin = &recipe->interface;
00985
00986 char *helptext;
00987 if (muse_cplframework() == MUSE_CPLFRAMEWORK_ESOREX) {
00988 helptext = cpl_sprintf("%s%s", muse_scipost_help,
00989 muse_scipost_help_esorex);
00990 } else {
00991 helptext = cpl_sprintf("%s", muse_scipost_help);
00992 }
00993
00994
00995 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
00996 CPL_PLUGIN_TYPE_RECIPE,
00997 "muse_scipost",
00998 "Prepare reduced and combined science products.",
00999 helptext,
01000 "Peter Weilbacher",
01001 "usd-help@eso.org",
01002 muse_get_license(),
01003 muse_scipost_create,
01004 muse_scipost_exec,
01005 muse_scipost_destroy);
01006 cpl_pluginlist_append(aList, plugin);
01007 cpl_free(helptext);
01008
01009 return 0;
01010 }
01011