Changeset 28011
- Timestamp:
- May 18, 2010, 3:49:34 PM (16 years ago)
- Location:
- branches/eam_branches/psModules.20100506
- Files:
-
- 6 edited
-
. (modified) (1 prop)
-
src/camera/pmFPAConstruct.c (modified) (11 diffs)
-
src/camera/pmFPAConstruct.h (modified) (2 diffs)
-
src/camera/pmFPAWrite.c (modified) (4 diffs)
-
src/camera/pmFPAfileFitsIO.c (modified) (1 diff)
-
src/camera/pmFPAfileIO.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/psModules.20100506
- Property svn:mergeinfo changed
/trunk/psModules (added) merged: 27989,27992,28006 /branches/eam_branches/stackphot.20100406/psModules removed
- Property svn:mergeinfo changed
-
branches/eam_branches/psModules.20100506/src/camera/pmFPAConstruct.c
r27762 r28011 100 100 101 101 return num; 102 }103 104 // Get the name of a PHU chip or cell from the header105 static psString phuNameFromHeader(const char *name, // The name to lookup: "CELL.NAME" or "CHIP.NAME"106 const psMetadata *fileInfo, // FILE within the camera format description107 const psMetadata *header // Primary header108 )109 {110 assert(name && strlen(name) > 0);111 assert(fileInfo);112 assert(header);113 114 bool mdok = true; // Result of MD lookup115 psString keyword = psMetadataLookupStr(&mdok, fileInfo, name);116 if (!mdok || strlen(keyword) == 0) {117 return false;118 }119 psMetadataItem *resultItem = psMetadataLookup(header, keyword);120 if (!resultItem) {121 psError(PS_ERR_IO, true, "Unable to find %s in primary header to identify %s.\n", keyword, name);122 return NULL;123 }124 return psMetadataItemParseString(resultItem);125 102 } 126 103 … … 1102 1079 // It returns a view corresponding to the PHU 1103 1080 static pmFPAview *addSource(pmFPA *fpa, // The FPA 1104 const char *fpaObs, // The desired FPA observation name1105 1081 const pmFPAview *phuView, // The view corresponding to the PHU, or NULL 1106 1082 const psMetadata *header, // The PHU header, or NULL … … 1114 1090 1115 1091 bool mdok; // Status of MD lookup 1116 1117 // If FPA.OBS is already defined, new name must match it; otherwise, warn the user that something1118 // potentially bad is happening.1119 if (fpaObs && install) {1120 const char *currentName = psMetadataLookupStr(&mdok, fpa->concepts, "FPA.OBS"); // Current name1121 if (mdok && currentName && strlen(currentName) > 0 && strcmp(currentName, fpaObs) != 0) {1122 psWarning("FPA.OBS for new source (%s) doesn't match FPA.OBS for current fpa (%s).",1123 fpaObs, currentName);1124 }1125 psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.OBS", PS_META_REPLACE, "Observation identifier",1126 fpaObs);1127 } else if (!psMetadataLookup(fpa->concepts, "FPA.OBS")) {1128 // Make sure there is an FPA.OBS1129 psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.OBS", 0, "Observation identifier", "UNKNOWN");1130 }1131 1092 1132 1093 psMetadata *fileInfo = psMetadataLookupMetadata(&mdok, format, "FILE"); // The file information … … 1350 1311 } 1351 1312 1352 bool pmFPAAddSourceFromFormat(pmFPA *fpa, const char *fpaObs, constpsMetadata *format)1313 bool pmFPAAddSourceFromFormat(pmFPA *fpa, const psMetadata *format) 1353 1314 { 1354 1315 PS_ASSERT_PTR_NON_NULL(fpa, false); … … 1359 1320 pmFPAview *view = pmFPAviewAlloc(0);// View for current level 1360 1321 if (phuLevel == PM_FPA_LEVEL_FPA) { 1361 if (!pmFPAAddSourceFromView(fpa, fpaObs,view, format)) {1322 if (!pmFPAAddSourceFromView(fpa, view, format)) { 1362 1323 psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA."); 1363 1324 psFree(view); … … 1368 1329 while ((chip = pmFPAviewNextChip(view, fpa, 1))) { 1369 1330 if (phuLevel == PM_FPA_LEVEL_CHIP) { 1370 if (!pmFPAAddSourceFromView(fpa, fpaObs,view, format)) {1331 if (!pmFPAAddSourceFromView(fpa, view, format)) { 1371 1332 psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA."); 1372 1333 psFree(view); … … 1377 1338 while ((cell = pmFPAviewNextCell(view, fpa, 1))) { 1378 1339 if (phuLevel == PM_FPA_LEVEL_CELL) { 1379 if (!pmFPAAddSourceFromView(fpa, fpaObs,view, format)) {1340 if (!pmFPAAddSourceFromView(fpa, view, format)) { 1380 1341 psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA."); 1381 1342 psFree(view); … … 1392 1353 } 1393 1354 1394 bool pmFPAAddSourceFromView(pmFPA *fpa, const char *fpaObs, constpmFPAview *phuView,1355 bool pmFPAAddSourceFromView(pmFPA *fpa, const pmFPAview *phuView, 1395 1356 const psMetadata *format) 1396 1357 { … … 1399 1360 PS_ASSERT_PTR_NON_NULL(format, false); 1400 1361 1401 pmFPAview *view = addSource(fpa, fpaObs,phuView, NULL, format, true);1362 pmFPAview *view = addSource(fpa, phuView, NULL, format, true); 1402 1363 bool status = (view != NULL); 1403 1364 psFree(view); … … 1418 1379 } 1419 1380 1420 // Check the name of the FPA 1421 psString fpaObs = phuNameFromHeader("FPA.OBS", fileInfo, phu); // New observation name for the FPA 1422 if (!fpaObs || strlen(fpaObs) == 0) { 1423 psWarning("Unable to determine FPA.OBS: check for FPA.OBS in FILE in camera format"); 1424 } 1425 1426 pmFPAview *view = addSource(fpa, fpaObs, NULL, phu, format, true); // View of PHU, to return 1427 psFree(fpaObs); 1381 pmFPAview *view = addSource(fpa, NULL, phu, format, true); // View of PHU, to return 1428 1382 1429 1383 return view; … … 1437 1391 PS_ASSERT_PTR_NON_NULL(format, NULL); 1438 1392 1439 return addSource(fpa, NULL, NULL,phu, format, false);1393 return addSource(fpa, NULL, phu, format, false); 1440 1394 } 1441 1395 -
branches/eam_branches/psModules.20100506/src/camera/pmFPAConstruct.h
r17911 r28011 29 29 /// This is suitable for generating an output FPA given the desired format. 30 30 bool pmFPAAddSourceFromFormat(pmFPA *fpa, ///< The FPA 31 const char *fpaObs, ///< FPA.NAME for the source32 31 const psMetadata *format ///< Format of file 33 32 ); … … 38 37 /// configuration is required in order to describe how the FPA is laid out in terms of disk files. 39 38 bool pmFPAAddSourceFromView(pmFPA *fpa, ///< The FPA 40 const char *fpaObs, ///< FPA.NAME for the source41 39 const pmFPAview *phuView, ///< The view, corresponding to the PHU 42 40 const psMetadata *format ///< Format of file -
branches/eam_branches/psModules.20100506/src/camera/pmFPAWrite.c
r25881 r28011 165 165 // generate the HDU, but only copies the structure. 166 166 if (!blank && !hdu->blankPHU && !*imageArray) { 167 if (!pmHDUGenerateForCell(cell)) {168 psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell --- likely programming error.");169 return false;170 }171 if (!*imageArray) {172 if (type == FPA_WRITE_TYPE_IMAGE) {173 psError(PS_ERR_UNKNOWN, false, "Expected to write an image, but it is missing...programming error?.");174 return false;175 }176 if (type == FPA_WRITE_TYPE_MASK) {177 psWarning("No mask image for this cell; skipping");178 }179 if (type == FPA_WRITE_TYPE_VARIANCE) {180 psWarning("No variance image for this cell; skipping");181 }182 return true;183 }167 if (!pmHDUGenerateForCell(cell)) { 168 psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell --- likely programming error."); 169 return false; 170 } 171 if (!*imageArray) { 172 if (type == FPA_WRITE_TYPE_IMAGE) { 173 psError(PS_ERR_UNKNOWN, false, "Expected to write an image, but it is missing...programming error?."); 174 return false; 175 } 176 if (type == FPA_WRITE_TYPE_MASK) { 177 psWarning("No mask image for this cell; skipping"); 178 } 179 if (type == FPA_WRITE_TYPE_VARIANCE) { 180 psWarning("No variance image for this cell; skipping"); 181 } 182 return true; 183 } 184 184 } 185 185 … … 307 307 308 308 if (writeBlank || writeImage) { 309 if (!pmConceptsWriteFPA(fpa, true, config)) {309 if (!pmConceptsWriteFPA(fpa, true, config)) { 310 310 psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n"); 311 311 return false; … … 341 341 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 342 342 343 // Update the FPA.OBS,CHIP.NAME and CELL.NAME in the FITS header, if required343 // Update the CHIP.NAME and CELL.NAME in the FITS header, if required 344 344 bool pmFPAUpdateNames(pmFPA *fpa, pmChip *chip, pmCell *cell, psS64 imageId, psS64 sourceId) 345 345 { … … 375 375 psError(PS_ERR_UNKNOWN, true, "Unable to find FILE information in camera format.\n"); 376 376 return false; 377 }378 if (fpa) {379 const char *fpaObsHdr = psMetadataLookupStr(&mdok, fileData, "FPA.OBS");380 if (mdok && fpaObsHdr && strlen(fpaObsHdr) > 0) {381 const char *fpaObs = psMetadataLookupStr(NULL, fpa->concepts, "FPA.OBS");382 psMetadataAddStr(hduHigh->header, PS_LIST_TAIL, fpaObsHdr, PS_META_REPLACE,383 "Observation identifier", fpaObs);384 }385 377 } 386 378 -
branches/eam_branches/psModules.20100506/src/camera/pmFPAfileFitsIO.c
r25878 r28011 75 75 } 76 76 77 pmFPA *nameSource = file->src; // Source of FPA.OBS78 if (!nameSource) {79 nameSource = file->fpa;80 }81 bool mdok; // Status of MD lookup82 const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Observation id83 84 77 pmFPA *copy = pmFPAConstruct(file->camera, file->cameraName); // FPA to return 85 if (!pmFPAAddSourceFromView(copy, fpaObs,phuView, file->format)) {78 if (!pmFPAAddSourceFromView(copy, phuView, file->format)) { 86 79 psError(PS_ERR_UNKNOWN, false, "Unable to insert HDU into FPA for writing.\n"); 87 80 psFree(copy); -
branches/eam_branches/psModules.20100506/src/camera/pmFPAfileIO.c
r26893 r28011 286 286 } 287 287 288 pmFPA *nameSource = file->src; // Source of FPA.OBS 289 if (!nameSource) { 290 nameSource = file->fpa; 291 } 292 bool mdok; // Status of MD lookup 293 const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Obs. id 294 295 pmFPAAddSourceFromView(file->fpa, fpaObs, view, format); 288 pmFPAAddSourceFromView(file->fpa, view, format); 296 289 psTrace ("psModules.camera", 5, "created fpa data elements for %s (%s) (%d:%d:%d)\n", 297 290 file->name, file->name, view->chip, view->cell, view->readout);
Note:
See TracChangeset
for help on using the changeset viewer.
