Changeset 17911 for trunk/psModules/src/camera
- Timestamp:
- Jun 4, 2008, 3:32:28 PM (18 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 9 edited
-
pmFPA.c (modified) (4 diffs)
-
pmFPA.h (modified) (2 diffs)
-
pmFPAConstruct.c (modified) (10 diffs)
-
pmFPAConstruct.h (modified) (4 diffs)
-
pmFPAWrite.c (modified) (2 diffs)
-
pmFPAfile.c (modified) (1 diff)
-
pmFPAfileDefine.c (modified) (7 diffs)
-
pmFPAfileFitsIO.c (modified) (1 diff)
-
pmFPAfileIO.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPA.c
r16716 r17911 305 305 tmpCell->conceptsRead = PM_CONCEPT_SOURCE_NONE; 306 306 if (!psMetadataAddStr(tmpCell->concepts, PS_LIST_HEAD, "CELL.NAME", 0, NULL, name)) { 307 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CELL.NAME to metadata.\n"); 307 psErrorClear(); 308 psWarning("Could not add CELL.NAME to metadata."); 308 309 } 309 310 pmConceptsBlankCell(tmpCell); … … 343 344 tmpChip->conceptsRead = PM_CONCEPT_SOURCE_NONE; 344 345 if (!psMetadataAddStr(tmpChip->concepts, PS_LIST_HEAD, "CHIP.NAME", 0, NULL, name)) { 345 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CHIP.NAME %s to concepts.\n", name); 346 psErrorClear(); 347 psWarning("Could not add CHIP.NAME %s to concepts.", name); 346 348 } 347 349 pmConceptsBlankChip(tmpChip); … … 355 357 } 356 358 357 pmFPA *pmFPAAlloc(const psMetadata *camera )359 pmFPA *pmFPAAlloc(const psMetadata *camera, const char *cameraName) 358 360 { 359 361 pmFPA *tmpFPA = (pmFPA *) psAlloc(sizeof(pmFPA)); … … 373 375 pmConceptsBlankFPA(tmpFPA); 374 376 377 if (!psMetadataAddStr(tmpFPA->concepts, PS_LIST_TAIL, "FPA.CAMERA", PS_META_REPLACE, 378 "Camera name (according to configuration)", cameraName)) { 379 psErrorClear(); 380 psWarning("Could not add FPA.CAMERA %s to concepts.", cameraName); 381 } 382 375 383 return tmpFPA; 376 384 } -
trunk/psModules/src/camera/pmFPA.h
r17249 r17911 6 6 * @author Eugene Magnier, IfA 7 7 * 8 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2008-0 3-31 22:39:06$8 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2008-06-05 01:31:33 $ 10 10 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 11 11 */ … … 169 169 170 170 /// Allocate an FPA 171 pmFPA *pmFPAAlloc(const psMetadata *camera); ///< Camera configuration (to store in FPA) 171 pmFPA *pmFPAAlloc(const psMetadata *camera, ///< Camera configuration (to store in FPA) 172 const char *cameraName ///< Name of camera (for FPA.CAMERA concept) 173 ); 172 174 bool psMemCheckFPA(psPtr ptr); 173 175 -
trunk/psModules/src/camera/pmFPAConstruct.c
r16912 r17911 1102 1102 // It returns a view corresponding to the PHU 1103 1103 static pmFPAview *addSource(pmFPA *fpa, // The FPA 1104 const char *fpa name, // The desired FPAname1104 const char *fpaObs, // The desired FPA observation name 1105 1105 const pmFPAview *phuView, // The view corresponding to the PHU, or NULL 1106 1106 const psMetadata *header, // The PHU header, or NULL … … 1115 1115 bool mdok; // Status of MD lookup 1116 1116 1117 // If FPA. NAMEis already defined, new name must match it; otherwise, warn the user that something1117 // If FPA.OBS is already defined, new name must match it; otherwise, warn the user that something 1118 1118 // potentially bad is happening. 1119 if (fpaname && install) { 1120 const char *currentName = psMetadataLookupStr(&mdok, fpa->concepts, "FPA.NAME"); // Current name 1121 if (mdok && currentName && strlen(currentName) > 0 && strcmp(currentName, fpaname) != 0) { 1122 psWarning("FPA.NAME for new source (%s) doesn't match FPA.NAME for current " 1123 "fpa (%s).\n", fpaname, currentName); 1124 } 1125 psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.NAME", PS_META_REPLACE, "Name of FPA", fpaname); 1126 } else if (!psMetadataLookup(fpa->concepts, "FPA.NAME")) { 1127 // Make sure there is an FPA.NAME 1128 psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.NAME", 0, "Name of FPA", "UNKNOWN"); 1119 if (fpaObs && install) { 1120 const char *currentName = psMetadataLookupStr(&mdok, fpa->concepts, "FPA.OBS"); // Current name 1121 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.OBS 1129 psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.OBS", 0, "Observation identifier", "UNKNOWN"); 1129 1130 } 1130 1131 … … 1308 1309 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1309 1310 1310 pmFPA *pmFPAConstruct(const psMetadata *camera )1311 pmFPA *pmFPAConstruct(const psMetadata *camera, const char *cameraName) 1311 1312 { 1312 1313 PS_ASSERT_PTR_NON_NULL(camera, NULL); 1313 1314 1314 pmFPA *fpa = pmFPAAlloc(camera ); // The FPA to fill out1315 pmFPA *fpa = pmFPAAlloc(camera, cameraName); // The FPA to fill out 1315 1316 1316 1317 bool mdok = true; // Status from MD lookups … … 1349 1350 } 1350 1351 1351 bool pmFPAAddSourceFromFormat(pmFPA *fpa, const char *fpa name, const psMetadata *format)1352 bool pmFPAAddSourceFromFormat(pmFPA *fpa, const char *fpaObs, const psMetadata *format) 1352 1353 { 1353 1354 PS_ASSERT_PTR_NON_NULL(fpa, false); … … 1358 1359 pmFPAview *view = pmFPAviewAlloc(0);// View for current level 1359 1360 if (phuLevel == PM_FPA_LEVEL_FPA) { 1360 if (!pmFPAAddSourceFromView(fpa, fpa name, view, format)) {1361 if (!pmFPAAddSourceFromView(fpa, fpaObs, view, format)) { 1361 1362 psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA."); 1362 1363 psFree(view); … … 1367 1368 while ((chip = pmFPAviewNextChip(view, fpa, 1))) { 1368 1369 if (phuLevel == PM_FPA_LEVEL_CHIP) { 1369 if (!pmFPAAddSourceFromView(fpa, fpa name, view, format)) {1370 if (!pmFPAAddSourceFromView(fpa, fpaObs, view, format)) { 1370 1371 psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA."); 1371 1372 psFree(view); … … 1376 1377 while ((cell = pmFPAviewNextCell(view, fpa, 1))) { 1377 1378 if (phuLevel == PM_FPA_LEVEL_CELL) { 1378 if (!pmFPAAddSourceFromView(fpa, fpa name, view, format)) {1379 if (!pmFPAAddSourceFromView(fpa, fpaObs, view, format)) { 1379 1380 psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA."); 1380 1381 psFree(view); … … 1391 1392 } 1392 1393 1393 bool pmFPAAddSourceFromView(pmFPA *fpa, const char *fpa name, const pmFPAview *phuView,1394 bool pmFPAAddSourceFromView(pmFPA *fpa, const char *fpaObs, const pmFPAview *phuView, 1394 1395 const psMetadata *format) 1395 1396 { … … 1398 1399 PS_ASSERT_PTR_NON_NULL(format, false); 1399 1400 1400 pmFPAview *view = addSource(fpa, fpa name, phuView, NULL, format, true);1401 pmFPAview *view = addSource(fpa, fpaObs, phuView, NULL, format, true); 1401 1402 bool status = (view != NULL); 1402 1403 psFree(view); … … 1418 1419 1419 1420 // Check the name of the FPA 1420 psString fpa name = phuNameFromHeader("FPA.NAME", fileInfo, phu); // Newname for the FPA1421 if (!fpa name || strlen(fpaname) == 0) {1422 psWarning("Unable to determine FPA. NAME: check for FPA.NAMEin FILE in camera format");1423 } 1424 1425 pmFPAview *view = addSource(fpa, fpa name, NULL, phu, format, true); // View of PHU, to return1426 psFree(fpa name);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); 1427 1428 1428 1429 return view; -
trunk/psModules/src/camera/pmFPAConstruct.h
r16912 r17911 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $7 * @date $Date: 2008-0 3-11 01:27:05$6 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2008-06-05 01:31:33 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 21 21 /// as the corresponding values (whitespace separated). The FPA hierarchy is created devoid of any 22 22 /// input/output sources (i.e., HDUs). 23 pmFPA *pmFPAConstruct(const psMetadata *camera ///< The camera configuration 23 pmFPA *pmFPAConstruct(const psMetadata *camera, ///< The camera configuration 24 const char *cameraName ///< Name of the camera (for FPA.CAMERA concept) 24 25 ); 25 26 … … 28 29 /// This is suitable for generating an output FPA given the desired format. 29 30 bool pmFPAAddSourceFromFormat(pmFPA *fpa, ///< The FPA 30 const char *fpa name, ///< FPA.NAME for the source31 const char *fpaObs, ///< FPA.NAME for the source 31 32 const psMetadata *format ///< Format of file 32 33 ); … … 37 38 /// configuration is required in order to describe how the FPA is laid out in terms of disk files. 38 39 bool pmFPAAddSourceFromView(pmFPA *fpa, ///< The FPA 39 const char *fpa name, ///< FPA.NAME for the source40 const char *fpaObs, ///< FPA.NAME for the source 40 41 const pmFPAview *phuView, ///< The view, corresponding to the PHU 41 42 const psMetadata *format ///< Format of file -
trunk/psModules/src/camera/pmFPAWrite.c
r16396 r17911 37 37 38 38 39 // Update the FPA. NAME, CHIP.NAME and CELL.NAME in the FITS header, if required39 // Update the FPA.OBS, CHIP.NAME and CELL.NAME in the FITS header, if required 40 40 bool pmFPAUpdateNames(pmFPA *fpa, pmChip *chip, pmCell *cell) 41 41 { … … 55 55 } 56 56 if (fpa) { 57 const char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME"); 58 if (mdok && fpaNameHdr && strlen(fpaNameHdr) > 0) { 59 const char *fpaName = psMetadataLookupStr(NULL, fpa->concepts, "FPA.NAME"); 60 psMetadataAddStr(hdu->header, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName); 57 const char *fpaObsHdr = psMetadataLookupStr(&mdok, fileData, "FPA.OBS"); 58 if (mdok && fpaObsHdr && strlen(fpaObsHdr) > 0) { 59 const char *fpaObs = psMetadataLookupStr(NULL, fpa->concepts, "FPA.OBS"); 60 psMetadataAddStr(hdu->header, PS_LIST_TAIL, fpaObsHdr, PS_META_REPLACE, 61 "Observation identifier", fpaObs); 61 62 } 62 63 } -
trunk/psModules/src/camera/pmFPAfile.c
r17036 r17911 181 181 newName = psStringCopy(rule); 182 182 183 if (strstr (newName, "{FPA. NAME}") != NULL) {184 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA. NAME");183 if (strstr (newName, "{FPA.OBS}") != NULL) { 184 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.OBS"); 185 185 if (name != NULL) { 186 psStringSubstitute(&newName, "fpa", "{FPA. NAME}");186 psStringSubstitute(&newName, "fpa", "{FPA.OBS}"); 187 187 } 188 188 } -
trunk/psModules/src/camera/pmFPAfileDefine.c
r17634 r17911 237 237 file->fpa = psMemIncrRefCounter(fpa); 238 238 } else { 239 file->fpa = pmFPAConstruct(file->camera );239 file->fpa = pmFPAConstruct(file->camera, file->cameraName); 240 240 } 241 241 … … 482 482 483 483 // build the template fpa, set up the basic view 484 fpa = pmFPAConstruct(config->camera );484 fpa = pmFPAConstruct(config->camera, config->cameraName); 485 485 if (!fpa) { 486 486 psError(PS_ERR_IO, false, "Failed to construct FPA from %s", realName); … … 783 783 784 784 // build the template fpa, set up the basic view 785 fpa = pmFPAConstruct (config->camera);785 fpa = pmFPAConstruct(config->camera, config->cameraName); 786 786 if (!fpa) { 787 787 psError(PS_ERR_IO, false, "Failed to construct FPA from %s", (char *)infiles->data[0]); … … 867 867 868 868 // build the template fpa, set up the basic view 869 pmFPA *fpa = pmFPAConstruct (config->camera);869 pmFPA *fpa = pmFPAConstruct(config->camera, config->cameraName); 870 870 if (!fpa) { 871 871 psError(PS_ERR_IO, false, "Failed to construct FPA for %s", filename); … … 949 949 if (!file) { 950 950 // build the template fpa, set up the basic view 951 fpa = pmFPAConstruct (config->camera);951 fpa = pmFPAConstruct(config->camera, config->cameraName); 952 952 if (!fpa) { 953 953 psError(PS_ERR_IO, false, "Failed to construct FPA for %s", filename); … … 1090 1090 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 1091 1091 1092 pmFPA *fpa = pmFPAConstruct(src->camera );1092 pmFPA *fpa = pmFPAConstruct(src->camera, psMetadataLookupStr(NULL, src->concepts, "FPA.CAMERA")); 1093 1093 // XXX should this use DefineOutputForFormat? 1094 1094 pmFPAfile *file = pmFPAfileDefineOutput (config, fpa, filename); … … 1139 1139 return NULL; 1140 1140 } 1141 file->fpa = pmFPAConstruct(file->camera );1141 file->fpa = pmFPAConstruct(file->camera, file->cameraName); 1142 1142 1143 1143 return file; -
trunk/psModules/src/camera/pmFPAfileFitsIO.c
r16841 r17911 67 67 } 68 68 69 pmFPA *nameSource = file->src; // Source of FPA. NAME69 pmFPA *nameSource = file->src; // Source of FPA.OBS 70 70 if (!nameSource) { 71 71 nameSource = file->fpa; 72 72 } 73 73 bool mdok; // Status of MD lookup 74 const char *fpa name = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.NAME"); // Name of FPA75 76 pmFPA *copy = pmFPAConstruct(file->camera ); // FPA to return77 if (!pmFPAAddSourceFromView(copy, fpa name, phuView, file->format)) {74 const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Observation id 75 76 pmFPA *copy = pmFPAConstruct(file->camera, file->cameraName); // FPA to return 77 if (!pmFPAAddSourceFromView(copy, fpaObs, phuView, file->format)) { 78 78 psError(PS_ERR_UNKNOWN, false, "Unable to insert HDU into FPA for writing.\n"); 79 79 psFree(copy); -
trunk/psModules/src/camera/pmFPAfileIO.c
r17832 r17911 263 263 } 264 264 265 pmFPA *nameSource = file->src; // Source of FPA. NAME265 pmFPA *nameSource = file->src; // Source of FPA.OBS 266 266 if (!nameSource) { 267 267 nameSource = file->fpa; 268 268 } 269 269 bool mdok; // Status of MD lookup 270 const char *fpaname = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.NAME"); // Name of FPA 271 272 pmFPAAddSourceFromView(file->fpa, fpaname, view, format); 273 psTrace ("psModules.camera", 5, "created fpa data elements for %s (%s) (%d:%d:%d)\n", file->name, file->name, view->chip, view->cell, view->readout); 270 const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Obs. id 271 272 pmFPAAddSourceFromView(file->fpa, fpaObs, view, format); 273 psTrace ("psModules.camera", 5, "created fpa data elements for %s (%s) (%d:%d:%d)\n", 274 file->name, file->name, view->chip, view->cell, view->readout); 274 275 break; 275 276 } … … 349 350 // (existing) fpa 350 351 if (file->type == PM_FPA_FILE_CMF) { 351 if (!pmFPAviewCheckDataStatusForSources (view, file)) {352 if (!pmFPAviewCheckDataStatusForSources (view, file)) { 352 353 psTrace("psModules.camera", 6, "skip write for %s, no data for this entry", file->name); 353 354 return true; … … 778 779 file->fits->options = psMemIncrRefCounter(file->options); 779 780 780 // in most cases, we have already open and read the phu and determined the format.781 // in some cases, (eg DetDB images), we have only just determined the filename.782 // we need to check the file format before we can work with the file783 if (!file->format) {784 psMetadata *phu = psFitsReadHeader (NULL, file->fits);785 if (!phu) {786 psError(PS_ERR_IO, false, "Failed to read file header %s\n", file->filename);787 return false;788 }789 790 // determine the current format from the header791 // determine camera if not specified already792 file->format = pmConfigCameraFormatFromHeader (config, phu, true);793 if (!file->format) {794 psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", file->filename);795 psFree(phu);796 return false;797 }798 psFree(phu);799 }800 801 // if needed, set the optional EXTWORD field based on the camera value802 psMetadata *fileMenu = psMetadataLookupMetadata (NULL, file->format, "FILE");803 if (!fileMenu) {804 psError (PS_ERR_IO, true, "FILE METADATA missing from camera format %s\n",805 config->formatName);806 return false;807 }808 char *extword = psMetadataLookupStr (&status, fileMenu, "EXTWORD");809 if (status) {810 psFitsSetExtnameWord (file->fits, extword);811 }781 // in most cases, we have already open and read the phu and determined the format. 782 // in some cases, (eg DetDB images), we have only just determined the filename. 783 // we need to check the file format before we can work with the file 784 if (!file->format) { 785 psMetadata *phu = psFitsReadHeader (NULL, file->fits); 786 if (!phu) { 787 psError(PS_ERR_IO, false, "Failed to read file header %s\n", file->filename); 788 return false; 789 } 790 791 // determine the current format from the header 792 // determine camera if not specified already 793 file->format = pmConfigCameraFormatFromHeader (config, phu, true); 794 if (!file->format) { 795 psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", file->filename); 796 psFree(phu); 797 return false; 798 } 799 psFree(phu); 800 } 801 802 // if needed, set the optional EXTWORD field based on the camera value 803 psMetadata *fileMenu = psMetadataLookupMetadata (NULL, file->format, "FILE"); 804 if (!fileMenu) { 805 psError (PS_ERR_IO, true, "FILE METADATA missing from camera format %s\n", 806 config->formatName); 807 return false; 808 } 809 char *extword = psMetadataLookupStr (&status, fileMenu, "EXTWORD"); 810 if (status) { 811 psFitsSetExtnameWord (file->fits, extword); 812 } 812 813 813 814 // XXX these are probably only needed for WRITE files
Note:
See TracChangeset
for help on using the changeset viewer.
