IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7849


Ignore:
Timestamp:
Jul 7, 2006, 7:21:12 PM (20 years ago)
Author:
Paul Price
Message:

Adding pmConceptsAverageCells() from previous cellConcepts() in pmFPAMosaic: given a list of cells, find a reasonable combination of the concepts. This is used in pmFPAMosaic and now also pmReadoutCombine.

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

Legend:

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

    r7755 r7849  
    44#include "pmFPA.h"
    55#include "pmHDU.h"
     6#include "pmConceptsAverage.h"
    67#include "pmHDUUtils.h"
    78#include "pmFPAMosaic.h"
     
    2728if ((value) > (max)) { \
    2829    (max) = (value); \
    29 }
    30 
    31 // Update a metadata entry directly
    32 #define MD_UPDATE(MD, NAME, TYPE, VALUE) \
    33 { \
    34     psMetadataItem *item = psMetadataLookup(MD, NAME); \
    35     item->data.TYPE = VALUE; \
    3630}
    3731
     
    529523
    530524    return mosaic;
    531 }
    532 
    533 
    534 // Set the concepts in the new cell, based on the values in the old one
    535 static bool cellConcepts(pmCell *target,// Target cell
    536                          psList *sources, // Source cells
    537                          int xBin, int yBin, // Binning
    538                          psRegion *trimsec // The trim section
    539                         )
    540 {
    541     assert(target);
    542     assert(sources);
    543     assert(xBin > 0 && yBin > 0);
    544     assert(trimsec);
    545 
    546     bool success = true;                // Result of setting everything
    547     float gain       = 0.0;             // Gain
    548     float readnoise  = 0.0;             // Read noise
    549     float saturation = INFINITY;        // Saturation level
    550     float bad        = -INFINITY;       // Bad level
    551     float exposure   = 0.0;             // Exposure time
    552     float darktime   = 0.0;             // Dark time
    553     double time      = 0.0;             // Time of observation
    554     psTimeType timeSys = 0;             // Time system
    555     int readdir      = 0;               // Cell read direction
    556 
    557     int nCells = 0;                     // Number of cells;
    558     psListIterator *sourcesIter = psListIteratorAlloc(sources, PS_LIST_HEAD, false); // Iterator for sources
    559     pmCell *cell = NULL;                // Source cell from iteration
    560     while ((cell = psListGetAndIncrement(sourcesIter))) {
    561         if (!cell) {
    562             continue;
    563         }
    564 
    565         nCells++;
    566         gain       += psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN");
    567         readnoise  += psMetadataLookupF32(NULL, cell->concepts, "CELL.READNOISE");
    568         exposure   += psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE");
    569         darktime   += psMetadataLookupF32(NULL, cell->concepts, "CELL.DARKTIME");
    570         psTime *cellTime = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TIME");
    571         time       += psTimeToMJD(cellTime);
    572         if (nCells == 1) {
    573             timeSys = psMetadataLookupS32(NULL, cell->concepts, "CELL.TIMESYS");
    574             readdir = psMetadataLookupS32(NULL, cell->concepts, "CELL.READDIR");
    575         } else {
    576             if (timeSys != psMetadataLookupS32(NULL, cell->concepts, "CELL.TIMESYS")) {
    577                 psLogMsg(__func__, PS_LOG_ERROR, "Differing time systems in use: %d vs %d\n", timeSys,
    578                          psMetadataLookupS32(NULL, cell->concepts, "CELL.TIMESYS"));
    579                 success = false;
    580             }
    581             if (readdir != psMetadataLookupS32(NULL, cell->concepts, "CELL.READDIR")) {
    582                 psLogMsg(__func__, PS_LOG_ERROR, "Differing cell read directions in use: %d vs %d\n", readdir,
    583                          psMetadataLookupS32(NULL, cell->concepts, "CELL.READDIR"));
    584                 success = false;
    585             }
    586         }
    587 
    588         float cellSaturation = psMetadataLookupF32(NULL, cell->concepts, "CELL.SATURATION");
    589         if (cellSaturation < saturation) {
    590             saturation = cellSaturation;
    591         }
    592         float cellBad = psMetadataLookupF32(NULL, cell->concepts, "CELL.BAD");
    593         if (cellBad > bad) {
    594             bad = cellBad;
    595         }
    596     }
    597     psFree(sourcesIter);
    598 
    599     gain      /= (float)nCells;
    600     readnoise /= (float)nCells;
    601     exposure  /= (float)nCells;
    602     darktime  /= (float)nCells;
    603     time      /= (double)nCells;
    604 
    605     MD_UPDATE(target->concepts, "CELL.GAIN", F32, gain);
    606     MD_UPDATE(target->concepts, "CELL.READNOISE", F32, readnoise);
    607     MD_UPDATE(target->concepts, "CELL.SATURATION", F32, saturation);
    608     MD_UPDATE(target->concepts, "CELL.BAD", F32, bad);
    609     MD_UPDATE(target->concepts, "CELL.EXPOSURE", F32, exposure);
    610     MD_UPDATE(target->concepts, "CELL.DARKTIME", F32, darktime);
    611     MD_UPDATE(target->concepts, "CELL.TIMESYS", S32, timeSys);
    612     MD_UPDATE(target->concepts, "CELL.X0", S32, 0);
    613     MD_UPDATE(target->concepts, "CELL.Y0", S32, 0);
    614     MD_UPDATE(target->concepts, "CELL.XPARITY", S32, 1);
    615     MD_UPDATE(target->concepts, "CELL.YPARITY", S32, 1);
    616     MD_UPDATE(target->concepts, "CELL.XBIN", S32, xBin);
    617     MD_UPDATE(target->concepts, "CELL.YBIN", S32, yBin);
    618     MD_UPDATE(target->concepts, "CELL.READDIR", S32, readdir);
    619 
    620     // CELL.TIME needs special care
    621     {
    622         psMetadataItem *timeItem = psMetadataLookup(target->concepts, "CELL.TIME");
    623         psFree(timeItem->data.V);
    624         timeItem->data.V = psTimeFromMJD(time);
    625     }
    626 
    627     // CELL.TRIMSEC needs special care
    628     {
    629         psMetadataItem *trimsecItem = psMetadataLookup(target->concepts, "CELL.TRIMSEC");
    630         psFree(trimsecItem->data.V);
    631         trimsecItem->data.V = psMemIncrRefCounter(trimsec);
    632     }
    633 
    634     return success;
    635525}
    636526
     
    1105995    // Set the concepts for the target cell
    1106996    psList *sourceCells = psArrayToList(source->cells); // List of cells
    1107     cellConcepts(targetCell, sourceCells, xBin, yBin, chipRegion);
     997    pmConceptsAverageCells(targetCell, sourceCells, xBin, yBin, chipRegion, NULL);
    1108998    psFree(sourceCells);
    1109999    psFree(chipRegion);
     
    12111101        }
    12121102    }
    1213     cellConcepts(targetCell, sourceCells, xBin, yBin, fpaRegion);
     1103    pmConceptsAverageCells(targetCell, sourceCells, xBin, yBin, fpaRegion, NULL);
    12141104    psFree(sourceCells);
    12151105    psFree(fpaRegion);
  • trunk/psModules/src/concepts/Makefile.am

    r7679 r7849  
    55libpsmoduleconcepts_la_SOURCES  = \
    66        pmConcepts.c \
     7        pmConceptsAverage.c \
    78        pmConceptsRead.c \
    89        pmConceptsWrite.c \
     
    1314psmoduleinclude_HEADERS = \
    1415        pmConcepts.h \
     16        pmConceptsAverage.h \
    1517        pmConceptsRead.h \
    1618        pmConceptsWrite.h \
  • trunk/psModules/src/imcombine/pmReadoutCombine.c

    r7802 r7849  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-07-04 00:19:11 $
     7 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-07-08 05:21:12 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1818#include "pmFPA.h"
    1919#include "pmFPAMaskWeight.h"
     20#include "pmConceptsAverage.h"
    2021
    2122#include "pmReadoutCombine.h"
     
    396397    psFree(mask);
    397398    psFree(weights);
    398 
    399399    psFree(stats);
     400
     401    // Update the "concepts"
     402    psList *inputCells = psListAlloc(NULL); // List of cells
     403    for (long i = 0; i < inputs->n; i++) {
     404        pmReadout *readout = inputs->data[i]; // Readout of interest
     405        psListAdd(inputCells, PS_LIST_TAIL, readout->parent);
     406    }
     407    pmConceptsAverageCells(output->parent, inputCells, 0, 0, NULL, NULL);
     408    psFree(inputCells);
    400409
    401410    return true;
Note: See TracChangeset for help on using the changeset viewer.