IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 13, 2007, 4:03:29 PM (19 years ago)
Author:
Paul Price
Message:

Adding dark normalisation. The idea is that the dark current is not always linear with the darktime, but may be described by a polynomial function of the darktime. We introduce in the camera configuration DARK.NORM, which is a filename within the search path (or it may be a metadata, which removes the need to read a file, but clutters the configuration file). This file is read in the usual course of configuration setup. When required, DARK.NORM.KEY (which is resolved in the usual way, so try, e.g., '{CHIP.NAME}') points at a metadata within the DARK.NORM that provides the polynomial for correcting the darktime. This means that the view must be passed in to pmBiasSubtract, so that the appropriate polynomial can be identified.

Location:
trunk/psModules/src/camera
Files:
2 added
3 edited

Legend:

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

    r12454 r13810  
    55libpsmodulescamera_la_SOURCES  = \
    66        pmFPA.c \
     7        pmFPACalibration.c \
    78        pmFPAConstruct.c \
    89        pmFPACopy.c \
     
    2930pkginclude_HEADERS = \
    3031        pmFPA.h \
     32        pmFPACalibration.h \
    3133        pmFPAConstruct.h \
    3234        pmFPACopy.h \
  • trunk/psModules/src/camera/pmFPAfile.c

    r13523 r13810  
    55#include <stdio.h>
    66#include <string.h>
    7 #include <strings.h>            /* for strn?casecmp */
     7#include <strings.h>            /* for strn?casecmp */
    88#include <pslib.h>
    99
     
    164164}
    165165
    166 // select the rule from the camera configuration, perform substitutions as needed
    167 psString pmFPAfileNameFromRule(const char *rule, const pmFPAfile *file, const pmFPAview *view)
    168 {
    169     PS_ASSERT_PTR_NON_NULL(rule, NULL);
    170     PS_ASSERT_INT_POSITIVE(strlen(rule), NULL);
    171     PS_ASSERT_PTR_NON_NULL(file, NULL);
     166psString pmFPANameFromRule(const char *rule, const pmFPA *fpa, const pmFPAview *view)
     167{
     168    PS_ASSERT_STRING_NON_EMPTY(rule, NULL);
    172169    PS_ASSERT_PTR_NON_NULL(view, NULL);
    173170
    174     char *newName = NULL;     // destination for resulting name
    175 
    176     newName = psStringCopy (rule);
    177 
    178     if (strstr (newName, "{OUTPUT}") != NULL) {
    179         char *name = psMetadataLookupStr (NULL, file->names, "OUTPUT");
    180         if (name != NULL) {
    181             psStringSubstitute(&newName, name, "{OUTPUT}");
    182         }
    183     }
     171    psString newName = NULL;            // New name, to be returned
     172    newName = psStringCopy(rule);
     173
    184174    if (strstr (newName, "{CHIP.NAME}") != NULL) {
    185         pmChip *chip = pmFPAviewThisChip (view, file->fpa);
     175        pmChip *chip = pmFPAviewThisChip (view, fpa);
    186176        if (chip != NULL) {
    187177            char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
     
    202192    }
    203193    if (strstr (newName, "{CELL.NAME}") != NULL) {
    204         pmCell *cell = pmFPAviewThisCell (view, file->fpa);
     194        pmCell *cell = pmFPAviewThisCell (view, fpa);
    205195        if (cell != NULL) {
    206196            char *name = psMetadataLookupStr (NULL, cell->concepts, "CELL.NAME");
     
    220210    }
    221211    if (strstr (newName, "{EXTNAME}") != NULL) {
    222         pmHDU *hdu = pmFPAviewThisHDU (view, file->fpa);
     212        pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
    223213        if (hdu->extname && *hdu->extname) {
    224214            psStringSubstitute(&newName, hdu->extname, "{EXTNAME}");
     
    226216    }
    227217    if (strstr (newName, "{FILTER}") != NULL) {
    228         if (file->fpa != NULL) {
    229             char *name = psMetadataLookupStr (NULL, file->fpa->concepts, "FPA.FILTER");
     218        if (fpa != NULL) {
     219            char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTER");
    230220            if (name && *name) {
    231221                psStringSubstitute(&newName, name, "{FILTER}");
     
    234224    }
    235225    if (strstr (newName, "{FILTER.ID}") != NULL) {
    236         if (file->fpa != NULL) {
    237             char *name = psMetadataLookupStr (NULL, file->fpa->concepts, "FPA.FILTERID");
     226        if (fpa != NULL) {
     227            char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTERID");
    238228            if (name && *name) {
    239229                psStringSubstitute(&newName, name, "{FILTER.ID}");
     
    242232    }
    243233    if (strstr (newName, "{CAMERA}") != NULL) {
    244         if (file->fpa != NULL) {
    245             char *name = psMetadataLookupStr (NULL, file->fpa->concepts, "FPA.INSTRUMENT");
     234        if (fpa != NULL) {
     235            char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT");
    246236            if (name && *name) {
    247237                psStringSubstitute(&newName, name, "{CAMERA}");
     
    250240    }
    251241    if (strstr (newName, "{INSTRUMENT}") != NULL) {
    252         if (file->fpa != NULL) {
    253             char *name = psMetadataLookupStr (NULL, file->fpa->concepts, "FPA.INSTRUMENT");
     242        if (fpa != NULL) {
     243            char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT");
    254244            if (name && *name) {
    255245                psStringSubstitute(&newName, name, "{INSTRUMENT}");
     
    258248    }
    259249    if (strstr (newName, "{DETECTOR}") != NULL) {
    260         if (file->fpa != NULL) {
    261             char *name = psMetadataLookupStr (NULL, file->fpa->concepts, "FPA.DETECTOR");
     250        if (fpa != NULL) {
     251            char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.DETECTOR");
    262252            if (name && *name) {
    263253                psStringSubstitute(&newName, name, "{DETECTOR}");
     
    266256    }
    267257    if (strstr (newName, "{TELESCOPE}") != NULL) {
    268         if (file->fpa != NULL) {
    269             char *name = psMetadataLookupStr (NULL, file->fpa->concepts, "FPA.TELESCOPE");
     258        if (fpa != NULL) {
     259            char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.TELESCOPE");
    270260            if (name && *name) {
    271261                psStringSubstitute(&newName, name, "{TELESCOPE}");
     
    273263        }
    274264    }
     265    return newName;
     266}
     267
     268// select the rule from the camera configuration, perform substitutions as needed
     269psString pmFPAfileNameFromRule(const char *rule, const pmFPAfile *file, const pmFPAview *view)
     270{
     271    PS_ASSERT_PTR_NON_NULL(rule, NULL);
     272    PS_ASSERT_INT_POSITIVE(strlen(rule), NULL);
     273    PS_ASSERT_PTR_NON_NULL(file, NULL);
     274    PS_ASSERT_PTR_NON_NULL(view, NULL);
     275
     276    psString newRule = NULL;            // Rule to pass on to pmFPANameFromRule
     277    newRule = psStringCopy(rule);
     278
     279    if (strstr(newRule, "{OUTPUT}") != NULL) {
     280        char *name = psMetadataLookupStr(NULL, file->names, "OUTPUT");
     281        if (name) {
     282            psStringSubstitute(&newRule, name, "{OUTPUT}");
     283        }
     284    }
     285
     286    psString newName = pmFPANameFromRule(newRule, file->fpa, view); // New name, to be returned
     287    psFree(newRule);
     288
    275289    return newName;
    276290}
     
    346360        status = pmChipCopyStructure (outChip, inChip, xBin, yBin);
    347361        return status;
    348     } 
     362    }
    349363    if (view->cell >= inChip->cells->n) {
    350364        psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld",
     
    410424    switch (type) {
    411425      case PM_FPA_FILE_SX:
    412         return ("SX");
     426        return ("SX");
    413427      case PM_FPA_FILE_OBJ:
    414         return ("OBJ");
     428        return ("OBJ");
    415429      case PM_FPA_FILE_CMP:
    416         return ("CMP");
     430        return ("CMP");
    417431      case PM_FPA_FILE_CMF:
    418         return ("CMF");
     432        return ("CMF");
    419433      case PM_FPA_FILE_RAW:
    420         return ("RAW");
     434        return ("RAW");
    421435      case PM_FPA_FILE_IMAGE:
    422         return ("IMAGE");
     436        return ("IMAGE");
    423437      case PM_FPA_FILE_PSF:
    424         return ("PSF");
     438        return ("PSF");
    425439      case PM_FPA_FILE_JPEG:
    426         return ("JPEG");
     440        return ("JPEG");
    427441      case PM_FPA_FILE_KAPA:
    428         return ("KAPA");
     442        return ("KAPA");
    429443      case PM_FPA_FILE_MASK:
    430         return ("MASK");
     444        return ("MASK");
    431445      case PM_FPA_FILE_WEIGHT:
    432         return ("WEIGHT");
     446        return ("WEIGHT");
    433447      case PM_FPA_FILE_FRINGE:
    434         return ("FRINGE");
     448        return ("FRINGE");
    435449      case PM_FPA_FILE_HEADER:
    436         return ("HEADER");
     450        return ("HEADER");
    437451      default:
    438         return ("NONE");
     452        return ("NONE");
    439453    }
    440454    return ("NONE");
  • trunk/psModules/src/camera/pmFPAfile.h

    r13523 r13810  
    44 * @author EAM, IfA
    55 *
    6  * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-05-26 02:50:36 $
     6 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-06-14 02:03:29 $
    88 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
    99 */
     
    5353typedef struct
    5454{
    55     pmFPAfileMode mode;                 // is this file read, written, or only used internally?
    56     pmFPAfileType type;                 // what type of data is read from / written to disk?
    57     pmFPAfileState state;               // have we opened the file, etc?
     55    pmFPAfileMode mode;                 // is this file read, written, or only used internally?
     56    pmFPAfileType type;                 // what type of data is read from / written to disk?
     57    pmFPAfileState state;               // have we opened the file, etc?
    5858
    59     pmFPALevel fileLevel;               // what level in the FPA hierarchy represents a unique file?
    60     pmFPALevel dataLevel;               // at what level do we read/write the data segment? (request by user)
    61     pmFPALevel freeLevel;               // at what level do we free the data segment? (set by program)
     59    pmFPALevel fileLevel;               // what level in the FPA hierarchy represents a unique file?
     60    pmFPALevel dataLevel;               // at what level do we read/write the data segment? (request by user)
     61    pmFPALevel freeLevel;               // at what level do we free the data segment? (set by program)
    6262    pmFPALevel mosaicLevel;             // at what level is the mosaic?
    6363
    64     pmFPA *fpa;                         // for I/O files, we carry a pointer to the complete fpa
    65     psFits *fits;                       // for I/O files of fits type (IMAGE, CMP, CMF), we carry a file handle
     64    pmFPA *fpa;                         // for I/O files, we carry a pointer to the complete fpa
     65    psFits *fits;                       // for I/O files of fits type (IMAGE, CMP, CMF), we carry a file handle
    6666
    67     bool phu;                           // have we written a PHU for this file?
    68     psMetadata *header;                 // pointer (view) to the current hdu header
     67    bool phu;                           // have we written a PHU for this file?
     68    psMetadata *header;                 // pointer (view) to the current hdu header
    6969
    70     pmReadout *readout;                 // for internal files, we only carry a single readout
     70    pmReadout *readout;                 // for internal files, we only carry a single readout
    7171
    72     psMetadata *names;                  // filenames supplied by the cmdline or detdb are saved here
     72    psMetadata *names;                  // filenames supplied by the cmdline or detdb are saved here
    7373
    74     char *filerule;                     // rule for constructing a filename when needed
    75     char *filesrc;                      // rule to find file in pmFPAfile->names list
     74    char *filerule;                     // rule for constructing a filename when needed
     75    char *filesrc;                      // rule to find file in pmFPAfile->names list
    7676
    77     char *name;                         // the name of the rule (useful for debugging / tracing)
    78     char *filename;                     // the current name of an active file
    79     char *extname;                      // the current name of an active file extension
     77    char *name;                         // the name of the rule (useful for debugging / tracing)
     78    char *filename;                     // the current name of an active file
     79    char *extname;                      // the current name of an active file extension
    8080
    8181    pmDetrendSelectResults *detrend;    // Detrend information, from pmDetrendSelect
     
    110110
    111111// convert the rule to a name based on the current view
     112psString pmFPANameFromRule(const char *rule, const pmFPA *fpa, const pmFPAview *view);
     113
     114// convert the rule to a name based on the current view
    112115psString pmFPAfileNameFromRule(const char *rule, const pmFPAfile *file, const pmFPAview *view);
    113116
Note: See TracChangeset for help on using the changeset viewer.