IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7067 for trunk/ppMerge/src


Ignore:
Timestamp:
May 4, 2006, 3:53:10 PM (20 years ago)
Author:
Paul Price
Message:

Code compiles now. Not yet tested.

Location:
trunk/ppMerge/src
Files:
10 edited

Legend:

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

    r7064 r7067  
    1212
    1313//#include "ppMem.h"
     14
     15// Yet to do:
     16//
     17// 1. Mask pixels with less than the minimum number of electrons
     18// 2. Sampling factor for background measurement
     19// 3. On/off pairs
    1420
    1521int main(int argc, char **argv)
  • trunk/ppMerge/src/ppMerge.h

    r7064 r7067  
    33
    44#define TIMERNAME "ppMerge"
     5#define RECIPENAME "PPMERGE"
    56
    67#endif
  • trunk/ppMerge/src/ppMergeBackground.c

    r7064 r7067  
    44#include <psmodules.h>
    55
     6#include "ppMerge.h"
    67#include "ppMergeBackground.h"
    78
     
    150151
    151152                    // Get the background
    152                     psImageStats(bgStats, image, readout->mask, options->maskVal);
     153                    psImageStats(bgStats, image, readout->mask, options->combine->maskVal);
    153154                    background->data.F64[i][cellNum] = getStat(bgStats, options->background);
    154155                }
  • trunk/ppMerge/src/ppMergeCheckInputs.c

    r7061 r7067  
    44#include <psmodules.h>
    55
     6#include "ppMerge.h"
    67#include "ppMergeCheckInputs.h"
    78#include "ppMergeData.h"
     
    910// Check input files to make sure everything's consistent
    1011ppMergeData *ppMergeCheckInputs(ppMergeOptions *options, // Options
    11                                 const pmConfig *config // Configuration
     12                                pmConfig *config // Configuration
    1213    )
    1314{
     
    3435        psFits *inFile = psFitsOpen(filenames->data[i], "r"); // The FITS file to read
    3536        if (!inFile) {
    36             psErrorPrint(PS_ERR_IO, false, "Unable to open input file %s --- ignored.\n", name);
     37            psLogMsg(__func__, PS_LOG_WARN, "Unable to open input file %s --- ignored.\n", name);
    3738            // Kick it out
    3839            psFree(filenames->data[i]);
     
    5152            data->format = pmConfigCameraFormatFromHeader(config, header);
    5253            psFree(header);
    53             if (!options->format) {
     54            if (!data->format) {
    5455                psLogMsg(__func__, PS_LOG_WARN, "Unable to identify camera format for input file %s --- "
    5556                             "ignored.\n", name);
     
    5960                continue;
    6061            }
    61         } else if (!pmConfigValidateCameraFormat(options->format, header)) {
     62        } else if (!pmConfigValidateCameraFormat(data->format, header)) {
    6263            psLogMsg(__func__, PS_LOG_WARN, "Input file %s doesn't match camera format --- ignored.\n", name);
    6364            // Kick it out
     
    99100    data->numCells = numCells;
    100101
    101     return (numGood > 1);
     102    if (numGood > 1) {
     103        return data;
     104    }
     105
     106    psFree(data);
     107    return NULL;
    102108}
    103109
  • trunk/ppMerge/src/ppMergeCheckInputs.h

    r7064 r7067  
    88// Check input files to make sure everything's consistent
    99ppMergeData *ppMergeCheckInputs(ppMergeOptions *options, // Options
    10                                 const pmConfig *config // Configuration
     10                                pmConfig *config // Configuration
    1111    );
    1212
  • trunk/ppMerge/src/ppMergeCombine.c

    r7061 r7067  
    44#include <psmodules.h>
    55
     6#include "ppMerge.h"
    67#include "ppMergeData.h"
    78#include "ppMergeCombine.h"
     
    2122    // Sanity checks
    2223    assert(!options->scale || scales);
    23     assert(!scales || !*scales || ((*scales)->type.type == PS_TYPE_F64 &&
    24                                    (*scales)->numCols == data->numCells &&
    25                                    (*scales)->numRows == filenames->n));
     24    assert(!scales || (scales->type.type == PS_TYPE_F64 &&
     25                       scales->numCols == data->numCells &&
     26                       scales->numRows == filenames->n));
    2627    assert(!options->zero || zeros);
    27     assert(!zeros || !*zeros || ((*zeros)->type.type == PS_TYPE_F64 &&
    28                                  (*zeros)->numCols == data->numCells &&
    29                                  (*zeros)->numRows == filenames->n));
     28    assert(!zeros || (zeros->type.type == PS_TYPE_F64 &&
     29                      zeros->numCols == data->numCells &&
     30                      zeros->numRows == filenames->n));
    3031
    3132    // Iterate over the FPA
     
    3839            continue;
    3940        }
    40         pmChipWrite(chip, outFile, config->database, false);
     41        pmChipWrite(chip, data->outFile, config->database, false);
    4142        psArray *cells = chip->cells;   // Array of output cells
    4243        for (int j = 0; j < cells->n; j++) {
     
    4647            }
    4748            cellNum++;
    48             pmCellWrite(cell, outFile, config->database, false);
     49            pmCellWrite(cell, data->outFile, config->database, false);
    4950            pmReadout *readout = pmReadoutAlloc(cell); // Output readout of interest
    5051            psArray *stack = psArrayAlloc(filenames->n); // Stack of readouts to combine
     
    5354                cellScales = psImageCol(NULL, scales, cellNum);
    5455            }
    55             psVector cellZeros = NULL;  // Zeros for this cell
     56            psVector *cellZeros = NULL;  // Zeros for this cell
    5657            if (zeros) {
    5758                cellZeros = psImageCol(NULL, zeros, cellNum);
     
    8182
    8283                    // Only reading and writing the first readout in each cell (plane 0)
    83                     stillReading |= pmReadoutReadNext(stack->data[k], fits, 0, options->rows);
     84                    stillReadingRows |= pmReadoutReadNext(stack->data[k], fits, 0, options->rows);
    8485                    psFitsClose(fits);
    8586                }
    8687
    87                 pmReadoutCombine(readout, stack, cellZeros, cellScales, combineParams);
    88                 pmReadoutWriteNext(readout, outFile, 0);
     88                pmReadoutCombine(readout, stack, cellZeros, cellScales, options->combine);
     89                pmReadoutWriteNext(readout, data->outFile, 0);
    8990
    9091            } while (stillReadingRows);
    9192
    9293            // Write the pixels
    93             pmCellWrite(cell, outFile, config->database, true);
     94            pmCellWrite(cell, data->outFile, config->database, true);
    9495
    9596            // Blow away the cell data
     
    104105
    105106        // Write the pixels
    106         pmChipWrite(chip, outFile, config->database, true);
     107        pmChipWrite(chip, data->outFile, config->database, true);
    107108
    108109        // Blow away the chip data
     
    117118
    118119    // Write the pixels
    119     pmFPAWrite(fpa, outFile, config->database, true);
     120    pmFPAWrite(data->out, data->outFile, config->database, true);
    120121
    121122    // Blow away the FPA data
     
    124125        pmFPAFreeData(fpaIn);
    125126    }
    126     pmFPAFreeData(fpa);
     127    pmFPAFreeData(data->out);
    127128
    128129    return true;
  • trunk/ppMerge/src/ppMergeConfig.c

    r7002 r7067  
    33#include <psmodules.h>
    44
     5#include "ppMerge.h"
    56#include "ppMergeConfig.h"
    67
  • trunk/ppMerge/src/ppMergeData.c

    r7061 r7067  
    22#include <pslib.h>
    33
     4#include "ppMerge.h"
    45#include "ppMergeData.h"
    56
     
    2021{
    2122    ppMergeData *data = psAlloc(sizeof(ppMergeData)); // The data, to return
    22     psMemSetFreeFunction(data, (psFreeFunc)mergeDataFree);
     23    psMemSetDeallocator(data, (psFreeFunc)mergeDataFree);
    2324
    2425    data->format = NULL;
  • trunk/ppMerge/src/ppMergeOptions.c

    r7061 r7067  
    22#include <pslib.h>
    33#include <psmodules.h>
     4
     5#include "ppMerge.h"
     6#include "ppMergeOptions.h"
    47
    58//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    710//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    811
    9 #if 0
    1012// Free function
    1113static void mergeOptionsFree(ppMergeOptions *options // Options to free
    1214    )
    1315{
     16    psFree(options->combine);
    1417}
    15 #endif
    1618
    1719// Allocator
     
    1921{
    2022    ppMergeOptions *options = psAlloc(sizeof(ppMergeOptions)); // The options, to return
    21     // psMemSetDeallocator(options, (psFreeFunc)mergeOptionsFree);
     23    psMemSetDeallocator(options, (psFreeFunc)mergeOptionsFree);
    2224
    2325    options->rows = 0;
     
    2931    options->background = PS_STAT_SAMPLE_MEDIAN;
    3032    options->onOff = 0;
    31     options->combine = PS_STAT_SAMPLE_MEAN;
    32     options->ref = 3.0;
    33     options->iter = 1;
    34     options->fracHigh = 0.0;
    35     options->fracLow = 0.0;
    36     options->nKeep = 1;
    37     options->maskVal = 0xffff;
     33    options->combine = pmCombineParamsAlloc(PS_STAT_SAMPLE_MEAN);
     34    options->combine->rej = 3.0;
     35    options->combine->iter = 1;
     36    options->combine->fracHigh = 0.0;
     37    options->combine->fracLow = 0.0;
     38    options->combine->nKeep = 1;
     39    options->combine->maskVal = 0xff;
    3840
    3941    return options;
     
    8486
    8587// Parse the options
    86 ppMergeOptions *ppMergeOptionsParse(ppConfig *config // Configuration
     88ppMergeOptions *ppMergeOptionsParse(pmConfig *config // Configuration
    8789    )
    8890{
    8991    ppMergeOptions *options = ppMergeOptionsAlloc(); // The merge options
    9092
     93    bool mdok = true;                   // Status of MD lookup
     94    psMetadata *recipe = psMetadataLookupMD(&mdok, config->recipes, RECIPENAME); // Recipe information
     95    if (!mdok || !recipe) {
     96        psError(PS_ERR_IO, true, "Unable to find recipe %s", RECIPENAME);
     97        exit(EXIT_FAILURE);
     98    }
     99
    91100    // First, deal with the recipe.  These are parameters that will typically be constant for a camera.
    92     OPTION_PARSE(options->rows,         config->recipe, "ROWS",      U16 );
    93     OPTION_PARSE(options->minElectrons, config->recipe, "ELECTRONS", F32 );
    94     OPTION_PARSE(options->sample,       config->recipe, "SAMPLE",    S32 );
    95     OPTION_PARSE(options->rej,          config->recipe, "REJ",       F32 );
    96     OPTION_PARSE(options->iter,         config->recipe, "ITER",      S32 );
    97     OPTION_PARSE(options->fracHigh,     config->recipe, "FRACHIGH",  F32 );
    98     OPTION_PARSE(options->fracLow,      config->recipe, "FRACLOW",   F32 );
    99     OPTION_PARSE(options->nKeep,        config->recipe, "NKEEP",     S32 );
    100     OPTION_PARSE(options->maskVal,      config->recipe, "MASKVAL",   U8  );
    101     options->combine = parseStat(config->recipe, "COMBINE");
    102     options->background = parseStat(config->recipe, "BACKGROUND");
     101    OPTION_PARSE(options->rows,              recipe, "ROWS",      U16 );
     102    OPTION_PARSE(options->minElectrons,      recipe, "ELECTRONS", F32 );
     103    OPTION_PARSE(options->sample,            recipe, "SAMPLE",    S32 );
     104    OPTION_PARSE(options->combine->rej,      recipe, "REJ",       F32 );
     105    OPTION_PARSE(options->combine->iter,     recipe, "ITER",      S32 );
     106    OPTION_PARSE(options->combine->fracHigh, recipe, "FRACHIGH",  F32 );
     107    OPTION_PARSE(options->combine->fracLow,  recipe, "FRACLOW",   F32 );
     108    OPTION_PARSE(options->combine->nKeep,    recipe, "NKEEP",     S32 );
     109    OPTION_PARSE(options->combine->maskVal,  recipe, "MASKVAL",   U8  );
     110    options->combine->combine = parseStat(recipe, "COMBINE");
     111    options->background       = parseStat(recipe, "BACKGROUND");
    103112
    104113    // Now the command-line options.  These are parameters that depend on what type of frame is being combined
     
    127136
    128137    // Or you can set them individually
    129     OPTION_PARSE(options->zero,    config->recipe, "-zero",    Bool);
    130     OPTION_PARSE(options->scale,   config->recipe, "-scale",   Bool);
    131     OPTION_PARSE(options->exptime, config->recipe, "-exptime", Bool);
     138    OPTION_PARSE(options->zero,    config->arguments, "-zero",    Bool);
     139    OPTION_PARSE(options->scale,   config->arguments, "-scale",   Bool);
     140    OPTION_PARSE(options->exptime, config->arguments, "-exptime", Bool);
    132141
    133142    // Number of on/off images
    134     OPTION_PARSE(options->onoff, config->recipe, "-onoff", S32);
     143    OPTION_PARSE(options->onOff, config->arguments, "-onoff", S32);
    135144
    136145    return options;
  • trunk/ppMerge/src/ppMergeOptions.h

    r7064 r7067  
    2424    psStatsOptions background;          // Statistic to use to measure the background
    2525    ppOnOff onOff;                      // On/off pairs?
    26     psStatsOptions combine;             // Statistic to use in combination
    27     float rej;                          // Rejection level in combination (for sigma clipping)
    28     unsigned int iter;                  // Number of iterations for combination (for sigma clipping)
    29     float fracHigh;                     // Fraction of high pixels to throw
    30     float fracLow;                      // Fraction of low pixels to throw
    31     int nKeep;                          // Minimum number of pixels to keep
    32     psMaskType maskVal;                 // Mask value
     26    pmCombineParams *combine;           // Combination parameters
    3327} ppMergeOptions;
    3428
    3529// Allocator
    36 ppMergeOptions *ppMergeOptionsAlloc(psStatsOptions stat // Statistic to use in the merge
    37     );
     30ppMergeOptions *ppMergeOptionsAlloc(void);
    3831
    3932
Note: See TracChangeset for help on using the changeset viewer.