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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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");
Note: See TracChangeset for help on using the changeset viewer.