Changeset 21474 for trunk/psModules/test/camera/tap_pmFPAReadWrite.c
- Timestamp:
- Feb 13, 2009, 12:47:32 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/camera/tap_pmFPAReadWrite.c (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/camera/tap_pmFPAReadWrite.c
r21221 r21474 56 56 readout->image = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32); 57 57 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); 59 59 for (psS32 i = 0 ; i < NUM_BIAS_DATA ; i++) { 60 60 psImage *tmpImage = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32); … … 94 94 cell->hdu->images = psArrayAlloc(NUM_HDUS); 95 95 cell->hdu->masks = psArrayAlloc(NUM_HDUS); 96 cell->hdu-> weights = psArrayAlloc(NUM_HDUS);96 cell->hdu->variances = psArrayAlloc(NUM_HDUS); 97 97 for (int k = 0 ; k < NUM_HDUS ; k++) { 98 98 cell->hdu->images->data[k] = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32); 99 99 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); 101 101 psImageInit(cell->hdu->images->data[k], (float) (BASE_IMAGE+k)); 102 102 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)); 104 104 } 105 105 … … 298 298 // ---------------------------------------------------------------------- 299 299 // ---------------------------------------------------------------------- 300 // pmCellWrite Weight(): tests301 // Verify pmCellWrite Weight() with NULL pmCell arg300 // pmCellWriteVariance(): tests 301 // Verify pmCellWriteVariance() with NULL pmCell arg 302 302 { 303 303 psMemId id = psMemGetId(); 304 304 psFits* fitsFileW = psFitsOpen(".tmp00", "w"); 305 ok(!pmCellWrite Weight(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 pmCellWrite Weight() with NULL pmFits arg305 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 312 312 { 313 313 psMemId id = psMemGetId(); … … 317 317 pmCell *cell = chip->cells->data[0]; 318 318 ok(cell != NULL, "Allocated a pmCell successfully"); 319 ok(!pmCellWrite Weight(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 pmCellWrite Weight() with acceptable input params327 // We first write a FITS file with the pmCellWrite Weight(), then we read it and verify.328 // First call pmCellWrite Weight()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() 329 329 { 330 330 psMemId id = psMemGetId(); … … 337 337 ok(cell != NULL, "Allocated a pmCell successfully"); 338 338 339 // Use pmCellWrite Weight() to write weight data to the FITS file340 bool rc = pmCellWrite Weight(cell, fitsFileW, NULL, false);341 ok(rc, "pmCellWrite Weight() 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"); 342 342 343 343 // Close the FITS file, free memory … … 350 350 351 351 // ---------------------------------------------------------------------- 352 // pmCellRead Weight() tests353 // Verify pmCellRead Weight() with NULL pmCell param354 { 355 psMemId id = psMemGetId(); 356 psFits* fitsFileR = psFitsOpen(".tmp00", "r"); 357 ok(!pmCellRead Weight(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 pmCellRead Weight() with NULL pmFits param352 // 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 364 364 { 365 365 psMemId id = psMemGetId(); … … 368 368 pmChip *chip = fpa->chips->data[0]; 369 369 pmCell *cell = chip->cells->data[0]; 370 ok(!pmCellRead Weight(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 pmCellRead Weight() 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) 378 378 { 379 379 psMemId id = psMemGetId(); … … 385 385 pmCell *cell = chip->cells->data[0]; 386 386 // 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 = pmCellRead Weight(cell, fitsFileR, NULL);392 ok(rc, "pmCellRead Weight() 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++) { 394 394 bool errorFlag = false; 395 psImage *msk = cell->hdu-> weights->data[k];395 psImage *msk = cell->hdu->variances->data[k]; 396 396 for (int i = 0 ; i < msk->numRows ; i++) { 397 397 for (int j = 0 ; j < msk->numCols ; j++) { … … 403 403 } 404 404 } 405 ok(!errorFlag, "pmCellWrite Weight()/pmCellReadWeight() properly set the weight data (image %d)", k);405 ok(!errorFlag, "pmCellWriteVariance()/pmCellReadVariance() properly set the weight data (image %d)", k); 406 406 } 407 407 psFitsClose(fitsFileR); … … 661 661 662 662 // ---------------------------------------------------------------------- 663 // pmChipWrite Weight() tests664 // Verify pmChipWrite Weight() with NULL pmChip param663 // pmChipWriteVariance() tests 664 // Verify pmChipWriteVariance() with NULL pmChip param 665 665 { 666 666 psMemId id = psMemGetId(); 667 667 psFits* fitsFileW = psFitsOpen(".tmp01", "w"); 668 ok(!pmChipWrite Weight(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 pmChipWrite Weight() with NULL pmFits param668 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 675 675 { 676 676 psMemId id = psMemGetId(); … … 680 680 pmChip *chip = fpa->chips->data[0]; 681 681 ok(chip != NULL, "Allocated a pmChip successfully"); 682 ok(!pmChipWrite Weight(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 pmChipWrite Weight() with acceptable data682 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 690 690 { 691 691 psMemId id = psMemGetId(); … … 697 697 ok(chip != NULL, "Allocated a pmChip successfully"); 698 698 699 // Use pmChipWrite Weight() to write image data to the FITS file700 bool rc = pmChipWrite Weight(chip, fitsFileW, NULL, false, true);701 ok(rc, "pmChipWrite Weight() 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"); 702 702 703 703 // Close the FITS file, free memory … … 757 757 if (VERBOSE) diag("Reading cell %d\n", chipID); 758 758 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++) { 760 760 if (VERBOSE) diag("NOTE: image %d\n", k); 761 psImage *wgt = cell->hdu-> weights->data[k];761 psImage *wgt = cell->hdu->variances->data[k]; 762 762 for (int i = 0 ; i < wgt->numRows ; i++) { 763 763 for (int j = 0 ; j < wgt->numCols ; j++) { … … 770 770 } 771 771 } 772 ok(!errorFlag, "pmChipWrite Weight()/pmChipReadWeight() properly set the weightdata (cell %d)", chipID);772 ok(!errorFlag, "pmChipWriteVariance()/pmChipReadVariance() properly set the variance data (cell %d)", chipID); 773 773 } 774 774 … … 975 975 // ---------------------------------------------------------------------- 976 976 // ---------------------------------------------------------------------- 977 // pmFPAWrite Weight() tests978 // pmFPAWrite Weight(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)979 // Verify pmFPAWrite Weight() with NULL pmFPA param977 // pmFPAWriteVariance() tests 978 // pmFPAWriteVariance(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse) 979 // Verify pmFPAWriteVariance() with NULL pmFPA param 980 980 { 981 981 psMemId id = psMemGetId(); 982 982 psFits* fitsFileW = psFitsOpen(".tmp01", "w"); 983 ok(!pmFPAWrite Weight(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 pmFPAWrite Weight() with NULL pmFits param983 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 990 990 { 991 991 psMemId id = psMemGetId(); … … 994 994 pmFPA* fpa = generateSimpleFPA(camera); 995 995 ok(fpa != NULL, "Allocated a pmFPA successfully"); 996 ok(!pmFPAWrite Weight(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 pmFPAWrite Weight() with acceptable data996 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 1004 1004 { 1005 1005 psMemId id = psMemGetId(); … … 1009 1009 pmFPA* fpa = generateSimpleFPA(camera); 1010 1010 ok(fpa != NULL, "Allocated a pmFPA successfully"); 1011 bool rc = pmFPAWrite Weight(fpa, fitsFileW, NULL, false, true);1012 ok(rc, "pmFPAWrite Weight() returned TRUE");1011 bool rc = pmFPAWriteVariance(fpa, fitsFileW, NULL, false, true); 1012 ok(rc, "pmFPAWriteVariance() returned TRUE"); 1013 1013 // Close the FITS file, free memory 1014 1014 psFitsClose(fitsFileW); … … 1020 1020 1021 1021 // ---------------------------------------------------------------------- 1022 // pmFPARead Weight() tests1022 // pmFPAReadVariance() tests 1023 1023 // Verify pmFPAReadWeight() with NULL pmFPA param 1024 1024 { 1025 1025 psMemId id = psMemGetId(); 1026 1026 psFits* fitsFileR = psFitsOpen(".tmp00", "r"); 1027 ok(!pmFPARead(NULL, fitsFileR, NULL), "pmFPARead Weight() returned NULL with NULL pmFPA param");1028 psFitsClose(fitsFileR); 1029 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 1030 } 1031 1032 1033 // Verify pmFPARead Weight() with NULL pmFits param1034 { 1035 psMemId id = psMemGetId(); 1036 psMetadata *camera = psMetadataAlloc(); 1037 pmFPA* fpa = generateSimpleFPA(camera); 1038 ok(!pmFPARead(fpa, NULL, NULL), "pmFPARead Weight() 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 pmFPARead Weight() with acceptable input data1027 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 1046 1046 { 1047 1047 psMemId id = psMemGetId(); … … 1051 1051 pmFPA* fpa = generateSimpleFPA(camera); 1052 1052 pmChip *chip = fpa->chips->data[0]; 1053 // Free the cells for chip 0 so we can verify that pmFPARead Weight() actually reads the data from file1053 // Free the cells for chip 0 so we can verify that pmFPAReadVariance() actually reads the data from file 1054 1054 if (0) { 1055 1055 for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) { … … 1062 1062 psFits* fitsFileR = psFitsOpen(".tmp00", "r"); 1063 1063 rc = pmFPARead(fpa, fitsFileR, NULL); 1064 ok(rc, "pmFPARead Weight() returned TRUE");1064 ok(rc, "pmFPAReadVariance() returned TRUE"); 1065 1065 bool errorFlag = false; 1066 1066 // XXX: fpaID should be chipID … … 1071 1071 if (VERBOSE) diag("Reading cell %d\n", chipID); 1072 1072 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++) { 1074 1074 if (VERBOSE) diag("NOTE: image %d\n", k); 1075 psImage *wgt = cell->hdu-> weights->data[k];1075 psImage *wgt = cell->hdu->variances->data[k]; 1076 1076 for (int i = 0 ; i < wgt->numRows ; i++) { 1077 1077 for (int j = 0 ; j < wgt->numCols ; j++) { … … 1084 1084 } 1085 1085 } 1086 ok(!errorFlag, "pmFPAWrite Weight()/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); 1087 1087 } 1088 1088 }
Note:
See TracChangeset
for help on using the changeset viewer.
