IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 12, 2007, 12:22:15 PM (19 years ago)
Author:
Paul Price
Message:

Adding fix to bug 853: when CELL.BIASSEC or CELL.TRIMSEC are specified by value in the CELLS part of the camera format, then they need to be updated by the binning. Added pmConceptsUpdate, which is run after concepts are read, and seaches for concepts to update (e.g., dependent on other concepts, which may not be available at read time --- just like CELL.TRIMSEC and CELL.XBIN/CELL.YBIN). To use this, changed the functions that parse/format standard concepts to receive the source of the concept. CELL.TRIMSEC and CELL.BIASSEC are updated for the binning if CELL.TRIMSEC.UPDATE or CELL.BIASSEC.UPDATE are set. Tested this quickly, and it seems to work.

File:
1 edited

Legend:

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

    r11687 r11749  
    4747psMetadataItem *p_pmConceptParse_FPA_FILTER(const psMetadataItem *concept,
    4848        const psMetadataItem *pattern,
     49                                            pmConceptSource source,
    4950        const psMetadata *cameraFormat,
    5051        const pmFPA *fpa,
     
    8283
    8384psMetadataItem *p_pmConceptFormat_FPA_FILTER(const psMetadataItem *concept,
     85                                            pmConceptSource source,
    8486        const psMetadata *cameraFormat,
    8587        const pmFPA *fpa,
     
    133135psMetadataItem *p_pmConceptParse_FPA_Coords(const psMetadataItem *concept,
    134136        const psMetadataItem *pattern,
     137                                            pmConceptSource source,
    135138        const psMetadata *cameraFormat,
    136139        const pmFPA *fpa,
     
    202205// FPA.RA and FPA.DEC
    203206psMetadataItem *p_pmConceptFormat_FPA_Coords(const psMetadataItem *concept,
     207                                            pmConceptSource source,
    204208        const psMetadata *cameraFormat,
    205209        const pmFPA *fpa,
     
    264268psMetadataItem *p_pmConceptParse_CELL_TRIMSEC(const psMetadataItem *concept,
    265269        const psMetadataItem *pattern,
     270                                            pmConceptSource source,
    266271        const psMetadata *cameraFormat,
    267272        const pmFPA *fpa,
     
    277282    if (concept->type != PS_DATA_STRING) {
    278283        psError(PS_ERR_UNKNOWN, true, "CELL.TRIMSEC after read is not of type STR (%x)\n", concept->type);
     284        return NULL;
    279285    } else {
    280286        *trimsec = psRegionFromString(concept->data.V);
     287    }
     288
     289    // Need to correct for binning when CELL.TRIMSEC are specified immutably in the CELLS
     290    if (source == PM_CONCEPT_SOURCE_CELLS) {
     291        psMetadataAddBool(cell->concepts, PS_LIST_TAIL, "CELL.TRIMSEC.UPDATE", 0,
     292                          "Need to update CELL.TRIMSEC when the binning is available.",
     293                          true);
    281294    }
    282295
     
    288301psMetadataItem *p_pmConceptParse_CELL_BIASSEC(const psMetadataItem *concept,
    289302        const psMetadataItem *pattern,
     303                                            pmConceptSource source,
    290304        const psMetadata *cameraFormat,
    291305        const pmFPA *fpa,
     
    336350    }
    337351
     352    // Need to correct for binning when CELL.BIASSEC are specified immutably in the CELLS
     353    if (source == PM_CONCEPT_SOURCE_CELLS) {
     354        psMetadataAddBool(cell->concepts, PS_LIST_TAIL, "CELL.BIASSEC.UPDATE", 0,
     355                          "Need to update CELL.BIASSEC when the binning is available.",
     356                          true);
     357    }
     358
    338359    psMetadataItem *item = psMetadataItemAllocPtr(pattern->name, PS_DATA_LIST, pattern->comment, biassecs);
    339360    psFree(biassecs);               // Drop reference
     
    344365psMetadataItem *p_pmConceptParse_CELL_Binning(const psMetadataItem *concept,
    345366        const psMetadataItem *pattern,
     367                                            pmConceptSource source,
    346368        const psMetadata *cameraFormat,
    347369        const pmFPA *fpa,
     
    381403psMetadataItem *p_pmConceptParse_TIMESYS(const psMetadataItem *concept,
    382404        const psMetadataItem *pattern,
     405                                            pmConceptSource source,
    383406        const psMetadata *cameraFormat,
    384407        const pmFPA *fpa,
     
    410433psMetadataItem *p_pmConceptParse_TIME(const psMetadataItem *concept,
    411434                                      const psMetadataItem *pattern,
     435                                            pmConceptSource source,
    412436                                      const psMetadata *cameraFormat,
    413437                                      const pmFPA *fpa,
     
    663687psMetadataItem *p_pmConceptParse_Positions(const psMetadataItem *concept,
    664688        const psMetadataItem *pattern,
     689                                            pmConceptSource source,
    665690        const psMetadata *cameraFormat,
    666691        const pmFPA *fpa,
     
    718743
    719744psMetadataItem *p_pmConceptFormat_CELL_TRIMSEC(const psMetadataItem *concept,
    720         const psMetadata *cameraFormat,
    721         const pmFPA *fpa,
    722         const pmChip *chip,
    723         const pmCell *cell)
    724 {
    725     assert(concept);
    726 
    727     psRegion *trimsec = concept->data.V; // The trimsec region
     745                                            pmConceptSource source,
     746        const psMetadata *cameraFormat,
     747        const pmFPA *fpa,
     748        const pmChip *chip,
     749        const pmCell *cell)
     750{
     751    assert(concept);
     752
     753    psRegion *trimsec = psMemIncrRefCounter(concept->data.V); // The trimsec region
     754
     755    // Correct trim section for binning if it's specified explicitly (i.e., immutably) in the CELLS.
     756    if (source == PM_CONCEPT_SOURCE_CELLS) {
     757        bool xStatus, yStatus;          // Status of MD lookups
     758        int xBin = psMetadataLookupS32(&xStatus, cell->concepts, "CELL.XBIN");
     759        int yBin = psMetadataLookupS32(&yStatus, cell->concepts, "CELL.YBIN");
     760        if (!xStatus || !yStatus || xBin == 0 || yBin == 0) {
     761            psWarning("Unable to find CELL.XBIN and CELL.YBIN to correct CELL.TRIMSEC.\n");
     762            return psMemIncrRefCounter((psPtr)concept); // Casting away "const" to increment
     763        }
     764        psRegion *newTrimsec = psRegionAlloc(trimsec->x0 * xBin, trimsec->x1 * xBin,
     765                                             trimsec->y0 * yBin, trimsec->y1 * yBin); // Adjusted for binning
     766        psFree(trimsec);
     767        trimsec = newTrimsec;
     768    }
     769
    728770    psString trimsecString = psRegionToString(*trimsec);
     771    psFree(trimsec);
    729772    psMetadataItem *formatted = psMetadataItemAllocStr(concept->name, concept->comment,
    730773                                trimsecString);
     
    734777
    735778psMetadataItem *p_pmConceptFormat_CELL_BIASSEC(const psMetadataItem *concept,
     779                                            pmConceptSource source,
    736780        const psMetadata *cameraFormat,
    737781        const pmFPA *fpa,
     
    745789    psList *new = psListAlloc(NULL);    // New list containing metadatas
    746790    while ((region = psListGetAndIncrement(biassecsIter))) {
     791
     792        // Correct bias section for binning if it's specified explicitly (i.e., immutably) in the CELLS.
     793        if (source == PM_CONCEPT_SOURCE_CELLS) {
     794            bool xStatus, yStatus;          // Status of MD lookups
     795            int xBin = psMetadataLookupS32(&xStatus, cell->concepts, "CELL.XBIN");
     796            int yBin = psMetadataLookupS32(&yStatus, cell->concepts, "CELL.YBIN");
     797            if (!xStatus || !yStatus || xBin == 0 || yBin == 0) {
     798                psWarning("Unable to find CELL.XBIN and CELL.YBIN to correct CELL.BIASSEC.\n");
     799            } else {
     800                psRegion *newTrimsec = psRegionAlloc(region->x0 * xBin, region->x1 * xBin,
     801                                                     region->y0 * yBin, region->y1 * yBin);
     802                region = newTrimsec;
     803            }
     804        } else {
     805            psMemIncrRefCounter(region);
     806        }
     807
    747808        psString regionString = psRegionToString(*region); // The string region "[x0:x1,y0:y1]"
     809        psFree(region);
    748810        psMetadataItem *item = psMetadataItemAllocStr(concept->name, concept->comment, regionString);
    749811        psFree(regionString);           // Drop reference
     
    760822// same header.
    761823psMetadataItem *p_pmConceptFormat_CELL_XBIN(const psMetadataItem *concept,
     824                                            pmConceptSource source,
    762825        const psMetadata *cameraFormat,
    763826        const pmFPA *fpa,
     
    787850// Only need to format if both if CELL.XBIN and CELL.YBIN are not specified by the same header.
    788851psMetadataItem *p_pmConceptFormat_CELL_YBIN(const psMetadataItem *concept,
     852                                            pmConceptSource source,
    789853        const psMetadata *cameraFormat,
    790854        const pmFPA *fpa,
     
    810874
    811875psMetadataItem *p_pmConceptFormat_TIMESYS(const psMetadataItem *concept,
     876                                            pmConceptSource source,
    812877        const psMetadata *cameraFormat,
    813878        const pmFPA *fpa,
     
    839904
    840905psMetadataItem *p_pmConceptFormat_TIME(const psMetadataItem *concept,
     906                                            pmConceptSource source,
    841907                                       const psMetadata *cameraFormat,
    842908                                       const pmFPA *fpa,
     
    9731039
    9741040psMetadataItem *p_pmConceptFormat_Positions(const psMetadataItem *concept,
     1041                                            pmConceptSource source,
    9751042        const psMetadata *cameraFormat,
    9761043        const pmFPA *fpa,
     
    10421109}
    10431110
     1111
Note: See TracChangeset for help on using the changeset viewer.