IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9510


Ignore:
Timestamp:
Oct 12, 2006, 11:38:28 AM (20 years ago)
Author:
Paul Price
Message:

Adding FPA.TIME, FPA.TIMESYS. Genericized the parse and format functions for CELL.TIME and CELL.TIMESYS so that they can be used for the FPA versions as well.

Location:
trunk/psModules/src/concepts
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/pmConcepts.c

    r9216 r9510  
    153153    }
    154154
     155    if (source & PM_CONCEPT_SOURCE_PHU && !(*read & PM_CONCEPT_SOURCE_PHU)) {
     156        if (!pmConceptsReadFromHeader(*specs, fpa, chip, cell, target)) {
     157            psError(PS_ERR_UNKNOWN, false, "Error reading concepts from header.\n");
     158            success = false;
     159        }
     160    }
     161
    155162    if (source & PM_CONCEPT_SOURCE_HEADER && !(*read & PM_CONCEPT_SOURCE_HEADER)) {
    156163        if (pmConceptsReadFromHeader(*specs, fpa, chip, cell, target)) {
     
    201208        pmConceptsWriteToDefaults(*specs, fpa, chip, cell, concepts);
    202209    }
    203     if (source & PM_CONCEPT_SOURCE_HEADER) {
     210    if (source & (PM_CONCEPT_SOURCE_PHU | PM_CONCEPT_SOURCE_HEADER)) {
    204211        pmConceptsWriteToHeader(*specs, fpa, chip, cell, concepts);
    205212    }
     
    218225    psTrace("psModules.concepts", 5, "Blanking FPA concepts: %p %p\n", conceptsFPA, fpa->concepts);
    219226    return conceptsBlank(&conceptsFPA, fpa->concepts);
     227}
     228
     229// Read the concepts for the given set of fpa, chip, cell
     230bool pmConceptsRead(pmFPA *fpa,         // FPA for which to read concepts
     231                    pmChip *chip,       // Chip for which to read concepts, or NULL
     232                    pmCell *cell,       // Cell for which to read concepts, or NULL
     233                    pmConceptSource source, // The source of the concepts to read
     234                    psDB *db            // Database handle
     235                   )
     236{
     237    PS_ASSERT_PTR_NON_NULL(fpa, false);
     238    bool success = conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, db, fpa->concepts);
     239    if (chip) {
     240        success |= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, db, chip->concepts);
     241    }
     242    if (cell) {
     243        success |= conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source, db, cell->concepts);
     244    }
     245
     246    return success;
    220247}
    221248
     
    501528        }
    502529
     530        // FPA.TIMESYS
     531        {
     532            psMetadataItem *fpaTimesys = psMetadataItemAllocS32("FPA.TIMESYS", "Time system", -1);
     533            pmConceptRegister(fpaTimesys, (pmConceptParseFunc)p_pmConceptParse_TIMESYS,
     534                              (pmConceptFormatFunc)p_pmConceptFormat_TIMESYS, PM_FPA_LEVEL_FPA);
     535            psFree(fpaTimesys);
     536        }
     537
     538        // FPA.TIME
     539        {
     540            psTime *time = psTimeAlloc(PS_TIME_TAI); // Blank time
     541            // Not particularly distinguishing, but should be good enough
     542            time->sec = 0;
     543            time->nsec = 0;
     544            psMetadataItem *fpaTime = psMetadataItemAlloc("FPA.TIME", PS_DATA_TIME,
     545                                      "Time of exposure", time);
     546            psFree(time);
     547            pmConceptRegister(fpaTime, (pmConceptParseFunc)p_pmConceptParse_TIME,
     548                              (pmConceptFormatFunc)p_pmConceptFormat_TIME, PM_FPA_LEVEL_FPA);
     549            psFree(fpaTime);
     550        }
     551
    503552        // Done with FPA level concepts
    504553    }
     
    675724        {
    676725            psMetadataItem *cellTimesys = psMetadataItemAllocS32("CELL.TIMESYS", "Time system", -1);
    677             pmConceptRegister(cellTimesys, (pmConceptParseFunc)p_pmConceptParse_CELL_TIMESYS,
    678                               (pmConceptFormatFunc)p_pmConceptFormat_CELL_TIMESYS, PM_FPA_LEVEL_CELL);
     726            pmConceptRegister(cellTimesys, (pmConceptParseFunc)p_pmConceptParse_TIMESYS,
     727                              (pmConceptFormatFunc)p_pmConceptFormat_TIMESYS, PM_FPA_LEVEL_CELL);
    679728            psFree(cellTimesys);
    680729        }
     
    689738                                       "Time of exposure", time);
    690739            psFree(time);
    691             pmConceptRegister(cellTime, (pmConceptParseFunc)p_pmConceptParse_CELL_TIME,
    692                               (pmConceptFormatFunc)p_pmConceptFormat_CELL_TIME, PM_FPA_LEVEL_CELL);
     740            pmConceptRegister(cellTime, (pmConceptParseFunc)p_pmConceptParse_TIME,
     741                              (pmConceptFormatFunc)p_pmConceptFormat_TIME, PM_FPA_LEVEL_CELL);
    693742            psFree(cellTime);
    694743        }
  • trunk/psModules/src/concepts/pmConcepts.h

    r7469 r9510  
    3737    PM_CONCEPT_SOURCE_CAMERA   = 0x01,  // Concept comes from the camera information
    3838    PM_CONCEPT_SOURCE_DEFAULTS = 0x02,  // Concept comes from defaults
    39     PM_CONCEPT_SOURCE_HEADER   = 0x04,  // Concept comes from FITS header
    40     PM_CONCEPT_SOURCE_DATABASE = 0x08,  // Concept comes from database
    41     PM_CONCEPT_SOURCE_ALL      = 0x0e   // All concepts
     39    PM_CONCEPT_SOURCE_PHU      = 0x04,  // Concept comes from PHU
     40    PM_CONCEPT_SOURCE_HEADER   = 0x08,  // Concept comes from FITS header
     41    PM_CONCEPT_SOURCE_DATABASE = 0x10,  // Concept comes from database
     42    PM_CONCEPT_SOURCE_ALL      = 0xff   // All concepts
    4243} pmConceptSource;
     44
     45// Read the concepts for the given set of fpa, chip, cell
     46bool pmConceptsRead(pmFPA *fpa,         // FPA for which to read concepts
     47                    pmChip *chip,       // Chip for which to read concepts, or NULL
     48                    pmCell *cell,       // Cell for which to read concepts, or NULL
     49                    pmConceptSource source, // The source of the concepts to read
     50                    psDB *db            // Database handle
     51                   );
    4352
    4453// Set blanks, read or write concepts at the appropriate level
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r8848 r9510  
    282282
    283283
    284 psMetadataItem *p_pmConceptParse_CELL_TIMESYS(psMetadataItem *concept,
     284psMetadataItem *p_pmConceptParse_TIMESYS(psMetadataItem *concept,
    285285        psMetadataItem *pattern,
    286286        psMetadata *cameraFormat,
     
    295295    psString sys = concept->data.V;     // The time system string
    296296    if (concept->type != PS_DATA_STRING || strlen(sys) <= 0) {
    297         psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
     297        psError(PS_ERR_UNKNOWN, true, "Can't interpret %s --- assuming UTC.\n", pattern->name);
    298298    } else if (strcasecmp(sys, "TAI") == 0) {
    299299        timeSys = PS_TIME_TAI;
     
    305305        timeSys = PS_TIME_TT;
    306306    } else {
    307         psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
     307        psError(PS_ERR_UNKNOWN, true, "Can't interpret %s --- assuming UTC.\n", pattern->name);
    308308    }
    309309
     
    311311}
    312312
    313 psMetadataItem *p_pmConceptParse_CELL_TIME(psMetadataItem *concept,
    314         psMetadataItem *pattern,
    315         psMetadata *cameraFormat,
    316         pmFPA *fpa,
    317         pmChip *chip,
    318         pmCell *cell)
     313psMetadataItem *p_pmConceptParse_TIME(psMetadataItem *concept,
     314                                      psMetadataItem *pattern,
     315                                      psMetadata *cameraFormat,
     316                                      pmFPA *fpa,
     317                                      pmChip *chip,
     318                                      pmCell *cell)
    319319{
    320320    assert(concept);
    321321    assert(cameraFormat);
    322     assert(cell);
    323 
    324     // Need CELL.TIMESYS first
    325     bool mdok = true;                  // Result of MD lookup
    326     psTimeType timeSys = psMetadataLookupS32(&mdok, cell->concepts, "CELL.TIMESYS"); // The time system
     322
     323    // Need TIMESYS first
     324    psString timesysName = psStringCopy(pattern->name); // e.g., "CELL.TIME" --> "CELL.TIMESYS"
     325    timesysName = psStringSubstitute(timesysName, "TIMESYS", "TIME");
     326    bool mdok = false;                  // Result of MD lookup
     327    psTimeType timeSys;                 // The time system
     328    if (cell) {
     329        timeSys = psMetadataLookupS32(&mdok, cell->concepts, timesysName);
     330    }
     331    if (!mdok && chip) {
     332        timeSys = psMetadataLookupS32(&mdok, chip->concepts, timesysName);
     333    }
     334    if (!mdok && fpa) {
     335        timeSys = psMetadataLookupS32(&mdok, fpa->concepts, timesysName);
     336    }
    327337    if (!mdok) {
    328         psLogMsg(__func__, PS_LOG_WARN, "Unable to find CELL.TIMESYS in concepts --- assuming UTC.\n");
     338        psLogMsg(__func__, PS_LOG_WARN, "Unable to find %s in concepts when parsing %s --- assuming UTC.\n",
     339                 timesysName, pattern->name);
    329340        timeSys = PS_TIME_UTC;
    330341    }
     342    psFree(timesysName);
    331343
    332344    // Work out how the time is represented
     
    344356    }
    345357
    346     psString timeFormat = psMetadataLookupStr(&mdok, formats, "CELL.TIME");
     358    psString timeFormat = psMetadataLookupStr(&mdok, formats, pattern->name);
    347359    if (!mdok || strlen(timeFormat) == 0) {
    348         psError(PS_ERR_UNKNOWN, true, "Unable to find CELL.TIME in FORMATS.\n");
     360        psError(PS_ERR_UNKNOWN, true, "Unable to find %s in FORMATS.\n", pattern->name);
    349361        return NULL;
    350362    }
     
    377389            usaTime = false;
    378390        } else {
    379             psError(PS_ERR_UNKNOWN, true, "Unrecognised FORMATS option for CELL.TIME: %s --- "
    380                     "ignored.\n", timeFormat);
     391            psError(PS_ERR_UNKNOWN, true, "Unrecognised FORMATS option for %s: %s --- "
     392                    "ignored.\n", pattern->name, timeFormat);
    381393            psFree(timeFormatsIter);
    382394            psFree(timeFormats);
     
    481493                time = psTimeFromMJD(timeValue);
    482494            } else {
    483                 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n",
    484                         timeValue);
     495                psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
     496                        pattern->name, timeValue);
    485497                time = psTimeFromJD(timeValue);
    486498            }
     
    494506                time = psTimeFromMJD(timeValue);
    495507            } else {
    496                 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n",
    497                         timeValue);
     508                psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
     509                        pattern->name, timeValue);
    498510                time = psTimeFromJD(timeValue);
    499511            }
     
    501513        }
    502514    default:
    503         psError(PS_ERR_UNKNOWN, true, "Unable to parse CELL.TIME.\n");
     515        psError(PS_ERR_UNKNOWN, true, "Unable to parse %s.\n", pattern->name);
    504516        return NULL;
    505517    }
     
    652664
    653665
    654 psMetadataItem *p_pmConceptFormat_CELL_TIMESYS(psMetadataItem *concept,
     666psMetadataItem *p_pmConceptFormat_TIMESYS(psMetadataItem *concept,
    655667        psMetadata *cameraFormat,
    656668        pmFPA *fpa,
     
    681693}
    682694
    683 psMetadataItem *p_pmConceptFormat_CELL_TIME(psMetadataItem *concept,
    684         psMetadata *cameraFormat,
    685         pmFPA *fpa,
    686         pmChip *chip,
    687         pmCell *cell)
     695psMetadataItem *p_pmConceptFormat_TIME(psMetadataItem *concept,
     696                                       psMetadata *cameraFormat,
     697                                       pmFPA *fpa,
     698                                       pmChip *chip,
     699                                       pmCell *cell)
    688700{
    689701    psTime *time = concept->data.V;     // The time
     
    700712    psMetadata *formats = psMetadataLookupMD(&mdok, cameraFormat, "FORMATS"); // The formats
    701713    if (mdok && formats) {
    702         psString format = psMetadataLookupStr(&mdok, formats, "CELL.TIME"); // The formats for CELL.TIME
     714        psString format = psMetadataLookupStr(&mdok, formats, concept->name); // The formats for eg, CELL.TIME
    703715        if (mdok && format && strlen(format) > 0) {
    704716            psList *formatList = psStringSplit(format, " ,;", false); // List of formats specified
     
    732744                    separateTime = false;
    733745                } else {
    734                     psLogMsg(__func__, PS_LOG_WARN, "Unrecognised FORMATS option for CELL.TIME: %s --- "
    735                              "ignored.\n", format);
     746                    psLogMsg(__func__, PS_LOG_WARN, "Unrecognised FORMATS option for %s: %s --- "
     747                             "ignored.\n", concept->name, format);
    736748                }
    737749            }
  • trunk/psModules/src/concepts/pmConceptsStandard.h

    r7441 r9510  
    3636        pmChip *chip,
    3737        pmCell *cell);
    38 psMetadataItem *p_pmConceptParse_CELL_TIMESYS(psMetadataItem *concept,
     38psMetadataItem *p_pmConceptParse_TIMESYS(psMetadataItem *concept,
    3939        psMetadataItem *pattern,
    4040        psMetadata *cameraFormat,
     
    4242        pmChip *chip,
    4343        pmCell *cell);
    44 psMetadataItem *p_pmConceptParse_CELL_TIME(psMetadataItem *concept,
    45         psMetadataItem *pattern,
    46         psMetadata *cameraFormat,
    47         pmFPA *fpa,
    48         pmChip *chip,
    49         pmCell *cell);
     44psMetadataItem *p_pmConceptParse_TIME(psMetadataItem *concept,
     45                                      psMetadataItem *pattern,
     46                                      psMetadata *cameraFormat,
     47                                      pmFPA *fpa,
     48                                      pmChip *chip,
     49                                      pmCell *cell);
    5050psMetadataItem *p_pmConceptParse_Positions(psMetadataItem *concept,
    5151        psMetadataItem *pattern,
     
    7474        pmChip *chip,
    7575        pmCell *cell);
    76 psMetadataItem *p_pmConceptFormat_CELL_TIMESYS(psMetadataItem *concept,
     76psMetadataItem *p_pmConceptFormat_TIMESYS(psMetadataItem *concept,
    7777        psMetadata *cameraFormat,
    7878        pmFPA *fpa,
    7979        pmChip *chip,
    8080        pmCell *cell);
    81 psMetadataItem *p_pmConceptFormat_CELL_TIME(psMetadataItem *concept,
    82         psMetadata *cameraFormat,
    83         pmFPA *fpa,
    84         pmChip *chip,
    85         pmCell *cell);
     81psMetadataItem *p_pmConceptFormat_TIME(psMetadataItem *concept,
     82                                       psMetadata *cameraFormat,
     83                                       pmFPA *fpa,
     84                                       pmChip *chip,
     85                                       pmCell *cell);
    8686psMetadataItem *p_pmConceptFormat_Positions(psMetadataItem *concept,
    8787        psMetadata *cameraFormat,
Note: See TracChangeset for help on using the changeset viewer.