Changeset 36441 for trunk/psModules/src/objects/pmSourceIO_CMF.c.in
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/bills_branches/bills_201312 (added) merged: 36383,36386,36388-36396,36406-36407,36409-36412,36415-36420,36422-36427,36433,36436-36439
- Property svn:mergeinfo changed
-
trunk/psModules
- Property svn:mergeinfo changed
/branches/bills_branches/bills_201312/psModules (added) merged: 36389,36412,36422-36424
- Property svn:mergeinfo changed
-
trunk/psModules/src/objects/pmSourceIO_CMF.c.in
r36375 r36441 708 708 return false; 709 709 } 710 // Find the source with this sequence number. 711 // XXX: I am assuming that sources is sorted in order of seq 710 // Find the source with this sequence number using the sourceIndex. 712 711 long seq = psMetadataLookupU32 (&status, row, "IPP_IDET"); 713 pmSource *source = NULL;714 #ifndef ASSUME_SORTED715 long j = seq < sources->n ? seq : sources->n - 1;716 for (; j >= 0; j--) {717 source = sources->data[j];718 if (source->seq == seq) {719 break;720 }721 }722 #else723 712 long j = sourceIndex[seq]; 724 713 psAssert(j >= 0 && j < sources->n, "invalid sourceIndex"); 725 source = sources->data[j]; 726 #endif 714 pmSource *source = sources->data[j]; 727 715 if (!source) { 728 716 psError(PS_ERR_UNKNOWN, false, "Failed to find source for row %ld sequence number %ld\n", i, seq); … … 793 781 // create a header to hold the output data 794 782 psMetadata *outhead = psMetadataAlloc (); 783 784 pmModelClassWriteHeader(outhead); 795 785 796 786 // write the links to the image header … … 1034 1024 return false; 1035 1025 } 1026 // set up the lookup table to translate between input model types and output model types 1027 // if not defined it is assumed that the tables are the same 1028 pmModelClassReadHeader(tableHeader); 1036 1029 1037 1030 for (long i = 0; i < numSources; i++) { … … 1042 1035 return false; 1043 1036 } 1044 // Find the source with this sequence number.1045 // XXX: I am assuming that sources is sorted in order of seq.1046 1037 long seq = psMetadataLookupU32 (&status, row, "IPP_IDET"); 1047 long j = seq < sources->n ? seq : sources->n - 1; 1048 pmSource *source = NULL; 1049 for (; j >= 0; j--) { 1050 source = sources->data[j]; 1051 if (source->seq == seq) { 1052 break; 1053 } 1054 } 1038 long j = sourceIndex[seq]; 1039 psAssert(j >= 0 && j < sources->n, "invalid sourceIndex"); 1040 pmSource *source = sources->data[j]; 1055 1041 if (!source) { 1056 1042 psError(PS_ERR_UNKNOWN, false, "Failed to find source for row %ld sequence number %ld\n", i, seq); … … 1095 1081 // in the psf table. 1096 1082 psS32 extModelType = psMetadataLookupS32(&status, row, "EXT_MODEL_TYPE"); 1097 if (!status) { 1083 if (status) { 1084 // translate between the type value in xfit and values used by this program 1085 extModelType = pmModelClassGetLocalType(extModelType); 1086 } else { 1098 1087 // older cmfs don't have this column 1099 1088 extModelType = -1; 1100 } 1089 } 1101 1090 1102 1091 psEllipseAxes axes; … … 1339 1328 return false; 1340 1329 } 1341 // Find the source with this sequence number.1342 // XXX: I am assuming that sources is sorted in order of seq.1343 1330 long seq = psMetadataLookupU32 (&status, row, "IPP_IDET"); 1344 long j = seq < sources->n ? seq : sources->n - 1; 1345 pmSource *source = NULL; 1346 for (; j >= 0; j--) { 1347 source = sources->data[j]; 1348 if (source->seq == seq) { 1349 break; 1350 } 1351 } 1331 long j = sourceIndex[seq]; 1332 psAssert(j >= 0 && j < sources->n, "invalid sourceIndex"); 1333 pmSource *source = sources->data[j]; 1352 1334 if (!source) { 1353 1335 psError(PS_ERR_UNKNOWN, false, "Failed to find source for row %ld sequence number %ld\n", i, seq); … … 1407 1389 1408 1390 // XXX where should I record the number of columns?? 1409 bool pmSourcesWrite_CMF_@CMFMODE@_XGAL (psFits *fits, p sArray *sources, char *extname, psMetadata *recipe)1391 bool pmSourcesWrite_CMF_@CMFMODE@_XGAL (psFits *fits, pmReadout *readout, psArray *sources, char *extname, psMetadata *recipe) 1410 1392 { 1411 1393 bool status = false; … … 1422 1404 // write the links to the image header 1423 1405 psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "galaxy table extension", extname); 1406 1407 psMetadataAddStr (outhead, PS_LIST_TAIL, "HI", PS_META_REPLACE, "does this get through?", "THERE"); 1424 1408 1425 1409 // let's write these out in S/N order … … 1491 1475 } 1492 1476 1477 bool pmSourcesRead_CMF_@CMFMODE@_XGAL(psFits *fits, pmReadout *readout, psMetadata *hduHeader, psMetadata *tableHeader, psArray *sources, long *sourceIndex) 1478 { 1479 PS_ASSERT_PTR_NON_NULL(fits, false); 1480 PS_ASSERT_PTR_NON_NULL(sources, false); 1481 1482 bool status; 1483 long numSources = psFitsTableSize(fits); // Number of sources in table 1484 if (numSources == 0) { 1485 psError(psErrorCodeLast(), false, "XGAL Table contains no entries\n"); 1486 return false; 1487 } 1488 1489 for (long i = 0; i < numSources; i++) { 1490 psMetadata *row = psFitsReadTableRow(fits, i); // Table row 1491 if (!row) { 1492 psError(psErrorCodeLast(), false, "Unable to read row %ld of sources", i); 1493 psFree(row); 1494 return false; 1495 } 1496 // Find the source with this sequence number. 1497 // XXX: I am assuming that sources is sorted in order of seq 1498 long seq = psMetadataLookupU32 (&status, row, "IPP_IDET"); 1499 long j = sourceIndex[seq]; 1500 psAssert(j >= 0 && j < sources->n, "invalid sourceIndex"); 1501 1502 pmSource *source = sources->data[j]; 1503 if (!source) { 1504 psError(PS_ERR_UNKNOWN, false, "Failed to find source for row %ld sequence number %ld\n", i, seq); 1505 psFree(row); 1506 return false; 1507 } 1508 1509 psVector *Flux = psMetadataLookupVector(&status, row, "GAL_FLUX"); 1510 psVector *dFlux = psMetadataLookupVector(&status, row, "GAL_FLUX_ERR"); 1511 psVector *chisq = psMetadataLookupVector(&status, row, "GAL_CHISQ"); 1512 1513 if (Flux && Flux->n > 0) { 1514 psFree(source->galaxyFits); 1515 source->galaxyFits = pmSourceGalaxyFitsAlloc(); 1516 source->galaxyFits->nPix = psMetadataLookupF32(&status, row, "NPIX"); 1517 1518 psFree(source->galaxyFits->Flux); 1519 source->galaxyFits->Flux = psMemIncrRefCounter(Flux); 1520 psFree(source->galaxyFits->dFlux); 1521 source->galaxyFits->dFlux = psMemIncrRefCounter(dFlux); 1522 psFree(source->galaxyFits->chisq); 1523 source->galaxyFits->chisq = psMemIncrRefCounter(chisq); 1524 } 1525 1526 psFree(row); 1527 } 1528 1529 return true; 1530 }
Note:
See TracChangeset
for help on using the changeset viewer.
