IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 4, 2008, 3:32:28 PM (18 years ago)
Author:
Paul Price
Message:

I've implemented the chip-dependent concepts. It uses a generalised version of the dependent DEFAULT concepts, which can, unfortunately, make the camera format configuration a bit longer, but it consolidates code and keeps things simple both for the code and the configuration.

In the process, I took care of a couple of other concept bugs that have been sitting in my inbox for nearly a year:

  • FPA.NAME has been replaced with FPA.OBS, which is intended to be an observation identifier (bug 885). You're welcome to change the name, so long as you also volunteer to fix all the camera formats.
  • FPA.CAMERA is automatically set (on construction of the FPA) to the camera name as used by the configuration files (bug 931). I've changed the ppStats REGISTER recipe to use FPA.CAMERA instead of FPA.INSTRUMENT (which is retained in the concepts as the instrument's name according to the instrument, whereas FPA.CAMERA is the instrument's name according to our configuration).
Location:
trunk/psModules/src/camera
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPA.c

    r16716 r17911  
    305305    tmpCell->conceptsRead = PM_CONCEPT_SOURCE_NONE;
    306306    if (!psMetadataAddStr(tmpCell->concepts, PS_LIST_HEAD, "CELL.NAME", 0, NULL, name)) {
    307         psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CELL.NAME to metadata.\n");
     307        psErrorClear();
     308        psWarning("Could not add CELL.NAME to metadata.");
    308309    }
    309310    pmConceptsBlankCell(tmpCell);
     
    343344    tmpChip->conceptsRead = PM_CONCEPT_SOURCE_NONE;
    344345    if (!psMetadataAddStr(tmpChip->concepts, PS_LIST_HEAD, "CHIP.NAME", 0, NULL, name)) {
    345         psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CHIP.NAME %s to concepts.\n", name);
     346        psErrorClear();
     347        psWarning("Could not add CHIP.NAME %s to concepts.", name);
    346348    }
    347349    pmConceptsBlankChip(tmpChip);
     
    355357}
    356358
    357 pmFPA *pmFPAAlloc(const psMetadata *camera)
     359pmFPA *pmFPAAlloc(const psMetadata *camera, const char *cameraName)
    358360{
    359361    pmFPA *tmpFPA = (pmFPA *) psAlloc(sizeof(pmFPA));
     
    373375    pmConceptsBlankFPA(tmpFPA);
    374376
     377    if (!psMetadataAddStr(tmpFPA->concepts, PS_LIST_TAIL, "FPA.CAMERA", PS_META_REPLACE,
     378                          "Camera name (according to configuration)", cameraName)) {
     379        psErrorClear();
     380        psWarning("Could not add FPA.CAMERA %s to concepts.", cameraName);
     381    }
     382
    375383    return tmpFPA;
    376384}
  • trunk/psModules/src/camera/pmFPA.h

    r17249 r17911  
    66 * @author Eugene Magnier, IfA
    77 *
    8  * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2008-03-31 22:39:06 $
     8 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2008-06-05 01:31:33 $
    1010 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    1111 */
     
    169169
    170170/// Allocate an FPA
    171 pmFPA *pmFPAAlloc(const psMetadata *camera); ///< Camera configuration (to store in FPA)
     171pmFPA *pmFPAAlloc(const psMetadata *camera, ///< Camera configuration (to store in FPA)
     172                  const char *cameraName ///< Name of camera (for FPA.CAMERA concept)
     173    );
    172174bool psMemCheckFPA(psPtr ptr);
    173175
  • trunk/psModules/src/camera/pmFPAConstruct.c

    r16912 r17911  
    11021102// It returns a view corresponding to the PHU
    11031103static pmFPAview *addSource(pmFPA *fpa,       // The FPA
    1104                             const char *fpaname, // The desired FPA name
     1104                            const char *fpaObs, // The desired FPA observation name
    11051105                            const pmFPAview *phuView, // The view corresponding to the PHU, or NULL
    11061106                            const psMetadata *header, // The PHU header, or NULL
     
    11151115    bool mdok;                          // Status of MD lookup
    11161116
    1117     // If FPA.NAME is already defined, new name must match it; otherwise, warn the user that something
     1117    // If FPA.OBS is already defined, new name must match it; otherwise, warn the user that something
    11181118    // potentially bad is happening.
    1119     if (fpaname && install) {
    1120         const char *currentName = psMetadataLookupStr(&mdok, fpa->concepts, "FPA.NAME"); // Current name
    1121         if (mdok && currentName && strlen(currentName) > 0 && strcmp(currentName, fpaname) != 0) {
    1122             psWarning("FPA.NAME for new source (%s) doesn't match FPA.NAME for current "
    1123                      "fpa (%s).\n", fpaname, currentName);
    1124         }
    1125         psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.NAME", PS_META_REPLACE, "Name of FPA", fpaname);
    1126     } else if (!psMetadataLookup(fpa->concepts, "FPA.NAME")) {
    1127         // Make sure there is an FPA.NAME
    1128         psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.NAME", 0, "Name of FPA", "UNKNOWN");
     1119    if (fpaObs && install) {
     1120        const char *currentName = psMetadataLookupStr(&mdok, fpa->concepts, "FPA.OBS"); // Current name
     1121        if (mdok && currentName && strlen(currentName) > 0 && strcmp(currentName, fpaObs) != 0) {
     1122            psWarning("FPA.OBS for new source (%s) doesn't match FPA.OBS for current fpa (%s).",
     1123                      fpaObs, currentName);
     1124        }
     1125        psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.OBS", PS_META_REPLACE, "Observation identifier",
     1126                         fpaObs);
     1127    } else if (!psMetadataLookup(fpa->concepts, "FPA.OBS")) {
     1128        // Make sure there is an FPA.OBS
     1129        psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.OBS", 0, "Observation identifier", "UNKNOWN");
    11291130    }
    11301131
     
    13081309//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    13091310
    1310 pmFPA *pmFPAConstruct(const psMetadata *camera)
     1311pmFPA *pmFPAConstruct(const psMetadata *camera, const char *cameraName)
    13111312{
    13121313    PS_ASSERT_PTR_NON_NULL(camera, NULL);
    13131314
    1314     pmFPA *fpa = pmFPAAlloc(camera);    // The FPA to fill out
     1315    pmFPA *fpa = pmFPAAlloc(camera, cameraName);    // The FPA to fill out
    13151316
    13161317    bool mdok = true;                   // Status from MD lookups
     
    13491350}
    13501351
    1351 bool pmFPAAddSourceFromFormat(pmFPA *fpa, const char *fpaname, const psMetadata *format)
     1352bool pmFPAAddSourceFromFormat(pmFPA *fpa, const char *fpaObs, const psMetadata *format)
    13521353{
    13531354    PS_ASSERT_PTR_NON_NULL(fpa, false);
     
    13581359    pmFPAview *view = pmFPAviewAlloc(0);// View for current level
    13591360    if (phuLevel == PM_FPA_LEVEL_FPA) {
    1360         if (!pmFPAAddSourceFromView(fpa, fpaname, view, format)) {
     1361        if (!pmFPAAddSourceFromView(fpa, fpaObs, view, format)) {
    13611362            psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA.");
    13621363            psFree(view);
     
    13671368        while ((chip = pmFPAviewNextChip(view, fpa, 1))) {
    13681369            if (phuLevel == PM_FPA_LEVEL_CHIP) {
    1369                 if (!pmFPAAddSourceFromView(fpa, fpaname, view, format)) {
     1370                if (!pmFPAAddSourceFromView(fpa, fpaObs, view, format)) {
    13701371                    psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA.");
    13711372                    psFree(view);
     
    13761377                while ((cell = pmFPAviewNextCell(view, fpa, 1))) {
    13771378                    if (phuLevel == PM_FPA_LEVEL_CELL) {
    1378                         if (!pmFPAAddSourceFromView(fpa, fpaname, view, format)) {
     1379                        if (!pmFPAAddSourceFromView(fpa, fpaObs, view, format)) {
    13791380                            psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA.");
    13801381                            psFree(view);
     
    13911392}
    13921393
    1393 bool pmFPAAddSourceFromView(pmFPA *fpa, const char *fpaname, const pmFPAview *phuView,
     1394bool pmFPAAddSourceFromView(pmFPA *fpa, const char *fpaObs, const pmFPAview *phuView,
    13941395                            const psMetadata *format)
    13951396{
     
    13981399    PS_ASSERT_PTR_NON_NULL(format, false);
    13991400
    1400     pmFPAview *view = addSource(fpa, fpaname, phuView, NULL, format, true);
     1401    pmFPAview *view = addSource(fpa, fpaObs, phuView, NULL, format, true);
    14011402    bool status = (view != NULL);
    14021403    psFree(view);
     
    14181419
    14191420    // Check the name of the FPA
    1420     psString fpaname = phuNameFromHeader("FPA.NAME", fileInfo, phu); // New name for the FPA
    1421     if (!fpaname || strlen(fpaname) == 0) {
    1422         psWarning("Unable to determine FPA.NAME: check for FPA.NAME in FILE in camera format");
    1423     }
    1424 
    1425     pmFPAview *view = addSource(fpa, fpaname, NULL, phu, format, true); // View of PHU, to return
    1426     psFree(fpaname);
     1421    psString fpaObs = phuNameFromHeader("FPA.OBS", fileInfo, phu); // New observation name for the FPA
     1422    if (!fpaObs || strlen(fpaObs) == 0) {
     1423        psWarning("Unable to determine FPA.OBS: check for FPA.OBS in FILE in camera format");
     1424    }
     1425
     1426    pmFPAview *view = addSource(fpa, fpaObs, NULL, phu, format, true); // View of PHU, to return
     1427    psFree(fpaObs);
    14271428
    14281429    return view;
  • trunk/psModules/src/camera/pmFPAConstruct.h

    r16912 r17911  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2008-03-11 01:27:05 $
     6 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2008-06-05 01:31:33 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    2121/// as the corresponding values (whitespace separated).  The FPA hierarchy is created devoid of any
    2222/// input/output sources (i.e., HDUs).
    23 pmFPA *pmFPAConstruct(const psMetadata *camera ///< The camera configuration
     23pmFPA *pmFPAConstruct(const psMetadata *camera, ///< The camera configuration
     24                      const char *cameraName ///< Name of the camera (for FPA.CAMERA concept)
    2425                     );
    2526
     
    2829/// This is suitable for generating an output FPA given the desired format.
    2930bool pmFPAAddSourceFromFormat(pmFPA *fpa, ///< The FPA
    30                               const char *fpaname, ///< FPA.NAME for the source
     31                              const char *fpaObs, ///< FPA.NAME for the source
    3132                              const psMetadata *format ///< Format of file
    3233    );
     
    3738/// configuration is required in order to describe how the FPA is laid out in terms of disk files.
    3839bool pmFPAAddSourceFromView(pmFPA *fpa,   ///< The FPA
    39                             const char *fpaname, ///< FPA.NAME for the source
     40                            const char *fpaObs, ///< FPA.NAME for the source
    4041                            const pmFPAview *phuView, ///< The view, corresponding to the PHU
    4142                            const psMetadata *format ///< Format of file
  • trunk/psModules/src/camera/pmFPAWrite.c

    r16396 r17911  
    3737
    3838
    39 // Update the FPA.NAME, CHIP.NAME and CELL.NAME in the FITS header, if required
     39// Update the FPA.OBS, CHIP.NAME and CELL.NAME in the FITS header, if required
    4040bool pmFPAUpdateNames(pmFPA *fpa, pmChip *chip, pmCell *cell)
    4141{
     
    5555    }
    5656    if (fpa) {
    57         const char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    58         if (mdok && fpaNameHdr && strlen(fpaNameHdr) > 0) {
    59             const char *fpaName = psMetadataLookupStr(NULL, fpa->concepts, "FPA.NAME");
    60             psMetadataAddStr(hdu->header, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName);
     57        const char *fpaObsHdr = psMetadataLookupStr(&mdok, fileData, "FPA.OBS");
     58        if (mdok && fpaObsHdr && strlen(fpaObsHdr) > 0) {
     59            const char *fpaObs = psMetadataLookupStr(NULL, fpa->concepts, "FPA.OBS");
     60            psMetadataAddStr(hdu->header, PS_LIST_TAIL, fpaObsHdr, PS_META_REPLACE,
     61                             "Observation identifier", fpaObs);
    6162        }
    6263    }
  • trunk/psModules/src/camera/pmFPAfile.c

    r17036 r17911  
    181181  newName = psStringCopy(rule);
    182182
    183   if (strstr (newName, "{FPA.NAME}") != NULL) {
    184     char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.NAME");
     183  if (strstr (newName, "{FPA.OBS}") != NULL) {
     184    char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.OBS");
    185185    if (name != NULL) {
    186       psStringSubstitute(&newName, "fpa", "{FPA.NAME}");
     186      psStringSubstitute(&newName, "fpa", "{FPA.OBS}");
    187187    }
    188188  }
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r17634 r17911  
    237237        file->fpa = psMemIncrRefCounter(fpa);
    238238    } else {
    239         file->fpa = pmFPAConstruct(file->camera);
     239        file->fpa = pmFPAConstruct(file->camera, file->cameraName);
    240240    }
    241241
     
    482482
    483483    // build the template fpa, set up the basic view
    484     fpa = pmFPAConstruct(config->camera);
     484    fpa = pmFPAConstruct(config->camera, config->cameraName);
    485485    if (!fpa) {
    486486        psError(PS_ERR_IO, false, "Failed to construct FPA from %s", realName);
     
    783783
    784784    // build the template fpa, set up the basic view
    785     fpa = pmFPAConstruct (config->camera);
     785    fpa = pmFPAConstruct(config->camera, config->cameraName);
    786786    if (!fpa) {
    787787        psError(PS_ERR_IO, false, "Failed to construct FPA from %s", (char *)infiles->data[0]);
     
    867867
    868868    // build the template fpa, set up the basic view
    869     pmFPA *fpa = pmFPAConstruct (config->camera);
     869    pmFPA *fpa = pmFPAConstruct(config->camera, config->cameraName);
    870870    if (!fpa) {
    871871        psError(PS_ERR_IO, false, "Failed to construct FPA for %s", filename);
     
    949949    if (!file) {
    950950        // build the template fpa, set up the basic view
    951         fpa = pmFPAConstruct (config->camera);
     951        fpa = pmFPAConstruct(config->camera, config->cameraName);
    952952        if (!fpa) {
    953953            psError(PS_ERR_IO, false, "Failed to construct FPA for %s", filename);
     
    10901090    PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
    10911091
    1092     pmFPA *fpa = pmFPAConstruct(src->camera);
     1092    pmFPA *fpa = pmFPAConstruct(src->camera, psMetadataLookupStr(NULL, src->concepts, "FPA.CAMERA"));
    10931093    // XXX should this use DefineOutputForFormat?
    10941094    pmFPAfile *file = pmFPAfileDefineOutput (config, fpa, filename);
     
    11391139        return NULL;
    11401140    }
    1141     file->fpa = pmFPAConstruct(file->camera);
     1141    file->fpa = pmFPAConstruct(file->camera, file->cameraName);
    11421142
    11431143    return file;
  • trunk/psModules/src/camera/pmFPAfileFitsIO.c

    r16841 r17911  
    6767    }
    6868
    69     pmFPA *nameSource = file->src; // Source of FPA.NAME
     69    pmFPA *nameSource = file->src; // Source of FPA.OBS
    7070    if (!nameSource) {
    7171        nameSource = file->fpa;
    7272    }
    7373    bool mdok;                  // Status of MD lookup
    74     const char *fpaname = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.NAME"); // Name of FPA
    75 
    76     pmFPA *copy = pmFPAConstruct(file->camera);  // FPA to return
    77     if (!pmFPAAddSourceFromView(copy, fpaname, phuView, file->format)) {
     74    const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Observation id
     75
     76    pmFPA *copy = pmFPAConstruct(file->camera, file->cameraName);  // FPA to return
     77    if (!pmFPAAddSourceFromView(copy, fpaObs, phuView, file->format)) {
    7878        psError(PS_ERR_UNKNOWN, false, "Unable to insert HDU into FPA for writing.\n");
    7979        psFree(copy);
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r17832 r17911  
    263263            }
    264264
    265             pmFPA *nameSource = file->src; // Source of FPA.NAME
     265            pmFPA *nameSource = file->src; // Source of FPA.OBS
    266266            if (!nameSource) {
    267267                nameSource = file->fpa;
    268268            }
    269269            bool mdok;                  // Status of MD lookup
    270             const char *fpaname = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.NAME"); // Name of FPA
    271 
    272             pmFPAAddSourceFromView(file->fpa, fpaname, view, format);
    273             psTrace ("psModules.camera", 5, "created fpa data elements for %s (%s) (%d:%d:%d)\n", file->name, file->name, view->chip, view->cell, view->readout);
     270            const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Obs. id
     271
     272            pmFPAAddSourceFromView(file->fpa, fpaObs, view, format);
     273            psTrace ("psModules.camera", 5, "created fpa data elements for %s (%s) (%d:%d:%d)\n",
     274                     file->name, file->name, view->chip, view->cell, view->readout);
    274275            break;
    275276    }
     
    349350    // (existing) fpa
    350351    if (file->type == PM_FPA_FILE_CMF) {
    351         if (!pmFPAviewCheckDataStatusForSources (view, file)) {
     352        if (!pmFPAviewCheckDataStatusForSources (view, file)) {
    352353        psTrace("psModules.camera", 6, "skip write for %s, no data for this entry", file->name);
    353354        return true;
     
    778779        file->fits->options = psMemIncrRefCounter(file->options);
    779780
    780         // in most cases, we have already open and read the phu and determined the format.
    781         // in some cases, (eg DetDB images), we have only just determined the filename.
    782         // we need to check the file format before we can work with the file
    783         if (!file->format) {
    784           psMetadata *phu = psFitsReadHeader (NULL, file->fits);
    785           if (!phu) {
    786             psError(PS_ERR_IO, false, "Failed to read file header %s\n", file->filename);
    787             return false;
    788           }
    789 
    790           // determine the current format from the header
    791           // determine camera if not specified already
    792           file->format = pmConfigCameraFormatFromHeader (config, phu, true);
    793           if (!file->format) {
    794             psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", file->filename);
    795             psFree(phu);
    796             return false;
    797           }
    798           psFree(phu);
    799         }
    800 
    801         // if needed, set the optional EXTWORD field based on the camera value
    802         psMetadata *fileMenu = psMetadataLookupMetadata (NULL, file->format, "FILE");
    803         if (!fileMenu) {
    804           psError (PS_ERR_IO, true, "FILE METADATA missing from camera format %s\n",
    805                    config->formatName);
    806           return false;
    807         }
    808         char *extword = psMetadataLookupStr (&status, fileMenu, "EXTWORD");
    809         if (status) {
    810           psFitsSetExtnameWord (file->fits, extword);
    811         }
     781        // in most cases, we have already open and read the phu and determined the format.
     782        // in some cases, (eg DetDB images), we have only just determined the filename.
     783        // we need to check the file format before we can work with the file
     784        if (!file->format) {
     785          psMetadata *phu = psFitsReadHeader (NULL, file->fits);
     786          if (!phu) {
     787            psError(PS_ERR_IO, false, "Failed to read file header %s\n", file->filename);
     788            return false;
     789          }
     790
     791          // determine the current format from the header
     792          // determine camera if not specified already
     793          file->format = pmConfigCameraFormatFromHeader (config, phu, true);
     794          if (!file->format) {
     795            psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", file->filename);
     796            psFree(phu);
     797            return false;
     798          }
     799          psFree(phu);
     800        }
     801
     802        // if needed, set the optional EXTWORD field based on the camera value
     803        psMetadata *fileMenu = psMetadataLookupMetadata (NULL, file->format, "FILE");
     804        if (!fileMenu) {
     805          psError (PS_ERR_IO, true, "FILE METADATA missing from camera format %s\n",
     806                   config->formatName);
     807          return false;
     808        }
     809        char *extword = psMetadataLookupStr (&status, fileMenu, "EXTWORD");
     810        if (status) {
     811          psFitsSetExtnameWord (file->fits, extword);
     812        }
    812813
    813814        // XXX these are probably only needed for WRITE files
Note: See TracChangeset for help on using the changeset viewer.