IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7355


Ignore:
Timestamp:
Jun 5, 2006, 3:47:48 PM (20 years ago)
Author:
Paul Price
Message:

Changes to allow user to specify scale and zero through concepts

Location:
trunk/ppMerge/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppMerge/src/ppMergeCombine.c

    r7260 r7355  
    8585                    // Only reading and writing the first readout in each cell (plane 0)
    8686                    if (pmReadoutReadNext(stack->data[k], fits, 0, options->rows)) {
     87                        pmReadoutSetMask(stack->data[k]);
    8788                        numRead++;
    8889                    }
  • trunk/ppMerge/src/ppMergeConfig.c

    r7073 r7355  
    6161                     "Array of inputs images", files);
    6262
    63 #if 0
     63#ifndef OMIT_PSDB
    6464    // Define database handle, if required
    65     config->database = pmConfigDB(config->site);
     65    config->database = pmConfigDB(config);
    6666#endif
     67
     68    // Add concepts for scale and zero
     69    psMetadataItem *scaleItem = psMetadataItemAllocF32("PPMERGE.SCALE", "Scaling for ppMerge", NAN);
     70    psMetadataItem *zeroItem = psMetadataItemAllocF32("PPMERGE.ZERO", "Zero offset for ppMerge", NAN);
     71    pmConceptRegister(scaleItem, NULL, NULL, PM_FPA_LEVEL_CELL);
     72    pmConceptRegister(zeroItem, NULL, NULL, PM_FPA_LEVEL_CELL);
     73    psFree(scaleItem);
     74    psFree(zeroItem);
    6775
    6876    return config;
  • trunk/ppMerge/src/ppMergeScaleZero.c

    r7263 r7355  
    4242    )
    4343{
     44    assert(data);
     45    assert(options);
     46    assert(config);
     47
     48    if (!options->scale && !options->zero) {
     49        return true;                    // We did everything we were asked for
     50    }
     51
    4452    assert(config->camera);             // Need the camera configuration
     53    assert(config->arguments);          // Need the list of files
    4554
    4655    psArray *filenames = psMetadataLookupPtr(NULL, config->arguments, "INPUT"); // The input file names
     
    5766                                 (*zeros)->numRows == filenames->n));
    5867
     68    // Allocate the outputs
     69    if (options->scale) {
     70        if (*scales) {
     71            psFree(*scales);
     72        }
     73        *scales = psImageAlloc(data->numCells, filenames->n, PS_TYPE_F32);
     74    }
     75    if (options->zero) {
     76        if (*zeros) {
     77            psFree(*zeros);
     78        }
     79        *zeros = psImageAlloc(data->numCells, filenames->n, PS_TYPE_F32);
     80    }
     81
     82    bool fromConcepts = false;          // Do we get the scale and zero points from the concepts
     83    bool first = true;                  // Are we on the first cell (that sets the standard for the rest)?
     84    bool done = false;                  // Are we done going through the list?
     85    bool mdok = true;                   // Status of MD lookup
     86    for (long i = 0; i < data->in->n && !done; i++) {
     87        pmFPA *fpa = data->in->data[i]; // The FPA
     88        if (!fpa) {
     89            continue;
     90        }
     91        long cellNum = -1;              // Number of the cell
     92        psArray *chips = fpa->chips;    // The array of chips
     93        for (long j = 0; j < chips->n && !done; j++) {
     94            pmChip *chip = chips->data[j]; // The chip
     95            if (!chip) {
     96                continue;
     97            }
     98            psArray *cells = chip->cells; // The array of cells
     99            for (long k = 0; k < cells->n && !done; k++) {
     100                pmCell *cell = cells->data[k]; // The cell
     101                if (!cell) {
     102                    continue;
     103                }
     104                cellNum++;
     105
     106                if (options->scale) {
     107                    float scale = psMetadataLookupF32(&mdok, cell->concepts, "PPMERGE.SCALE"); // The scale
     108                    if (mdok && !isnan(scale)) {
     109                        if (!first && !fromConcepts) {
     110                            psLogMsg(__func__, PS_LOG_WARN, "PPMERGE.SCALE and PPMERGE.ZERO have been set "
     111                                     "for some, but not all cells --- we will re-measure it for all cells.");
     112                            done = true;
     113                            continue;
     114                        }
     115                        fromConcepts = true;
     116                        (*scales)->data.F32[i][cellNum] = scale;
     117                        psTrace(__func__, 9, "Scale for input %ld, chip %ld, cell %ld: %f\n", i, j, k, scale);
     118                    } else if (!first && fromConcepts) {
     119                        psLogMsg(__func__, PS_LOG_WARN, "PPMERGE.SCALE and PPMERGE.ZERO have been set "
     120                                 "for some, but not all cells --- we will re-measure it for all cells.");
     121                        fromConcepts = false;
     122                        done = true;
     123                        continue;
     124                    }
     125                }
     126
     127                if (options->zero) {
     128                    float zero = psMetadataLookupF32(&mdok, cell->concepts, "PPMERGE.ZERO"); // The zero
     129                    if (mdok && !isnan(zero)) {
     130                        if (!first && !fromConcepts) {
     131                            psLogMsg(__func__, PS_LOG_WARN, "PPMERGE.SCALE and PPMERGE.ZERO have been set "
     132                                     "for some, but not all cells --- we will re-measure it for all cells.");
     133                            done = true;
     134                            continue;
     135                        }
     136                        fromConcepts = true;
     137                        (*zeros)->data.F32[i][cellNum] = zero;
     138                        psTrace(__func__, 9, "Zero for input %ld, chip %ld, cell %ld: %f\n", i, j, k, zero);
     139                   } else if (!first && fromConcepts) {
     140                        psLogMsg(__func__, PS_LOG_WARN, "PPMERGE.SCALE and PPMERGE.ZERO have been set "
     141                                 "for some, but not all cells --- we will re-measure it for all cells.");
     142                        fromConcepts = false;
     143                        done = true;
     144                        continue;
     145                    }
     146                }
     147
     148                first = false;
     149            }
     150        }
     151    }
     152
     153    if (fromConcepts) {
     154        // We've already done everything we need to
     155        return true;
     156    }
     157
    59158    psImage *background = psImageAlloc(data->numCells, filenames->n, PS_TYPE_F32); // Background measurements
    60159    psImageInit(background, NAN);
     
    108207                // Normalising by the exposure time
    109208                if (options->exptime) {
    110                     bool mdok = true;   // Status of MD lookup
    111209                    exptime->data.F32[i][cellNum] = psMetadataLookupF32(&mdok, cell->concepts,
    112210                                                                        "CELL.EXPOSURE");
     
    203301        psFree(gains);
    204302
    205         *scales = psImageCopy(*scales, background, PS_TYPE_F32);
    206303        psImage *scalesDeref = *scales; // Dereference the pointer
    207304
     
    217314        if (!options->scale) {
    218315            // Copy over the exposure times
    219             psImageCopy(*scales, exptime, PS_TYPE_F32);
     316            *scales = psImageCopy(*scales, exptime, PS_TYPE_F32);
    220317        } else {
    221             psBinaryOp(*scales, *scales, "*", exptime);
     318            *scales = (psImage*)psBinaryOp(*scales, *scales, "*", exptime);
    222319        }
    223320    }
Note: See TracChangeset for help on using the changeset viewer.