Changeset 6895
- Timestamp:
- Apr 18, 2006, 2:54:44 PM (20 years ago)
- Location:
- trunk/psModules/src/astrom
- Files:
-
- 3 edited
-
pmConcepts.c (modified) (26 diffs)
-
pmConcepts.h (modified) (1 diff)
-
pmConceptsStandard.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmConcepts.c
r6872 r6895 41 41 pmConceptParseFunc parse, // Function to call to parse the concept 42 42 pmConceptFormatFunc format, // Function to call to format the concept 43 pm ConceptLevel level // Level at which to store concept in the FPA hierarchy43 pmFPALevel level // Level at which to store concept in the FPA hierarchy 44 44 ) 45 45 { … … 52 52 psMetadata **target = NULL; // The metadata of known concepts to write to 53 53 switch (level) { 54 case PM_ CONCEPT_LEVEL_FPA:54 case PM_FPA_LEVEL_FPA: 55 55 target = &conceptsFPA; 56 56 break; 57 case PM_ CONCEPT_LEVEL_CHIP:57 case PM_FPA_LEVEL_CHIP: 58 58 target = &conceptsChip; 59 59 break; 60 case PM_ CONCEPT_LEVEL_CELL:60 case PM_FPA_LEVEL_CELL: 61 61 target = &conceptsCell; 62 62 break; 63 63 default: 64 psError(PS_ERR_IO, true, " Unknownconcept level provided: %d\n", level);64 psError(PS_ERR_IO, true, "Invalid concept level provided: %d\n", level); 65 65 psFree(spec); 66 66 return false; … … 285 285 { 286 286 psMetadataItem *fpaName = psMetadataItemAllocStr("FPA.NAME", "Name of FPA", ""); 287 pmConceptRegister(fpaName, NULL, NULL, PM_ CONCEPT_LEVEL_FPA);287 pmConceptRegister(fpaName, NULL, NULL, PM_FPA_LEVEL_FPA); 288 288 psFree(fpaName); 289 289 } … … 293 293 { 294 294 psMetadataItem *fpaAirmass = psMetadataItemAllocF32("FPA.AIRMASS", "Airmass at boresight", 0.0); 295 pmConceptRegister(fpaAirmass, NULL, NULL, PM_ CONCEPT_LEVEL_FPA);295 pmConceptRegister(fpaAirmass, NULL, NULL, PM_FPA_LEVEL_FPA); 296 296 psFree(fpaAirmass); 297 297 } … … 300 300 { 301 301 psMetadataItem *fpaFilter = psMetadataItemAllocStr("FPA.FILTER", "Filter used", ""); 302 pmConceptRegister(fpaFilter, NULL, NULL, PM_ CONCEPT_LEVEL_FPA);302 pmConceptRegister(fpaFilter, NULL, NULL, PM_FPA_LEVEL_FPA); 303 303 psFree(fpaFilter); 304 304 } … … 308 308 psMetadataItem *fpaPosangle = psMetadataItemAllocF32("FPA.POSANGLE", 309 309 "Position angle of instrument", 0.0); 310 pmConceptRegister(fpaPosangle, NULL, NULL, PM_ CONCEPT_LEVEL_FPA);310 pmConceptRegister(fpaPosangle, NULL, NULL, PM_FPA_LEVEL_FPA); 311 311 psFree(fpaPosangle); 312 312 } … … 316 316 psMetadataItem *fpaRadecsys = psMetadataItemAllocStr("FPA.RADECSYS", 317 317 "Celestial coordinate system", ""); 318 pmConceptRegister(fpaRadecsys, NULL, NULL, PM_ CONCEPT_LEVEL_FPA);318 pmConceptRegister(fpaRadecsys, NULL, NULL, PM_FPA_LEVEL_FPA); 319 319 psFree(fpaRadecsys); 320 320 } … … 324 324 psMetadataItem *fpaRa = psMetadataItemAllocF64("FPA.RA", "Right Ascension of boresight", NAN); 325 325 pmConceptRegister(fpaRa, (pmConceptParseFunc)pmConceptParse_FPA_Coords, 326 (pmConceptFormatFunc)pmConceptFormat_FPA_Coords, PM_ CONCEPT_LEVEL_FPA);326 (pmConceptFormatFunc)pmConceptFormat_FPA_Coords, PM_FPA_LEVEL_FPA); 327 327 psFree(fpaRa); 328 328 } … … 332 332 psMetadataItem *fpaDec = psMetadataItemAllocF64("FPA.DEC", "Declination of boresight", NAN); 333 333 pmConceptRegister(fpaDec, (pmConceptParseFunc)pmConceptParse_FPA_Coords, 334 (pmConceptFormatFunc)pmConceptFormat_FPA_Coords, PM_ CONCEPT_LEVEL_FPA);334 (pmConceptFormatFunc)pmConceptFormat_FPA_Coords, PM_FPA_LEVEL_FPA); 335 335 psFree(fpaDec); 336 336 } … … 352 352 { 353 353 psMetadataItem *cellGain = psMetadataItemAllocF32("CELL.GAIN", "CCD gain (e/count)", NAN); 354 pmConceptRegister(cellGain, NULL, NULL, PM_ CONCEPT_LEVEL_CELL);354 pmConceptRegister(cellGain, NULL, NULL, PM_FPA_LEVEL_CELL); 355 355 psFree(cellGain); 356 356 } … … 360 360 psMetadataItem *cellReadnoise = psMetadataItemAllocF32("CELL.READNOISE", 361 361 "CCD read noise (e)", NAN); 362 pmConceptRegister(cellReadnoise, NULL, NULL, PM_ CONCEPT_LEVEL_CELL);362 pmConceptRegister(cellReadnoise, NULL, NULL, PM_FPA_LEVEL_CELL); 363 363 psFree(cellReadnoise); 364 364 } … … 368 368 psMetadataItem *cellSaturation = psMetadataItemAllocF32("CELL.SATURATION", 369 369 "Saturation level (counts)", NAN); 370 pmConceptRegister(cellSaturation, NULL, NULL, PM_ CONCEPT_LEVEL_CELL);370 pmConceptRegister(cellSaturation, NULL, NULL, PM_FPA_LEVEL_CELL); 371 371 psFree(cellSaturation); 372 372 } … … 375 375 { 376 376 psMetadataItem *cellBad = psMetadataItemAllocF32("CELL.BAD", "Bad level (counts)", NAN); 377 pmConceptRegister(cellBad, NULL, NULL, PM_ CONCEPT_LEVEL_CELL);377 pmConceptRegister(cellBad, NULL, NULL, PM_FPA_LEVEL_CELL); 378 378 psFree(cellBad); 379 379 } … … 383 383 psMetadataItem *cellXparity = psMetadataItemAllocS32("CELL.XPARITY", 384 384 "Orientation in x compared to the rest of the FPA", 0); 385 pmConceptRegister(cellXparity, NULL, NULL, PM_ CONCEPT_LEVEL_CELL);385 pmConceptRegister(cellXparity, NULL, NULL, PM_FPA_LEVEL_CELL); 386 386 psFree(cellXparity); 387 387 } … … 391 391 psMetadataItem *cellYparity = psMetadataItemAllocS32("CELL.YPARITY", 392 392 "Orientation in x compared to the rest of the FPA", 0); 393 pmConceptRegister(cellYparity, NULL, NULL, PM_ CONCEPT_LEVEL_CELL);393 pmConceptRegister(cellYparity, NULL, NULL, PM_FPA_LEVEL_CELL); 394 394 psFree(cellYparity); 395 395 } … … 399 399 psMetadataItem *cellReaddir = psMetadataItemAllocS32("CELL.READDIR", 400 400 "Read direction, rows=1, cols=2", 0); 401 pmConceptRegister(cellReaddir, NULL, NULL, PM_ CONCEPT_LEVEL_CELL);401 pmConceptRegister(cellReaddir, NULL, NULL, PM_FPA_LEVEL_CELL); 402 402 psFree(cellReaddir); 403 403 } … … 414 414 psMetadataItem *cellExposure = psMetadataItemAllocF32("CELL.EXPOSURE", 415 415 "Exposure time (sec)", NAN); 416 pmConceptRegister(cellExposure, NULL, NULL, PM_ CONCEPT_LEVEL_CELL);416 pmConceptRegister(cellExposure, NULL, NULL, PM_FPA_LEVEL_CELL); 417 417 psFree(cellExposure); 418 418 } … … 422 422 psMetadataItem *cellDarktime = psMetadataItemAllocF32("CELL.DARKTIME", 423 423 "Time since flush (sec)", NAN); 424 pmConceptRegister(cellDarktime, NULL, NULL, PM_ CONCEPT_LEVEL_CELL);424 pmConceptRegister(cellDarktime, NULL, NULL, PM_FPA_LEVEL_CELL); 425 425 psFree(cellDarktime); 426 426 } … … 434 434 psFree(trimsec); 435 435 pmConceptRegister(cellTrimsec, (pmConceptParseFunc)pmConceptParse_CELL_TRIMSEC, 436 (pmConceptFormatFunc)pmConceptFormat_CELL_TRIMSEC, PM_ CONCEPT_LEVEL_CELL);436 (pmConceptFormatFunc)pmConceptFormat_CELL_TRIMSEC, PM_FPA_LEVEL_CELL); 437 437 psFree(cellTrimsec); 438 438 } … … 445 445 psFree(biassecs); 446 446 pmConceptRegister(cellBiassec, (pmConceptParseFunc)pmConceptParse_CELL_BIASSEC, 447 (pmConceptFormatFunc)pmConceptFormat_CELL_BIASSEC, PM_ CONCEPT_LEVEL_CELL);447 (pmConceptFormatFunc)pmConceptFormat_CELL_BIASSEC, PM_FPA_LEVEL_CELL); 448 448 psFree(cellBiassec); 449 449 } … … 453 453 psMetadataItem *cellXbin = psMetadataItemAllocS32("CELL.XBIN", "Binning in x", 0); 454 454 pmConceptRegister(cellXbin, (pmConceptParseFunc)pmConceptParse_CELL_Binning, 455 (pmConceptFormatFunc)pmConceptFormat_CELL_XBIN, PM_ CONCEPT_LEVEL_CELL);455 (pmConceptFormatFunc)pmConceptFormat_CELL_XBIN, PM_FPA_LEVEL_CELL); 456 456 psFree(cellXbin); 457 457 } … … 461 461 psMetadataItem *cellYbin = psMetadataItemAllocS32("CELL.YBIN", "Binning in y", 0); 462 462 pmConceptRegister(cellYbin, (pmConceptParseFunc)pmConceptParse_CELL_Binning, 463 (pmConceptFormatFunc)pmConceptFormat_CELL_YBIN, PM_ CONCEPT_LEVEL_CELL);463 (pmConceptFormatFunc)pmConceptFormat_CELL_YBIN, PM_FPA_LEVEL_CELL); 464 464 psFree(cellYbin); 465 465 } … … 469 469 psMetadataItem *cellTimesys = psMetadataItemAllocS32("CELL.TIMESYS", "Time system", -1); 470 470 pmConceptRegister(cellTimesys, (pmConceptParseFunc)pmConceptParse_CELL_TIMESYS, 471 (pmConceptFormatFunc)pmConceptFormat_CELL_TIMESYS, PM_ CONCEPT_LEVEL_CELL);471 (pmConceptFormatFunc)pmConceptFormat_CELL_TIMESYS, PM_FPA_LEVEL_CELL); 472 472 psFree(cellTimesys); 473 473 } … … 483 483 psFree(time); 484 484 pmConceptRegister(cellTime, (pmConceptParseFunc)pmConceptParse_CELL_TIME, 485 (pmConceptFormatFunc)pmConceptFormat_CELL_TIME, PM_ CONCEPT_LEVEL_CELL);485 (pmConceptFormatFunc)pmConceptFormat_CELL_TIME, PM_FPA_LEVEL_CELL); 486 486 psFree(cellTime); 487 487 } … … 491 491 psMetadataItem *cellX0 = psMetadataItemAllocS32("CELL.X0", "Position of (0,0) on the chip", 0); 492 492 pmConceptRegister(cellX0, (pmConceptParseFunc)pmConceptParse_CELL_Positions, 493 (pmConceptFormatFunc)pmConceptFormat_CELL_Positions, PM_ CONCEPT_LEVEL_CELL);493 (pmConceptFormatFunc)pmConceptFormat_CELL_Positions, PM_FPA_LEVEL_CELL); 494 494 psFree(cellX0); 495 495 } … … 499 499 psMetadataItem *cellY0 = psMetadataItemAllocS32("CELL.Y0", "Position of (0,0) on the chip", 0); 500 500 pmConceptRegister(cellY0, (pmConceptParseFunc)pmConceptParse_CELL_Positions, 501 (pmConceptFormatFunc)pmConceptFormat_CELL_Positions, PM_ CONCEPT_LEVEL_CELL);501 (pmConceptFormatFunc)pmConceptFormat_CELL_Positions, PM_FPA_LEVEL_CELL); 502 502 psFree(cellY0); 503 503 } -
trunk/psModules/src/astrom/pmConcepts.h
r6872 r6895 27 27 ); 28 28 29 // Level at which to store a concept in the FPA hierarchy30 typedef enum {31 PM_CONCEPT_LEVEL_FPA, // Store in the FPA32 PM_CONCEPT_LEVEL_CHIP, // Store in the chip33 PM_CONCEPT_LEVEL_CELL // Store in the cell34 } pmConceptLevel;35 36 29 // Register a new concept 37 30 bool pmConceptRegister(psMetadataItem *blank, // Blank value; contains the name 38 31 pmConceptParseFunc parse, // Function to call to parse the concept 39 32 pmConceptFormatFunc format, // Function to call to format the concept 40 pm ConceptLevel level // Level at which to store concept in the FPA hierarchy33 pmFPALevel level // Level at which to store concept in the FPA hierarchy 41 34 ); 42 35 -
trunk/psModules/src/astrom/pmConceptsStandard.c
r6872 r6895 14 14 (a)->y0 == (b)->y0 && \ 15 15 (a)->y1 == (b)->y1) ? true : false) 16 17 #define TYPE_CASE(assign, item, TYPE) \ 18 case PS_TYPE_##TYPE: \ 19 assign = item->data.TYPE; \ 20 break; 21 16 22 17 23 … … 218 224 219 225 int binning = 1; // Binning factor in x 220 if (concept->type == PS_DATA_STRING) { 221 psString binString = concept->data.V; // The string containing the binning 222 if ((strcmp(pattern->name, "CELL.XBIN") == 0 && sscanf(binString, "%d %*d", &binning) != 1 && 223 sscanf(binString, "%d,%*d", &binning) != 1) || 224 (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 && 225 sscanf(binString, "%*d,%d", &binning) != 1)) { 226 psError(PS_ERR_IO, true, "Unable to parse string to get %s: %s\n", pattern->name, binString); 227 } 228 } else if (concept->type == PS_TYPE_S32) { 229 binning = concept->data.S32; 230 } else { 226 switch (concept->type) { 227 case PS_DATA_STRING: { 228 psString binString = concept->data.V; // The string containing the binning 229 if ((strcmp(pattern->name, "CELL.XBIN") == 0 && sscanf(binString, "%d %*d", &binning) != 1 && 230 sscanf(binString, "%d,%*d", &binning) != 1) || 231 (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 && 232 sscanf(binString, "%*d,%d", &binning) != 1)) { 233 psError(PS_ERR_IO, true, "Unable to parse string to get %s: %s\n", pattern->name, binString); 234 } 235 } 236 TYPE_CASE(binning, concept, U8); 237 TYPE_CASE(binning, concept, U16); 238 TYPE_CASE(binning, concept, U32); 239 TYPE_CASE(binning, concept, S8); 240 TYPE_CASE(binning, concept, S16); 241 TYPE_CASE(binning, concept, S32); 242 default: 231 243 psError(PS_ERR_IO, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name, 232 244 concept->type); … … 324 336 double seconds = NAN; 325 337 switch (timeItem->type) { 326 case PS_TYPE_S32: 327 seconds = timeItem->data.S32; 328 break; 329 case PS_TYPE_F32: 330 seconds = timeItem->data.F32; 331 break; 332 case PS_TYPE_F64: 333 seconds = timeItem->data.F64; 334 break; 338 TYPE_CASE(seconds, timeItem, U8); 339 TYPE_CASE(seconds, timeItem, U16); 340 TYPE_CASE(seconds, timeItem, U32); 341 TYPE_CASE(seconds, timeItem, S8); 342 TYPE_CASE(seconds, timeItem, S16); 343 TYPE_CASE(seconds, timeItem, S32); 344 TYPE_CASE(seconds, timeItem, F32); 345 TYPE_CASE(seconds, timeItem, F64); 335 346 default: 336 347 psError(PS_ERR_IO, true, "Time is not of an expected type: %x\n", timeItem->type); … … 424 435 assert(cameraFormat); 425 436 426 if (concept->type != PS_TYPE_S32) { 427 psError(PS_ERR_IO, true, "Concept %s is not of type S32, as expected.\n", pattern->name); 437 int offset = 0; // Offset of cell (0,0) corner from the chip (0,0) corner 438 439 switch (concept->type) { 440 TYPE_CASE(offset, concept, U8); 441 TYPE_CASE(offset, concept, U16); 442 TYPE_CASE(offset, concept, U32); 443 TYPE_CASE(offset, concept, S8); 444 TYPE_CASE(offset, concept, S16); 445 TYPE_CASE(offset, concept, S32); 446 default: 447 psError(PS_ERR_IO, true, "Concept %s is not of integer type, as expected.\n", pattern->name); 428 448 return NULL; 429 449 } 430 int offset = concept->data.S32;431 450 offset -= fortranCorr(cameraFormat, pattern->name); 432 451 return psMetadataItemAllocS32(pattern->name, pattern->comment, offset);
Note:
See TracChangeset
for help on using the changeset viewer.
