IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 1, 2006, 10:16:15 AM (20 years ago)
Author:
Paul Price
Message:

Working version for flat-fielding. Need to add extenal scale/zero input, mask saturated pixels, test on dark, bias, fringe.

File:
1 edited

Legend:

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

    r7067 r7260  
    77#include "ppMergeData.h"
    88#include "ppMergeCombine.h"
     9
    910
    1011// Combine the inputs
     
    2223    // Sanity checks
    2324    assert(!options->scale || scales);
    24     assert(!scales || (scales->type.type == PS_TYPE_F64 &&
     25    assert(!scales || (scales->type.type == PS_TYPE_F32 &&
    2526                       scales->numCols == data->numCells &&
    2627                       scales->numRows == filenames->n));
    2728    assert(!options->zero || zeros);
    28     assert(!zeros || (zeros->type.type == PS_TYPE_F64 &&
     29    assert(!zeros || (zeros->type.type == PS_TYPE_F32 &&
    2930                      zeros->numCols == data->numCells &&
    3031                      zeros->numRows == filenames->n));
     
    3233    // Iterate over the FPA
    3334    int cellNum = -1;                   // Cell number
    34     pmFPAWrite(data->out, data->outFile, config->database, false);
     35    pmFPAWrite(data->out, data->outFile, config->database, false, false); // Write header only
    3536    psArray *chips = data->out->chips;  // Array of output chips
    3637    for (int i = 0; i < chips->n; i++) {
     
    3940            continue;
    4041        }
    41         pmChipWrite(chip, data->outFile, config->database, false);
     42        pmChipWrite(chip, data->outFile, config->database, false, false); // Write header only
    4243        psArray *cells = chip->cells;   // Array of output cells
    4344        for (int j = 0; j < cells->n; j++) {
     
    4748            }
    4849            cellNum++;
    49             pmCellWrite(cell, data->outFile, config->database, false);
     50            pmCellWrite(cell, data->outFile, config->database, false); // Write header only
    5051            pmReadout *readout = pmReadoutAlloc(cell); // Output readout of interest
    5152            psArray *stack = psArrayAlloc(filenames->n); // Stack of readouts to combine
     53            stack->n = filenames->n;
    5254            psVector *cellScales = NULL; // Scales for this cell
    5355            if (scales) {
     
    5961            }
    6062
    61             bool stillReadingRows = false;  // Still reading rows from any of the files?
    62 
     63            int numRead;  // Number of inputs read
    6364            do {
     65                numRead = 0;
    6466                for (int k = 0; k < filenames->n; k++) {
    6567                    if (! filenames->data[k] || strlen(filenames->data[k]) == 0) {
     
    8284
    8385                    // Only reading and writing the first readout in each cell (plane 0)
    84                     stillReadingRows |= pmReadoutReadNext(stack->data[k], fits, 0, options->rows);
     86                    if (pmReadoutReadNext(stack->data[k], fits, 0, options->rows)) {
     87                        numRead++;
     88                    }
    8589                    psFitsClose(fits);
    8690                }
    8791
    88                 pmReadoutCombine(readout, stack, cellZeros, cellScales, options->combine);
    89                 pmReadoutWriteNext(readout, data->outFile, 0);
     92                if (numRead > 0) {
     93                    pmReadoutCombine(readout, stack, cellZeros, cellScales, options->combine);
     94                    psTrace(__func__, 5, "Chip %d, cell %d, readout size %dx%d\n", i, j,
     95                            readout->image->numCols, readout->image->numRows);
     96                }
    9097
    91             } while (stillReadingRows);
    92 
    93             // Write the pixels
    94             pmCellWrite(cell, data->outFile, config->database, true);
     98            } while (numRead > 0);
    9599
    96100            // Blow away the cell data
     
    101105                pmCellFreeData(cellIn);
    102106            }
    103             pmCellFreeData(cell);
     107
     108            // Write the pixels
     109            if (cell->hdu) {
     110                psTrace(__func__, 5, "Writing out cell HDU.\n");
     111                pmCellWrite(cell, data->outFile, config->database, true);
     112                pmCellFreeData(cell);
     113            }
    104114        }
    105 
    106         // Write the pixels
    107         pmChipWrite(chip, data->outFile, config->database, true);
    108115
    109116        // Blow away the chip data
     
    113120            pmChipFreeData(chipIn);
    114121        }
    115         pmChipFreeData(chip);
    116122
     123        // Write the pixels
     124        if (chip->hdu) {
     125            psTrace(__func__, 5, "Writing out chip HDU.\n");
     126            pmChipWrite(chip, data->outFile, config->database, true, false);
     127            pmChipFreeData(chip);
     128        }
    117129    }
    118130
    119     // Write the pixels
    120     pmFPAWrite(data->out, data->outFile, config->database, true);
     131    if (data->out->hdu) {
     132        // Write the pixels
     133        psTrace(__func__, 5, "Writing out FPA HDU.\n");
     134        pmFPAWrite(data->out, data->outFile, config->database, true, false);
     135    }
    121136
    122137    // Blow away the FPA data
Note: See TracChangeset for help on using the changeset viewer.