38#include "vircam_dfs.h"
39#include "vircam_utils.h"
42#define DELEXTN "^(ESO.INS |ESO.OBS |ESO.TEL |INSTRUME|PIPEFILE|ORIGIN" \
43 "|TELESCOP|OBJECT|RA|DEC|EPOCH|EQUINOX|DATAMD5|RADECSYS" \
44 "|RADESYS|HDRVER|DATE-OBS|MJD-OBS|UTC|LST|PI-COI|OBSERVER).*$"
46#define REGFIX "^(ORIGIN|TELESCOP|INSTRUME|OBJECT|RA|DEC|EPOCH|EQUINOX" \
47 "|RADECSYS|RADESYS|DATE-OBS|MJD-OBS|UTC|LST|PI-COI|OBSERVER)$"
70static cpl_error_code vircam_dfs_rename_ref_frame(cpl_propertylist * list) {
71 if (!list)
return CPL_ERROR_NULL_INPUT;
73 if (cpl_propertylist_has(list,
"RADECSYS")) {
74 if (cpl_propertylist_has(list,
"RADESYS"))
75 cpl_propertylist_erase(list,
"RADECSYS");
77 char * radec_val = cpl_strdup(cpl_propertylist_get_string(
79 char * radec_com = cpl_strdup(cpl_propertylist_get_comment(
81 cpl_propertylist_erase(list,
"RADECSYS");
82 cpl_propertylist_update_string(list,
"RADESYS", radec_val);
83 cpl_propertylist_set_comment(list,
"RADESYS", radec_com);
88 return cpl_error_get_code();
116 cpl_frame *cur_frame;
118 const char *fctid =
"vircam_dfs_set_groups";
128 nframes = cpl_frameset_get_size(set);
132 for (i = 0; i < nframes; i++) {
133 cur_frame = cpl_frameset_get_position(set,i);
134 tag = cpl_frame_get_tag(cur_frame);
138 if (!strcmp(tag,VIRCAM_DARKCUR_RAW) ||
139 !strcmp(tag,VIRCAM_DARK_RAW) ||
140 !strcmp(tag,VIRCAM_NOISE_FLAT_RAW) ||
141 !strcmp(tag,VIRCAM_NOISE_DARK_RAW) ||
142 !strcmp(tag,VIRCAM_DOME_RAW) ||
143 !strcmp(tag,VIRCAM_SCI_OBJECT_RAW) ||
144 !strcmp(tag,VIRCAM_SCI_OBJECT_EXT_RAW) ||
145 !strcmp(tag,VIRCAM_OFFSET_SKY_RAW) ||
146 !strcmp(tag,VIRCAM_TEST_SCIENCE_RAW) ||
147 !strcmp(tag,VIRCAM_LIN_DOME_RAW) ||
148 !strcmp(tag,VIRCAM_LIN_DOME_CHECK) ||
149 !strcmp(tag,VIRCAM_LIN_DARK_RAW) ||
150 !strcmp(tag,VIRCAM_LIN_DARK_CHECK) ||
151 !strcmp(tag,VIRCAM_ILLUM_RAW) ||
152 !strcmp(tag,VIRCAM_RESET_RAW) ||
153 !strcmp(tag,VIRCAM_STD_OBJECT_RAW) ||
154 !strcmp(tag,VIRCAM_TWI_RAW) ||
155 !strcmp(tag,VIRCAM_PRO_OBJCAT_SCI) ||
156 !strcmp(tag,VIRCAM_PRO_CONF_SCI) ||
157 !strcmp(tag,VIRCAM_PRO_JITTERED_SCI))
158 cpl_frame_set_group(cur_frame,CPL_FRAME_GROUP_RAW);
162 else if (!strcmp(tag,VIRCAM_CAL_RESET) ||
163 !strcmp(tag,VIRCAM_CAL_DARK) ||
164 !strcmp(tag,VIRCAM_CAL_DOME_FLAT) ||
165 !strcmp(tag,VIRCAM_CAL_TWILIGHT_FLAT) ||
166 !strcmp(tag,VIRCAM_CAL_CONF) ||
167 !strcmp(tag,VIRCAM_CAL_BPM) ||
168 !strcmp(tag,VIRCAM_CAL_FRINGE) ||
169 !strcmp(tag,VIRCAM_CAL_CHANTAB) ||
170 !strcmp(tag,VIRCAM_CAL_READGAINFILE) ||
171 !strcmp(tag,VIRCAM_CAL_CHANTAB_INIT) ||
172 !strcmp(tag,VIRCAM_CAL_PHOTTAB) ||
173 !strcmp(tag,VIRCAM_CAL_STDTAB) ||
174 !strcmp(tag,VIRCAM_CAL_OBJCAT) ||
175 !strcmp(tag,VIRCAM_CAL_MSTDTAB) ||
176 !strcmp(tag,VIRCAM_CAL_2MASS) ||
177 !strcmp(tag,VIRCAM_CAL_SCHL_N) ||
178 !strcmp(tag,VIRCAM_CAL_SCHL_S) ||
179 !strcmp(tag,VIRCAM_CAL_REFCAT) ||
180 !strcmp(tag,VIRCAM_CAL_SKY) ||
181 !strcmp(tag,VIRCAM_CAL_OBJMASK) ||
182 !strcmp(tag,VIRCAM_REF_RESET) ||
183 !strcmp(tag,VIRCAM_REF_DARK) ||
184 !strcmp(tag,VIRCAM_REF_DOME_FLAT) ||
185 !strcmp(tag,VIRCAM_REF_TWILIGHT_FLAT))
186 cpl_frame_set_group(cur_frame,CPL_FRAME_GROUP_CALIB);
188 cpl_msg_info(fctid,
"No such tag as %s in frame %s",tag,
189 cpl_frame_get_filename(cur_frame));
229 cpl_frameset *frameset,
230 cpl_parameterlist *parlist,
235 const char *fctid=
"vircam_dfs_set_product_primary_header";
236 char package[PACKSZ];
237 cpl_propertylist *pcopy;
241 (void)snprintf(package,PACKSZ,
"%s/%s",PACKAGE,PACKAGE_VERSION);
247 pcopy = cpl_propertylist_duplicate(plist);
251 if (cpl_dfs_setup_product_header(plist,frame,frameset,parlist,recipeid,
252 package,dict,inherit) != CPL_ERROR_NONE) {
253 cpl_msg_warning(fctid,
254 "Problem with the product primary DFS compliance -- %s",
255 cpl_error_get_message());
262 cpl_propertylist_copy_property_regexp(plist,
263 (
const cpl_propertylist *)pcopy,
265 cpl_propertylist_erase_regexp(plist,
"HDRVER", 0);
266 vircam_dfs_rename_ref_frame(plist);
267 cpl_propertylist_delete(pcopy);
301 cpl_frameset *frameset,
302 cpl_parameterlist *parlist,
305 cpl_frame *inherit) {
306 const char *fctid=
"vircam_dfs_set_product_exten_header";
307 char package[PACKSZ];
311 (void)snprintf(package,PACKSZ,
"%s/%s",PACKAGE,PACKAGE_VERSION);
315 if (cpl_dfs_setup_product_header(plist,frame,frameset,parlist,recipeid,
316 package,dict,inherit) != CPL_ERROR_NONE) {
317 cpl_msg_warning(fctid,
318 "Problem with the product extn DFS compliance -- %s",
319 cpl_error_get_message());
325 cpl_propertylist_erase_regexp(plist,DELEXTN,0);
328 cpl_errorstate state = cpl_errorstate_get();
329 cpl_wcs * wcs = cpl_wcs_new_from_propertylist(plist);
331 cpl_propertylist_update_bool(plist,
"INHERIT", 1);
332 cpl_propertylist_set_comment(plist,
"INHERIT",
333 "denotes the INHERIT keyword convention");
336 cpl_errorstate_set(state);
int vircam_dfs_set_groups(cpl_frameset *set)
void vircam_dfs_set_product_primary_header(cpl_propertylist *plist, cpl_frame *frame, cpl_frameset *frameset, cpl_parameterlist *parlist, char *recipeid, const char *dict, cpl_frame *inherit, int synch)
void vircam_dfs_set_product_exten_header(cpl_propertylist *plist, cpl_frame *frame, cpl_frameset *frameset, cpl_parameterlist *parlist, char *recipeid, const char *dict, cpl_frame *inherit)