IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11749


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.

Location:
trunk/psModules/src/concepts
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/Makefile.am

    r8990 r11749  
    99        pmConceptsWrite.c \
    1010        pmConceptsStandard.c \
    11         pmConceptsPhotcode.c
     11        pmConceptsPhotcode.c \
     12        pmConceptsUpdate.c
    1213
    1314pkginclude_HEADERS = \
     
    1718        pmConceptsWrite.h \
    1819        pmConceptsStandard.h \
    19         pmConceptsPhotcode.h
     20        pmConceptsPhotcode.h \
     21        pmConceptsUpdate.h
    2022
    2123CLEANFILES = *~
  • trunk/psModules/src/concepts/pmConcepts.c

    r11284 r11749  
    1313#include "pmConceptsWrite.h"
    1414#include "pmConceptsStandard.h"
     15#include "pmConceptsUpdate.h"
    1516
    1617static bool conceptsInitialised = false;// Have concepts been read?
     
    222223    #endif
    223224
     225    pmConceptsUpdate(fpa, chip, cell);
     226
    224227    return success;
    225228}
     
    486489        {
    487490            psMetadataItem *fpaFilterid = psMetadataItemAllocStr("FPA.FILTERID",
    488                                           "Filter used (parsed, abstract name) ", "");
     491                                                                 "Filter used (parsed, abstract name) ", "");
    489492            pmConceptRegister(fpaFilterid, (pmConceptParseFunc)p_pmConceptParse_FPA_FILTER,
    490493                              (pmConceptFormatFunc)p_pmConceptFormat_FPA_FILTER, PM_FPA_LEVEL_FPA);
  • trunk/psModules/src/concepts/pmConcepts.h

    r11253 r11749  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-01-24 02:54:14 $
     6 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-02-12 22:22:15 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    1919#include "pmFPALevel.h"
    2020
     21/// Source for concepts when reading and writing.
     22///
     23/// Since some sources become available at different times from others, we need to provide some specificity to
     24/// reading and writing concepts (or we're forced to wait until everything's available, which we don't want to
     25/// do).  Concepts may be read from or written to multiple sources at once by OR-ing them.
     26typedef enum {
     27    PM_CONCEPT_SOURCE_NONE     = 0x00,  ///< No concepts
     28    PM_CONCEPT_SOURCE_CELLS    = 0x01,  ///< Concept comes from the camera information
     29    PM_CONCEPT_SOURCE_DEFAULTS = 0x02,  ///< Concept comes from defaults
     30    PM_CONCEPT_SOURCE_PHU      = 0x04,  ///< Concept comes from PHU
     31    PM_CONCEPT_SOURCE_HEADER   = 0x08,  ///< Concept comes from FITS header
     32    PM_CONCEPT_SOURCE_DATABASE = 0x10,  ///< Concept comes from database
     33    PM_CONCEPT_SOURCE_ALL      = 0xff   ///< All concepts
     34} pmConceptSource;
     35
    2136/// Function to call to parse a concept once it has been read
    2237typedef psMetadataItem* (*pmConceptParseFunc)(const psMetadataItem *concept, ///< Concept to parse
    2338        const psMetadataItem *pattern, ///< Pattern for parsing
     39                                              pmConceptSource source, ///< Source of concept
    2440        const psMetadata *cameraFormat, ///< Camera format definition
    2541        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    3046/// Function to call to format a concept for writing
    3147typedef psMetadataItem* (*pmConceptFormatFunc)(const psMetadataItem *concept, ///< Concept to format
     48                                               pmConceptSource source, ///< Source of concept
    3249        const psMetadata *cameraFormat, ///< Camera format definition
    3350        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    6582                       pmFPALevel level ///< Level at which to store concept in the FPA hierarchy
    6683                      );
    67 
    68 /// Source for concepts when reading and writing.
    69 ///
    70 /// Since some sources become available at different times from others, we need to provide some specificity to
    71 /// reading and writing concepts (or we're forced to wait until everything's available, which we don't want to
    72 /// do).  Concepts may be read from or written to multiple sources at once by OR-ing them.
    73 typedef enum {
    74     PM_CONCEPT_SOURCE_NONE     = 0x00,  ///< No concepts
    75     PM_CONCEPT_SOURCE_CELLS    = 0x01,  ///< Concept comes from the camera information
    76     PM_CONCEPT_SOURCE_DEFAULTS = 0x02,  ///< Concept comes from defaults
    77     PM_CONCEPT_SOURCE_PHU      = 0x04,  ///< Concept comes from PHU
    78     PM_CONCEPT_SOURCE_HEADER   = 0x08,  ///< Concept comes from FITS header
    79     PM_CONCEPT_SOURCE_DATABASE = 0x10,  ///< Concept comes from database
    80     PM_CONCEPT_SOURCE_ALL      = 0xff   ///< All concepts
    81 } pmConceptSource;
    8284
    8385/// Get a list of defined concepts for a particular level.
  • trunk/psModules/src/concepts/pmConceptsRead.c

    r11404 r11749  
    5353static bool conceptParse(pmConceptSpec *spec, // The concept specification
    5454                         psMetadataItem *concept, // The concept to parse
     55                         pmConceptSource source, // The concept source
    5556                         psMetadata *cameraFormat, // The camera format
    5657                         psMetadata *target, // The target
     
    7172    psMetadataItem *parsed = NULL;  // The parsed concept
    7273    if (spec->parse) {
    73         parsed = spec->parse(concept, spec->blank, cameraFormat, fpa, chip, cell);
     74        parsed = spec->parse(concept, spec->blank, source, cameraFormat, fpa, chip, cell);
    7475    } else {
    7576        parsed = parsePlain(concept, spec->blank);
     
    144145                psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source
    145146                psFree(nameSource);
    146                 if (mdok && strlen(source) > 0 && strcasecmp(source, "VALUE") == 0) {
    147                     if (!conceptParse(spec, conceptItem, cameraFormat, target, NULL, NULL, cell)) {
     147                if (mdok && source && strlen(source) > 0 && strcasecmp(source, "VALUE") == 0) {
     148                    if (!conceptParse(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS,
     149                                      cameraFormat, target, NULL, NULL, cell)) {
    148150                        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from camera "
    149151                                "configuration\n", name);
     
    158160            } else {
    159161                // Another type --- should be OK
    160                 if (!conceptParse(spec, conceptItem, cameraFormat, target, NULL, NULL, cell)) {
     162                if (!conceptParse(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS,
     163                                  cameraFormat, target, NULL, NULL, cell)) {
    161164                    psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from camera "
    162165                            "configuration.\n", name);
     
    241244            // Now we can parse this as we would ordinarily
    242245        }
    243         if (conceptItem && !conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell)) {
     246        if (conceptItem && !conceptParse(spec, conceptItem, PM_CONCEPT_SOURCE_DEFAULTS,
     247                                         cameraFormat, target, fpa, chip, cell)) {
    244248            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from DEFAULTS.\n", name);
    245249            status = false;
     
    340344        // This will also clean up the name
    341345        if (headerItem) {
    342             if (!conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell)) {
     346            if (!conceptParse(spec, headerItem, PM_CONCEPT_SOURCE_HEADER,
     347                              cameraFormat, target, fpa, chip, cell)) {
    343348                psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from header.\n", name);
    344349                status = false;
     
    459464
    460465                    // Now we have the result
    461                     if (!conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell)) {
     466                    if (!conceptParse(spec, conceptItem, PM_CONCEPT_SOURCE_DATABASE,
     467                                      cameraFormat, target, fpa, chip, cell)) {
    462468                        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from database.\n",
    463469                                name);
  • 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
  • trunk/psModules/src/concepts/pmConceptsStandard.h

    r11253 r11749  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-01-24 02:54:15 $
     6 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-02-12 22:22:15 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    1717#include <pslib.h>
    1818#include "pmFPA.h"
     19#include "pmConcepts.h"
    1920
    2021/// Parse the FPA.FILTER concept to apply a lookup table
    2122psMetadataItem *p_pmConceptParse_FPA_FILTER(const psMetadataItem *concept, ///< Concept to parse
    2223        const psMetadataItem *pattern, ///< Pattern to use in parsing
     24                                            pmConceptSource source, ///< Source for concept
    2325        const psMetadata *cameraFormat, ///< Camera format definition
    2426        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    2931/// Format the FPA.FILTER concept to (reverse-)apply a lookup table
    3032psMetadataItem *p_pmConceptFormat_FPA_FILTER(const psMetadataItem *concept, ///< Concept to format
     33                                            pmConceptSource source, ///< Source for concept
    3134        const psMetadata *cameraFormat, ///< Camera format definition
    3235        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    3841psMetadataItem *p_pmConceptParse_FPA_Coords(const psMetadataItem *concept, ///< Concept to parse
    3942        const psMetadataItem *pattern, ///< Pattern to use in parsing
     43                                            pmConceptSource source, ///< Source for concept
    4044        const psMetadata *cameraFormat, ///< Camera format definition
    4145        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    4650/// Format the coordinates concepts: FPA.RA and FPA.DEC
    4751psMetadataItem *p_pmConceptFormat_FPA_Coords(const psMetadataItem *concept, ///< Concept to format
     52                                            pmConceptSource source, ///< Source for concept
    4853        const psMetadata *cameraFormat, ///< Camera format definition
    4954        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    5560psMetadataItem *p_pmConceptParse_CELL_TRIMSEC(const psMetadataItem *concept, ///< Concept to parse
    5661        const psMetadataItem *pattern, ///< Pattern to use in parsing
     62                                            pmConceptSource source, ///< Source for concept
    5763        const psMetadata *cameraFormat, ///< Camera format definition
    5864        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    6470psMetadataItem *p_pmConceptParse_CELL_BIASSEC(const psMetadataItem *concept, ///< Concept to parse
    6571        const psMetadataItem *pattern, ///< Pattern to use in parsing
     72                                            pmConceptSource source, ///< Source for concept
    6673        const psMetadata *cameraFormat, ///< Camera format definition
    6774        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    7380psMetadataItem *p_pmConceptParse_CELL_Binning(const psMetadataItem *concept, ///< Concept to parse
    7481        const psMetadataItem *pattern, ///< Pattern to use in parsing
     82                                            pmConceptSource source, ///< Source for concept
    7583        const psMetadata *cameraFormat, ///< Camera format definition
    7684        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    8290psMetadataItem *p_pmConceptParse_TIMESYS(const psMetadataItem *concept, ///< Concept to parse
    8391        const psMetadataItem *pattern, ///< Pattern to use in parsing
     92                                            pmConceptSource source, ///< Source for concept
    8493        const psMetadata *cameraFormat, ///< Camera format definition
    8594        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    91100psMetadataItem *p_pmConceptParse_TIME(const psMetadataItem *concept, ///< Concept to parse
    92101                                      const psMetadataItem *pattern, ///< Pattern to use in parsing
     102                                            pmConceptSource source, ///< Source for concept
    93103                                      const psMetadata *cameraFormat, ///< Camera format definition
    94104                                      const pmFPA *fpa, ///< FPA for concept, or NULL
     
    100110psMetadataItem *p_pmConceptParse_Positions(const psMetadataItem *concept, ///< Concept to parse
    101111        const psMetadataItem *pattern, ///< Pattern to use in parsing
    102         const psMetadata *cameraFormat, ///< Camera format definition
     112                                            pmConceptSource source, ///< Source for concept
     113       const psMetadata *cameraFormat, ///< Camera format definition
    103114        const pmFPA *fpa, ///< FPA for concept, or NULL
    104115        const pmChip *chip, ///< Chip for concept, or NULL
     
    108119/// Format the CELL.TRIMSEC concept
    109120psMetadataItem *p_pmConceptFormat_CELL_TRIMSEC(const psMetadataItem *concept, ///< Concept to format
     121                                            pmConceptSource source, ///< Source for concept
    110122        const psMetadata *cameraFormat, ///< Camera format definition
    111123        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    116128/// Format the CELL.BIASSEC concept
    117129psMetadataItem *p_pmConceptFormat_CELL_BIASSEC(const psMetadataItem *concept, ///< Concept to format
     130                                            pmConceptSource source, ///< Source for concept
    118131        const psMetadata *cameraFormat, ///< Camera format definition
    119132        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    124137/// Format the CELL.XBIN concept
    125138psMetadataItem *p_pmConceptFormat_CELL_XBIN(const psMetadataItem *concept, ///< Concept to format
     139                                            pmConceptSource source, ///< Source for concept
    126140        const psMetadata *cameraFormat, ///< Camera format definition
    127141        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    132146/// Format the CELL.YBIN concept
    133147psMetadataItem *p_pmConceptFormat_CELL_YBIN(const psMetadataItem *concept, ///< Concept to format
     148                                            pmConceptSource source, ///< Source for concept
    134149        const psMetadata *cameraFormat, ///< Camera format definition
    135150        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    140155/// Format the time system concepts: FPA.TIMESYS and CELL.TIMESYS
    141156psMetadataItem *p_pmConceptFormat_TIMESYS(const psMetadataItem *concept, ///< Concept to format
     157                                            pmConceptSource source, ///< Source for concept
    142158        const psMetadata *cameraFormat, ///< Camera format definition
    143159        const pmFPA *fpa, ///< FPA for concept, or NULL
     
    148164/// Format the time concepts: FPA.TIME and CELL.TIME
    149165psMetadataItem *p_pmConceptFormat_TIME(const psMetadataItem *concept, ///< Concept to format
     166                                            pmConceptSource source, ///< Source for concept
    150167                                       const psMetadata *cameraFormat, ///< Camera format definition
    151168                                       const pmFPA *fpa, ///< FPA for concept, or NULL
     
    156173/// Format a cell position concept, e.g., CELL.X0
    157174psMetadataItem *p_pmConceptFormat_Positions(const psMetadataItem *concept, ///< Concept to format
     175                                            pmConceptSource source, ///< Source for concept
    158176        const psMetadata *cameraFormat, ///< Camera format definition
    159177        const pmFPA *fpa, ///< FPA for concept, or NULL
  • trunk/psModules/src/concepts/pmConceptsWrite.c

    r11257 r11749  
    106106static psMetadataItem *conceptFormat(const pmConceptSpec *spec, // The concept specification
    107107                                     const psMetadataItem *concept, // The concept to parse
     108                                     pmConceptSource source, // The concept source
    108109                                     const psMetadata *cameraFormat, // The camera format
    109110                                     const pmFPA *fpa, // The FPA
     
    118119        psMetadataItem *formatted = NULL;  // The formatted concept
    119120        if (spec->format) {
    120             formatted = spec->format(concept, cameraFormat, fpa, chip, cell);
     121            formatted = spec->format(concept, source, cameraFormat, fpa, chip, cell);
    121122        } else if (strcmp(concept->name, spec->blank->name) != 0) {
    122123            // Adjust so that the name is correct
     
    251252            // Grab the concept
    252253            psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The concept
    253             // Formatted version
    254             psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, NULL, NULL, cell);
    255             if (!formatted) {
    256                 continue;
    257             }
     254
    258255            psString nameSource = NULL; // String with the concept name and ".SOURCE" added
    259256            psStringAppend(&nameSource, "%s.SOURCE", name);
     
    268265                        continue;
    269266                    }
     267
     268                    // Formatted version
     269                    psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER,
     270                                                              cameraFormat, NULL, NULL, cell);
     271                    if (!formatted) {
     272                        continue;
     273                    }
     274
    270275                    psTrace("psModules.concepts", 8, "Writing %s to header %s\n", name, cameraItem->data.str);
    271276                    writeHeader(hdu, cameraItem->data.V, formatted);
     277                    psFree(formatted);
    272278                } else if (strcasecmp(source, "VALUE") == 0) {
     279                    // Formatted version
     280                    psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS,
     281                                                              cameraFormat, NULL, NULL, cell);
     282                    if (!formatted) {
     283                        continue;
     284                    }
     285
    273286                    psTrace("psModules.concepts", 8, "Checking %s against camera format.\n", name);
    274287                    if (! compareConcepts(formatted, cameraItem)) {
     
    276289                                 "format, but the values don't match.\n", name);
    277290                    }
     291                    psFree(formatted);
    278292                } else {
    279293                    psLogMsg(__func__, PS_LOG_WARN, "Concept source %s isn't HEADER or VALUE --- can't "
    280294                             "write\n", nameSource);
    281295                }
    282             } else if (! compareConcepts(formatted, cameraItem)) {
     296            } else {
    283297                // Assume it's specified by value
    284                 psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by value in the camera "
    285                          "format, but the values don't match.\n", name);
    286             }
    287             psFree(formatted);
     298                psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS,
     299                                                          cameraFormat, NULL, NULL, cell);
     300                if (!formatted) {
     301                    continue;
     302                }
     303
     304                if (! compareConcepts(formatted, cameraItem)) {
     305                    psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by value in the camera "
     306                             "format, but the values don't match.\n", name);
     307                }
     308                psFree(formatted);
     309            }
    288310            psFree(nameSource);
    289311        }
     
    346368            }
    347369            conceptItem = psMetadataLookup(concepts, name); // The item from the concepts
    348             psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, fpa, chip, cell);
     370            psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DEFAULTS,
     371                                                      cameraFormat, fpa, chip, cell);
    349372            if (!formatted) {
    350373                continue;
     
    394417            psTrace("psModules.concepts", 3, "Writing %s to header %s\n", name, headerItem->data.str);
    395418            psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts
    396             psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, fpa, chip, cell);
     419            psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER,
     420                                                      cameraFormat, fpa, chip, cell);
    397421            if (!formatted) {
    398422                continue;
     
    446470
    447471            psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts
    448             psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, fpa, chip, cell);
     472            psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DATABASE,
     473                                                      cameraFormat, fpa, chip, cell);
    449474            if (!formatted) {
    450475                continue;
Note: See TracChangeset for help on using the changeset viewer.