IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 13, 2009, 12:47:32 PM (17 years ago)
Author:
giebink
Message:

Account for weight(s) to variance(s) change

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/camera/tap_pmFPAReadWrite.c

    r21221 r21474  
    5656    readout->image = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32);
    5757    readout->mask = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_U8);
    58     readout->weight = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32);
     58    readout->variance = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32);
    5959    for (psS32 i = 0 ; i < NUM_BIAS_DATA ; i++) {
    6060        psImage *tmpImage = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32);
     
    9494    cell->hdu->images = psArrayAlloc(NUM_HDUS);
    9595    cell->hdu->masks = psArrayAlloc(NUM_HDUS);
    96     cell->hdu->weights = psArrayAlloc(NUM_HDUS);
     96    cell->hdu->variances = psArrayAlloc(NUM_HDUS);
    9797    for (int k = 0 ; k < NUM_HDUS ; k++) {
    9898        cell->hdu->images->data[k]  = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32);
    9999        cell->hdu->masks->data[k]   = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_MASK);
    100         cell->hdu->weights->data[k] = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32);
     100        cell->hdu->variances->data[k] = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32);
    101101        psImageInit(cell->hdu->images->data[k], (float) (BASE_IMAGE+k));
    102102        psImageInit(cell->hdu->masks->data[k], (psU8) (BASE_MASK+k));
    103         psImageInit(cell->hdu->weights->data[k], (float) (BASE_WEIGHT+k));
     103        psImageInit(cell->hdu->variances->data[k], (float) (BASE_WEIGHT+k));
    104104    }
    105105
     
    298298    // ----------------------------------------------------------------------
    299299    // ----------------------------------------------------------------------
    300     // pmCellWriteWeight(): tests
    301     // Verify pmCellWriteWeight() with NULL pmCell arg
     300    // pmCellWriteVariance(): tests
     301    // Verify pmCellWriteVariance() with NULL pmCell arg
    302302    {
    303303        psMemId id = psMemGetId();
    304304        psFits* fitsFileW = psFitsOpen(".tmp00", "w");
    305         ok(!pmCellWriteWeight(NULL, fitsFileW, NULL, false), "pmCellWriteWeight() returned FALSE with NULL pmCell input");
    306         psFitsClose(fitsFileW);
    307         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    308     }
    309 
    310 
    311     // Verify pmCellWriteWeight() with NULL pmFits arg
     305        ok(!pmCellWriteVariance(NULL, fitsFileW, NULL, false), "pmCellWriteVariance() returned FALSE with NULL pmCell input");
     306        psFitsClose(fitsFileW);
     307        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     308    }
     309
     310
     311    // Verify pmCellWriteVariance() with NULL pmFits arg
    312312    {
    313313        psMemId id = psMemGetId();
     
    317317        pmCell *cell = chip->cells->data[0];
    318318        ok(cell != NULL, "Allocated a pmCell successfully");
    319         ok(!pmCellWriteWeight(cell, NULL, NULL, false), "pmCellWriteWeight() returned FALSE with NULL psFits param");
    320         psFree(fpa);
    321         psFree(camera);
    322         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    323     }
    324 
    325 
    326     // Verify pmCellWriteWeight() with acceptable input params
    327     // We first write a FITS file with the pmCellWriteWeight(), then we read it and verify.
    328     // First call pmCellWriteWeight()
     319        ok(!pmCellWriteVariance(cell, NULL, NULL, false), "pmCellWriteVariance() returned FALSE with NULL psFits param");
     320        psFree(fpa);
     321        psFree(camera);
     322        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     323    }
     324
     325
     326    // Verify pmCellWriteVariance() with acceptable input params
     327    // We first write a FITS file with the pmCellWriteVariance(), then we read it and verify.
     328    // First call pmCellWriteVariance()
    329329    {
    330330        psMemId id = psMemGetId();
     
    337337        ok(cell != NULL, "Allocated a pmCell successfully");
    338338
    339         //  Use pmCellWriteWeight() to write weight data to the FITS file
    340         bool rc = pmCellWriteWeight(cell, fitsFileW, NULL, false);
    341         ok(rc, "pmCellWriteWeight() returned TRUE");
     339        //  Use pmCellWriteVariance() to write weight data to the FITS file
     340        bool rc = pmCellWriteVariance(cell, fitsFileW, NULL, false);
     341        ok(rc, "pmCellWriteVariance() returned TRUE");
    342342
    343343        //  Close the FITS file, free memory
     
    350350
    351351    // ----------------------------------------------------------------------
    352     // pmCellReadWeight() tests
    353     // Verify pmCellReadWeight() with NULL pmCell param
    354     {
    355         psMemId id = psMemGetId();
    356         psFits* fitsFileR = psFitsOpen(".tmp00", "r");
    357         ok(!pmCellReadWeight(NULL, fitsFileR, NULL), "pmCellReadWeight() returned FALSE with NULL pmCell param");
    358         psFitsClose(fitsFileR);
    359         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    360     }
    361 
    362 
    363     // Verify pmCellReadWeight() with NULL pmFits param
     352    // pmCellReadVariance() tests
     353    // Verify pmCellReadVariance() with NULL pmCell param
     354    {
     355        psMemId id = psMemGetId();
     356        psFits* fitsFileR = psFitsOpen(".tmp00", "r");
     357        ok(!pmCellReadVariance(NULL, fitsFileR, NULL), "pmCellReadVariance() returned FALSE with NULL pmCell param");
     358        psFitsClose(fitsFileR);
     359        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     360    }
     361
     362
     363    // Verify pmCellReadVariance() with NULL pmFits param
    364364    {
    365365        psMemId id = psMemGetId();
     
    368368        pmChip *chip = fpa->chips->data[0];
    369369        pmCell *cell = chip->cells->data[0];
    370         ok(!pmCellReadWeight(cell, NULL, NULL), "pmCellReadWeight() returned FALSE with NULL pmFits param");
    371         psFree(fpa);
    372         psFree(camera);
    373         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    374     }
    375 
    376 
    377     // Verify pmCellReadWeight() with acceptable data (using the FITS file created above)
     370        ok(!pmCellReadVariance(cell, NULL, NULL), "pmCellReadVariance() returned FALSE with NULL pmFits param");
     371        psFree(fpa);
     372        psFree(camera);
     373        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     374    }
     375
     376
     377    // Verify pmCellReadVariance() with acceptable data (using the FITS file created above)
    378378    {
    379379        psMemId id = psMemGetId();
     
    385385        pmCell *cell = chip->cells->data[0];
    386386        // Free the existing cell hdu weight data (so we can verify that pmCellReadWeight() actually reads the data
    387         psFree(cell->hdu->weights);
    388         cell->hdu->weights = NULL;
    389         psFits* fitsFileR = psFitsOpen(".tmp00", "r");
    390 
    391         rc = pmCellReadWeight(cell, fitsFileR, NULL);
    392         ok(rc, "pmCellReadWeight() returned TRUE");
    393         for (int k = 0 ; k < cell->hdu->weights->n ; k++) {
     387        psFree(cell->hdu->variances);
     388        cell->hdu->variances = NULL;
     389        psFits* fitsFileR = psFitsOpen(".tmp00", "r");
     390
     391        rc = pmCellReadVariance(cell, fitsFileR, NULL);
     392        ok(rc, "pmCellReadVariance() returned TRUE");
     393        for (int k = 0 ; k < cell->hdu->variances->n ; k++) {
    394394            bool errorFlag = false;
    395             psImage *msk = cell->hdu->weights->data[k];
     395            psImage *msk = cell->hdu->variances->data[k];
    396396            for (int i = 0 ; i < msk->numRows ; i++) {
    397397                for (int j = 0 ; j < msk->numCols ; j++) {
     
    403403                }
    404404            }
    405             ok(!errorFlag, "pmCellWriteWeight()/pmCellReadWeight() properly set the weight data (image %d)", k);
     405            ok(!errorFlag, "pmCellWriteVariance()/pmCellReadVariance() properly set the weight data (image %d)", k);
    406406        }
    407407        psFitsClose(fitsFileR);
     
    661661
    662662    // ----------------------------------------------------------------------
    663     // pmChipWriteWeight() tests
    664     // Verify pmChipWriteWeight() with NULL pmChip param
     663    // pmChipWriteVariance() tests
     664    // Verify pmChipWriteVariance() with NULL pmChip param
    665665    {
    666666        psMemId id = psMemGetId();
    667667        psFits* fitsFileW = psFitsOpen(".tmp01", "w");
    668         ok(!pmChipWriteWeight(NULL, fitsFileW, NULL, false, true), "pmChipWriteWeight() returned NULL with NULL pmChip param");
    669         psFitsClose(fitsFileW);
    670         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    671     }
    672 
    673 
    674     // Verify pmChipWriteWeight() with NULL pmFits param
     668        ok(!pmChipWriteVariance(NULL, fitsFileW, NULL, false, true), "pmChipWriteVariance() returned NULL with NULL pmChip param");
     669        psFitsClose(fitsFileW);
     670        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     671    }
     672
     673
     674    // Verify pmChipWriteVariance() with NULL pmFits param
    675675    {
    676676        psMemId id = psMemGetId();
     
    680680        pmChip *chip = fpa->chips->data[0];
    681681        ok(chip != NULL, "Allocated a pmChip successfully");
    682         ok(!pmChipWriteWeight(chip, NULL, NULL, false, true), "pmChipWriteWeight() returned NULL with NULL pmFits param");
    683         psFree(fpa);
    684         psFree(camera);
    685         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    686     }
    687 
    688 
    689     // Verify pmChipWriteWeight() with acceptable data
     682        ok(!pmChipWriteVariance(chip, NULL, NULL, false, true), "pmChipWriteVariance() returned NULL with NULL pmFits param");
     683        psFree(fpa);
     684        psFree(camera);
     685        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     686    }
     687
     688
     689    // Verify pmChipWriteVariance() with acceptable data
    690690    {
    691691        psMemId id = psMemGetId();
     
    697697        ok(chip != NULL, "Allocated a pmChip successfully");
    698698
    699         //  Use pmChipWriteWeight() to write image data to the FITS file
    700         bool rc = pmChipWriteWeight(chip, fitsFileW, NULL, false, true);
    701         ok(rc, "pmChipWriteWeight() returned TRUE");
     699        //  Use pmChipWriteVariance() to write image data to the FITS file
     700        bool rc = pmChipWriteVariance(chip, fitsFileW, NULL, false, true);
     701        ok(rc, "pmChipWriteVariance() returned TRUE");
    702702
    703703        //  Close the FITS file, free memory
     
    757757            if (VERBOSE) diag("Reading cell %d\n", chipID);
    758758            pmCell *cell = (pmCell *) chip->cells->data[chipID];
    759             for (int k = 0 ; k < cell->hdu->weights->n ; k++) {
     759            for (int k = 0 ; k < cell->hdu->variances->n ; k++) {
    760760                if (VERBOSE) diag("NOTE: image %d\n", k);
    761                 psImage *wgt = cell->hdu->weights->data[k];
     761                psImage *wgt = cell->hdu->variances->data[k];
    762762                for (int i = 0 ; i < wgt->numRows ; i++) {
    763763                    for (int j = 0 ; j < wgt->numCols ; j++) {
     
    770770                }
    771771            }
    772             ok(!errorFlag, "pmChipWriteWeight()/pmChipReadWeight() properly set the weight data (cell %d)", chipID);
     772            ok(!errorFlag, "pmChipWriteVariance()/pmChipReadVariance() properly set the variance data (cell %d)", chipID);
    773773        }
    774774
     
    975975    // ----------------------------------------------------------------------
    976976    // ----------------------------------------------------------------------
    977     // pmFPAWriteWeight() tests
    978     // pmFPAWriteWeight(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
    979     // Verify pmFPAWriteWeight() with NULL pmFPA param
     977    // pmFPAWriteVariance() tests
     978    // pmFPAWriteVariance(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
     979    // Verify pmFPAWriteVariance() with NULL pmFPA param
    980980    {
    981981        psMemId id = psMemGetId();
    982982        psFits* fitsFileW = psFitsOpen(".tmp01", "w");
    983         ok(!pmFPAWriteWeight(NULL, fitsFileW, NULL, false, true), "pmFPAWriteWeight() returned NULL with NULL pmFPA param");
    984         psFitsClose(fitsFileW);
    985         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    986     }
    987 
    988 
    989     // Verify pmFPAWriteWeight() with NULL pmFits param
     983        ok(!pmFPAWriteVariance(NULL, fitsFileW, NULL, false, true), "pmFPAWriteVariance() returned NULL with NULL pmFPA param");
     984        psFitsClose(fitsFileW);
     985        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     986    }
     987
     988
     989    // Verify pmFPAWriteVariance() with NULL pmFits param
    990990    {
    991991        psMemId id = psMemGetId();
     
    994994        pmFPA* fpa = generateSimpleFPA(camera);
    995995        ok(fpa != NULL, "Allocated a pmFPA successfully");
    996         ok(!pmFPAWriteWeight(fpa, NULL, NULL, false, true), "pmFPAWriteWeight() returned NULL with NULL pmFits param");
    997         psFree(fpa);
    998         psFree(camera);
    999         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    1000     }
    1001 
    1002 
    1003     // Verify pmFPAWriteWeight() with acceptable data
     996        ok(!pmFPAWriteVariance(fpa, NULL, NULL, false, true), "pmFPAWriteVariance() returned NULL with NULL pmFits param");
     997        psFree(fpa);
     998        psFree(camera);
     999        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     1000    }
     1001
     1002
     1003    // Verify pmFPAWriteVariance() with acceptable data
    10041004    {
    10051005        psMemId id = psMemGetId();
     
    10091009        pmFPA* fpa = generateSimpleFPA(camera);
    10101010        ok(fpa != NULL, "Allocated a pmFPA successfully");
    1011         bool rc = pmFPAWriteWeight(fpa, fitsFileW, NULL, false, true);
    1012         ok(rc, "pmFPAWriteWeight() returned TRUE");
     1011        bool rc = pmFPAWriteVariance(fpa, fitsFileW, NULL, false, true);
     1012        ok(rc, "pmFPAWriteVariance() returned TRUE");
    10131013        //  Close the FITS file, free memory
    10141014        psFitsClose(fitsFileW);
     
    10201020
    10211021    // ----------------------------------------------------------------------
    1022     // pmFPAReadWeight() tests
     1022    // pmFPAReadVariance() tests
    10231023    // Verify pmFPAReadWeight() with NULL pmFPA param
    10241024    {
    10251025        psMemId id = psMemGetId();
    10261026        psFits* fitsFileR = psFitsOpen(".tmp00", "r");
    1027         ok(!pmFPARead(NULL, fitsFileR, NULL), "pmFPAReadWeight() returned NULL with NULL pmFPA param");
    1028         psFitsClose(fitsFileR);
    1029         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    1030     }
    1031 
    1032 
    1033     // Verify pmFPAReadWeight() with NULL pmFits param
    1034     {
    1035         psMemId id = psMemGetId();
    1036         psMetadata *camera = psMetadataAlloc();
    1037         pmFPA* fpa = generateSimpleFPA(camera);
    1038         ok(!pmFPARead(fpa, NULL, NULL), "pmFPAReadWeight() returned NULL with NULL pmFits param");
    1039         psFree(fpa);
    1040         psFree(camera);
    1041         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    1042     }
    1043 
    1044 
    1045     // Verify pmFPAReadWeight() with acceptable input data
     1027        ok(!pmFPARead(NULL, fitsFileR, NULL), "pmFPAReadVariance() returned NULL with NULL pmFPA param");
     1028        psFitsClose(fitsFileR);
     1029        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     1030    }
     1031
     1032
     1033    // Verify pmFPAReadVariance() with NULL pmFits param
     1034    {
     1035        psMemId id = psMemGetId();
     1036        psMetadata *camera = psMetadataAlloc();
     1037        pmFPA* fpa = generateSimpleFPA(camera);
     1038        ok(!pmFPARead(fpa, NULL, NULL), "pmFPAReadVariance() returned NULL with NULL pmFits param");
     1039        psFree(fpa);
     1040        psFree(camera);
     1041        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     1042    }
     1043
     1044
     1045    // Verify pmFPAReadVariance() with acceptable input data
    10461046    {
    10471047        psMemId id = psMemGetId();
     
    10511051        pmFPA* fpa = generateSimpleFPA(camera);
    10521052        pmChip *chip = fpa->chips->data[0];
    1053         // Free the cells for chip 0 so we can verify that pmFPAReadWeight() actually reads the data from file
     1053        // Free the cells for chip 0 so we can verify that pmFPAReadVariance() actually reads the data from file
    10541054        if (0) {
    10551055            for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) {
     
    10621062        psFits* fitsFileR = psFitsOpen(".tmp00", "r");
    10631063        rc = pmFPARead(fpa, fitsFileR, NULL);
    1064         ok(rc, "pmFPAReadWeight() returned TRUE");
     1064        ok(rc, "pmFPAReadVariance() returned TRUE");
    10651065        bool errorFlag = false;
    10661066        // XXX: fpaID should be chipID
     
    10711071                if (VERBOSE) diag("Reading cell %d\n", chipID);
    10721072                pmCell *cell = (pmCell *) chip->cells->data[chipID];
    1073                 for (int k = 0 ; k < cell->hdu->weights->n ; k++) {
     1073                for (int k = 0 ; k < cell->hdu->variances->n ; k++) {
    10741074                    if (VERBOSE) diag("NOTE: image %d\n", k);
    1075                     psImage *wgt = cell->hdu->weights->data[k];
     1075                    psImage *wgt = cell->hdu->variances->data[k];
    10761076                    for (int i = 0 ; i < wgt->numRows ; i++) {
    10771077                        for (int j = 0 ; j < wgt->numCols ; j++) {
     
    10841084                        }
    10851085                    }
    1086                 ok(!errorFlag, "pmFPAWriteWeight()/pmFPAReadWeight() properly set the image data (chip %d, cell %d)", fpaID, chipID);
     1086                ok(!errorFlag, "pmFPAWriteVariance()/pmFPAReadVariance() properly set the image data (chip %d, cell %d)", fpaID, chipID);
    10871087            }
    10881088        }
Note: See TracChangeset for help on using the changeset viewer.