Changeset 32971 for trunk/psModules/src/objects/pmSourceIO.c
- Timestamp:
- Dec 19, 2011, 1:22:04 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSourceIO.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceIO.c
r32633 r32971 57 57 #define BLANK_HEADERS "BLANK.HEADERS" // Name of metadata in camera configuration containing header names 58 58 // for putting values into a blank PHU 59 static bool pmReadoutReadXSRC(pmFPAfile *file, char * exttype, psMetadata *hduHeader, psString xsrcname, psArray *sources, long *sourceIndex); 60 static bool pmReadoutReadXFIT(pmFPAfile *file, char * exttype, psMetadata *hduHeader, psString xfitname, psArray *sources, long *sourceIndex); 61 static bool pmReadoutReadXRAD(pmFPAfile *file, char * exttype, psMetadata *hduHeader, psString xfitname, psArray *sources, long *sourceIndex); 59 62 60 63 // lookup the EXTNAME values used for table data and image header segments … … 961 964 psString dataname = NULL; 962 965 psString deteffname = NULL; 963 if (!pmSourceIOextnames(&headname, &dataname, &deteffname, NULL, NULL, NULL, file, view)) { 966 psString xsrcname = NULL; 967 psString xfitname = NULL; 968 psString xradname = NULL; 969 970 // determine the output table format. Assume if we need to output extendend source 971 // parameters that they may exist in the input. 972 // XXX: Perhaps we should use different recipe values. 973 // I.E. EXTENDED_SOURCE_ANALYSIS_READ or something like that 974 psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT"); 975 if (!status) { 976 psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data"); 977 return false; 978 } 979 // if this is not TRUE, the output files only contain the psf measurements. 980 bool XSRC_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_ANALYSIS"); 981 bool XFIT_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_FITS"); 982 bool XRAD_OUTPUT = psMetadataLookupBool(&status, recipe, "RADIAL_APERTURES"); 983 984 if (!pmSourceIOextnames(&headname, &dataname, &deteffname, 985 XSRC_OUTPUT ? &xsrcname : NULL, 986 XFIT_OUTPUT ? &xfitname : NULL, 987 XRAD_OUTPUT ? &xradname : NULL, 988 file, view)) { 964 989 return false; 965 990 } … … 1039 1064 } 1040 1065 1066 long *sourceIndex = NULL; 1067 if (XSRC_OUTPUT || XFIT_OUTPUT || XRAD_OUTPUT) { 1068 long seq_max = -1; 1069 for (long i = sources->n -1; i >= 0; i--) { 1070 pmSource *source = sources->data[i]; 1071 if (source->seq > seq_max) { 1072 seq_max = source->seq; 1073 } 1074 } 1075 sourceIndex = psAlloc((seq_max + 1) * sizeof(long)); 1076 for (long i = 0; i < seq_max; i++) { 1077 sourceIndex[i] = -1; 1078 } 1079 for (long i = 0; i < sources->n; i++) { 1080 pmSource *source = sources->data[i]; 1081 sourceIndex[source->seq] = i; 1082 } 1083 } 1084 if (XSRC_OUTPUT && xsrcname) { 1085 if (!pmReadoutReadXSRC(file, exttype, hdu->header, xsrcname, sources, sourceIndex)) { 1086 // XXX: is this an error? 1087 psErrorClear(); 1088 } 1089 psFree(xsrcname); 1090 } 1091 if (XFIT_OUTPUT && xfitname) { 1092 if (!pmReadoutReadXFIT(file, exttype, hdu->header, xfitname, sources, sourceIndex)) { 1093 // XXX: is this an error? 1094 psErrorClear(); 1095 } 1096 psFree(xfitname); 1097 } 1098 if (XRAD_OUTPUT && xradname) { 1099 if (!pmReadoutReadXRAD(file, exttype, hdu->header, xradname, sources, sourceIndex)) { 1100 // XXX: is this an error? 1101 psErrorClear(); 1102 } 1103 psFree(xradname); 1104 } 1105 psFree(sourceIndex); 1106 1041 1107 if (!pmReadoutReadDetEff(file->fits, readout, deteffname)) { 1042 1108 #if 0 … … 1165 1231 } 1166 1232 1167 1233 // XXX: We might be able to macroize this and reuse for the other types 1234 1235 static bool pmReadoutReadXSRC(pmFPAfile *file, char *exttype, psMetadata *hduHeader, psString xsrcname, psArray *sources, long *sourceIndex) 1236 { 1237 if (!psFitsMoveExtName (file->fits, xsrcname)) { 1238 psError(PS_ERR_UNKNOWN, false, "cannot find xsrc extension %s in %s", xsrcname, file->filename); 1239 return false; 1240 } 1241 1242 psMetadata *tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header 1243 if (!tableHeader) psAbort("cannot read table header"); 1244 1245 char *xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION"); 1246 if (!xtension) psAbort("cannot read table type"); 1247 if (strcmp (xtension, "BINTABLE")) { 1248 psWarning ("no binary table in extension %s, skipping\n", xsrcname); 1249 return false; 1250 } 1251 1252 // XXX these are case-sensitive since the EXTYPE is case-sensitive 1253 bool status = false; 1254 if (file->type == PM_FPA_FILE_CMF) { 1255 #ifdef notyet 1256 if (!strcmp (exttype, "SMPDATA")) { 1257 status = pmSourcesRead_SMPDATA_XSRC (file->fits, hduHeader, sources); 1258 } 1259 if (!strcmp (exttype, "PS1_DEV_0")) { 1260 status = pmSourcesRead_PS1_DEV_0_XSRC (file->fits, hduHeader, sources); 1261 } 1262 if (!strcmp (exttype, "PS1_DEV_1")) { 1263 status = pmSourcesRead_PS1_DEV_1_XSRC (file->fits, hduHeader, sources); 1264 } 1265 if (!strcmp (exttype, "PS1_V1")) { 1266 status = pmSourcesRead_CMF_PS1_V1_XSRC (file->fits, hduHeader, sources); 1267 } 1268 if (!strcmp (exttype, "PS1_V2")) { 1269 status = pmSourcesRead_CMF_PS1_V2_XSRC (file->fits, hduHeader, sources); 1270 } 1271 if (!strcmp (exttype, "PS1_V3")) { 1272 status = pmSourcesRead_CMF_PS1_V3_XSRC (file->fits, hduHeader, sources); 1273 } 1274 if (!strcmp (exttype, "PS1_V4")) { 1275 status = pmSourcesRead_CMF_PS1_V4_XSRC (file->fits, hduHeader, sources); 1276 } 1277 #endif // notyet 1278 if (!strcmp (exttype, "PS1_SV1")) { 1279 status = pmSourcesRead_CMF_PS1_SV1_XSRC (file->fits, hduHeader, sources, sourceIndex); 1280 } 1281 #ifdef notyet 1282 if (!strcmp (exttype, "PS1_DV1")) { 1283 status = pmSourcesRead_CMF_PS1_DV1_XSRC (file->fits, hduHeader, sources); 1284 } 1285 if (!strcmp (exttype, "PS1_DV2")) { 1286 status = pmSourcesRead_CMF_PS1_DV2_XSRC (file->fits, hduHeader, sources); 1287 } 1288 #endif // notyet 1289 } 1290 psFree(tableHeader); 1291 return status; 1292 } 1293 1294 static bool pmReadoutReadXFIT(pmFPAfile *file, char *exttype, psMetadata *hduHeader, psString extname, psArray *sources, long *sourceIndex) 1295 { 1296 if (!psFitsMoveExtName (file->fits, extname)) { 1297 psError(PS_ERR_UNKNOWN, false, "cannot find extension %s in %s", extname, file->filename); 1298 return false; 1299 } 1300 1301 psMetadata *tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header 1302 if (!tableHeader) psAbort("cannot read table header"); 1303 1304 char *xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION"); 1305 if (!xtension) psAbort("cannot read table type"); 1306 if (strcmp (xtension, "BINTABLE")) { 1307 psWarning ("no binary table in extension %s, skipping\n", extname); 1308 return false; 1309 } 1310 1311 // XXX these are case-sensitive since the EXTYPE is case-sensitive 1312 bool status = false; 1313 if (file->type == PM_FPA_FILE_CMF) { 1314 #ifdef notyet 1315 if (!strcmp (exttype, "SMPDATA")) { 1316 status = pmSourcesRead_SMPDATA_XFIT (file->fits, hduHeader, sources); 1317 } 1318 if (!strcmp (exttype, "PS1_DEV_0")) { 1319 status = pmSourcesRead_PS1_DEV_0_XFIT (file->fits, hduHeader, sources); 1320 } 1321 if (!strcmp (exttype, "PS1_DEV_1")) { 1322 status = pmSourcesRead_PS1_DEV_1_XFIT (file->fits, hduHeader, sources); 1323 } 1324 if (!strcmp (exttype, "PS1_V1")) { 1325 status = pmSourcesRead_CMF_PS1_V1_XFIT (file->fits, hduHeader, sources); 1326 } 1327 if (!strcmp (exttype, "PS1_V2")) { 1328 status = pmSourcesRead_CMF_PS1_V2_XFIT (file->fits, hduHeader, sources); 1329 } 1330 if (!strcmp (exttype, "PS1_V3")) { 1331 status = pmSourcesRead_CMF_PS1_V3_XFIT (file->fits, hduHeader, sources); 1332 } 1333 if (!strcmp (exttype, "PS1_V4")) { 1334 status = pmSourcesRead_CMF_PS1_V4_XFIT (file->fits, hduHeader, sources); 1335 } 1336 #endif // notyet 1337 if (!strcmp (exttype, "PS1_SV1")) { 1338 status = pmSourcesRead_CMF_PS1_SV1_XFIT (file->fits, hduHeader, sources, sourceIndex); 1339 } 1340 #ifdef notyet 1341 if (!strcmp (exttype, "PS1_DV1")) { 1342 status = pmSourcesRead_CMF_PS1_DV1_XFIT (file->fits, hduHeader, sources); 1343 } 1344 if (!strcmp (exttype, "PS1_DV2")) { 1345 status = pmSourcesRead_CMF_PS1_DV2_XFIT (file->fits, hduHeader, sources); 1346 } 1347 #endif // notyet 1348 } 1349 psFree(tableHeader); 1350 return status; 1351 } 1352 static bool pmReadoutReadXRAD(pmFPAfile *file, char *exttype, psMetadata *hduHeader, psString extname, psArray *sources, long *sourceIndex) 1353 { 1354 if (!psFitsMoveExtName (file->fits, extname)) { 1355 psError(PS_ERR_UNKNOWN, false, "cannot find extension %s in %s", extname, file->filename); 1356 return false; 1357 } 1358 1359 psMetadata *tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header 1360 if (!tableHeader) psAbort("cannot read table header"); 1361 1362 char *xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION"); 1363 if (!xtension) psAbort("cannot read table type"); 1364 if (strcmp (xtension, "BINTABLE")) { 1365 psWarning ("no binary table in extension %s, skipping\n", extname); 1366 return false; 1367 } 1368 1369 // XXX these are case-sensitive since the EXTYPE is case-sensitive 1370 bool status = false; 1371 if (file->type == PM_FPA_FILE_CMF) { 1372 #ifdef notyet 1373 if (!strcmp (exttype, "SMPDATA")) { 1374 status = pmSourcesRead_SMPDATA_XRAD (file->fits, hduHeader, sources); 1375 } 1376 if (!strcmp (exttype, "PS1_DEV_0")) { 1377 status = pmSourcesRead_PS1_DEV_0_XRAD (file->fits, hduHeader, sources); 1378 } 1379 if (!strcmp (exttype, "PS1_DEV_1")) { 1380 status = pmSourcesRead_PS1_DEV_1_XRAD (file->fits, hduHeader, sources); 1381 } 1382 if (!strcmp (exttype, "PS1_V1")) { 1383 status = pmSourcesRead_CMF_PS1_V1_XRAD (file->fits, hduHeader, sources); 1384 } 1385 if (!strcmp (exttype, "PS1_V2")) { 1386 status = pmSourcesRead_CMF_PS1_V2_XRAD (file->fits, hduHeader, sources); 1387 } 1388 if (!strcmp (exttype, "PS1_V3")) { 1389 status = pmSourcesRead_CMF_PS1_V3_XRAD (file->fits, hduHeader, sources); 1390 } 1391 if (!strcmp (exttype, "PS1_V4")) { 1392 status = pmSourcesRead_CMF_PS1_V4_XRAD (file->fits, hduHeader, sources); 1393 } 1394 #endif // notyet 1395 if (!strcmp (exttype, "PS1_SV1")) { 1396 status = pmSourcesRead_CMF_PS1_SV1_XRAD (file->fits, hduHeader, sources, sourceIndex); 1397 } 1398 #ifdef notyet 1399 if (!strcmp (exttype, "PS1_DV1")) { 1400 status = pmSourcesRead_CMF_PS1_DV1_XRAD (file->fits, hduHeader, sources); 1401 } 1402 if (!strcmp (exttype, "PS1_DV2")) { 1403 status = pmSourcesRead_CMF_PS1_DV2_XRAD (file->fits, hduHeader, sources); 1404 } 1405 #endif // notyet 1406 } 1407 psFree(tableHeader); 1408 return status; 1409 }
Note:
See TracChangeset
for help on using the changeset viewer.
