IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6580


Ignore:
Timestamp:
Mar 13, 2006, 6:40:37 PM (20 years ago)
Author:
Paul Price
Message:

Compiled, but concept ingest not yet working, so can't read FPA

Location:
branches/rel10_ifa/psModules/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/astrom/pmConcepts.c

    r6575 r6580  
    7676
    7777// Set all registered concepts to blank value for the specified level
    78 static bool conceptsBlank(psMetadata *specs,  // One of the concepts specifications
     78static bool conceptsBlank(psMetadata **specs,  // One of the concepts specifications
    7979                          psMetadata *target // Place to install the concepts
    8080                         )
     
    8383        pmConceptsInit();
    8484    }
    85     psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator on specs
     85    psMetadataIterator *specsIter = psMetadataIteratorAlloc(*specs, PS_LIST_HEAD, NULL); // Iterator on specs
    8686    psMetadataItem *specItem = NULL;    // Item from the specs metadata
    8787    while ((specItem = psMetadataGetAndIncrement(specsIter))) {
     
    9999
    100100// Read all registered concepts for the specified level
    101 static bool conceptsRead(psMetadata *specs, // One of the concepts specifications
     101static bool conceptsRead(psMetadata **specs, // One of the concepts specifications
    102102                         pmFPA *fpa,    // The FPA
    103103                         pmChip *chip,  // The chip
     
    113113
    114114    if (source & PM_CONCEPT_SOURCE_CAMERA || source == PM_CONCEPT_SOURCE_ALL) {
    115         pmConceptsReadFromCamera(specs, cell, target);
     115        pmConceptsReadFromCamera(*specs, cell, target);
    116116    }
    117117    if (source & PM_CONCEPT_SOURCE_DEFAULTS || source == PM_CONCEPT_SOURCE_ALL) {
    118         pmConceptsReadFromDefaults(specs, fpa, chip, cell, target);
     118        pmConceptsReadFromDefaults(*specs, fpa, chip, cell, target);
    119119    }
    120120    if (source & PM_CONCEPT_SOURCE_HEADER || source == PM_CONCEPT_SOURCE_ALL) {
    121         pmConceptsReadFromHeader(specs, fpa, chip, cell, target);
     121        pmConceptsReadFromHeader(*specs, fpa, chip, cell, target);
    122122    }
    123123    if (source & PM_CONCEPT_SOURCE_DATABASE || source == PM_CONCEPT_SOURCE_ALL) {
    124         pmConceptsReadFromDatabase(specs, fpa, chip, cell, db, target);
     124        pmConceptsReadFromDatabase(*specs, fpa, chip, cell, db, target);
    125125    }
    126126
     
    129129
    130130// Write all registered concepts for the specified level
    131 static bool conceptsWrite(psMetadata *specs, // One of the concepts specifications
     131static bool conceptsWrite(psMetadata **specs, // One of the concepts specifications
    132132                          pmFPA *fpa,   // The FPA
    133133                          pmChip *chip, // The chip
     
    143143
    144144    if (source & PM_CONCEPT_SOURCE_CAMERA || source == PM_CONCEPT_SOURCE_ALL) {
    145         pmConceptsWriteToCamera(specs, cell, concepts);
     145        pmConceptsWriteToCamera(*specs, cell, concepts);
    146146    }
    147147    if (source & PM_CONCEPT_SOURCE_DEFAULTS || source == PM_CONCEPT_SOURCE_ALL) {
    148         pmConceptsWriteToDefaults(specs, fpa, chip, cell, concepts);
     148        pmConceptsWriteToDefaults(*specs, fpa, chip, cell, concepts);
    149149    }
    150150    if (source & PM_CONCEPT_SOURCE_HEADER || source == PM_CONCEPT_SOURCE_ALL) {
    151         pmConceptsWriteToHeader(specs, fpa, chip, cell, concepts);
     151        pmConceptsWriteToHeader(*specs, fpa, chip, cell, concepts);
    152152    }
    153153    if (source & PM_CONCEPT_SOURCE_DATABASE || source == PM_CONCEPT_SOURCE_ALL) {
    154         pmConceptsWriteToDatabase(specs, fpa, chip, cell, db, concepts);
     154        pmConceptsWriteToDatabase(*specs, fpa, chip, cell, db, concepts);
    155155    }
    156156
     
    164164{
    165165    psTrace("psModule.concepts", 5, "Blanking FPA concepts: %x %x\n", conceptsFPA, fpa->concepts);
    166     return conceptsBlank(conceptsFPA, fpa->concepts);
     166    return conceptsBlank(&conceptsFPA, fpa->concepts);
    167167}
    168168
     
    174174{
    175175    psTrace("psModule.concepts", 5, "Reading FPA concepts: %x %x\n", conceptsFPA, fpa->concepts);
    176     return conceptsRead(conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
     176    return conceptsRead(&conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
    177177}
    178178
     
    184184{
    185185    psTrace("psModule.concepts", 5, "Writing FPA concepts: %x %x\n", conceptsFPA, fpa->concepts);
    186     return conceptsWrite(conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
     186    return conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
    187187}
    188188
     
    192192{
    193193    psTrace("psModule.concepts", 5, "Blanking chip concepts: %x %x\n", conceptsChip, chip->concepts);
    194     return conceptsBlank(conceptsChip, chip->concepts);
     194    return conceptsBlank(&conceptsChip, chip->concepts);
    195195}
    196196
     
    203203    psTrace("psModule.concepts", 5, "Reading chip concepts: %x %x\n", conceptsChip, chip->concepts);
    204204    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    205     return conceptsRead(conceptsChip, fpa, chip, NULL, source, db, chip->concepts);
     205    return conceptsRead(&conceptsChip, fpa, chip, NULL, source, db, chip->concepts);
    206206}
    207207
     
    214214    psTrace("psModule.concepts", 5, "Writing chip concepts: %x %x\n", conceptsChip, chip->concepts);
    215215    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    216     return conceptsWrite(conceptsChip, fpa, chip, NULL, source, db, chip->concepts);
     216    return conceptsWrite(&conceptsChip, fpa, chip, NULL, source, db, chip->concepts);
    217217}
    218218
     
    222222{
    223223    psTrace("psModule.concepts", 5, "Blanking cell concepts: %x %x\n", conceptsCell, cell->concepts);
    224     return conceptsBlank(conceptsCell, cell->concepts);
     224    return conceptsBlank(&conceptsCell, cell->concepts);
    225225}
    226226
     
    234234    pmChip *chip = cell->parent;        // Chip to which the cell belongs
    235235    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    236     return conceptsRead(conceptsCell, fpa, chip, cell, source, db, cell->concepts);
     236    return conceptsRead(&conceptsCell, fpa, chip, cell, source, db, cell->concepts);
    237237}
    238238
     
    246246    pmChip *chip = cell->parent;        // Chip to which the cell belongs
    247247    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    248     return conceptsWrite(conceptsCell, fpa, chip, cell, source, db, cell->concepts);
     248    return conceptsWrite(&conceptsCell, fpa, chip, cell, source, db, cell->concepts);
    249249}
    250250
  • branches/rel10_ifa/psModules/src/astrom/pmConceptsRead.c

    r6575 r6580  
    175175}
    176176
     177
    177178//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    178179// Public functions
     
    201202                bool mdok = true;       // Status of MD lookup
    202203                psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source
    203                 if (mdok && strlen(source)) {
    204                     if (strcasecmp(source, "HEADER") == 0 && conceptItem->type == PS_DATA_STRING) {
    205                         value = psMetadataLookup(hdu->header, conceptItem->data.V);
    206                     } else if (strcasecmp(source, "VALUE") == 0) {
    207                         value = psMemIncrRefCounter(conceptItem);
    208                     } else {
    209                         psError(PS_ERR_IO, true, "%s isn't HEADER or VALUE --- can't read %s\n", source,
    210                                 name);
    211                         continue;
    212                     }
    213                 } else {
    214                     // Assume it's specified by value
     204                if (mdok && strlen(source) > 0 && strcasecmp(source, "VALUE") == 0) {
    215205                    value = psMemIncrRefCounter(conceptItem);
     206                    conceptParse(spec, value, cameraFormat, target, NULL, NULL, cell);
     207                } else if (source && (strlen(source) == 0 || strcasecmp(source, "HEADER") != 0)) {
     208                    // We leave "HEADER" to pmConceptsReadFromHeader
     209                    psError(PS_ERR_IO, true, "%s isn't HEADER or VALUE --- can't read %s\n", source, name);
     210                    continue;
    216211                }
    217                 conceptParse(spec, value, cameraFormat, target, NULL, NULL, cell);
    218212            }
    219213        }
     
    253247}
    254248
     249
    255250bool pmConceptsReadFromHeader(psMetadata *specs, // The concept specifications
    256251                              pmFPA *fpa, // The FPA
     
    265260    psMetadata *transSpec = psMetadataLookupMD(&mdok, cameraFormat, "TRANSLATION"); // The TRANSLATION spec
    266261    if (mdok && transSpec) {
    267         pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level
    268         psMetadata *cameraFormat = hdu->format; // The camera format
    269262        psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator
    270263        psMetadataItem *specItem = NULL;    // Item from the specs metadata
     
    272265            pmConceptSpec *spec = specItem->data.V; // The specification
    273266            psString name = specItem->name; // The concept name
    274             psString keywords = psMetadataLookupStr(&mdok, transSpec, name); // The FITS keywords
    275             if (mdok && strlen(keywords) > 0) {
    276                 // In case there are multiple headers
    277                 psList *keys = psStringSplit(keywords, " ,;"); // List of keywords
    278                 psMetadataItem *headerItem = NULL; // The item, to be returned
    279                 if (keys->n == 1) {
    280                     // Only one key --- proceed as usual
    281                     headerItem = psMetadataLookup(hdu->header, keywords);
    282                 } else {
    283                     psListIterator *keysIter = psListIteratorAlloc(keys, PS_LIST_HEAD, false); // Iterator
    284                     psString key = NULL; // Item from iteration
    285                     psList *values = psListAlloc(NULL); // List containing the values
    286                     while ((key = psListGetAndIncrement(keysIter))) {
    287                         psMetadataItem *value = psMetadataLookup(hdu->header, key);
    288                         psListAdd(values, PS_LIST_TAIL, value);
     267            psMetadataItem *headerItem = NULL; // The value of the concept from the header
     268            // First check the cell configuration
     269            if (cell && cell->config) {
     270                psMetadataItem *conceptItem = psMetadataLookup(cell->config, name); // The concept, or NULL
     271                if (conceptItem) {
     272                    // Check the SOURCE
     273                    psString nameSource = NULL; // String with the concept name and ".SOURCE" added
     274                    psStringAppend(&nameSource, "%s.SOURCE", name);
     275                    psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source
     276                    if (mdok && strlen(source) && strcasecmp(source, "HEADER") == 0) {
     277                        headerItem = psMetadataLookup(hdu->header, conceptItem->data.V);
    289278                    }
    290                     psFree(keysIter);
    291                     headerItem = psMetadataItemAlloc(name, PS_DATA_LIST, specItem->comment, values);
    292                     psFree(values);
     279                    // Leave the error handling to pmConceptsFromCamera, which should already have been called
    293280                }
    294                 psFree(keys);
    295 
    296                 // This will also clean up the name
    297                 conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell);
    298             }
     281            }
     282            if (! headerItem) {
     283                psString keywords = psMetadataLookupStr(&mdok, transSpec, name); // The FITS keywords
     284                if (mdok && strlen(keywords) > 0) {
     285                    // In case there are multiple headers
     286                    psList *keys = psStringSplit(keywords, " ,;"); // List of keywords
     287                    if (keys->n == 1) {
     288                        // Only one key --- proceed as usual
     289                        headerItem = psMetadataLookup(hdu->header, keywords);
     290                    } else {
     291                        psListIterator *keysIter = psListIteratorAlloc(keys, PS_LIST_HEAD, false); // Iterator
     292                        psString key = NULL; // Item from iteration
     293                        psList *values = psListAlloc(NULL); // List containing the values
     294                        while ((key = psListGetAndIncrement(keysIter))) {
     295                            psMetadataItem *value = psMetadataLookup(hdu->header, key);
     296                            psListAdd(values, PS_LIST_TAIL, value);
     297                        }
     298                        psFree(keysIter);
     299                        headerItem = psMetadataItemAlloc(name, PS_DATA_LIST, specItem->comment, values);
     300                        psFree(values);
     301                    }
     302                    psFree(keys);
     303                }
     304            }
     305
     306            // This will also clean up the name
     307            conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell);
    299308        }
    300309        psFree(specsIter);
     
    303312    return false;
    304313}
     314
    305315
    306316// XXX --- the below code has NOT been tested!
  • branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.c

    r6575 r6580  
    147147        while ((cellName = psListGetAndIncrement(cellNamesIter))) {
    148148            pmCell *cell = pmCellAlloc(chip, cellName); // New cell
    149             pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_DEFAULTS, NULL);
    150149            psFree(cell);               // Drop reference
    151150        }
    152         pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_DEFAULTS, NULL);
    153151        psFree(chip);                   // Drop reference
    154152        psFree(cellNamesIter);
    155153    }
    156154    psFree(componentsIter);
    157     pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS, NULL);
    158155
    159156    return fpa;
     
    166163                    pmCell *cell,       // Cell to which to add, or NULL
    167164                    psMetadata *phu,    // Primary header of file
    168                     const psMetadata *format // Format of file
     165                    psMetadata *format // Format of file
    169166                   )
    170167{
     
    192189    pmHDU *phdu = pmHDUAlloc("PHU");    // The primary header data unit
    193190    phdu->header = psMemIncrRefCounter(phu);
     191    phdu->format = psMemIncrRefCounter(format);
    194192    if (fpa && !fpa->hdu && strcasecmp(phuType, "FPA") == 0) {
    195193        fpa->hdu = phdu;
     194        pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL);
    196195    } else if (chip && !chip->hdu && strcasecmp(phuType, "CHIP") == 0) {
    197196        chip->hdu = phdu;
     197        pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, NULL);
    198198    } else if (cell && !cell->hdu && strcasecmp(phuType, "CELL") == 0) {
    199199        // cell->hdu = phdu;
     
    244244            }
    245245            cell->config = psMemIncrRefCounter(cellData);
    246             pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA, NULL);
     246            pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS, NULL);
    247247        }
    248248    }
     
    295295                }
    296296                cell->config = psMemIncrRefCounter(cellData);
    297                 pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA, NULL);
     297                pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS, NULL);
    298298            }
    299299
     
    337337                }
    338338                cell->config = psMemIncrRefCounter(cellData);
    339                 pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA, NULL);
     339                pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS, NULL);
    340340            }
    341341
     
    346346    }
    347347    psFree(contentsIter);
     348
     349    pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS, NULL);
    348350
    349351    return true;
  • branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.h

    r6552 r6580  
    1414                    pmCell *cell,       // Cell to which to add, or NULL
    1515                    psMetadata *phu,    // Primary header of file
    16                     const psMetadata *format // Format of file
     16                    psMetadata *format // Format of file
    1717                   );
    1818
  • branches/rel10_ifa/psModules/src/astrom/pmFPAfile.h

    r6573 r6580  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-03-14 02:21:07 $
     9*  @version $Revision: 1.1.2.6 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-03-14 04:40:37 $
    1111*
    1212*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
     
    1515#ifndef PM_FPA_FILE_H
    1616#define PM_FPA_FILE_H
     17
     18#include "pslib.h"
     19#include "pmFPA.h"
     20#include "pmFPAview.h"
    1721
    1822typedef enum {
  • branches/rel10_ifa/psModules/src/astrom/pmFPAview.h

    r6573 r6580  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-03-14 02:21:07 $
     9*  @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-03-14 04:40:37 $
    1111*
    1212*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
     
    1515#ifndef PM_FPA_VIEW_H
    1616#define PM_FPA_VIEW_H
     17
     18#include "pmFPA.h"
    1719
    1820/// @addtogroup AstroImage
  • branches/rel10_ifa/psModules/src/config/pmConfig.c

    r6569 r6580  
    33 *  @author PAP, IfA
    44 *
    5  *  @version $Revision: 1.7.4.4 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-03-10 02:05:06 $
     5 *  @version $Revision: 1.7.4.5 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-03-14 04:40:37 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    477477    PS_ASSERT_PTR_NON_NULL(config->camera, false);
    478478
     479    if (!config->recipes) {
     480        config->recipes = psMetadataAlloc();
     481    }
     482
    479483    bool mdok = true;                   // Status of MD lookup
    480484    psMetadata *recipes = psMetadataLookupMD(&mdok, config->camera, "RECIPES"); // The list of recipes
Note: See TracChangeset for help on using the changeset viewer.