Changeset 6663
- Timestamp:
- Mar 21, 2006, 1:52:54 PM (20 years ago)
- Location:
- branches/rel10_ifa/psModules/src
- Files:
-
- 11 edited
-
astrom/Makefile.am (modified) (4 diffs)
-
astrom/pmConceptsStandard.c (modified) (4 diffs)
-
astrom/pmConceptsWrite.c (modified) (8 diffs)
-
astrom/pmFPAConstruct.c (modified) (4 diffs)
-
astrom/pmFPARead.c (modified) (1 diff)
-
astrom/pmFPAWrite.c (modified) (2 diffs)
-
astrom/pmFPAWrite.h (modified) (1 diff)
-
astrom/pmHDU.c (modified) (3 diffs)
-
astrom/pmHDU.h (modified) (1 diff)
-
pslib/psMetadataItemParse.c (modified) (1 diff)
-
psmodules.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psModules/src/astrom/Makefile.am
r6618 r6663 8 8 pmFPAMaskWeight.c \ 9 9 pmFPARead.c \ 10 pmFPAWrite.c \ 10 11 pmHDU.c \ 11 12 pmHDUGetLowest.c \ … … 21 22 # pmAstrometryObjects.c 22 23 # pmChipMosaic.c 23 # pmFPAWrite.c24 24 25 25 psmoduleincludedir = $(includedir) … … 29 29 pmFPAMaskWeight.h \ 30 30 pmFPARead.h \ 31 pmFPAWrite.h \ 31 32 pmHDU.h \ 32 33 pmHDUGetLowest.h \ … … 44 45 # 45 46 # pmChipMosaic.h 46 # pmFPAWrite.h -
branches/rel10_ifa/psModules/src/astrom/pmConceptsStandard.c
r6581 r6663 413 413 psString format = psMetadataLookupStr(&mdok, formats, name); 414 414 if (mdok && strlen(format) > 0 && strcasecmp(format, "FORTRAN") == 0) { 415 return -1;415 return 1; 416 416 } 417 417 } … … 429 429 } 430 430 int offset = concept->data.S32; 431 offset += fortranCorr(cameraFormat, pattern->name);431 offset -= fortranCorr(cameraFormat, pattern->name); 432 432 return psMetadataItemAllocS32(pattern->name, pattern->comment, offset); 433 433 } … … 486 486 psMetadataItem *yBinItem = psMetadataLookup(cell->concepts, "CELL.YBIN"); // Binning factor in y 487 487 psString binString = psStringCopy(""); 488 psStringAppend(&binString, "%d ,%d", concept->data.S32, yBinItem->data.S32);488 psStringAppend(&binString, "%d %d", concept->data.S32, yBinItem->data.S32); 489 489 psMetadataItem *binItem = psMetadataItemAllocStr(concept->name, concept->comment, binString); 490 490 psFree(binString); … … 611 611 } 612 612 int offset = concept->data.S32; 613 offset -= fortranCorr(cameraFormat, concept->name);613 offset += fortranCorr(cameraFormat, concept->name); 614 614 return psMetadataItemAllocS32(concept->name, concept->comment, offset); 615 615 } -
branches/rel10_ifa/psModules/src/astrom/pmConceptsWrite.c
r6575 r6663 132 132 if (cell) { 133 133 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level 134 if (!hdu) { 135 return false; 136 } 134 137 psMetadata *cameraFormat = hdu->format; // The camera format 135 138 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator … … 145 148 // Formatted version 146 149 psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, NULL, NULL, cell); 150 if (!formatted) { 151 continue; 152 } 147 153 psString nameSource = NULL; // String with the concept name and ".SOURCE" added 148 154 psStringAppend(&nameSource, "%s.SOURCE", name); … … 193 199 { 194 200 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level 201 if (!hdu) { 202 return false; 203 } 195 204 psMetadata *cameraFormat = hdu->format; // The camera format 196 205 bool mdok = true; // Status of MD lookup … … 208 217 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts 209 218 psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, fpa, chip, cell); 219 if (!formatted) { 220 continue; 221 } 210 222 if (! compareConcepts(defaultItem, formatted)) { 211 223 psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by the DEFAULTS in the camera " … … 229 241 { 230 242 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level 243 if (!hdu) { 244 return false; 245 } 231 246 psMetadata *cameraFormat = hdu->format; // The camera format 232 247 bool mdok = true; // Status of MD lookup … … 249 264 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts 250 265 psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, fpa, chip, cell); 266 if (!formatted) { 267 continue; 268 } 251 269 psList *keywords = psStringSplit(headerItem->data.V, " ,;"); // List of header keywords 252 270 if (formatted->type == PS_DATA_LIST) { … … 289 307 { 290 308 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level 309 if (!hdu) { 310 return false; 311 } 291 312 psMetadata *cameraFormat = hdu->format; // The camera format 292 313 bool mdok = true; // Status of MD lookup … … 311 332 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts 312 333 psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, fpa, chip, cell); 334 if (!formatted) { 335 continue; 336 } 313 337 314 338 psMetadata *dbLookup = dbItem->data.V; // How to look up the value of interest -
branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.c
r6618 r6663 115 115 return false; 116 116 } 117 ps String result = psMetadataLookupStr(&mdok,header, keyword);118 if (! mdok || strlen(result) == 0) {117 psMetadataItem *resultItem = psMetadataLookup(header, keyword); 118 if (! resultItem) { 119 119 psError(PS_ERR_IO, false, "Unable to find %s in primary header to identify %s.\n", keyword, name); 120 120 return NULL; 121 121 } 122 123 return result; 122 return psMetadataItemParseString(resultItem); 124 123 } 125 124 … … 190 189 } 191 190 psMetadataItem *fpaNameItem = psMetadataLookup(phu, nameKeyword); // Name of the FPA 191 if (!fpaNameItem) { 192 psError(PS_ERR_IO, false, "Unable to find keyword %s with the name of the FPA.\n", nameKeyword); 193 return NULL; 194 } 192 195 const char *newFPAname = psMetadataItemParseString(fpaNameItem); // FPA.NAME for new source 193 196 fpaNameItem = psMetadataLookup(fpa->concepts, "FPA.NAME"); // Current name of FPA … … 421 424 psString chipName = NULL; // Name of chip under consideration 422 425 pmChip *chip = NULL; // The chip we're looking for 423 if (! fpa->hdu->phu) { 426 #if 1 427 // Think I'm doing this at the start now 428 if (!fpa->hdu || !fpa->hdu->phu) { 424 429 // Need to look up the name of the chip 425 430 chipName = phuNameFromHeader("CHIP.NAME", formatSpec, phu); … … 431 436 chip = fpa->chips->data[chipNum]; 432 437 } 438 #endif 433 439 for (int i = 0; i < names->n; i++) { 434 440 psString cellType = values->data[i]; // The type of the cell 435 441 psString cellName = NULL; // The name of the cell 436 if (fpa->hdu ->phu) {442 if (fpa->hdu && fpa->hdu->phu) { 437 443 // We've got chipName:cellType with cellType == cellName 438 444 chipName = names->data[i]; -
branches/rel10_ifa/psModules/src/astrom/pmFPARead.c
r6622 r6663 59 59 #if 0 60 60 bool pmReadoutRead(pmReadout *readout, // Readout to read into 61 psFits *fits // FITS file from which to read 61 psFits *fits, // FITS file from which to read 62 int numSections // Total number of sections 63 int section // The section of interest 62 64 ) 63 65 { -
branches/rel10_ifa/psModules/src/astrom/pmFPAWrite.c
r6552 r6663 4 4 5 5 #include "pmFPA.h" 6 #include "pm FPARead.h"6 #include "pmHDU.h" 7 7 #include "pmConcepts.h" 8 8 9 10 bool pmCellWrite(pmCell *cell, // Cell to write 11 psFits *fits, // FITS file to which to write 12 psDB *db // Database handle for "concepts" update 13 ) 14 { 15 pmConceptsWriteCell(cell, PM_CONCEPT_SOURCE_HEADER, false, NULL); 16 17 pmHDU *hdu = cell->hdu; // The HDU 18 if (hdu && !pmHDUWrite(hdu, fits)) { 19 psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n"); 20 return false; 21 } 22 23 return true; 24 } 25 26 27 bool pmChipWrite(pmChip *chip, // Chip to write 28 psFits *fits, // FITS file to which to write 29 psDB *db // Database handle for "concepts" update 30 ) 31 { 32 pmConceptsWriteChip(chip, PM_CONCEPT_SOURCE_HEADER, false, NULL); 33 34 pmHDU *hdu = chip->hdu; // The HDU 35 if (hdu && !pmHDUWrite(hdu, fits)) { 36 psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n"); 37 return false; 38 } 39 40 bool success = true; // Success of writing 41 psArray *cells = chip->cells; // Array of cells 42 for (int i = 0; i < cells->n; i++) { 43 pmCell *cell = cells->data[i]; // The cell of interest 44 success |= pmCellWrite(cell, fits, db); 45 } 46 47 return success; 48 } 49 50 51 52 53 bool pmFPAWrite(pmFPA *fpa, // FPA to write 54 psFits *fits, // FITS file to which to write 55 psDB *db // Database handle for "concepts" update 56 ) 57 { 58 pmConceptsWriteFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL); 59 60 pmHDU *hdu = fpa->hdu; // The HDU 61 if (hdu && !pmHDUWrite(hdu, fits)) { 62 psError(PS_ERR_IO, false, "Unable to write HDU for FPA.\n"); 63 return false; 64 } 65 66 bool success = true; // Success of writing 67 psArray *chips = fpa->chips; // Array of chips 68 for (int i = 0; i < chips->n; i++) { 69 pmChip *chip = chips->data[i]; // The chip of interest 70 success |= pmChipWrite(chip, fits, db); 71 } 72 73 return success; 74 } 75 76 77 78 79 #if 0 9 80 static bool writeHDU(psFits *fits, // FITS file to which to write 10 81 pmHDU *hdu // Pixel data to write … … 258 329 return true; 259 330 } 331 #endif -
branches/rel10_ifa/psModules/src/astrom/pmFPAWrite.h
r6448 r6663 5 5 #include "pmFPA.h" 6 6 7 bool pmFPAWrite(psFits *fits, // FITS file to which to write 8 pmFPA *fpa, // FPA to write 9 psDB *db // Database to update 7 8 bool pmCellWrite(pmCell *cell, // Cell to write 9 psFits *fits, // FITS file to which to write 10 psDB *db // Database handle for "concepts" update 11 ); 12 bool pmChipWrite(pmChip *chip, // Chip to write 13 psFits *fits, // FITS file to which to write 14 psDB *db // Database handle for "concepts" update 15 ); 16 bool pmFPAWrite(pmFPA *fpa, // FPA to write 17 psFits *fits, // FITS file to which to write 18 psDB *db // Database handle for "concepts" update 10 19 ); 11 20 12 bool pmFPAWriteMask(pmFPA *fpa, // FPA containing mask to write13 psFits *fits // FITS file for image14 );15 16 bool pmFPAWriteWeight(pmFPA *fpa, // FPA containing mask to write17 psFits *fits // FITS file for image18 );19 20 21 21 #endif -
branches/rel10_ifa/psModules/src/astrom/pmHDU.c
r6590 r6663 114 114 assert(fits); 115 115 116 psTrace(__func__, 7, "Writing HDU %s\n", hdu->extname); 117 116 118 if (hdu->images && hdu->table && !hdu->header) { 117 119 psError(PS_ERR_IO, true, "Both image and table data provided in HDU, but no header --- " … … 120 122 } 121 123 124 // Preserve the extension name, if it's the PHU 125 char *extname = hdu->extname; // The name of the extension 126 if (strcasecmp(extname, "PHU") == 0) { 127 bool mdok = true; // Status of MD lookup 128 extname = psMetadataLookupStr(&mdok, hdu->header, "EXTNAME"); 129 if (!mdok || strlen(extname) == 0) { 130 extname = ""; 131 } 132 } 133 134 if (!hdu->images && !psFitsWriteHeader(hdu->header, fits)) { 135 psError(PS_ERR_IO, false, "Unable to write header for extension %s\n", extname); 136 } 137 122 138 #ifdef FITS_TABLES 123 139 if (hdu->images && (!hdu->table || psFitsIsImage(hdu->header))) { 124 #endif 125 psFitsWriteImageCube(fits, hdu->header, hdu->images, hdu->extname); 140 psFitsWriteImageCube(fits, hdu->header, hdu->images, extname); 126 141 return true; 127 #ifdef FITS_TABLES128 129 142 } 130 143 … … 136 149 psError(PS_ERR_IO, true, "No idea what this HDU consists of!\n"); 137 150 return false; 151 #else 152 153 if (hdu->images) { 154 psTrace(__func__, 9, "Writing pixels for %s\n", hdu->extname); 155 if (!psFitsWriteImageCube(fits, hdu->header, hdu->images, extname)) { 156 psError(PS_ERR_IO, false, "Unable to write image to extension %s\n", hdu->extname); 157 return false; 158 } 159 } 160 return true; 138 161 #endif 139 162 } 140 163 141 142 143 #if 0144 145 146 147 148 // Read the PHU of a file149 static bool readPHU(pmCameraFile *file // File for which to read the PHU150 )151 {152 if (! file->phu) {153 if (! file->fits) {154 file->fits = psFitsOpen(file->name, "r");155 }156 (void)psFitsMoveExtNum(file->fits, 0, false);157 file->phu = psFitsReadHeader(NULL, file->fits);158 159 return true;160 }161 162 return false;163 }164 165 bool pmCameraFileFormat(pmCameraFile *file, // File to inspect166 psMetadata *camera // Camera description167 )168 {169 if (! camera) {170 return false;171 }172 173 readPHU(file);174 175 bool mdok = true; // Result of MD lookup176 psMetadata *formats = psMetadataLookupMD(&mdok, camera, "FORMATS"); // List of known formats177 if (! mdok || ! formats) {178 psLogMsg(__func__, PS_LOG_WARN, "Unable to find list of FORMATS in camera configuration!\n");179 return false;180 }181 182 bool result = false; // Result of search183 psMetadataIterator *formatsIter = psMetadataIteratorAlloc(formats, NULL); // Iterator for formats184 psMetadataItem *formatsItem = NULL; // Item from formats185 while ((formatsItem = psMetadataGetAndIncrement(formatsIter))) {186 if (formatsItem->type != PS_DATA_STRING) {187 psLogMsg(__func__, PS_LOG_WARN, "Entry not of type STR found in camera FORMATS list.\n");188 continue;189 }190 psTrace(__func__, 7, "Trying format file: %s\n", formatsItem->name);191 int numBadLines = 0; // Number of bad lines in file192 psMetadata *format = psMetadataConfigParse(NULL, &numBadLines, formatsItem->data.V, true);193 if (numBadLines > 0) {194 psLogMsg(__func__, PS_LOG_WARN, "%d bad lines found in %s.\n", formatsItem->name);195 }196 if (pmConfigValidateCamera(format, file->phu)) {197 file->format = format;198 result = true;199 psLogMsg(__func__, PS_LOG_INFO + 2, "File %s matches camera format file %s\n", file->name,200 formatsItem->data.V);201 break;202 }203 psFree(format);204 }205 psFree(formatsIter);206 207 return result;208 }209 210 211 bool pmConfigValidateCamera(const psMetadata *camera, const psMetadata *header);212 213 pmFPA *pmFPASourceFile(pmFPA *fpa, // FPA to which to add214 pmFile *file, // File to add215 const char *name, // Symbolic name for file, e.g., "INPUT", "OUTPUT", "TESTFILE"216 pmConfig *config // Configuration set217 )218 {219 assert(file);220 assert(name);221 222 if (! file->fits) {223 file->fits = psFitsOpen(file->name, "r");224 }225 if (! file->phu) {226 (void)psFitsMoveExtNum(file->fits, 0, false);227 file->phu = psFitsReadHeader(NULL, file->fits);228 }229 230 psMetadata *fileConfig = NULL; // The file configuration231 if (fpa && fpa->camera) {232 fpa233 234 bool pmConfigValidateCamera(const psMetadata *camera, const psMetadata *header);235 #endif -
branches/rel10_ifa/psModules/src/astrom/pmHDU.h
r6575 r6663 23 23 ); 24 24 25 // Write the HDU 26 bool pmHDUWrite(pmHDU *hdu, // HDU to write 27 psFits *fits // FITS file to write to 28 ); 29 25 30 #endif -
branches/rel10_ifa/psModules/src/pslib/psMetadataItemParse.c
r6635 r6663 48 48 case PS_TYPE_F32: 49 49 psLogMsg(__func__, PS_LOG_WARN, "Item %s (%s) should be S32, but is F32 --- converting.\n", 50 item->name, comment);50 item->name, item->comment); 51 51 return (int)item->data.F32; 52 52 case PS_TYPE_F64: 53 53 psLogMsg(__func__, PS_LOG_WARN, "Item %s (%s) should be S32, but is F64 --- converting.\n", 54 item->name, comment);54 item->name, item->comment); 55 55 return (int)item->data.F64; 56 56 default: -
branches/rel10_ifa/psModules/src/psmodules.h
r6577 r6663 19 19 #include "pmFPAConstruct.h" 20 20 #include "pmFPARead.h" 21 //#include "pmFPAWrite.h"21 #include "pmFPAWrite.h" 22 22 #include "pmReadout.h" 23 23 #include "pmFPAfile.h"
Note:
See TracChangeset
for help on using the changeset viewer.
