27#include <cxmessages.h>
30#include <cpl_recipe.h>
31#include <cpl_plugininfo.h>
32#include <cpl_parameterlist.h>
33#include <cpl_frameset.h>
42#include "gifiberutils.h"
43#include "gislitgeometry.h"
46#include "gilocalize.h"
49#include "gitransmission.h"
55static cxint gimasterflat(cpl_parameterlist* config, cpl_frameset* set);
56static cxint giqcmasterflat(cpl_frameset* set);
65gimasterflat_create(cpl_plugin* plugin)
68 cpl_recipe* recipe = (cpl_recipe*)plugin;
82 recipe->parameters = cpl_parameterlist_new();
83 cx_assert(recipe->parameters != NULL);
116 p = cpl_parameter_new_value(
"giraffe.masterflat.transmission",
118 "Controls the relative fiber transmission "
120 "giraffe.masterflat",
123 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"transmission");
124 cpl_parameterlist_append(recipe->parameters, p);
129 p = cpl_parameter_new_value(
"giraffe.masterflat.slight",
131 "Controls the scattered light model "
133 "giraffe.masterflat",
135 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"slight");
136 cpl_parameterlist_append(recipe->parameters, p);
150gimasterflat_exec(cpl_plugin* plugin)
153 cpl_recipe* recipe = (cpl_recipe*)plugin;
158 if (recipe->parameters == NULL || recipe->frames == NULL) {
162 status = gimasterflat(recipe->parameters, recipe->frames);
168 status = giqcmasterflat(recipe->frames);
180gimasterflat_destroy(cpl_plugin* plugin)
183 cpl_recipe* recipe = (cpl_recipe*)plugin;
192 cpl_parameterlist_delete(recipe->parameters);
194 giraffe_error_clear();
206gimasterflat(cpl_parameterlist* config, cpl_frameset* set)
209 const cxchar*
const _id =
"gimasterflat";
212 cxbool transmission = FALSE;
213 cxbool slmodel = FALSE;
220 cxdouble exptime = 0.;
223 cx_slist* flats = NULL;
225 cpl_parameter* p = NULL;
227 cpl_propertylist* properties = NULL;
229 cpl_matrix* biasareas = NULL;
231 cpl_frame* flat_frame = NULL;
232 cpl_frame* mbias_frame = NULL;
233 cpl_frame* mdark_frame = NULL;
234 cpl_frame* bpixel_frame = NULL;
235 cpl_frame* slight_frame = NULL;
236 cpl_frame* mlocy_frame = NULL;
237 cpl_frame* mlocw_frame = NULL;
238 cpl_frame* mlpsf_frame = NULL;
239 cpl_frame* mflat_frame = NULL;
240 cpl_frame* sloc_frame = NULL;
241 cpl_frame* ploc_frame = NULL;
242 cpl_frame* sext_frame = NULL;
243 cpl_frame* slit_frame = NULL;
244 cpl_frame* grating_frame = NULL;
245 cpl_frame* wcal_frame = NULL;
247 GiImage* bpixel = NULL;
248 GiImage* mbias = NULL;
249 GiImage* mdark = NULL;
250 GiImage* slight = NULL;
251 GiImage* sflat = NULL;
252 GiImage* mflat = NULL;
254 GiTable* fibers = NULL;
255 GiTable* grating = NULL;
256 GiTable* slitgeometry = NULL;
257 GiTable* wlsolution = NULL;
259 GiLocalization* sloc = NULL;
260 GiLocalization* ploc = NULL;
261 GiLocalization* mloc = NULL;
263 GiExtraction* extraction = NULL;
265 GiBiasConfig* bias_config = NULL;
267 GiFibersConfig* fibers_config = NULL;
269 GiLocalizeConfig* localize_config = NULL;
271 GiPsfConfig* psf_config = NULL;
273 GiExtractConfig* extract_config = NULL;
275 GiTransmissionConfig* transmission_config = NULL;
277 GiRecipeInfo info = {(cxchar*)_id, 1, NULL, config};
279 GiGroupInfo groups[] = {
280 {GIFRAME_FIBER_FLAT, CPL_FRAME_GROUP_RAW},
281 {GIFRAME_BADPIXEL_MAP, CPL_FRAME_GROUP_CALIB},
282 {GIFRAME_BIAS_MASTER, CPL_FRAME_GROUP_CALIB},
283 {GIFRAME_DARK_MASTER, CPL_FRAME_GROUP_CALIB},
284 {GIFRAME_SCATTERED_LIGHT_MODEL, CPL_FRAME_GROUP_CALIB},
285 {GIFRAME_LOCALIZATION_CENTROID, CPL_FRAME_GROUP_CALIB},
286 {GIFRAME_LOCALIZATION_WIDTH, CPL_FRAME_GROUP_CALIB},
287 {GIFRAME_PSF_DATA, CPL_FRAME_GROUP_CALIB},
288 {GIFRAME_WAVELENGTH_SOLUTION, CPL_FRAME_GROUP_CALIB},
289 {GIFRAME_SLITSETUP, CPL_FRAME_GROUP_CALIB},
290 {GIFRAME_SLITMASTER, CPL_FRAME_GROUP_CALIB},
291 {GIFRAME_GRATING, CPL_FRAME_GROUP_CALIB},
292 {NULL, CPL_FRAME_GROUP_NONE}
298 cpl_msg_error(_id,
"Invalid parameter list! Aborting ...");
303 cpl_msg_error(_id,
"Invalid frame set! Aborting ...");
307 status = giraffe_frameset_set_groups(set, groups);
310 cpl_msg_error(_id,
"Setting frame group information failed!");
315 p = cpl_parameterlist_find(config,
"giraffe.masterflat.transmission");
318 transmission = cpl_parameter_get_bool(p);
321 p = cpl_parameterlist_find(config,
"giraffe.masterflat.slight");
324 slmodel = cpl_parameter_get_bool(p);
332 nflats = cpl_frameset_count_tags(set, GIFRAME_FIBER_FLAT);
335 cpl_msg_error(_id,
"Too few (%d) raw frames (%s) present in "
336 "frame set! Aborting ...", nflats, GIFRAME_FIBER_FLAT);
341 bpixel_frame = cpl_frameset_find(set, GIFRAME_BADPIXEL_MAP);
344 cpl_msg_info(_id,
"No bad pixel map present in frame set.");
347 mbias_frame = cpl_frameset_find(set, GIFRAME_BIAS_MASTER);
350 cpl_msg_info(_id,
"No master bias present in frame set.");
353 mdark_frame = cpl_frameset_find(set, GIFRAME_DARK_MASTER);
356 cpl_msg_info(_id,
"No master dark present in frame set.");
359 mlocy_frame = cpl_frameset_find(set, GIFRAME_LOCALIZATION_CENTROID);
362 cpl_msg_info(_id,
"No master localization (centroid position) "
363 "present in frame set.");
366 mlocw_frame = cpl_frameset_find(set, GIFRAME_LOCALIZATION_WIDTH);
369 cpl_msg_info(_id,
"No master localization (spectrum width) "
370 "present in frame set.");
373 mlpsf_frame = cpl_frameset_find(set, GIFRAME_PSF_DATA);
376 cpl_msg_info(_id,
"No master localization (PSF parameters) "
377 "present in frame set.");
380 slight_frame = cpl_frameset_find(set, GIFRAME_SCATTERED_LIGHT_MODEL);
383 cpl_msg_info(_id,
"No scattered light model present in frame set.");
386 grating_frame = cpl_frameset_find(set, GIFRAME_GRATING);
388 if (!grating_frame) {
389 cpl_msg_info(_id,
"No grating data present in frame set. "
397 cpl_msg_info(_id,
"No slitgeometry present in frame set. "
402 wcal_frame = cpl_frameset_find(set, GIFRAME_WAVELENGTH_SOLUTION);
405 cpl_msg_info(_id,
"No wavelength solution present in frame set.");
413 flats = cx_slist_new();
415 flat_frame = cpl_frameset_find(set, GIFRAME_FIBER_FLAT);
417 for (i = 0; i < nflats; i++) {
419 const cxchar* filename = cpl_frame_get_filename(flat_frame);
427 cpl_msg_error(_id,
"Cannot load raw flat from '%s'. "
428 "Aborting ...", filename);
435 cx_slist_push_back(flats, raw);
437 flat_frame = cpl_frameset_find(set, NULL);
450 cpl_msg_info(_id,
"Averaging flat field frames ...");
452 nflats = (cxint)cx_slist_size(flats);
453 sflat = cx_slist_pop_front(flats);
456 cx_assert(properties != NULL);
458 exptime = cpl_propertylist_get_double(properties, GIALIAS_EXPTIME);
460 for (i = 1; i < nflats; i++) {
462 cpl_propertylist* _properties;
464 GiImage* flat = cx_slist_pop_front(flats);
470 cx_assert(_properties != NULL);
472 exptime += cpl_propertylist_get_double(_properties, GIALIAS_EXPTIME);
480 cx_assert(cx_slist_empty(flats));
481 cx_slist_delete(flats);
489 cpl_msg_info(_id,
"Updating stacked flat field image properties ...");
491 cpl_propertylist_update_double(properties, GIALIAS_EXPTIME,
494 cpl_propertylist_update_double(properties, GIALIAS_EXPTTOT, exptime);
495 cpl_propertylist_set_comment(properties, GIALIAS_EXPTTOT,
496 "Total exposure time of all frames "
499 cpl_propertylist_update_int(properties, GIALIAS_DATANCOM, nflats);
500 cpl_propertylist_set_comment(properties, GIALIAS_DATANCOM,
"Number of "
503 cpl_propertylist_erase(properties, GIALIAS_TPLEXPNO);
512 if (bias_config->method == GIBIAS_METHOD_MASTER ||
513 bias_config->method == GIBIAS_METHOD_ZMASTER) {
516 cpl_msg_error(_id,
"Missing master bias frame! Selected bias "
517 "removal method requires a master bias frame!");
525 const cxchar* filename = cpl_frame_get_filename(mbias_frame);
532 cpl_msg_error(_id,
"Cannot load master bias from '%s'. "
533 "Aborting ...", filename);
550 const cxchar* filename = cpl_frame_get_filename(bpixel_frame);
557 cpl_msg_error(_id,
"Cannot load bad pixel map from '%s'. "
558 "Aborting ...", filename);
592 cpl_msg_error(_id,
"Bias removal failed. Aborting ...");
597 if (bpixel != NULL) {
613 const cxchar* filename = cpl_frame_get_filename(mdark_frame);
615 GiDarkConfig dark_config = {GIDARK_METHOD_ZMASTER, 0.};
622 cpl_msg_error(_id,
"Cannot load master dark from '%s'. "
623 "Aborting ...", filename);
628 if (bpixel != NULL) {
640 cpl_msg_error(_id,
"Dark subtraction failed! Aborting ...");
648 if (bpixel != NULL) {
667 cpl_msg_info(_id,
"Writing master flat field image ...");
672 GIFRAME_FIBER_FLAT_MASTER,
673 CPL_FRAME_LEVEL_FINAL,
676 if (mflat_frame == NULL) {
677 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
688 cpl_frameset_insert(set, mflat_frame);
695 cpl_msg_info(_id,
"Recipe Step: Fiber setup");
698 flat_frame = cpl_frameset_find(set, GIFRAME_FIBER_FLAT);
700 cpl_msg_info(_id,
"Building fiber setup for frame '%s'.",
701 cpl_frame_get_filename(flat_frame));
703 if (mlocy_frame == NULL) {
705 GiTable *active_fibers = NULL;
707 if (slit_frame != NULL) {
709 const cxchar *tag = cpl_frame_get_tag(slit_frame);
710 const cxchar *filename = cpl_frame_get_filename(slit_frame);
712 if (strcmp(tag, GIFRAME_SLITSETUP) == 0) {
716 cpl_frame_get_filename(slit_frame),
717 1,
"SLIT_GEOMETRY_SETUP");
720 cpl_msg_error(_id,
"Cannot load expected fiber setup from "
721 "slit geometry '%s'! Aborting ...", filename);
741 cpl_msg_error(_id,
"Cannot determine fiber setup from flat "
742 "field frame '%s'! Aborting ...",
743 cpl_frame_get_filename(flat_frame));
758 active_fibers = NULL;
760 cpl_msg_info(_id,
"Fiber setup taken from flat field frame '%s'.",
761 cpl_frame_get_filename(flat_frame));
766 cpl_msg_info(_id,
"Fiber reference setup taken from localization "
767 "frame '%s'.", cpl_frame_get_filename(mlocy_frame));
772 cpl_msg_error(_id,
"Cannot create fiber setup for frame '%s'! "
773 "Aborting ...", cpl_frame_get_filename(flat_frame));
795 if (mlocy_frame != NULL) {
797 const cxchar* filename = cpl_frame_get_filename(mlocy_frame);
800 mloc = giraffe_localization_new();
805 cpl_msg_error(_id,
"Cannot load master localization centroids "
806 "from '%s'. Aborting ...", filename);
808 giraffe_localization_delete(mloc);
827 if (localize_config->full == FALSE) {
833 cpl_msg_error(_id,
"Localization computation using only SIWC spectra "
834 "is not yet supported! Aborting ...");
849 sloc = giraffe_localization_new();
852 bpixel, localize_config);
855 cpl_msg_error(_id,
"Spectrum localization failed! Aborting ...");
858 giraffe_localization_destroy(sloc);
861 giraffe_localization_destroy(mloc);
879 giraffe_localization_destroy(mloc);
888 cpl_msg_info(_id,
"Writing fiber localization ...");
896 GIFRAME_LOCALIZATION_CENTROID,
897 CPL_FRAME_LEVEL_FINAL,
900 if (sloc_frame == NULL) {
901 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
903 giraffe_localization_destroy(sloc);
918 cpl_msg_error(_id,
"Cannot attach fiber setup to local file '%s'! "
919 "Aborting ...", cpl_frame_get_filename(sloc_frame));
921 cpl_frame_delete(sloc_frame);
923 giraffe_localization_destroy(sloc);
935 cpl_frameset_insert(set, sloc_frame);
943 GIFRAME_LOCALIZATION_WIDTH,
944 CPL_FRAME_LEVEL_FINAL,
947 if (sloc_frame == NULL) {
948 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
950 giraffe_localization_destroy(sloc);
965 cpl_msg_error(_id,
"Cannot attach fiber setup to local file '%s'! "
966 "Aborting ...", cpl_frame_get_filename(sloc_frame));
968 cpl_frame_delete(sloc_frame);
970 giraffe_localization_destroy(sloc);
982 cpl_frameset_insert(set, sloc_frame);
991 GIFRAME_LOCALIZATION_FIT,
992 CPL_FRAME_LEVEL_FINAL,
995 if (sloc_frame == NULL) {
996 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
998 giraffe_localization_destroy(sloc);
1011 cpl_frameset_insert(set, sloc_frame);
1028 if (psf_config == NULL) {
1029 cpl_msg_error(_id,
"Invalid fiber profile fit configuration!");
1031 giraffe_localization_destroy(sloc);
1040 if (bpixel != NULL) {
1049 ploc = giraffe_localization_new();
1052 bpixel, psf_config);
1055 cpl_msg_error(_id,
"Fiber profile computation failed! Aborting ...");
1057 giraffe_localization_destroy(ploc);
1063 giraffe_localization_destroy(sloc);
1072 if (bpixel != NULL) {
1084 giraffe_localization_destroy(sloc);
1093 cpl_msg_info(_id,
"Writing fiber traces ...");
1101 GIFRAME_PSF_CENTROID,
1102 CPL_FRAME_LEVEL_FINAL,
1105 if (ploc_frame == NULL) {
1106 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
1108 giraffe_localization_destroy(ploc);
1117 if (bpixel != NULL) {
1128 cpl_msg_error(_id,
"Cannot attach fiber setup to local file '%s'! "
1129 "Aborting ...", cpl_frame_get_filename(ploc_frame));
1131 cpl_frame_delete(ploc_frame);
1133 giraffe_localization_destroy(ploc);
1142 if (bpixel != NULL) {
1150 cpl_frameset_insert(set, ploc_frame);
1159 CPL_FRAME_LEVEL_FINAL,
1162 if (ploc_frame == NULL) {
1163 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
1165 giraffe_localization_destroy(ploc);
1174 if (bpixel != NULL) {
1185 cpl_msg_error(_id,
"Cannot attach fiber setup to local file '%s'! "
1186 "Aborting ...", cpl_frame_get_filename(ploc_frame));
1188 cpl_frame_delete(ploc_frame);
1190 giraffe_localization_destroy(ploc);
1199 if (bpixel != NULL) {
1207 cpl_frameset_insert(set, ploc_frame);
1216 CPL_FRAME_LEVEL_FINAL,
1219 if (ploc_frame == NULL) {
1220 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
1222 giraffe_localization_destroy(ploc);
1231 if (bpixel != NULL) {
1242 cpl_msg_error(_id,
"Cannot attach fiber setup to local file '%s'! "
1243 "Aborting ...", cpl_frame_get_filename(ploc_frame));
1245 cpl_frame_delete(ploc_frame);
1247 giraffe_localization_destroy(ploc);
1256 if (bpixel != NULL) {
1264 cpl_frameset_insert(set, ploc_frame);
1269 GiFrameCreator creator = (GiFrameCreator) giraffe_psfdata_save;
1274 CPL_FRAME_LEVEL_FINAL,
1275 properties, ploc->psf,
1279 if (ploc_frame == NULL) {
1280 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
1282 giraffe_localization_destroy(ploc);
1291 if (bpixel != NULL) {
1302 cpl_msg_error(_id,
"Cannot attach fiber setup to local "
1303 "file '%s'! Aborting ...",
1304 cpl_frame_get_filename(ploc_frame));
1306 cpl_frame_delete(ploc_frame);
1308 giraffe_localization_destroy(ploc);
1317 if (bpixel != NULL) {
1325 cpl_frameset_insert(set, ploc_frame);
1336 if (slmodel == TRUE) {
1338 cpl_frame* slmodel_frame = NULL;
1340 GiSLightConfig* slight_config = NULL;
1343 cpl_msg_info(_id,
"Computing scattered light model ...");
1347 if (slight_config == NULL) {
1348 cpl_msg_error(_id,
"Invalid scattered light model "
1358 giraffe_localization_destroy(ploc);
1368 bpixel, NULL, slight_config);
1371 cpl_msg_error(_id,
"Scattered light model computation failed! "
1381 if (bpixel != NULL) {
1386 giraffe_localization_destroy(ploc);
1394 slight_config = NULL;
1401 cpl_msg_info(_id,
"Writing scattered light model ...");
1407 GIFRAME_SCATTERED_LIGHT_MODEL,
1408 CPL_FRAME_LEVEL_FINAL,
1411 if (slmodel_frame == NULL) {
1412 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
1419 if (bpixel != NULL) {
1424 giraffe_localization_destroy(ploc);
1430 cpl_frameset_insert(set, slmodel_frame);
1442 cpl_msg_info(_id,
"Extracting spectra ...");
1444 if (slight_frame != NULL) {
1446 const cxchar* filename = cpl_frame_get_filename(slight_frame);
1453 cpl_msg_error(_id,
"Cannot load scattered light model from '%s'. "
1454 "Aborting ...", filename);
1461 if (bpixel != NULL) {
1466 giraffe_localization_destroy(ploc);
1477 extraction = giraffe_extraction_new();
1480 ploc, bpixel, slight,
1484 cpl_msg_error(_id,
"Spectrum extraction failed! Aborting ...");
1486 giraffe_extraction_destroy(extraction);
1490 giraffe_localization_destroy(ploc);
1496 if (bpixel != NULL) {
1509 if (bpixel != NULL) {
1526 cpl_propertylist_update_double(properties, GIALIAS_FLAT_SCALE, mean);
1527 cpl_propertylist_set_comment(properties, GIALIAS_FLAT_SCALE,
1528 "Flat field scale factor");
1534 cpl_propertylist_update_double(properties, GIALIAS_FLAT_SCALE, mean);
1535 cpl_propertylist_set_comment(properties, GIALIAS_FLAT_SCALE,
1536 "Flat field scale factor");
1543 if (transmission == TRUE) {
1545 const cxchar* filename = NULL;
1550 cpl_msg_info(_id,
"Computing relative fiber transmission ...");
1552 filename = cpl_frame_get_filename(grating_frame);
1558 cpl_msg_error(_id,
"Cannot load grating data from '%s'. "
1559 "Aborting ...", filename);
1565 giraffe_extraction_destroy(extraction);
1567 giraffe_localization_destroy(ploc);
1576 filename = cpl_frame_get_filename(slit_frame);
1580 if (slitgeometry == NULL) {
1581 cpl_msg_error(_id,
"Cannot load slit geometry data from '%s'. "
1582 "Aborting ...", filename);
1588 giraffe_extraction_destroy(extraction);
1590 giraffe_localization_destroy(ploc);
1606 cpl_msg_error(_id,
"Slit geometry data from '%s' is not "
1607 "applicable for current fiber setup! "
1608 "Aborting ...", filename);
1615 giraffe_extraction_destroy(extraction);
1617 giraffe_localization_destroy(ploc);
1628 if (wcal_frame != NULL) {
1630 filename = cpl_frame_get_filename(wcal_frame);
1632 cpl_msg_info(_id,
"Loading wavelength solution from '%s'",
1639 cpl_msg_error(_id,
"Cannot load wavelength solution from "
1640 "'%s'. Aborting ...", filename);
1648 giraffe_extraction_destroy(extraction);
1650 giraffe_localization_destroy(ploc);
1661 status = giraffe_transmission_compute(extraction, fibers,
1663 grating, slitgeometry);
1666 cpl_msg_error(_id,
"Relative transmission computation failed! "
1669 if (wlsolution != NULL) {
1679 giraffe_extraction_destroy(extraction);
1681 giraffe_localization_destroy(ploc);
1689 if (wlsolution != NULL) {
1701 giraffe_localization_destroy(ploc);
1710 cpl_msg_info(_id,
"Writing extracted spectra ...");
1717 GIFRAME_FIBER_FLAT_EXTSPECTRA,
1718 CPL_FRAME_LEVEL_FINAL,
1721 if (sext_frame == NULL) {
1722 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
1724 giraffe_extraction_destroy(extraction);
1733 cpl_msg_error(_id,
"Cannot attach fiber setup to local file '%s'! "
1734 "Aborting ...", cpl_frame_get_filename(sext_frame));
1736 cpl_frame_delete(sext_frame);
1738 giraffe_extraction_destroy(extraction);
1744 cpl_frameset_insert(set, sext_frame);
1751 GIFRAME_FIBER_FLAT_EXTERRORS,
1752 CPL_FRAME_LEVEL_FINAL,
1755 if (sext_frame == NULL) {
1756 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
1758 giraffe_extraction_destroy(extraction);
1767 cpl_msg_error(_id,
"Cannot attach fiber setup to local file '%s'! "
1768 "Aborting ...", cpl_frame_get_filename(sext_frame));
1770 cpl_frame_delete(sext_frame);
1772 giraffe_extraction_destroy(extraction);
1778 cpl_frameset_insert(set, sext_frame);
1782 if (extraction->npixels != NULL) {
1787 GIFRAME_FIBER_FLAT_EXTPIXELS,
1788 CPL_FRAME_LEVEL_FINAL,
1791 if (sext_frame == NULL) {
1792 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
1794 giraffe_extraction_destroy(extraction);
1803 cpl_msg_error(_id,
"Cannot attach fiber setup to local file '%s'! "
1804 "Aborting ...", cpl_frame_get_filename(sext_frame));
1806 cpl_frame_delete(sext_frame);
1808 giraffe_extraction_destroy(extraction);
1814 cpl_frameset_insert(set, sext_frame);
1823 GIFRAME_FIBER_FLAT_EXTTRACE,
1824 CPL_FRAME_LEVEL_FINAL,
1827 if (sext_frame == NULL) {
1828 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
1830 giraffe_extraction_destroy(extraction);
1839 cpl_msg_error(_id,
"Cannot attach fiber setup to local file '%s'! "
1840 "Aborting ...", cpl_frame_get_filename(sext_frame));
1842 cpl_frame_delete(sext_frame);
1844 giraffe_extraction_destroy(extraction);
1850 cpl_frameset_insert(set, sext_frame);
1854 if (extraction->model != NULL) {
1859 GIFRAME_FIBER_FLAT_EXTMODEL,
1860 CPL_FRAME_LEVEL_FINAL,
1863 if (sext_frame == NULL) {
1864 cpl_msg_error(_id,
"Cannot create local file! Aborting ...");
1866 giraffe_extraction_destroy(extraction);
1875 cpl_msg_error(_id,
"Cannot attach fiber setup to local file '%s'! "
1876 "Aborting ...", cpl_frame_get_filename(sext_frame));
1878 cpl_frame_delete(sext_frame);
1880 giraffe_extraction_destroy(extraction);
1886 cpl_frameset_insert(set, sext_frame);
1895 giraffe_extraction_destroy(extraction);
1904giqcmasterflat(cpl_frameset* set)
1907 const cxchar*
const fctid =
"giqcmasterflat";
1914 cxint nsaturated = 0;
1917 const cxdouble saturation = 60000.;
1918 const cxdouble* pixels = NULL;
1919 cxdouble efficiency[2] = {0., 0.};
1920 cxdouble qcfluxm = 0;
1921 cxdouble scale = 1.;
1923 cxdouble meanfull = 0.;
1927 cxdouble* _pdata = NULL;
1928 cxdouble* _tdata = NULL;
1930 cpl_propertylist* properties = NULL;
1931 cpl_propertylist* qclog = NULL;
1933 cpl_frame* rframe = NULL;
1934 cpl_frame* pframe = NULL;
1936 cpl_image* _rimage = NULL;
1937 cpl_image* _pimage = NULL;
1938 cpl_image* _test = NULL;
1940 cpl_table* _ptable = NULL;
1942 GiImage* rimage = NULL;
1943 GiImage* pimage = NULL;
1945 GiTable* ptable = NULL;
1949 GiWindow w = {0, 0, 0, 0};
1951 cxdouble fibmed = 0.;
1955 cpl_msg_info(fctid,
"Computing QC1 parameters ...");
1957 qc = giraffe_qclog_open(0);
1960 cpl_msg_error(fctid,
"Cannot create QC1 log!");
1964 qclog = giraffe_paf_get_properties(qc);
1965 cx_assert(qclog != NULL);
1974 CPL_FRAME_GROUP_PRODUCT);
1976 if (pframe == NULL) {
1978 cpl_msg_warning(fctid,
"Product '%s' not found.",
1979 GIFRAME_FIBER_FLAT_EXTSPECTRA);
1981 cpl_msg_warning(fctid,
"Setting lamp efficiencies (%s, %s) to 0.",
1982 GIALIAS_QCLAMP, GIALIAS_QCLAMP_SIMCAL);
1994 cpl_msg_error(fctid,
"Could not load extracted spectra '%s'!",
1995 cpl_frame_get_filename(pframe));
2000 giraffe_paf_delete(qc);
2007 cx_assert(_pimage != NULL);
2015 cpl_msg_error(fctid,
"Could not load extracted spectra fiber setup!");
2023 giraffe_paf_delete(qc);
2030 cx_assert(_ptable != NULL);
2032 if (cpl_table_has_column(_ptable,
"RP") == FALSE) {
2034 cpl_msg_warning(fctid,
"Column 'RP' not found in fiber setup table!");
2035 cpl_msg_warning(fctid,
"Setting lamp efficiencies (%s, %s) to 0.",
2036 GIALIAS_QCLAMP, GIALIAS_QCLAMP_SIMCAL);
2045 cx_assert(properties != NULL);
2047 if (cpl_propertylist_has(properties, GIALIAS_EXPTIME) == FALSE) {
2049 cpl_msg_warning(fctid,
"Property '%s' not found in '%s'.",
2050 GIALIAS_EXPTIME, cpl_frame_get_filename(rframe));
2051 cpl_msg_warning(fctid,
"Setting lamp efficiencies (%s, %s) to 0.",
2052 GIALIAS_QCLAMP, GIALIAS_QCLAMP_SIMCAL);
2060 cxbool scaled = cpl_propertylist_has(properties,
2061 GIALIAS_FLAT_SCALE);
2064 cxint nb = cpl_image_get_size_y(_pimage);
2065 cxint nf[2] = {0, 0};
2067 cxdouble exptime = cpl_propertylist_get_double(properties,
2069 cxdouble* _sum = NULL;
2071 cpl_image* sum = NULL;
2074 if (scaled == TRUE) {
2076 scale = cpl_propertylist_get_double(properties,
2077 GIALIAS_FLAT_SCALE);
2078 cpl_image_multiply_scalar(_pimage, scale);
2083 sum = cpl_image_collapse_create(_pimage, 0);
2084 _sum = cpl_image_get_data_double(sum);
2086 for (fiber = 0; fiber < cpl_table_get_nrow(_ptable); ++fiber) {
2088 cxint rp = cpl_table_get_int(_ptable,
"RP", fiber, NULL);
2091 efficiency[1] += _sum[fiber];
2095 efficiency[0] += _sum[fiber];
2101 fibmed = cpl_image_get_median(sum) / scale / nb;
2105 cpl_image_delete(sum);
2109 cpl_msg_warning(fctid,
"No OzPoz fibers found in the "
2110 "current fiber setup.");
2111 cpl_msg_warning(fctid,
"Setting lamp efficiency (%s) to 0.",
2116 efficiency[0] /= nf[0] * nb * exptime;
2120 cpl_msg_warning(fctid,
"No simultaneous calibration fibers "
2121 "found in the current fiber setup.");
2122 cpl_msg_warning(fctid,
"Setting lamp efficiency (%s) to 0.",
2123 GIALIAS_QCLAMP_SIMCAL);
2127 efficiency[1] /= nf[1] * nb * exptime;
2152 CPL_FRAME_GROUP_PRODUCT);
2154 if (pframe == NULL) {
2155 cpl_msg_error(fctid,
"Missing product frame (%s)",
2156 GIFRAME_FIBER_FLAT_MASTER);
2158 giraffe_paf_delete(qc);
2164 cpl_msg_info(fctid,
"Processing product frame '%s' (%s)",
2165 cpl_frame_get_filename(pframe), cpl_frame_get_tag(pframe));
2171 cpl_msg_error(fctid,
"Could not load master flat field '%s'!",
2172 cpl_frame_get_filename(pframe));
2177 giraffe_paf_delete(qc);
2188 rframe = cpl_frameset_find(set, GIFRAME_FIBER_FLAT);
2190 if (rframe == NULL) {
2191 cpl_msg_error(fctid,
"Missing raw frame (%s)", GIFRAME_FIBER_FLAT);
2196 giraffe_paf_delete(qc);
2207 cpl_msg_error(fctid,
"Could not load flat field '%s'!",
2208 cpl_frame_get_filename(rframe));
2216 giraffe_paf_delete(qc);
2224 cx_assert(_rimage != NULL);
2227 cx_assert(properties != NULL);
2239 cpl_propertylist_update_string(qclog,
"PRO.CATG",
2240 cpl_frame_get_tag(pframe));
2241 cpl_propertylist_set_comment(qclog,
"PRO.CATG",
2242 "Pipeline product category");
2244 const char * flattype = giraffe_get_flat_type(properties);
2247 cx_assert(properties != NULL);
2265 cx_assert(properties != NULL);
2267 if (cpl_propertylist_has(properties, GIALIAS_OVSCX) == TRUE) {
2269 cxint _ox = cpl_propertylist_get_int(properties, GIALIAS_OVSCX);
2270 cxint _nx = cpl_image_get_size_x(_rimage) - 2 * CX_MAX(0, _ox) - 1;
2272 w.x0 = CX_MAX(0, _ox) + 1;
2277 if (cpl_propertylist_has(properties, GIALIAS_OVSCY) == TRUE) {
2279 cxint _oy = cpl_propertylist_get_int(properties, GIALIAS_OVSCY);
2280 cxint _ny = cpl_image_get_size_y(_rimage) - 2 * CX_MAX(0, _oy) - 1;
2282 w.y0 = CX_MAX(0, _oy) + 1;
2287 mean = cpl_image_get_mean_window(_rimage, w.x0, w.y0, w.x1, w.y1);
2288 meanfull = cpl_image_get_mean(_rimage);
2290 if (cpl_propertylist_has(properties, GIALIAS_EXPTIME) == FALSE) {
2291 cpl_msg_warning(fctid,
"Property '%s' not found in '%s'.",
2292 GIALIAS_EXPTIME, cpl_frame_get_filename(rframe));
2293 cpl_msg_warning(fctid,
"Setting flux mean (%s) to 0.", GIALIAS_QCFLUXM);
2298 cpl_propertylist_get_double(properties, GIALIAS_EXPTIME);
2300 qcfluxm = meanfull / exptime;
2304 pixels = cpl_image_get_data(_rimage);
2305 npixel = cpl_image_get_size_x(_rimage) * cpl_image_get_size_y(_rimage);
2307 for (i = 0; i < npixel; i++) {
2308 if (pixels[i] > saturation) {
2315 cx_assert(properties != NULL);
2317 cpl_propertylist_update_double(properties, GIALIAS_QCMEAN, mean);
2318 cpl_propertylist_set_comment(properties, GIALIAS_QCMEAN,
"Mean level of "
2324 cpl_propertylist_update_double(properties, GIALIAS_QCRAWM, meanfull);
2325 cpl_propertylist_set_comment(properties, GIALIAS_QCRAWM,
"Mean level of "
2326 "first raw full frame");
2331 cpl_propertylist_update_double(properties, GIALIAS_QCFLUXM, qcfluxm);
2332 cpl_propertylist_set_comment(properties, GIALIAS_QCFLUXM,
"Mean flux of "
2333 "first raw frame (ADU/s)");
2338 if (flattype != NULL) {
2339 cpl_propertylist_update_string(properties, GIALIAS_QCFLAT, flattype);
2340 cpl_propertylist_set_comment(properties, GIALIAS_QCFLAT,
"Type of "
2341 "flat field of first raw frame");
2348 cpl_propertylist_update_int(properties, GIALIAS_QCNSAT, nsaturated);
2349 cpl_propertylist_set_comment(properties, GIALIAS_QCNSAT,
"Number of "
2350 "saturated pixels in the first raw frame");
2357 cpl_propertylist_update_double(properties, GIALIAS_QCFIBMED, fibmed);
2358 cpl_propertylist_set_comment(properties, GIALIAS_QCFIBMED,
2359 "Median of per fibre mean values");
2369 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP, efficiency[0]);
2370 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP,
2371 "Calibration lamp efficiency");
2376 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP_SIMCAL,
2378 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP_SIMCAL,
2379 "SIMCAL lamp efficiency");
2382 GIALIAS_QCLAMP_SIMCAL);
2394 giraffe_qclog_close(qc);
2402 qc = giraffe_qclog_open(1);
2405 cpl_msg_error(fctid,
"Cannot create QC1 log!");
2413 qclog = giraffe_paf_get_properties(qc);
2414 cx_assert(qclog != NULL);
2417 CPL_FRAME_GROUP_PRODUCT);
2419 if (pframe == NULL) {
2420 cpl_msg_error(fctid,
"Missing product frame (%s)",
2421 GIFRAME_LOCALIZATION_CENTROID);
2423 giraffe_paf_delete(qc);
2432 cpl_msg_info(fctid,
"Processing product frame '%s' (%s)",
2433 cpl_frame_get_filename(pframe), cpl_frame_get_tag(pframe));
2440 cpl_msg_error(fctid,
"Could not load localization centroids '%s'!",
2441 cpl_frame_get_filename(pframe));
2449 giraffe_paf_delete(qc);
2460 cpl_msg_error(fctid,
"Could not load localization centroids '%s'!",
2461 cpl_frame_get_filename(pframe));
2472 giraffe_paf_delete(qc);
2479 cx_assert(properties != NULL);
2491 cpl_propertylist_update_string(qclog,
"PRO.CATG",
2492 cpl_frame_get_tag(pframe));
2493 cpl_propertylist_set_comment(qclog,
"PRO.CATG",
2494 "Pipeline product category");
2497 cx_assert(properties != NULL);
2517 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP, efficiency[0]);
2518 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP,
2519 "Calibration lamp efficiency");
2524 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP_SIMCAL,
2526 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP_SIMCAL,
2527 "SIMCAL lamp efficiency");
2530 GIALIAS_QCLAMP_SIMCAL);
2537 _test = cpl_image_collapse_create(_pimage, 0);
2538 cpl_image_divide_scalar(_test, cpl_image_get_size_y(_pimage));
2540 _pdata = cpl_image_get_data(_pimage);
2541 _tdata = cpl_image_get_data(_test);
2545 nx = cpl_image_get_size_x(_pimage);
2546 ny = cpl_image_get_size_y(_pimage);
2548 cpl_vector* xoff = cpl_vector_new(nx-1);
2550 double meanoff = 0.;
2554 for (i = 0; i < nx; i++) {
2560 cxdouble xmin = 1e6;
2561 cxdouble xmax = -1e6;
2563 for (j = 0; j < ny; j++) {
2564 if (_pdata[j * nx + i] < xmin) {
2565 xmin = _pdata[j * nx + i];
2567 if (_pdata[j * nx + i] > xmax) {
2568 xmax = _pdata[j * nx + i];
2570 _rms += pow(_pdata[j * nx + i] - _tdata[i], 2.);
2573 rms += sqrt(_rms / (ny - 1));
2577 for (i = 1; i < nx; i++) {
2578 double xoffi = _tdata[i] - _tdata[i-1];
2579 cpl_vector_set(xoff, i-1, xoffi);
2580 if(xoffi > 0. && xoffi < 30.){
2587 for(i=0; i<nx-1; i++){
2588 double xoffi = cpl_vector_get(xoff, i) - meanoff;
2589 if(xoffi < - 1.5 || xoffi > 1.5){
2596 cpl_image_delete(_test);
2599 cpl_vector_delete(xoff);
2601 cpl_propertylist_update_double(properties, GIALIAS_QCLCRMS, rms);
2602 cpl_propertylist_set_comment(properties, GIALIAS_QCLCRMS,
2603 "Mean fibre signal curvature");
2608 cpl_propertylist_update_double(properties, GIALIAS_QCXDMRMS, rms);
2609 cpl_propertylist_set_comment(properties, GIALIAS_QCXDMRMS,
2610 "STDEV fibre signal curvature");
2615 cpl_propertylist_update_double(properties, GIALIAS_QCNUMOUT, numout);
2616 cpl_propertylist_set_comment(properties, GIALIAS_QCNUMOUT,
2617 "Number of fibre pos outliers");
2627 for (i = 0; i < nx; i++) {
2629 cxdouble min = cpl_image_get_min_window(_pimage,
2630 i + 1, 1, i + 1, ny);
2631 cxdouble max = cpl_image_get_max_window(_pimage,
2632 i + 1, 1, i + 1, ny);
2640 cpl_propertylist_update_double(properties, GIALIAS_QCLCDIFF, diff);
2641 cpl_propertylist_set_comment(properties, GIALIAS_QCLCDIFF,
2642 "Mean difference of fibre signal "
2648 cpl_propertylist_update_double(properties, GIALIAS_QCXDM, diff);
2649 cpl_propertylist_set_comment(properties, GIALIAS_QCXDM,
2650 "Mean difference of fibre signal "
2660 cpl_msg_error(fctid,
"Could not save localization centroids '%s'!",
2661 cpl_frame_get_filename(pframe));
2672 giraffe_paf_delete(qc);
2682 cpl_msg_error(fctid,
"Could not save localization centroids '%s'!",
2683 cpl_frame_get_filename(pframe));
2694 giraffe_paf_delete(qc);
2706 giraffe_qclog_close(qc);
2714 qc = giraffe_qclog_open(2);
2717 cpl_msg_error(fctid,
"Cannot create QC1 log!");
2725 qclog = giraffe_paf_get_properties(qc);
2726 cx_assert(qclog != NULL);
2729 CPL_FRAME_GROUP_PRODUCT);
2731 if (pframe == NULL) {
2732 cpl_msg_error(fctid,
"Missing product frame (%s)",
2733 GIFRAME_LOCALIZATION_WIDTH);
2735 giraffe_paf_delete(qc);
2744 cpl_msg_info(fctid,
"Processing product frame '%s' (%s)",
2745 cpl_frame_get_filename(pframe), cpl_frame_get_tag(pframe));
2752 cpl_msg_error(fctid,
"Could not load localization widths '%s'!",
2753 cpl_frame_get_filename(pframe));
2761 giraffe_paf_delete(qc);
2772 cpl_msg_error(fctid,
"Could not load localization widths '%s'!",
2773 cpl_frame_get_filename(pframe));
2784 giraffe_paf_delete(qc);
2791 cx_assert(properties != NULL);
2803 cpl_propertylist_update_string(qclog,
"PRO.CATG",
2804 cpl_frame_get_tag(pframe));
2805 cpl_propertylist_set_comment(qclog,
"PRO.CATG",
2806 "Pipeline product category");
2809 cx_assert(properties != NULL);
2827 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP, efficiency[0]);
2828 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP,
2829 "Calibration lamp efficiency");
2834 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP_SIMCAL,
2836 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP_SIMCAL,
2837 "SIMCAL lamp efficiency");
2840 GIALIAS_QCLAMP_SIMCAL);
2847 _test = cpl_image_collapse_create(_pimage, 0);
2848 cpl_image_divide_scalar(_test, cpl_image_get_size_y(_pimage));
2850 _pdata = cpl_image_get_data(_pimage);
2851 _tdata = cpl_image_get_data(_test);
2856 nx = cpl_image_get_size_x(_pimage);
2857 ny = cpl_image_get_size_y(_pimage);
2864 for (i = 0; i < nx; i++) {
2871 for (j = 0; j < ny; j++) {
2872 _rms += pow(_pdata[j * nx + i] - _tdata[i], 2.);
2876 rms += sqrt(_rms / (ny - 1));
2883 rms2 = cpl_image_get_stdev(_pimage);
2885 cpl_image_delete(_test);
2889 cpl_propertylist_update_double(properties, GIALIAS_QCLWAVG, mean);
2890 cpl_propertylist_set_comment(properties, GIALIAS_QCLWAVG,
2891 "Mean fibre half width");
2896 cpl_propertylist_update_double(properties, GIALIAS_QCLWRMS, rms);
2897 cpl_propertylist_set_comment(properties, GIALIAS_QCLWRMS,
2898 "RMS of fibre half width");
2903 cpl_propertylist_update_double(properties, GIALIAS_QCWMEAN, mean);
2904 cpl_propertylist_set_comment(properties, GIALIAS_QCWMEAN,
2905 "Mean fibre half width");
2910 cpl_propertylist_update_double(properties, GIALIAS_QCWRMS, rms2);
2911 cpl_propertylist_set_comment(properties, GIALIAS_QCWRMS,
2912 "RMS of fibre half width");
2921 cpl_msg_error(fctid,
"Could not save localization widths '%s'!",
2922 cpl_frame_get_filename(pframe));
2933 giraffe_paf_delete(qc);
2943 cpl_msg_error(fctid,
"Could not save localization widths '%s'!",
2944 cpl_frame_get_filename(pframe));
2955 giraffe_paf_delete(qc);
2967 giraffe_qclog_close(qc);
2975 qc = giraffe_qclog_open(3);
2978 cpl_msg_error(fctid,
"Cannot create QC1 log!");
2986 qclog = giraffe_paf_get_properties(qc);
2987 cx_assert(qclog != NULL);
2990 CPL_FRAME_GROUP_PRODUCT);
2992 if (pframe == NULL) {
2993 cpl_msg_error(fctid,
"Missing product frame (%s)",
2994 GIFRAME_FIBER_FLAT_EXTSPECTRA);
2996 giraffe_paf_delete(qc);
3005 cpl_msg_info(fctid,
"Processing product frame '%s' (%s)",
3006 cpl_frame_get_filename(pframe), cpl_frame_get_tag(pframe));
3013 cpl_msg_error(fctid,
"Could not load extracted flat field spectra "
3014 "'%s'!", cpl_frame_get_filename(pframe));
3022 giraffe_paf_delete(qc);
3033 cpl_msg_error(fctid,
"Could not load extracted flat field spectra "
3034 "'%s'!", cpl_frame_get_filename(pframe));
3045 giraffe_paf_delete(qc);
3052 cx_assert(properties != NULL);
3064 cpl_propertylist_update_string(qclog,
"PRO.CATG",
3065 cpl_frame_get_tag(pframe));
3066 cpl_propertylist_set_comment(qclog,
"PRO.CATG",
3067 "Pipeline product category");
3070 cx_assert(properties != NULL);
3088 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP, efficiency[0]);
3089 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP,
3090 "Calibration lamp efficiency");
3095 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP_SIMCAL,
3097 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP_SIMCAL,
3098 "SIMCAL lamp efficiency");
3101 GIALIAS_QCLAMP_SIMCAL);
3106 if (cpl_table_has_column(_ptable,
"TRANSMISSION") == FALSE) {
3107 cpl_msg_warning(fctid,
"Relative fiber transmission not available! "
3108 "QC parameter computation skipped.");
3112 const cxdouble low = 0.5;
3113 const cxdouble high = 2.0;
3120 cpl_table* ttable = NULL;
3125 cpl_table_unselect_all(_ptable);
3127 cpl_table_or_selected_int(_ptable,
"RP", CPL_GREATER_THAN, 0);
3128 cpl_table_and_selected_double(_ptable,
"TRANSMISSION",
3129 CPL_GREATER_THAN, low);
3130 cpl_table_and_selected_double(_ptable,
"TRANSMISSION",
3131 CPL_LESS_THAN, high);
3133 ttable = cpl_table_extract_selected(_ptable);
3135 nf = cpl_table_get_nrow(ttable);
3136 if (ttable == NULL || nf <= 0) {
3137 cpl_msg_warning(fctid,
"No fiber found within transmission "
3138 "range ]%.2f, %.2f[", low, high);
3143 t = cpl_table_get_column_median(ttable,
"TRANSMISSION");
3147 for (i = 0; i < cpl_table_get_nrow(ttable); i++) {
3149 cxdouble _t = cpl_table_get_double(ttable,
3150 "TRANSMISSION", i, NULL);
3151 rms += pow(_t - t, 2.);
3155 rms = sqrt(rms / (cpl_table_get_nrow(ttable) - 1));
3165 if (!cpl_table_has_column(_ptable,
"DTRANSMISSION")) {
3166 cpl_msg_warning(fctid,
"Relative fiber transmission error not "
3167 "available! QC parameter computation skipped.");
3171 cx_assert(cpl_table_has_column(ttable,
"DTRANSMISSION") != 0);
3172 dt = cpl_table_get_column_median(ttable,
"DTRANSMISSION");
3176 cpl_table_delete(ttable);
3180 cpl_propertylist_update_double(properties, GIALIAS_QCTRMED, t);
3181 cpl_propertylist_set_comment(properties, GIALIAS_QCTRMED,
"Median of "
3182 "relative fibre transmission");
3188 cpl_propertylist_update_double(properties, GIALIAS_QCTRRMS, rms);
3189 cpl_propertylist_set_comment(properties, GIALIAS_QCTRRMS,
"RMS of "
3190 "relative fibre transmission");
3196 cpl_propertylist_update_double(properties, GIALIAS_QCTRERR, dt);
3197 cpl_propertylist_set_comment(properties, GIALIAS_QCTRERR,
"Median of "
3198 "relative fibre transmission error");
3206 cpl_propertylist_update_int(properties, GIALIAS_QCTRNF, nf);
3207 cpl_propertylist_set_comment(properties, GIALIAS_QCTRNF,
"Number "
3208 "of fibres used for median transmission computation.");
3211 properties, GIALIAS_QCTRNF);
3213 cpl_msg_debug(fctid,
"%d fibers used for median transmission "
3214 "computation.", nf);
3221 cpl_msg_error(fctid,
"Could not save extracted flat field spectra "
3222 "'%s'!", cpl_frame_get_filename(pframe));
3233 giraffe_paf_delete(qc);
3243 cpl_msg_error(fctid,
"Could not save extracted flat field spectra "
3244 "'%s'!", cpl_frame_get_filename(pframe));
3255 giraffe_paf_delete(qc);
3267 giraffe_qclog_close(qc);
3288cpl_plugin_get_info(cpl_pluginlist* list)
3291 cpl_recipe* recipe = cx_calloc(1,
sizeof *recipe);
3292 cpl_plugin* plugin = &recipe->interface;
3295 cpl_plugin_init(plugin,
3297 GIRAFFE_BINARY_VERSION,
3298 CPL_PLUGIN_TYPE_RECIPE,
3300 "Create the fiber master flat field and the "
3301 "localization mask.",
3302 "For detailed information please refer to the "
3303 "GIRAFFE pipeline user manual.\nIt is available at "
3304 "http://www.eso.org/pipelines.",
3308 gimasterflat_create,
3310 gimasterflat_destroy);
3312 cpl_pluginlist_append(list, plugin);
GiBiasConfig * giraffe_bias_config_create(cpl_parameterlist *list)
Creates a setup structure for a bias removal task.
void giraffe_bias_config_add(cpl_parameterlist *list)
Adds parameters for the bias removal.
cxint giraffe_bias_remove(GiImage *result, const GiImage *raw, const GiImage *master_bias, const GiImage *bad_pixels, const cpl_matrix *biaslimits, const GiBiasConfig *config)
Removes the bias from an image.
void giraffe_bias_config_destroy(GiBiasConfig *config)
Destroys a bias removal setup structure.
cxint giraffe_subtract_dark(GiImage *image, const GiImage *dark, const GiImage *bpixel, GiDarkResults *data, const GiDarkConfig *config)
Subtract the dark current from a bias corrected image.
GiTable * giraffe_fibers_setup(const cpl_frame *frame, const cpl_frame *reference)
Setup a fiber list.
GiFibersConfig * giraffe_fibers_config_create(cpl_parameterlist *list)
Creates a setup structure for the fiber selection.
GiTable * giraffe_fibers_select(const cpl_frame *frame, const GiTable *reference, GiFibersConfig *config)
Selects the spectra to process.
void giraffe_fibers_config_destroy(GiFibersConfig *config)
Destroys a fibers setup structure.
void giraffe_fibers_config_add(cpl_parameterlist *list)
Adds parameters for the spectrum selection.
cxint giraffe_fiberlist_compare(const GiTable *fibers, const GiTable *reference)
Compare two fiber lists.
cxint giraffe_fiberlist_attach(cpl_frame *frame, GiTable *fibers)
Attach a fiber table to a frame.
cxint giraffe_fiberlist_clear_index(GiTable *fibers)
Remove the reference index column from a fiber list.
cpl_frame * giraffe_get_frame(const cpl_frameset *set, const cxchar *tag, cpl_frame_group group)
Get a frame from a frame set.
cpl_frame * giraffe_frame_create(const cxchar *tag, cpl_frame_level level, const cpl_propertylist *properties, cxcptr object, cxcptr data, GiFrameCreator creator)
Create a product frame using a provided frame creator.
cpl_frame * giraffe_frame_create_image(GiImage *image, const cxchar *tag, cpl_frame_level level, cxbool save, cxbool update)
Create an image product frame.
cpl_frame * giraffe_get_slitgeometry(const cpl_frameset *set)
Get the slit geometry frame from a frame set.
cpl_frame * giraffe_frame_create_table(GiTable *table, const cxchar *tag, cpl_frame_level level, cxbool save, cxbool update)
Create a table product frame.
cpl_image * giraffe_image_get(const GiImage *self)
Gets the image data.
cpl_propertylist * giraffe_image_get_properties(const GiImage *self)
Get the properties of an image.
void giraffe_image_delete(GiImage *self)
Destroys an image.
cxint giraffe_image_add_info(GiImage *image, const GiRecipeInfo *info, const cpl_frameset *set)
Add additional frame information to an image.
cxint giraffe_image_save(GiImage *self, const cxchar *filename)
Write a Giraffe image to a file.
GiImage * giraffe_image_new(cpl_type type)
Creates an empty image container.
cxint giraffe_image_load(GiImage *self, const cxchar *filename, cxint position)
Gets image data and properties from a file.
GiLocalizeConfig * giraffe_localize_config_create(cpl_parameterlist *list)
Creates a setup structure for the spectrum localization.
void giraffe_localize_config_destroy(GiLocalizeConfig *config)
Destroys a spectrum localization setup structure.
void giraffe_localize_config_add(cpl_parameterlist *list)
Adds parameters for the spectrum localization.
cxint giraffe_localize_spectra(GiLocalization *result, GiImage *image, GiTable *fibers, GiLocalization *master, GiImage *badpixels, GiLocalizeConfig *config)
Finds the location of spectra in a Giraffe observation.
void giraffe_psf_config_destroy(GiPsfConfig *self)
Destroys a PSF profile fit setup object.
GiPsfConfig * giraffe_psf_config_create(cpl_parameterlist *list)
Creates a setup object for the PSF profile fit.
cxint giraffe_compute_fiber_profiles(GiLocalization *result, GiImage *image, GiTable *fibers, GiLocalization *master, GiImage *bpixel, GiPsfConfig *config)
Compute the position and width of the spectra from the fiber profile.
void giraffe_psf_config_add(cpl_parameterlist *list)
Adds parameters for the PSF profile computation of the fibers.
void giraffe_slight_config_add(cpl_parameterlist *list)
Adds parameters for the scattered light computation.
cxint giraffe_adjust_scattered_light(GiImage *result, const GiImage *image, const GiLocalization *localization, const GiImage *bpixel, GiImage *phff, const GiSLightConfig *config)
Compute a scattered light model for a given image.
void giraffe_slight_config_destroy(GiSLightConfig *config)
Destroys a scattered light setup structure.
GiSLightConfig * giraffe_slight_config_create(cpl_parameterlist *list)
Creates a setup structure for the scattered light computation.
GiTable * giraffe_slitgeometry_load(const GiTable *fibers, const cxchar *filename, cxint pos, const cxchar *tag)
Load the slit geometry information for a given fiber setup.
GiTable * giraffe_table_new(void)
Creates a new, empty Giraffe table.
cxint giraffe_table_load(GiTable *self, const cxchar *filename, cxint position, const cxchar *id)
Reads a data set from a file into a Giraffe table.
cxint giraffe_table_attach(GiTable *self, const cxchar *filename, cxint position, const cxchar *id)
Attach a Giraffe table to a file.
void giraffe_table_delete(GiTable *self)
Destroys a Giraffe table.
cpl_table * giraffe_table_get(const GiTable *self)
Get the table data from a Giraffe table.
cxint giraffe_table_add_info(GiTable *table, const GiRecipeInfo *info, const cpl_frameset *set)
Add additional frame information to a table.
GiTransmissionConfig * giraffe_transmission_config_create(cpl_parameterlist *list)
Creates a setup structure for the relative transmission computation.
void giraffe_transmission_config_add(cpl_parameterlist *list)
Adds parameters for the transmission correction computation.
void giraffe_transmission_config_destroy(GiTransmissionConfig *config)
Destroys a transmission field setup structure.
cxint giraffe_propertylist_copy(cpl_propertylist *self, const cxchar *name, const cpl_propertylist *other, const cxchar *othername)
Copy a property from one list to another.
const cxchar * giraffe_get_license(void)
Get the pipeline copyright and license.