00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifdef HAVE_CONFIG_H
00023 #include <config.h>
00024 #endif
00025
00026
00027
00028
00029
00030 #include <muse.h>
00031 #include "muse_scipost_calibrate_flux_z.h"
00032
00033
00034
00035
00036
00037
00046
00047 int
00048 muse_scipost_calibrate_flux_compute(muse_processing *aProcessing,
00049 muse_scipost_calibrate_flux_params_t *aParams)
00050 {
00051 UNUSED_ARGUMENT(aParams);
00052
00053 cpl_table *response = muse_table_load(aProcessing, MUSE_TAG_STD_RESPONSE, 0),
00054 *extinction = muse_table_load(aProcessing, MUSE_TAG_EXTINCT_TABLE, 0),
00055 *telluric = muse_table_load(aProcessing, MUSE_TAG_STD_TELLURIC, 0);
00056
00057 cpl_frameset *inframes = muse_frameset_find_tags(aProcessing->inframes,
00058 aProcessing->intags, 0,
00059 CPL_FALSE);
00060 cpl_error_code rc = CPL_ERROR_NONE;
00061 cpl_size iframe, nframes = cpl_frameset_get_size(inframes);
00062 for (iframe = 0; iframe < nframes; iframe++) {
00063 cpl_frame *frame = cpl_frameset_get_position(inframes, iframe);
00064 const char *fn = cpl_frame_get_filename(frame);
00065 muse_pixtable *pixtable = muse_pixtable_load_restricted_wavelength(fn,
00066 aParams->lambdamin,
00067 aParams->lambdamax);
00068 if (pixtable == NULL) {
00069 cpl_msg_error(__func__, "NULL pixel table for %s", fn);
00070 rc = CPL_ERROR_NULL_INPUT;
00071 break;
00072 }
00073 muse_processing_append_used(aProcessing, frame, CPL_FRAME_GROUP_RAW, 1);
00074
00075 cpl_propertylist_erase_regexp(pixtable->header, "ESO QC ", 0);
00076 rc = muse_flux_calibrate(pixtable, response, extinction, telluric);
00077 if (rc != CPL_ERROR_NONE) {
00078 cpl_msg_error(__func__, "while muse_flux_calibrate(%s)",
00079 cpl_frame_get_filename(frame));
00080 muse_pixtable_delete(pixtable);
00081 break;
00082 }
00083 muse_processing_save_table(aProcessing, 0, pixtable, NULL,
00084 MUSE_TAG_PIXTABLE_REDUCED,
00085 MUSE_TABLE_TYPE_PIXTABLE);
00086 muse_pixtable_delete(pixtable);
00087 }
00088 cpl_frameset_delete(inframes);
00089
00090 cpl_table_delete(response);
00091 cpl_table_delete(extinction);
00092 cpl_table_delete(telluric);
00093
00094 return rc;
00095 }