IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 21, 2005, 5:00:14 PM (20 years ago)
Author:
Paul Price
Message:

Mask and weight input and output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/scripts/src/phase2/papPhase2.c

    r5467 r5564  
    2929// * Write calibrated image
    3030// * Write source catalogue, astrometry, etc.
    31  
     31
    3232// Currently neglecting different input types (F32, S32, U16, etc)
    3333
     
    302302#else
    303303    psFree(inputFile);
     304#endif
     305
     306
     307#if 1
     308    {
     309        // Generate mask and weight frame
     310        p_pmHDU *hdu = NULL;
     311        if (input->hdu) {
     312            hdu = input->hdu;
     313        }
     314        psArray *chips = input->chips;
     315        for (int chipNum = 0; chipNum < chips->n; chipNum++) {
     316            pmChip *chip = chips->data[chipNum];
     317            if (chip->valid) {
     318                if (chip->hdu) {
     319                    hdu = chip->hdu;
     320                }
     321                psArray *cells = chip->cells;
     322                for (int cellNum = 0; cellNum < cells->n; cellNum++) {
     323                    pmCell *cell = cells->data[cellNum];
     324                    if (cell->valid) {
     325                        if (cell->hdu) {
     326                            hdu = cell->hdu;
     327                        }
     328                       
     329                        hdu->masks = psArrayAlloc(hdu->images->n);
     330                        hdu->weights = psArrayAlloc(hdu->images->n);
     331                        psArray *readouts = cell->readouts;
     332                        for (int readNum = 0; readNum < hdu->images->n; readNum++) {
     333                            psImage *image = hdu->images->data[readNum];
     334                            psImage *mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8);
     335                            psImage *weight = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32);
     336                            pmReadout *readout = readouts->data[readNum];
     337                            for (int j = 0; j < image->numRows; j++) {
     338                                for (int i = 0; i < image->numCols; i++) {
     339                                    mask->data.U8[j][i] = j + i;
     340                                    weight->data.F32[j][i] = sqrtf(image->data.F32[j][i]);
     341                                }
     342                            }
     343                            hdu->masks->data[readNum] = mask;
     344                            hdu->weights->data[readNum] = weight;
     345                            readout->mask = psMemIncrRefCounter(mask);
     346                            readout->weight = psMemIncrRefCounter(weight);
     347                        }
     348                    }
     349                }
     350            }
     351        }
     352    }
    304353#endif
    305354
     
    741790                                                       inputReadout->image->numRows,
    742791                                                       PS_TYPE_U8);
    743                     pmReadout *dummyMask = pmReadoutAlloc(NULL, dummyImage, NULL, 0, 0, 1, 1, 1, 1);
     792                    pmReadout *dummyMask = pmReadoutAlloc(NULL, dummyImage, NULL, 0, 0, 1, 1);
    744793                    (void)pmFlatField(inputReadout, dummyMask, flatReadout);
    745794                    psFree(dummyMask);
     
    771820    // Write the output
    772821    pmFPAWrite(outputFile, input, database);
    773 //    pmFPAWriteMask(outputMaskFile, input);
     822    pmFPAWriteMask(input, outputFile);
     823    pmFPAWriteWeight(input, outputFile);
     824
    774825#ifdef PRODUCTION
    775826    psFitsClose(outputFile);
Note: See TracChangeset for help on using the changeset viewer.