Changeset 25331
- Timestamp:
- Sep 10, 2009, 4:55:32 PM (17 years ago)
- Location:
- branches/pap/psModules/src/objects
- Files:
-
- 3 edited
-
pmDetEff.c (modified) (2 diffs)
-
pmDetEff.h (modified) (3 diffs)
-
pmSourceIO.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/psModules/src/objects/pmDetEff.c
r25327 r25331 78 78 } 79 79 80 bool pmReadoutWriteDetEff(psFits *fits, const pmReadout *readout, 81 const psMetadata *header, const char *extname) 82 { 83 PM_ASSERT_READOUT_NON_NULL(readout, false); 84 85 bool mdok; // Status of MD lookup 86 pmDetEff *de = psMetadataLookupPtr(&mdok, readout->analysis, PM_DETEFF_ANALYSIS); // Detection efficiency 87 if (!mdok || !de) { 88 // Wrote everything there was to write 89 return true; 90 } 91 return pmDetEffWrite(fits, de, header, extname); 92 } 93 80 94 81 95 pmDetEff *pmDetEffRead(psFits *fits, const char *extname) … … 138 152 } 139 153 154 bool pmReadoutReadDetEff(psFits *fits, const pmReadout *readout, const char *extname) 155 { 156 PM_ASSERT_READOUT_NON_NULL(readout, false); 157 158 pmDetEff *de = pmDetEffRead(fits, extname); 159 if (!de) { 160 if (psErrorCodeLast() != PS_ERR_NONE) { 161 return false; 162 } 163 return true; 164 } 165 166 return psMetadataAddPtr(readout->analysis, PS_LIST_TAIL, PM_DETEFF_ANALYSIS, 167 PS_META_REPLACE | PS_DATA_UNKNOWN, "Detection efficiency", de); 168 } -
branches/pap/psModules/src/objects/pmDetEff.h
r25327 r25331 4 4 #include <pslib.h> 5 5 #include <string.h> 6 7 #include "pmFPA.h" 6 8 7 9 #define PM_DETEFF_ANALYSIS "DETEFF" // Location of detection efficiency on pmReadout.analysis … … 26 28 ); 27 29 30 /// Write detection efficiency to FITS file 28 31 bool pmDetEffWrite(psFits *fits, // FITS file to which to write 29 32 pmDetEff *deteff, // Detection efficiency to write … … 32 35 ); 33 36 37 /// Write detection efficiency from a readout to a FITS file 38 bool pmReadoutWriteDetEff(psFits *fits,// FITS file to which to write 39 const pmReadout *readout, // Readout with detection efficiency 40 const psMetadata *header, // Header to write 41 const char *extname // Extension name 42 ); 43 44 /// Read detection efficiency 34 45 pmDetEff *pmDetEffRead(psFits *fits, // FITS file from which to read 35 46 const char *extname // Extension name 36 47 ); 48 49 /// Read detection efficiency into a readout 50 bool pmReadoutReadDetEff(psFits *fits,// FITS file to which to write 51 const pmReadout *readout, // Readout with detection efficiency 52 const char *extname // Extension name 53 ); 37 54 38 55 #define PM_ASSERT_DETEFF_NON_NULL(DE, RETURN) { \ -
branches/pap/psModules/src/objects/pmSourceIO.c
r24694 r25331 42 42 #include "pmSource.h" 43 43 #include "pmModelClass.h" 44 #include "pmDetEff.h" 44 45 #include "pmSourceIO.h" 45 46 46 47 #define BLANK_HEADERS "BLANK.HEADERS" // Name of metadata in camera configuration containing header names 47 48 // for putting values into a blank PHU 49 50 // lookup the EXTNAME values used for table data and image header segments 51 static bool sourceExtensions(psString *headname, // Extension name for header 52 psString *dataname, // Extension name for data 53 psString *deteffname, // Extension name for detection efficiency 54 psString *xsrcname, // Extension name for extended sources 55 psString *xfitname, // Extension name for extended fits 56 const pmFPAfile *file, // File of interest 57 const pmFPAview *view // View to level of interest 58 ) 59 { 60 bool status; // Status of MD lookup 61 62 // Menu of EXTNAME rules 63 psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES"); 64 if (!menu) { 65 psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config"); 66 return false; 67 } 68 69 // EXTNAME for image header 70 if (headname) { 71 const char *rule = psMetadataLookupStr(&status, menu, "CMF.HEAD"); 72 if (!rule) { 73 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config"); 74 return false; 75 } 76 *headname = pmFPAfileNameFromRule(rule, file, view); 77 } 78 79 // EXTNAME for table data 80 if (dataname) { 81 const char *rule = psMetadataLookupStr(&status, menu, "CMF.DATA"); 82 if (!rule) { 83 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config"); 84 return false; 85 } 86 *dataname = pmFPAfileNameFromRule(rule, file, view); 87 } 88 89 // EXTNAME for detection efficiency 90 if (deteffname) { 91 const char *rule = psMetadataLookupStr(&status, menu, "CMF.DETEFF"); 92 if (!rule) { 93 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DETEFF in EXTNAME.RULES in camera.config"); 94 return false; 95 } 96 *deteffname = pmFPAfileNameFromRule(rule, file, view); 97 } 98 99 // EXTNAME for extended source data table 100 if (xsrcname) { 101 const char *rule = psMetadataLookupStr(&status, menu, "CMF.XSRC"); 102 if (!rule) { 103 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XSRC in EXTNAME.RULES in camera.config"); 104 return false; 105 } 106 *xsrcname = pmFPAfileNameFromRule (rule, file, view); 107 } 108 109 if (xfitname) { 110 // EXTNAME for extended source data table 111 const char *rule = psMetadataLookupStr(&status, menu, "CMF.XFIT"); 112 if (!rule) { 113 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XFIT in EXTNAME.RULES in camera.config"); 114 return false; 115 } 116 *xfitname = pmFPAfileNameFromRule (rule, file, view); 117 } 118 119 return true; 120 } 121 48 122 49 123 // translations between psphot object types and dophot object types … … 271 345 272 346 char *exttype = NULL; 273 char *dataname = NULL;274 char *xsrcname = NULL;275 char *xfitname = NULL;276 char *headname = NULL;277 347 278 348 // if sources is NULL, write out an empty table … … 354 424 355 425 // define the EXTNAME values for the different data segments: 356 { 357 // lookup the EXTNAME values used for table data and image header segments 358 char *rule = NULL; 359 360 // Menu of EXTNAME rules 361 psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES"); 362 if (!menu) { 363 psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config"); 364 return false; 365 } 366 367 // EXTNAME for image header 368 rule = psMetadataLookupStr(&status, menu, "CMF.HEAD"); 369 if (!rule) { 370 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config"); 371 return false; 372 } 373 headname = pmFPAfileNameFromRule (rule, file, view); 374 375 // EXTNAME for table data 376 rule = psMetadataLookupStr(&status, menu, "CMF.DATA"); 377 if (!rule) { 378 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config"); 379 return false; 380 } 381 dataname = pmFPAfileNameFromRule (rule, file, view); 382 383 if (XSRC_OUTPUT) { 384 // EXTNAME for extended source data table 385 rule = psMetadataLookupStr(&status, menu, "CMF.XSRC"); 386 if (!rule) { 387 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XSRC in EXTNAME.RULES in camera.config"); 388 return false; 389 } 390 xsrcname = pmFPAfileNameFromRule (rule, file, view); 391 } 392 if (XFIT_OUTPUT) { 393 // EXTNAME for extended source data table 394 rule = psMetadataLookupStr(&status, menu, "CMF.XFIT"); 395 if (!rule) { 396 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XFIT in EXTNAME.RULES in camera.config"); 397 return false; 398 } 399 xfitname = pmFPAfileNameFromRule (rule, file, view); 400 } 426 psString headname = NULL; 427 psString dataname = NULL; 428 psString deteffname = NULL; 429 psString xsrcname = NULL; 430 psString xfitname = NULL; 431 if (!sourceExtensions(&headname, &dataname, &deteffname, XSRC_OUTPUT ? &xsrcname : NULL, 432 XFIT_OUTPUT ? &xfitname : NULL, file, view)) { 433 return false; 401 434 } 402 435 … … 480 513 481 514 // XXX these are case-sensitive since the EXTYPE is case-sensitive 482 status = false;515 status = true; 483 516 if (!strcmp (exttype, "SMPDATA")) { 484 status = pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname);517 status &= pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname); 485 518 } 486 519 if (!strcmp (exttype, "PS1_DEV_0")) { 487 status = pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname);520 status &= pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname); 488 521 } 489 522 if (!strcmp (exttype, "PS1_DEV_1")) { 490 status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname);523 status &= pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname); 491 524 } 492 525 if (!strcmp (exttype, "PS1_CAL_0")) { 493 status = pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname);526 status &= pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname); 494 527 } 495 528 if (!strcmp (exttype, "PS1_V1")) { 496 status = pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname);529 status &= pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname); 497 530 } 498 531 if (!strcmp (exttype, "PS1_V2")) { 499 status = pmSourcesWrite_CMF_PS1_V2 (file->fits, readout, sources, file->header, outhead, dataname); 500 } 532 status &= pmSourcesWrite_CMF_PS1_V2 (file->fits, readout, sources, file->header, outhead, dataname); 533 } 534 535 if (deteffname) { 536 status &= pmReadoutWriteDetEff(file->fits, readout, outhead, deteffname); 537 } 538 501 539 if (xsrcname) { 502 540 if (!strcmp (exttype, "PS1_DEV_1")) { 503 status = pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname, recipe);541 status &= pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname, recipe); 504 542 } 505 543 if (!strcmp (exttype, "PS1_CAL_0")) { 506 status = pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);544 status &= pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe); 507 545 } 508 546 if (!strcmp (exttype, "PS1_V1")) { 509 status = pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe);547 status &= pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe); 510 548 } 511 549 if (!strcmp (exttype, "PS1_V2")) { 512 status = pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe);550 status &= pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe); 513 551 } 514 552 } 515 553 if (xfitname) { 516 554 if (!strcmp (exttype, "PS1_DEV_1")) { 517 status = pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);555 status &= pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname); 518 556 } 519 557 if (!strcmp (exttype, "PS1_CAL_0")) { 520 status = pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname);558 status &= pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname); 521 559 } 522 560 if (!strcmp (exttype, "PS1_V1")) { 523 status = pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname);561 status &= pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname); 524 562 } 525 563 if (!strcmp (exttype, "PS1_V2")) { 526 status = pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname);564 status &= pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname); 527 565 } 528 566 } … … 572 610 // not needed if only one chip 573 611 if (file->fpa->chips->n == 1) { 574 pmSourceIO_WriteMatchedRefs (file->fits, file->fpa, config);575 return true;612 pmSourceIO_WriteMatchedRefs (file->fits, file->fpa, config); 613 return true; 576 614 } 577 615 … … 885 923 hdu = pmFPAviewThisHDU (view, file->fpa); 886 924 887 // lookup the EXTNAME values used for table data and image header segments 888 char *rule = NULL; 889 // Menu of EXTNAME rules 890 psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES"); 891 if (!menu) { 892 psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config"); 893 return false; 894 } 895 // EXTNAME for image header 896 rule = psMetadataLookupStr(&status, menu, "CMF.HEAD"); 897 if (!rule) { 898 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config"); 899 return false; 900 } 901 char *headname = pmFPAfileNameFromRule (rule, file, view); 902 // EXTNAME for table data 903 rule = psMetadataLookupStr(&status, menu, "CMF.DATA"); 904 if (!rule) { 905 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config"); 906 return false; 907 } 908 char *dataname = pmFPAfileNameFromRule (rule, file, view); 925 // define the EXTNAME values for the different data segments: 926 psString headname = NULL; 927 psString dataname = NULL; 928 psString deteffname = NULL; 929 if (!sourceExtensions(&headname, &dataname, &deteffname, NULL, NULL, file, view)) { 930 return false; 931 } 909 932 910 933 // advance to the IMAGE HEADER extension … … 958 981 sources = pmSourcesRead_CMF_PS1_V2 (file->fits, hdu->header); 959 982 } 983 984 if (!pmReadoutReadDetEff(file->fits, readout, deteffname)) { 985 psError(PS_ERR_IO, false, "Unable to read detection efficiency"); 986 return false; 987 } 960 988 } 961 989 … … 1070 1098 } 1071 1099 1072 1100
Note:
See TracChangeset
for help on using the changeset viewer.
