00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifdef HAVE_CONFIG_H
00032 #include <config.h>
00033 #endif
00034
00035 #include <string.h>
00036 #include <cpl.h>
00037
00038 #include "vircam_dfs.h"
00039 #include "vircam_utils.h"
00040
00041 #define PACKSZ 1024
00042 #define DELEXTN "^(ESO.INS |ESO.OBS |ESO.TEL |INSTRUME|PIPEFILE|ORIGIN" \
00043 "|TELESCOP|OBJECT|RA|DEC|EPOCH|EQUINOX|DATAMD5|RADECSYS" \
00044 "|DATE-OBS|MJD-OBS|UTC|LST|PI-COI|OBSERVER).*$"
00045
00046 #define REGFIX "^(ORIGIN|TELESCOP|INSTRUME|OBJECT|RA|DEC|EPOCH|EQUINOX" \
00047 "|RADECSYS|DATE-OBS|MJD-OBS|UTC|LST|PI-COI|OBSERVER)$"
00048
00063
00085
00086
00087 extern int vircam_dfs_set_groups(cpl_frameset *set) {
00088 cpl_frame *cur_frame;
00089 const char *tag;
00090 const char *fctid = "vircam_dfs_set_groups";
00091 int nframes,i;
00092
00093
00094
00095 if (set == NULL)
00096 return(VIR_FATAL);
00097
00098
00099
00100 nframes = cpl_frameset_get_size(set);
00101
00102
00103
00104 for (i = 0; i < nframes; i++) {
00105 cur_frame = cpl_frameset_get_frame(set,i);
00106 tag = cpl_frame_get_tag(cur_frame);
00107
00108
00109
00110 if (!strcmp(tag,VIRCAM_CROSSTALK_RAW) ||
00111 !strcmp(tag,VIRCAM_DARK_RAW) ||
00112 !strcmp(tag,VIRCAM_DARKCUR_RAW) ||
00113 !strcmp(tag,VIRCAM_NOISE_FLAT_RAW) ||
00114 !strcmp(tag,VIRCAM_NOISE_DARK_RAW) ||
00115 !strcmp(tag,VIRCAM_DOME_RAW) ||
00116 !strcmp(tag,VIRCAM_SCI_OBJECT_RAW) ||
00117 !strcmp(tag,VIRCAM_SCI_OBJECT_EXT_RAW) ||
00118 !strcmp(tag,VIRCAM_OFFSET_SKY_RAW) ||
00119 !strcmp(tag,VIRCAM_TEST_SCIENCE_RAW) ||
00120 !strcmp(tag,VIRCAM_LIN_DOME_RAW) ||
00121 !strcmp(tag,VIRCAM_LIN_DOME_CHECK) ||
00122 !strcmp(tag,VIRCAM_LIN_DARK_RAW) ||
00123 !strcmp(tag,VIRCAM_LIN_DARK_CHECK) ||
00124 !strcmp(tag,VIRCAM_ILLUM_RAW) ||
00125 !strcmp(tag,VIRCAM_PERSIST_OBJ_RAW) ||
00126 !strcmp(tag,VIRCAM_PERSIST_DARK_RAW) ||
00127 !strcmp(tag,VIRCAM_RESET_RAW) ||
00128 !strcmp(tag,VIRCAM_STD_OBJECT_RAW) ||
00129 !strcmp(tag,VIRCAM_TWI_RAW))
00130 cpl_frame_set_group(cur_frame,CPL_FRAME_GROUP_RAW);
00131
00132
00133
00134 else if (!strcmp(tag,VIRCAM_CAL_RESET) ||
00135 !strcmp(tag,VIRCAM_CAL_DARK) ||
00136 !strcmp(tag,VIRCAM_CAL_DOME_FLAT) ||
00137 !strcmp(tag,VIRCAM_CAL_TWILIGHT_FLAT) ||
00138 !strcmp(tag,VIRCAM_CAL_CONF) ||
00139 !strcmp(tag,VIRCAM_CAL_BPM) ||
00140 !strcmp(tag,VIRCAM_CAL_FRINGE) ||
00141 !strcmp(tag,VIRCAM_CAL_CHANTAB) ||
00142 !strcmp(tag,VIRCAM_CAL_READGAINFILE) ||
00143 !strcmp(tag,VIRCAM_CAL_CHANTAB_INIT) ||
00144 !strcmp(tag,VIRCAM_CAL_PHOTTAB) ||
00145 !strcmp(tag,VIRCAM_CAL_STDTAB) ||
00146 !strcmp(tag,VIRCAM_CAL_OBJCAT) ||
00147 !strcmp(tag,VIRCAM_CAL_MSTDTAB) ||
00148 !strcmp(tag,VIRCAM_CAL_2MASS) ||
00149 !strcmp(tag,VIRCAM_CAL_REFCAT) ||
00150 !strcmp(tag,VIRCAM_CAL_SKY) ||
00151 !strcmp(tag,VIRCAM_REF_RESET) ||
00152 !strcmp(tag,VIRCAM_REF_DARK) ||
00153 !strcmp(tag,VIRCAM_REF_DOME_FLAT) ||
00154 !strcmp(tag,VIRCAM_REF_TWILIGHT_FLAT))
00155 cpl_frame_set_group(cur_frame,CPL_FRAME_GROUP_CALIB);
00156 else
00157 cpl_msg_info(fctid,"No such tag as %s in frame %s",tag,
00158 cpl_frame_get_filename(cur_frame));
00159 }
00160 return(VIR_OK);
00161 }
00162
00163
00194
00195
00196 extern void vircam_dfs_set_product_primary_header(cpl_propertylist *plist,
00197 cpl_frame *frame,
00198 cpl_frameset *frameset,
00199 cpl_parameterlist *parlist,
00200 char *recipeid,
00201 const char *dict,
00202 cpl_frame *inherit,
00203 int synch) {
00204 const char *fctid="vircam_dfs_set_product_primary_header";
00205 char package[PACKSZ];
00206 cpl_propertylist *pcopy;
00207
00208
00209
00210 (void)snprintf(package,PACKSZ,"%s/%s",PACKAGE,PACKAGE_VERSION);
00211
00212
00213
00214
00215
00216 pcopy = cpl_propertylist_duplicate(plist);
00217
00218
00219
00220 if (cpl_dfs_setup_product_header(plist,frame,frameset,parlist,recipeid,
00221 package,dict,inherit) != CPL_ERROR_NONE) {
00222 cpl_msg_warning(fctid,
00223 "Problem with the product primary DFS compliance -- %s",
00224 cpl_error_get_message());
00225 cpl_error_reset();
00226 }
00227
00228
00229
00230 if (synch)
00231 cpl_propertylist_copy_property_regexp(plist,
00232 (const cpl_propertylist *)pcopy,
00233 REGFIX,0);
00234 cpl_propertylist_delete(pcopy);
00235 }
00236
00237
00264
00265
00266 extern void vircam_dfs_set_product_exten_header(cpl_propertylist *plist,
00267 cpl_frame *frame,
00268 cpl_frameset *frameset,
00269 cpl_parameterlist *parlist,
00270 char *recipeid,
00271 const char *dict,
00272 cpl_frame *inherit) {
00273 const char *fctid="vircam_dfs_set_product_exten_header";
00274 char package[PACKSZ];
00275
00276
00277
00278 (void)snprintf(package,PACKSZ,"%s/%s",PACKAGE,PACKAGE_VERSION);
00279
00280
00281
00282 if (cpl_dfs_setup_product_header(plist,frame,frameset,parlist,recipeid,
00283 package,dict,inherit) != CPL_ERROR_NONE) {
00284 cpl_msg_warning(fctid,
00285 "Problem with the product extn DFS compliance -- %s",
00286 cpl_error_get_message());
00287 cpl_error_reset();
00288 }
00289
00290
00291
00292 cpl_propertylist_erase_regexp(plist,DELEXTN,0);
00293
00294 }
00295
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434