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"
48 #include "giextract.h"
49 #include "gitransmission.h"
55 static cxint gimasterflat(cpl_parameterlist* config, cpl_frameset* set);
56 static cxint giqcmasterflat(cpl_frameset* set);
65 gimasterflat_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);
150 gimasterflat_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);
180 gimasterflat_destroy(cpl_plugin* plugin)
183 cpl_recipe* recipe = (cpl_recipe*)plugin;
192 cpl_parameterlist_delete(recipe->parameters);
194 giraffe_error_clear();
206 gimasterflat(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);
1904 giqcmasterflat(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 scale = 1.;
1924 cxdouble* _pdata = NULL;
1925 cxdouble* _tdata = NULL;
1927 cpl_propertylist* properties = NULL;
1928 cpl_propertylist* qclog = NULL;
1930 cpl_frame* rframe = NULL;
1931 cpl_frame* pframe = NULL;
1933 cpl_image* _rimage = NULL;
1934 cpl_image* _pimage = NULL;
1935 cpl_image* _test = NULL;
1937 cpl_table* _ptable = NULL;
1939 GiImage* rimage = NULL;
1940 GiImage* pimage = NULL;
1942 GiTable* ptable = NULL;
1946 GiWindow w = {0, 0, 0, 0};
1950 cpl_msg_info(fctid,
"Computing QC1 parameters ...");
1952 qc = giraffe_qclog_open(0);
1955 cpl_msg_error(fctid,
"Cannot create QC1 log!");
1959 qclog = giraffe_paf_get_properties(qc);
1960 cx_assert(qclog != NULL);
1969 CPL_FRAME_GROUP_PRODUCT);
1971 if (pframe == NULL) {
1973 cpl_msg_warning(fctid,
"Product '%s' not found.",
1974 GIFRAME_FIBER_FLAT_EXTSPECTRA);
1976 cpl_msg_warning(fctid,
"Setting lamp efficiencies (%s, %s) to 0.",
1977 GIALIAS_QCLAMP, GIALIAS_QCLAMP_SIMCAL);
1989 cpl_msg_error(fctid,
"Could not load extracted spectra '%s'!",
1990 cpl_frame_get_filename(pframe));
1995 giraffe_paf_delete(qc);
2002 cx_assert(_pimage != NULL);
2010 cpl_msg_error(fctid,
"Could not load extracted spectra fiber setup!");
2018 giraffe_paf_delete(qc);
2025 cx_assert(_ptable != NULL);
2027 if (cpl_table_has_column(_ptable,
"RP") == FALSE) {
2029 cpl_msg_warning(fctid,
"Column 'RP' not found in fiber setup table!");
2030 cpl_msg_warning(fctid,
"Setting lamp efficiencies (%s, %s) to 0.",
2031 GIALIAS_QCLAMP, GIALIAS_QCLAMP_SIMCAL);
2040 cx_assert(properties != NULL);
2042 if (cpl_propertylist_has(properties, GIALIAS_EXPTIME) == FALSE) {
2044 cpl_msg_warning(fctid,
"Property '%s' not found in '%s'.",
2045 GIALIAS_EXPTIME, cpl_frame_get_filename(rframe));
2046 cpl_msg_warning(fctid,
"Setting lamp efficiencies (%s, %s) to 0.",
2047 GIALIAS_QCLAMP, GIALIAS_QCLAMP_SIMCAL);
2055 cxbool scaled = cpl_propertylist_has(properties,
2056 GIALIAS_FLAT_SCALE);
2059 cxint nb = cpl_image_get_size_y(_pimage);
2060 cxint nf[2] = {0, 0};
2062 cxdouble exptime = cpl_propertylist_get_double(properties,
2064 cxdouble* _sum = NULL;
2066 cpl_image* sum = NULL;
2069 if (scaled == TRUE) {
2071 scale = cpl_propertylist_get_double(properties,
2072 GIALIAS_FLAT_SCALE);
2073 cpl_image_multiply_scalar(_pimage, scale);
2078 sum = cpl_image_collapse_create(_pimage, 0);
2079 _sum = cpl_image_get_data_double(sum);
2081 for (fiber = 0; fiber < cpl_table_get_nrow(_ptable); ++fiber) {
2083 cxint rp = cpl_table_get_int(_ptable,
"RP", fiber, NULL);
2086 efficiency[1] += _sum[fiber];
2090 efficiency[0] += _sum[fiber];
2098 cpl_image_delete(sum);
2102 cpl_msg_warning(fctid,
"No OzPoz fibers found in the "
2103 "current fiber setup.");
2104 cpl_msg_warning(fctid,
"Setting lamp efficiency (%s) to 0.",
2109 efficiency[0] /= nf[0] * nb * exptime;
2113 cpl_msg_warning(fctid,
"No simultaneous calibration fibers "
2114 "found in the current fiber setup.");
2115 cpl_msg_warning(fctid,
"Setting lamp efficiency (%s) to 0.",
2116 GIALIAS_QCLAMP_SIMCAL);
2120 efficiency[1] /= nf[1] * nb * exptime;
2145 CPL_FRAME_GROUP_PRODUCT);
2147 if (pframe == NULL) {
2148 cpl_msg_error(fctid,
"Missing product frame (%s)",
2149 GIFRAME_FIBER_FLAT_MASTER);
2151 giraffe_paf_delete(qc);
2157 cpl_msg_info(fctid,
"Processing product frame '%s' (%s)",
2158 cpl_frame_get_filename(pframe), cpl_frame_get_tag(pframe));
2164 cpl_msg_error(fctid,
"Could not load master flat field '%s'!",
2165 cpl_frame_get_filename(pframe));
2170 giraffe_paf_delete(qc);
2181 rframe = cpl_frameset_find(set, GIFRAME_FIBER_FLAT);
2183 if (rframe == NULL) {
2184 cpl_msg_error(fctid,
"Missing raw frame (%s)", GIFRAME_FIBER_FLAT);
2189 giraffe_paf_delete(qc);
2200 cpl_msg_error(fctid,
"Could not load flat field '%s'!",
2201 cpl_frame_get_filename(rframe));
2209 giraffe_paf_delete(qc);
2217 cx_assert(_rimage != NULL);
2220 cx_assert(properties != NULL);
2232 cpl_propertylist_update_string(qclog,
"PRO.CATG",
2233 cpl_frame_get_tag(pframe));
2234 cpl_propertylist_set_comment(qclog,
"PRO.CATG",
2235 "Pipeline product category");
2238 cx_assert(properties != NULL);
2256 cx_assert(properties != NULL);
2258 if (cpl_propertylist_has(properties, GIALIAS_OVSCX) == TRUE) {
2260 cxint _ox = cpl_propertylist_get_int(properties, GIALIAS_OVSCX);
2261 cxint _nx = cpl_image_get_size_x(_rimage) - 2 * CX_MAX(0, _ox) - 1;
2263 w.x0 = CX_MAX(0, _ox) + 1;
2268 if (cpl_propertylist_has(properties, GIALIAS_OVSCY) == TRUE) {
2270 cxint _oy = cpl_propertylist_get_int(properties, GIALIAS_OVSCY);
2271 cxint _ny = cpl_image_get_size_y(_rimage) - 2 * CX_MAX(0, _oy) - 1;
2273 w.y0 = CX_MAX(0, _oy) + 1;
2278 mean = cpl_image_get_mean_window(_rimage, w.x0, w.y0, w.x1, w.y1);
2280 pixels = cpl_image_get_data(_rimage);
2281 npixel = cpl_image_get_size_x(_rimage) * cpl_image_get_size_y(_rimage);
2283 for (i = 0; i < npixel; i++) {
2284 if (pixels[i] > saturation) {
2291 cx_assert(properties != NULL);
2293 cpl_propertylist_update_double(properties, GIALIAS_QCMEAN, mean);
2294 cpl_propertylist_set_comment(properties, GIALIAS_QCMEAN,
"Mean level of "
2301 cpl_propertylist_update_int(properties, GIALIAS_QCNSAT, nsaturated);
2302 cpl_propertylist_set_comment(properties, GIALIAS_QCNSAT,
"Number of "
2303 "saturated pixels in the first raw frame");
2313 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP, efficiency[0]);
2314 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP,
2315 "Calibration lamp efficiency");
2320 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP_SIMCAL,
2322 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP_SIMCAL,
2323 "SIMCAL lamp efficiency");
2326 GIALIAS_QCLAMP_SIMCAL);
2338 giraffe_qclog_close(qc);
2346 qc = giraffe_qclog_open(1);
2349 cpl_msg_error(fctid,
"Cannot create QC1 log!");
2357 qclog = giraffe_paf_get_properties(qc);
2358 cx_assert(qclog != NULL);
2361 CPL_FRAME_GROUP_PRODUCT);
2363 if (pframe == NULL) {
2364 cpl_msg_error(fctid,
"Missing product frame (%s)",
2365 GIFRAME_LOCALIZATION_CENTROID);
2367 giraffe_paf_delete(qc);
2376 cpl_msg_info(fctid,
"Processing product frame '%s' (%s)",
2377 cpl_frame_get_filename(pframe), cpl_frame_get_tag(pframe));
2384 cpl_msg_error(fctid,
"Could not load localization centroids '%s'!",
2385 cpl_frame_get_filename(pframe));
2393 giraffe_paf_delete(qc);
2404 cpl_msg_error(fctid,
"Could not load localization centroids '%s'!",
2405 cpl_frame_get_filename(pframe));
2416 giraffe_paf_delete(qc);
2423 cx_assert(properties != NULL);
2435 cpl_propertylist_update_string(qclog,
"PRO.CATG",
2436 cpl_frame_get_tag(pframe));
2437 cpl_propertylist_set_comment(qclog,
"PRO.CATG",
2438 "Pipeline product category");
2441 cx_assert(properties != NULL);
2459 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP, efficiency[0]);
2460 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP,
2461 "Calibration lamp efficiency");
2466 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP_SIMCAL,
2468 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP_SIMCAL,
2469 "SIMCAL lamp efficiency");
2472 GIALIAS_QCLAMP_SIMCAL);
2479 _test = cpl_image_collapse_create(_pimage, 0);
2480 cpl_image_divide_scalar(_test, cpl_image_get_size_y(_pimage));
2482 _pdata = cpl_image_get_data(_pimage);
2483 _tdata = cpl_image_get_data(_test);
2487 nx = cpl_image_get_size_x(_pimage);
2488 ny = cpl_image_get_size_y(_pimage);
2490 for (i = 0; i < nx; i++) {
2497 for (j = 0; j < ny; j++) {
2498 _rms += pow(_pdata[j * nx + i] - _tdata[i], 2.);
2501 rms += sqrt(_rms / (ny - 1));
2507 cpl_image_delete(_test);
2510 cpl_propertylist_update_double(properties, GIALIAS_QCLCRMS, rms);
2511 cpl_propertylist_set_comment(properties, GIALIAS_QCLCRMS,
2512 "Mean fibre signal curvature");
2522 for (i = 0; i < nx; i++) {
2524 cxdouble min = cpl_image_get_min_window(_pimage,
2525 i + 1, 1, i + 1, ny);
2526 cxdouble max = cpl_image_get_max_window(_pimage,
2527 i + 1, 1, i + 1, ny);
2535 cpl_propertylist_update_double(properties, GIALIAS_QCLCDIFF, diff);
2536 cpl_propertylist_set_comment(properties, GIALIAS_QCLCDIFF,
2537 "Mean difference of fibre signal "
2547 cpl_msg_error(fctid,
"Could not save localization centroids '%s'!",
2548 cpl_frame_get_filename(pframe));
2559 giraffe_paf_delete(qc);
2569 cpl_msg_error(fctid,
"Could not save localization centroids '%s'!",
2570 cpl_frame_get_filename(pframe));
2581 giraffe_paf_delete(qc);
2593 giraffe_qclog_close(qc);
2601 qc = giraffe_qclog_open(2);
2604 cpl_msg_error(fctid,
"Cannot create QC1 log!");
2612 qclog = giraffe_paf_get_properties(qc);
2613 cx_assert(qclog != NULL);
2616 CPL_FRAME_GROUP_PRODUCT);
2618 if (pframe == NULL) {
2619 cpl_msg_error(fctid,
"Missing product frame (%s)",
2620 GIFRAME_LOCALIZATION_WIDTH);
2622 giraffe_paf_delete(qc);
2631 cpl_msg_info(fctid,
"Processing product frame '%s' (%s)",
2632 cpl_frame_get_filename(pframe), cpl_frame_get_tag(pframe));
2639 cpl_msg_error(fctid,
"Could not load localization widths '%s'!",
2640 cpl_frame_get_filename(pframe));
2648 giraffe_paf_delete(qc);
2659 cpl_msg_error(fctid,
"Could not load localization widths '%s'!",
2660 cpl_frame_get_filename(pframe));
2671 giraffe_paf_delete(qc);
2678 cx_assert(properties != NULL);
2690 cpl_propertylist_update_string(qclog,
"PRO.CATG",
2691 cpl_frame_get_tag(pframe));
2692 cpl_propertylist_set_comment(qclog,
"PRO.CATG",
2693 "Pipeline product category");
2696 cx_assert(properties != NULL);
2714 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP, efficiency[0]);
2715 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP,
2716 "Calibration lamp efficiency");
2721 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP_SIMCAL,
2723 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP_SIMCAL,
2724 "SIMCAL lamp efficiency");
2727 GIALIAS_QCLAMP_SIMCAL);
2734 _test = cpl_image_collapse_create(_pimage, 0);
2735 cpl_image_divide_scalar(_test, cpl_image_get_size_y(_pimage));
2737 _pdata = cpl_image_get_data(_pimage);
2738 _tdata = cpl_image_get_data(_test);
2743 nx = cpl_image_get_size_x(_pimage);
2744 ny = cpl_image_get_size_y(_pimage);
2746 for (i = 0; i < nx; i++) {
2753 for (j = 0; j < ny; j++) {
2754 _rms += pow(_pdata[j * nx + i] - _tdata[i], 2.);
2758 rms += sqrt(_rms / (ny - 1));
2765 cpl_image_delete(_test);
2769 cpl_propertylist_update_double(properties, GIALIAS_QCLWAVG, mean);
2770 cpl_propertylist_set_comment(properties, GIALIAS_QCLWAVG,
2771 "Mean fibre half width");
2776 cpl_propertylist_update_double(properties, GIALIAS_QCLWRMS, rms);
2777 cpl_propertylist_set_comment(properties, GIALIAS_QCLWRMS,
2778 "RMS of fibre half width");
2787 cpl_msg_error(fctid,
"Could not save localization widths '%s'!",
2788 cpl_frame_get_filename(pframe));
2799 giraffe_paf_delete(qc);
2809 cpl_msg_error(fctid,
"Could not save localization widths '%s'!",
2810 cpl_frame_get_filename(pframe));
2821 giraffe_paf_delete(qc);
2833 giraffe_qclog_close(qc);
2841 qc = giraffe_qclog_open(3);
2844 cpl_msg_error(fctid,
"Cannot create QC1 log!");
2852 qclog = giraffe_paf_get_properties(qc);
2853 cx_assert(qclog != NULL);
2856 CPL_FRAME_GROUP_PRODUCT);
2858 if (pframe == NULL) {
2859 cpl_msg_error(fctid,
"Missing product frame (%s)",
2860 GIFRAME_FIBER_FLAT_EXTSPECTRA);
2862 giraffe_paf_delete(qc);
2871 cpl_msg_info(fctid,
"Processing product frame '%s' (%s)",
2872 cpl_frame_get_filename(pframe), cpl_frame_get_tag(pframe));
2879 cpl_msg_error(fctid,
"Could not load extracted flat field spectra "
2880 "'%s'!", cpl_frame_get_filename(pframe));
2888 giraffe_paf_delete(qc);
2899 cpl_msg_error(fctid,
"Could not load extracted flat field spectra "
2900 "'%s'!", cpl_frame_get_filename(pframe));
2911 giraffe_paf_delete(qc);
2918 cx_assert(properties != NULL);
2930 cpl_propertylist_update_string(qclog,
"PRO.CATG",
2931 cpl_frame_get_tag(pframe));
2932 cpl_propertylist_set_comment(qclog,
"PRO.CATG",
2933 "Pipeline product category");
2936 cx_assert(properties != NULL);
2954 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP, efficiency[0]);
2955 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP,
2956 "Calibration lamp efficiency");
2961 cpl_propertylist_update_double(properties, GIALIAS_QCLAMP_SIMCAL,
2963 cpl_propertylist_set_comment(properties, GIALIAS_QCLAMP_SIMCAL,
2964 "SIMCAL lamp efficiency");
2967 GIALIAS_QCLAMP_SIMCAL);
2972 if (cpl_table_has_column(_ptable,
"TRANSMISSION") == FALSE) {
2973 cpl_msg_warning(fctid,
"Relative fiber transmission not available! "
2974 "QC parameter computation skipped.");
2978 const cxdouble low = 0.5;
2979 const cxdouble high = 2.0;
2986 cpl_table* ttable = NULL;
2991 cpl_table_unselect_all(_ptable);
2993 cpl_table_or_selected_int(_ptable,
"RP", CPL_GREATER_THAN, 0);
2994 cpl_table_and_selected_double(_ptable,
"TRANSMISSION",
2995 CPL_GREATER_THAN, low);
2996 cpl_table_and_selected_double(_ptable,
"TRANSMISSION",
2997 CPL_LESS_THAN, high);
2999 ttable = cpl_table_extract_selected(_ptable);
3001 nf = cpl_table_get_nrow(ttable);
3002 if (ttable == NULL || nf <= 0) {
3003 cpl_msg_warning(fctid,
"No fiber found within transmission "
3004 "range ]%.2f, %.2f[", low, high);
3009 t = cpl_table_get_column_median(ttable,
"TRANSMISSION");
3013 for (i = 0; i < cpl_table_get_nrow(ttable); i++) {
3015 cxdouble _t = cpl_table_get_double(ttable,
3016 "TRANSMISSION", i, NULL);
3017 rms += pow(_t - t, 2.);
3021 rms = sqrt(rms / (cpl_table_get_nrow(ttable) - 1));
3031 if (!cpl_table_has_column(_ptable,
"DTRANSMISSION")) {
3032 cpl_msg_warning(fctid,
"Relative fiber transmission error not "
3033 "available! QC parameter computation skipped.");
3037 cx_assert(cpl_table_has_column(ttable,
"DTRANSMISSION") != 0);
3038 dt = cpl_table_get_column_median(ttable,
"DTRANSMISSION");
3042 cpl_table_delete(ttable);
3046 cpl_propertylist_update_double(properties, GIALIAS_QCTRMED, t);
3047 cpl_propertylist_set_comment(properties, GIALIAS_QCTRMED,
"Median of "
3048 "relative fibre transmission");
3054 cpl_propertylist_update_double(properties, GIALIAS_QCTRRMS, rms);
3055 cpl_propertylist_set_comment(properties, GIALIAS_QCTRRMS,
"RMS of "
3056 "relative fibre transmission");
3062 cpl_propertylist_update_double(properties, GIALIAS_QCTRERR, dt);
3063 cpl_propertylist_set_comment(properties, GIALIAS_QCTRERR,
"Median of "
3064 "relative fibre transmission error");
3072 cpl_propertylist_update_int(properties, GIALIAS_QCTRNF, nf);
3073 cpl_propertylist_set_comment(properties, GIALIAS_QCTRNF,
"Number "
3074 "of fibres used for median transmission computation.");
3077 properties, GIALIAS_QCTRNF);
3079 cpl_msg_debug(fctid,
"%d fibers used for median transmission "
3080 "computation.", nf);
3087 cpl_msg_error(fctid,
"Could not save extracted flat field spectra "
3088 "'%s'!", cpl_frame_get_filename(pframe));
3099 giraffe_paf_delete(qc);
3109 cpl_msg_error(fctid,
"Could not save extracted flat field spectra "
3110 "'%s'!", cpl_frame_get_filename(pframe));
3121 giraffe_paf_delete(qc);
3133 giraffe_qclog_close(qc);
3154 cpl_plugin_get_info(cpl_pluginlist* list)
3157 cpl_recipe* recipe = cx_calloc(1,
sizeof *recipe);
3158 cpl_plugin* plugin = &recipe->interface;
3161 cpl_plugin_init(plugin,
3163 GIRAFFE_BINARY_VERSION,
3164 CPL_PLUGIN_TYPE_RECIPE,
3166 "Create the fiber master flat field and the "
3167 "localization mask.",
3168 "For detailed information please refer to the "
3169 "GIRAFFE pipeline user manual.\nIt is available at "
3170 "http://www.eso.org/pipelines.",
3174 gimasterflat_create,
3176 gimasterflat_destroy);
3178 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_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.
GiFibersConfig * giraffe_fibers_config_create(cpl_parameterlist *list)
Creates a setup structure for the fiber selection.
GiTable * giraffe_fibers_setup(const cpl_frame *frame, const cpl_frame *reference)
Setup a fiber list.
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_frame_create_table(GiTable *table, const cxchar *tag, cpl_frame_level level, cxbool save, cxbool update)
Create a table product frame.
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_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.
void giraffe_image_delete(GiImage *self)
Destroys an image.
cpl_propertylist * giraffe_image_get_properties(const GiImage *self)
Get the properties of 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.
cpl_image * giraffe_image_get(const GiImage *self)
Gets the image data.
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.
GiSLightConfig * giraffe_slight_config_create(cpl_parameterlist *list)
Creates a setup structure 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.
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.
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.
GiTable * giraffe_table_new(void)
Creates a new, empty Giraffe table.
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.