IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 11, 2007, 5:18:11 PM (19 years ago)
Author:
Paul Price
Message:

Attempt to set TRIMSEC and BIASSEC from the camera format if they are specified by value.

File:
1 edited

Legend:

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

    r14955 r15299  
    1313#include "pmFPALevel.h"
    1414#include "pmHDUUtils.h"
     15#include "pmConcepts.h"
     16#include "pmConceptsStandard.h"
    1517#include "pmHDUGenerate.h"
    1618
     
    169171    return true;
    170172}
     173
     174// Attempt to read CELL.TRIMSEC and CELL.BIASSEC from the cell format if they are specified by VALUE
     175static bool readTrimBias(psList *cells // List of cells below the HDU
     176    )
     177{
     178    bool mdok;                          // Status of MD lookup
     179    psListIterator *cellsIter = psListIteratorAlloc(cells, PS_LIST_HEAD, false); // Iterator for cells
     180    pmCell *cell = NULL;                // Cell from iteration
     181    bool allFixed = true;               // We're able to fix all TRIMSEC and BIASSEC
     182    while ((cell = psListGetAndIncrement(cellsIter))) {
     183        psMetadataItem *trimsecItem = psMetadataLookup(cell->concepts, "CELL.TRIMSEC"); // Item with trimsec
     184        if (!trimsecItem || trimsecItem->type != PS_DATA_REGION) {
     185            psWarning("CELL.TRIMSEC has not been initialised in cell --- ignored.\n");
     186            return false;
     187        }
     188        psRegion *trimsec = trimsecItem->data.V; // Trim section
     189        if (psRegionIsNaN(*trimsec)) {
     190            const char *trimsecSource = psMetadataLookupStr(&mdok, cell->config, "CELL.TRIMSEC.SOURCE");
     191            if (strcmp(trimsecSource, "VALUE") == 0) {
     192
     193                const char *trimsecStr = psMetadataLookupStr(&mdok, cell->config, "CELL.TRIMSEC");
     194                *trimsec = psRegionFromString(trimsecStr);
     195            } else {
     196                allFixed = false;
     197            }
     198        }
     199
     200        psMetadataItem *biassecItem = psMetadataLookup(cell->concepts, "CELL.BIASSEC"); // Bias sections
     201        if (!biassecItem) {
     202            psWarning("CELL.BIASSEC has not been initialised in cell --- ignored.\n");
     203            return false;
     204        }
     205        psList *biassecs = biassecItem->data.V;
     206        if (biassecs->n != 0) {
     207            allFixed = false;
     208            continue;
     209        }
     210
     211        const char *biassecSource = psMetadataLookupStr(&mdok, cell->config, "CELL.BIASSEC.SOURCE");
     212        if (strcmp(biassecSource, "VALUE") == 0) {
     213            const char *biassecStr = psMetadataLookupStr(&mdok, cell->config, "CELL.BIASSEC");
     214            psFree(biassecItem->data.V);
     215            biassecItem->data.V = p_pmConceptParseRegions(biassecStr);
     216        } else {
     217            allFixed = false;
     218        }
     219    }
     220    psFree(cellsIter);
     221
     222    return allFixed;
     223}
     224
    171225
    172226// Generate CELL.TRIMSEC and CELL.BIASSEC for the cells
     
    341395    // Get the size of the HDU, either from existing trimsec and biassec, or generate these and try again
    342396    int xSize = 0, ySize = 0;           // Size of HDU
    343     if (!sizeHDU(&xSize, &ySize, cells) && !(generateTrimBias(cells) && sizeHDU(&xSize, &ySize, cells))) {
     397    if (!sizeHDU(&xSize, &ySize, cells) &&
     398        !(readTrimBias(cells) && sizeHDU(&xSize, &ySize, cells)) &&
     399        !(generateTrimBias(cells) && sizeHDU(&xSize, &ySize, cells))) {
    344400        psError(PS_ERR_IO, true, "Unable to determine size of HDU!\n");
    345401        return false;
Note: See TracChangeset for help on using the changeset viewer.