Changeset 36375 for trunk/psModules/src/objects/pmSourceIO.c
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
trunk/psModules
- Property svn:mergeinfo changed
-
trunk/psModules/src/objects/pmSourceIO.c
r35610 r36375 69 69 psString *xfitname, // Extension name for extended fitted measurements 70 70 psString *xradname, // Extension name for radial apertures 71 psString *xgalname, // Extension name for galaxy shapes 71 72 const pmFPAfile *file, // File of interest 72 73 const pmFPAview *view // View to level of interest … … 140 141 } 141 142 *xradname = pmFPAfileNameFromRule (rule, file, view); 143 } 144 145 // EXTNAME for radial apertures 146 if (xgalname) { 147 const char *rule = psMetadataLookupStr(&status, menu, "CMF.XGAL"); 148 if (!rule) { 149 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XGAL in EXTNAME.RULES in camera.config"); 150 return false; 151 } 152 *xgalname = pmFPAfileNameFromRule (rule, file, view); 142 153 } 143 154 … … 362 373 status &= pmSourcesWrite_##TYPE##_XRAD (file->fits, readout, sources, file->header, xradname, recipe); \ 363 374 } \ 375 if (xgalname) { \ 376 status &= pmSourcesWrite_##TYPE##_XGAL (file->fits, sources, xgalname, recipe); \ 377 } \ 364 378 } 365 379 … … 464 478 } 465 479 466 // if this is not TRUE, the output files only contain the psf measurements. 467 bool XSRC_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_ANALYSIS"); 480 // if none of these are TRUE, the output files only contain the psf measurements. 481 bool doPetrosian = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_PETROSIAN"); 482 bool doAnnuli = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANNULI"); 483 bool XSRC_OUTPUT = doPetrosian || doAnnuli; 468 484 bool XFIT_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_FITS"); 469 485 bool XRAD_OUTPUT = psMetadataLookupBool(&status, recipe, "RADIAL_APERTURES"); 486 bool XGAL_OUTPUT = psMetadataLookupBool(&status, recipe, "GALAXY_SHAPES"); 470 487 471 488 // define the EXTNAME values for the different data segments: … … 476 493 psString xfitname = NULL; 477 494 psString xradname = NULL; 495 psString xgalname = NULL; 478 496 if (!pmSourceIOextnames(&headname, &dataname, &deteffname, 479 497 XSRC_OUTPUT ? &xsrcname : NULL, 480 498 XFIT_OUTPUT ? &xfitname : NULL, 481 499 XRAD_OUTPUT ? &xradname : NULL, 500 XGAL_OUTPUT ? &xgalname : NULL, 482 501 file, view)) { 483 502 return false; … … 563 582 psMetadataAddStr (outhead, PS_LIST_TAIL, "XRADNAME", PS_META_REPLACE, "name of XRAD table extension", xradname); 564 583 } 584 if (xgalname) { 585 psMetadataAddStr (outhead, PS_LIST_TAIL, "XGALNAME", PS_META_REPLACE, "name of XGAL table extension", xgalname); 586 } 565 587 566 588 // these are case-sensitive since the EXTYPE is case-sensitive … … 609 631 psFree (xfitname); 610 632 psFree (xradname); 633 psFree (xgalname); 611 634 psFree (deteffname); 612 635 … … 620 643 psFree (xfitname); 621 644 psFree (xradname); 645 psFree (xgalname); 622 646 psFree (deteffname); 623 647 return false; 624 648 649 case PM_FPA_FILE_CFF: { 650 // determine the output table format 651 psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT"); 652 if (!status) { 653 psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data"); 654 return false; 655 } 656 657 hdu = pmFPAviewThisHDU (view, fpa); 658 pmConfigConformHeader(hdu->header, file->format); 659 psFitsWriteBlank (file->fits, hdu->header, NULL); 660 file->header = hdu->header; 661 file->wrote_phu = true; 662 if (!pmSourcesWrite_CFF(readout, file->fits, sources, hdu->header, recipe)) { 663 psError(PS_ERR_UNKNOWN, false, "failed to write CFF"); 664 return false; 665 } 666 break; 667 } 668 625 669 default: 626 670 fprintf (stderr, "warning: type mismatch\n"); … … 914 958 psArray *sources = NULL; 915 959 pmHDU *hdu; 960 961 // define the EXTNAME values for the different data segments: 962 psString headname = NULL; 963 psString dataname = NULL; 964 psString deteffname = NULL; 965 psString xsrcname = NULL; 966 psString xfitname = NULL; 967 psString xradname = NULL; 968 psString xgalname = NULL; 969 970 psMetadata *tableHeader = NULL; 971 char *xtension = NULL; 916 972 917 973 switch (file->type) { … … 963 1019 hdu = pmFPAviewThisHDU (view, file->fpa); 964 1020 965 // define the EXTNAME values for the different data segments:966 psString headname = NULL;967 psString dataname = NULL;968 psString deteffname = NULL;969 psString xsrcname = NULL;970 psString xfitname = NULL;971 psString xradname = NULL;972 973 1021 // determine the output table format. Assume if we need to output extendend source 974 1022 // parameters that they may exist in the input. … … 981 1029 } 982 1030 983 // if this is not TRUE, the output files only contain the psf measurements. 984 bool XSRC_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_ANALYSIS"); 1031 // if none of these are TRUE, we only read the psf measurements 1032 // XXX: shouldn't we look for these extensions and read the regardless of the recipe values? 1033 bool doPetrosian = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_PETROSIAN"); 1034 bool doAnnuli = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANNULI"); 1035 bool XSRC_OUTPUT = doPetrosian || doAnnuli; 985 1036 bool XFIT_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_FITS"); 986 1037 bool XRAD_OUTPUT = psMetadataLookupBool(&status, recipe, "RADIAL_APERTURES"); 1038 bool XGAL_OUTPUT = false; // psMetadataLookupBool(&status, recipe, "GALAXY_SHAPES"); 987 1039 988 1040 if (!pmSourceIOextnames(&headname, &dataname, &deteffname, … … 990 1042 XFIT_OUTPUT ? &xfitname : NULL, 991 1043 XRAD_OUTPUT ? &xradname : NULL, 1044 XGAL_OUTPUT ? &xgalname : NULL, 992 1045 file, view)) { 993 1046 return false; … … 1033 1086 } 1034 1087 1035 psMetadata *tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header1088 tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header 1036 1089 if (!tableHeader) psAbort("cannot read table header"); 1037 1090 1038 char *xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION");1091 xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION"); 1039 1092 if (!xtension) psAbort("cannot read table type"); 1040 1093 if (strcmp (xtension, "BINTABLE")) { … … 1132 1185 break; 1133 1186 1187 case PM_FPA_FILE_CFF: 1188 // read in header, if not yet loaded 1189 hdu = pmFPAviewThisHDU (view, file->fpa); 1190 1191 // look these up in the camera config? 1192 // headrule = {CHIP.NAME}.hdr 1193 // datarule = {CHIP.NAME}.cff 1194 1195 // define the EXTNAME values for the different data segments: 1196 headname = pmFPAfileNameFromRule("{CHIP.NAME}.hdr", file, view); 1197 dataname = pmFPAfileNameFromRule("{CHIP.NAME}.cff", file, view); 1198 1199 // advance to the IMAGE HEADER extension 1200 if (hdu->header == NULL) { 1201 // if the IMAGE header does not exist, we have no data for this view 1202 if (!psFitsMoveExtNameClean (file->fits, headname)) { 1203 readout->data_exists = false; 1204 psFree (headname); 1205 psFree (dataname); 1206 return true; 1207 } 1208 hdu->header = psFitsReadHeader (NULL, file->fits); 1209 } 1210 1211 // advance to the table data extension 1212 // since we have read the IMAGE header, the TABLE header should exist 1213 if (!psFitsMoveExtName (file->fits, dataname)) { 1214 psAbort("cannot find data extension %s in %s", dataname, file->filename); 1215 } 1216 1217 tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header 1218 if (!tableHeader) psAbort("cannot read table header"); 1219 1220 // verify this is a binary table 1221 char *xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION"); 1222 if (!xtension) psAbort("cannot read table type"); 1223 if (strcmp (xtension, "BINTABLE")) { 1224 psWarning ("no binary table in extension %s, skipping\n", dataname); 1225 psFree(tableHeader); 1226 return false; 1227 } 1228 1229 sources = pmSourcesRead_CFF(file->fits, hdu->header); 1230 1231 psTrace("psModules.objects", 6, "read CMF table from %s : %s : %s", file->filename, headname, dataname); 1232 psFree (headname); 1233 psFree (dataname); 1234 psFree (tableHeader); 1235 break; 1236 1134 1237 default: 1135 1238 fprintf (stderr, "warning: type mismatch\n");
Note:
See TracChangeset
for help on using the changeset viewer.
