Changeset 30118 for branches/czw_branch/20101203/psLib
- Timestamp:
- Dec 20, 2010, 2:30:45 PM (16 years ago)
- Location:
- branches/czw_branch/20101203
- Files:
-
- 10 deleted
- 19 edited
- 6 copied
-
. (modified) (1 prop)
-
psLib/src/fits/psFitsImage.c (modified) (1 diff)
-
psLib/src/imageops (modified) (1 prop)
-
psLib/src/imageops/psImageMapFit.c (modified) (13 diffs)
-
psLib/src/imageops/psImageMapFit.h (modified) (4 diffs)
-
psLib/src/jpeg/psImageJpeg.c (modified) (3 diffs)
-
psLib/src/math/psStats.c (modified) (7 diffs)
-
psLib/src/sys/psSlurp.c (modified) (6 diffs)
-
psLib/src/sys/psSlurp.h (modified) (2 diffs)
-
psLib/src/sys/psString.c (modified) (1 diff)
-
psLib/src/sys/psString.h (modified) (2 diffs)
-
psLib/src/types/psMetadata.c (modified) (4 diffs)
-
psLib/src/types/psMetadataConfig.c (modified) (1 diff)
-
psLib/src/types/psMetadataConfig.h (modified) (2 diffs)
-
psLib/test/astro/tst_psCoord.c (deleted)
-
psLib/test/astro/tst_psCoord01.c (deleted)
-
psLib/test/astro/tst_psCoord02.c (deleted)
-
psLib/test/astro/tst_psEarthOrientation.c (deleted)
-
psLib/test/astro/tst_psSphereOps.c (deleted)
-
psLib/test/astro/tst_psTime_01.c (deleted)
-
psLib/test/astro/tst_psTime_02.c (deleted)
-
psLib/test/astro/tst_psTime_03.c (deleted)
-
psLib/test/astro/tst_psTime_04.c (deleted)
-
psLib/test/db/tst_psDB.c (deleted)
-
psLib/test/imageops (modified) (1 prop)
-
psLib/test/imageops/Makefile.am (modified) (1 diff)
-
psLib/test/imageops/tap_psImageInterpolate3.c (copied) (copied from trunk/psLib/test/imageops/tap_psImageInterpolate3.c )
-
psLib/test/math (modified) (1 prop)
-
psLib/test/math/data/yraw_01.dat (copied) (copied from trunk/psLib/test/math/data/yraw_01.dat )
-
psLib/test/math/data/yraw_02.dat (copied) (copied from trunk/psLib/test/math/data/yraw_02.dat )
-
psLib/test/math/data/yraw_03.dat (copied) (copied from trunk/psLib/test/math/data/yraw_03.dat )
-
psLib/test/math/data/yraw_04.dat (copied) (copied from trunk/psLib/test/math/data/yraw_04.dat )
-
psLib/test/math/mana.stats.pro (copied) (copied from trunk/psLib/test/math/mana.stats.pro )
-
psLib/test/math/tap_psStats_Sample_01.c (modified) (5 diffs)
-
psLib/test/types/tap_psMetadataConfigWrite.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20101203
- Property svn:mergeinfo changed
-
branches/czw_branch/20101203/psLib/src/fits/psFitsImage.c
r28509 r30118 900 900 901 901 if (nAxis == 2) { 902 psImage *image = psFitsReadImage(fits, region, 0); 903 if (!image) { 904 psFitsError(status, true, "Could not read image into cube"); 905 return NULL; 906 } 902 907 psArray *images = psArrayAlloc(1); // Single image plane 903 images->data[0] = psFitsReadImage(fits, region, 0);908 images->data[0] = image; 904 909 return images; 905 910 } -
branches/czw_branch/20101203/psLib/src/imageops
-
Property svn:mergeinfo
set to
/branches/eam_branches/ipp-20101103/psLib/src/imageops merged eligible /branches/eam_branches/ipp-20101205/psLib/src/imageops merged eligible /trunk/psLib/src/imageops merged eligible
-
Property svn:mergeinfo
set to
-
branches/czw_branch/20101203/psLib/src/imageops/psImageMapFit.c
r25753 r30118 48 48 49 49 // map defines the output image dimensions and scaling. 50 bool psImageMapFit( psImageMap *map, const psVector *mask, psVectorMaskType maskValue,50 bool psImageMapFit(bool *pGoodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 51 51 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 52 52 { 53 53 // XXX Add Asserts 54 55 *pGoodFit = false; 54 56 55 57 // dimensions of the output map image … … 81 83 map->map->data.F32[0][0] = psStatsGetValue(map->stats, mean); 82 84 map->error->data.F32[0][0] = psStatsGetValue(map->stats, stdev); 85 if (isfinite(map->map->data.F32[0][0]) && isfinite( map->error->data.F32[0][0])) { 86 *pGoodFit = true; 87 } 83 88 return true; 84 89 } … … 86 91 if (Nx == 1) { 87 92 bool status; 88 status = psImageMapFit1DinY ( map, mask, maskValue, x, y, f, df);93 status = psImageMapFit1DinY (pGoodFit, map, mask, maskValue, x, y, f, df); 89 94 return status; 90 95 } 91 96 if (Ny == 1) { 92 97 bool status; 93 status = psImageMapFit1DinX ( map, mask, maskValue, x, y, f, df);98 status = psImageMapFit1DinX (pGoodFit, map, mask, maskValue, x, y, f, df); 94 99 return status; 95 100 } … … 310 315 311 316 if (!psMatrixGJSolve(A, B)) { 312 psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations. Returning NULL.\n");313 317 psFree (A); 314 318 psFree (B); 315 return false;319 return true; 316 320 } 317 321 … … 337 341 psFree (Empty); 338 342 343 *pGoodFit = true; 339 344 return true; 340 345 } 341 346 342 347 // measure residuals on each pass and clip outliers based on stats 343 bool psImageMapClipFit( psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue,348 bool psImageMapClipFit(bool *pGoodFit, psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue, 344 349 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 345 350 { … … 351 356 psAssert(f, "impossible"); 352 357 358 *pGoodFit = false; 359 353 360 // the user supplies one of various stats option pairs, 354 361 // determine the desired mean and stdev STATS options: … … 393 400 psTrace("psLib.imageops", 6, "Loop iteration %d. Calling psImageMapFit()\n", N); 394 401 psS32 Nkeep = 0; 395 if (!psImageMapFit( map, mask, maskValue, x, y, f, df)) {402 if (!psImageMapFit(pGoodFit, map, mask, maskValue, x, y, f, df)) { 396 403 psError(PS_ERR_UNKNOWN, false, "Could not fit image map.\n"); 397 404 psFree(resid); … … 399 406 return false; 400 407 } 408 if (!*pGoodFit) { 409 psWarning ("bad fit to image map, try something else"); 410 return true; 411 } 401 412 402 413 psVector *fit = psImageMapEvalVector(map, mask, maskValue, x, y); … … 454 465 psFree(resid); 455 466 if (!inMask) psFree (mask); 467 *pGoodFit = true; // XXX probably don't need to set this (set by psImageMapFit) 456 468 return true; 457 469 } 458 470 459 471 // map defines the output image dimensions and scaling. 460 bool psImageMapFit1DinY( psImageMap *map, const psVector *mask, psVectorMaskType maskValue,472 bool psImageMapFit1DinY(bool *pGoodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 461 473 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 462 474 { 463 475 // XXX Add Asserts 464 476 assert (map->binning->nXruff == 1); 477 478 *pGoodFit = false; 465 479 466 480 // dimensions of the output map image … … 578 592 579 593 if (!psMatrixGJSolve(A, B)) { 580 psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations.\n");581 594 psFree (A); 582 595 psFree (B); 583 596 psFree (Empty); 584 return false;597 return true; 585 598 } 586 599 … … 602 615 psFree (Empty); 603 616 617 *pGoodFit = true; 604 618 return true; 605 619 } 606 620 607 621 // map defines the output image dimensions and scaling. 608 bool psImageMapFit1DinX( psImageMap *map, const psVector *mask, psVectorMaskType maskValue,622 bool psImageMapFit1DinX(bool *pGoodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 609 623 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 610 624 { 611 625 // XXX Add Asserts 612 626 assert (map->binning->nYruff == 1); 627 628 *pGoodFit = false; 613 629 614 630 // dimensions of the output map image … … 726 742 727 743 if (!psMatrixGJSolve(A, B)) { 728 psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations..\n");729 744 psFree (A); 730 745 psFree (B); 731 746 psFree (Empty); 732 return false;747 return true; 733 748 } 734 749 … … 750 765 psFree (Empty); 751 766 767 *pGoodFit = true; 752 768 return true; 753 769 } -
branches/czw_branch/20101203/psLib/src/imageops/psImageMapFit.h
r25753 r30118 8 8 9 9 // fit the image map to a set of points 10 bool psImageMapFit(psImageMap *map, 10 bool psImageMapFit(bool *pGoodFit, 11 psImageMap *map, 11 12 const psVector *mask, 12 13 psVectorMaskType maskValue, // … … 18 19 19 20 // fit the image map to a set of points 20 bool psImageMapClipFit(psImageMap *map, 21 bool psImageMapClipFit(bool *pGoodFit, 22 psImageMap *map, 21 23 psStats *stats, 22 24 psVector *mask, // WARNING: Mask is modified! … … 28 30 ); 29 31 30 bool psImageMapFit1DinY(psImageMap *map, 32 bool psImageMapFit1DinY(bool *pGoodFit, 33 psImageMap *map, 31 34 const psVector *mask, 32 35 psVectorMaskType maskValue, … … 37 40 ); 38 41 39 bool psImageMapFit1DinX(psImageMap *map, 42 bool psImageMapFit1DinX(bool *pGoodFit, 43 psImageMap *map, 40 44 const psVector *mask, 41 45 psVectorMaskType maskValue, -
branches/czw_branch/20101203/psLib/src/jpeg/psImageJpeg.c
r29542 r30118 167 167 int dy = image->numRows; 168 168 169 bDrawBuffer *bdbuf = bDrawBufferCreate(dx, dy); 169 int Npalette; 170 png_color *palette = KapaPNGPalette (&Npalette); 171 172 bDrawBuffer *bdbuf = bDrawBufferCreate(dx, dy, 1, palette, Npalette); 170 173 171 174 return bdbuf; … … 180 183 int dy = bdbuf->Ny; 181 184 182 int Npalette; 183 png_color *palette = KapaPNGPalette (&Npalette); 185 png_color *palette = bdbuf->palette; 184 186 bDrawColor white = KapaColorByName ("white"); 185 187 for (int j = 0; j < dy; j++) { … … 336 338 337 339 // set the scalebar labels 340 int Npalette; 341 png_color *palette = KapaPNGPalette (&Npalette); 342 338 343 char string[64]; 339 bDrawBuffer *labels = bDrawBufferCreate(dx, PS_JPEG_LABELPAD );344 bDrawBuffer *labels = bDrawBufferCreate(dx, PS_JPEG_LABELPAD, 1, palette, Npalette); 340 345 SetRotFont ("helvetica", 8); 341 bDrawSetBuffer(labels);342 346 sprint_double (string, options->min); 343 bDrawRotText( 2, 2, string, 2, 0.0);347 bDrawRotText(labels, 2, 2, string, 2, 0.0); 344 348 sprint_double (string, options->max); 345 bDrawRotText( dx - 2, 2, string, 0, 0.0);349 bDrawRotText(labels, dx - 2, 2, string, 0, 0.0); 346 350 sprint_double (string, 0.5*(options->min + options->max)); 347 bDrawRotText( 0.5*dx, 2, string, 1, 0.0);351 bDrawRotText(labels, 0.5*dx, 2, string, 1, 0.0); 348 352 psImageJpegOverlayDraw(jpegImage, labels, 0, offset); 353 bDrawBufferFree(labels); 349 354 } 350 355 -
branches/czw_branch/20101203/psLib/src/math/psStats.c
r28998 r30118 827 827 // values; nearly bi-modal distribution). if so, keep only points within 5? 10? 828 828 // bins of that excess bin: 829 int nMaxBin = 0;829 int nMaxBin = histogram->nums->data.F32[0]; 830 830 int iMaxBin = 0; 831 831 for (long i = 1; i < histogram->nums->n; i++) { … … 843 843 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal) continue; 844 844 bool invalid = false; 845 invalid |= (myVector->data.F32[i] < =minKeep);846 invalid |= (myVector->data.F32[i] > =maxKeep);845 invalid |= (myVector->data.F32[i] < minKeep); 846 invalid |= (myVector->data.F32[i] > maxKeep); 847 847 invalid |= (!isfinite(myVector->data.F32[i])); 848 848 if (!invalid) continue; … … 852 852 853 853 if (nInvalid) { 854 psTrace(TRACE, 6, "data is concentrated in a single bin, masking %d extreme outliers and retrying\n", nInvalid); 854 psTrace(TRACE, 6, "data is concentrated in a single bin (%d = %f - %f), masking %d extreme outliers and retrying\n", 855 iMaxBin, histogram->bounds->data.F32[iMaxBin], histogram->bounds->data.F32[iMaxBin+1], nInvalid); 855 856 psFree(histogram); 856 857 psFree(cumulative); … … 1108 1109 // If the mean is NAN, then generate a warning and set the stdev to NAN. 1109 1110 if (isnan(stats->robustMedian)) { 1110 stats->fittedStdev = NAN; 1111 stats->fittedStdev = NAN; 1111 stats->fittedMean = NAN; 1112 stats->fittedStdev = NAN; 1113 stats->results |= PS_STAT_FITTED_MEAN; 1114 stats->results |= PS_STAT_FITTED_STDEV; 1115 return true; 1116 } 1117 1118 if (stats->robustStdev <= FLT_EPSILON) { 1119 stats->fittedMean = stats->robustMedian; 1120 stats->fittedStdev = stats->robustStdev; 1121 stats->results |= PS_STAT_FITTED_MEAN; 1122 stats->results |= PS_STAT_FITTED_STDEV; 1112 1123 return true; 1113 1124 } … … 1289 1300 // If the mean is NAN, then generate a warning and set the stdev to NAN. 1290 1301 if (isnan(stats->robustMedian)) { 1291 stats->fittedStdev = NAN; 1292 stats->fittedStdev = NAN; 1293 psTrace(TRACE, 4, "---- %s() end ----\n", __func__); 1302 stats->fittedMean = NAN; 1303 stats->fittedStdev = NAN; 1304 stats->results |= PS_STAT_FITTED_MEAN_V2; 1305 stats->results |= PS_STAT_FITTED_STDEV_V2; 1306 return true; 1307 } 1308 1309 if (stats->robustStdev <= FLT_EPSILON) { 1310 stats->fittedMean = stats->robustMedian; 1311 stats->fittedStdev = stats->robustStdev; 1312 stats->results |= PS_STAT_FITTED_MEAN_V2; 1313 stats->results |= PS_STAT_FITTED_STDEV_V2; 1294 1314 return true; 1295 1315 } … … 1486 1506 // If the mean is NAN, then generate a warning and set the stdev to NAN. 1487 1507 if (isnan(stats->robustMedian)) { 1488 stats->fittedStdev = NAN; 1489 stats->fittedStdev = NAN; 1490 psTrace(TRACE, 4, "---- %s() end ----\n", __func__); 1508 stats->fittedMean = NAN; 1509 stats->fittedStdev = NAN; 1510 stats->results |= PS_STAT_FITTED_MEAN_V3; 1511 stats->results |= PS_STAT_FITTED_STDEV_V3; 1512 return true; 1513 } 1514 1515 if (stats->robustStdev <= FLT_EPSILON) { 1516 stats->fittedMean = stats->robustMedian; 1517 stats->fittedStdev = stats->robustStdev; 1518 stats->results |= PS_STAT_FITTED_MEAN_V3; 1519 stats->results |= PS_STAT_FITTED_STDEV_V3; 1491 1520 return true; 1492 1521 } … … 1782 1811 1783 1812 // If the mean is NAN, then generate a warning and set the stdev to NAN. 1784 if (isnan(stats->robustMedian)) goto escape; 1813 if (isnan(stats->robustMedian)) { 1814 stats->fittedMean = NAN; 1815 stats->fittedStdev = NAN; 1816 stats->results |= PS_STAT_FITTED_MEAN_V4; 1817 stats->results |= PS_STAT_FITTED_STDEV_V4; 1818 return true; 1819 } 1820 1821 if (stats->robustStdev <= FLT_EPSILON) { 1822 stats->fittedMean = stats->robustMedian; 1823 stats->fittedStdev = stats->robustStdev; 1824 stats->results |= PS_STAT_FITTED_MEAN_V4; 1825 stats->results |= PS_STAT_FITTED_STDEV_V4; 1826 return true; 1827 } 1785 1828 1786 1829 float guessStdev = stats->robustStdev; // pass the guess sigma -
branches/czw_branch/20101203/psLib/src/sys/psSlurp.c
r12072 r30118 27 27 #include "psMemory.h" 28 28 29 #define SLURP_SIZE 4096 29 # define SLURP_SIZE 4096 30 31 # if (PS_SLURP_GZIP) 32 33 psString psSlurpFD(int fd) { 34 35 gzFile file = gzdopen (fd, "r"); 36 if (file == Z_NULL) { 37 psError(PS_ERR_IO, true, "Failed to open file\n"); 38 return NULL; 39 } 40 41 psString str = psSlurpGZIP(file); 42 43 return str; 44 } 45 46 # else 30 47 31 48 psString psSlurpFD(int fd) … … 38 55 // increase the allocated string size 39 56 size += SLURP_SIZE; 40 str = ps Realloc(str, size);57 str = psStringRealloc(str, size); 41 58 42 59 // read a block from the stream … … 59 76 return str; 60 77 } 78 # endif 61 79 80 # if (PS_SLURP_GZIP) 81 psString psSlurpGZIP(gzFile fd) 82 { 83 psString str = NULL; // String to which to write 84 size_t size = 1; // bytes allocated - make sure there is room for '\0' 85 size_t used = 0; // bytes actually used 86 ssize_t bytes; // Number of bytes read 87 do { 88 // increase the allocated string size 89 size += SLURP_SIZE; 90 str = psStringRealloc(str, size); 91 92 // read a block from the stream 93 bytes = gzread(fd, str + used, SLURP_SIZE); 94 if (bytes < 0) { 95 // it's an error 96 psError(PS_ERR_IO, true, "slurp failed on read"); 97 psFree(str); 98 return NULL; 99 } 100 101 // Increase the size of the known string 102 used += bytes; 103 104 } while (bytes != 0); 105 106 // append '\0' to the end of the string 107 str[used] = '\0'; 108 109 return str; 110 } 111 # endif 62 112 63 113 psString psSlurpFile(FILE *stream) … … 70 120 { 71 121 PS_ASSERT_PTR_NON_NULL(filename, NULL); 122 123 # if (PS_SLURP_GZIP) 124 gzFile fd = gzopen(filename, "r"); 125 if (fd == Z_NULL) { 126 psError(PS_ERR_IO, true, "Failed to open specified file, %s\n", filename); 127 return NULL; 128 } 129 psString text = psSlurpGZIP(fd); 130 131 if (gzclose(fd) != Z_OK) { 132 psError(PS_ERR_IO, true, "Failed to close specified file, %s\n", filename); 133 psFree(text); 134 return NULL; 135 } 136 137 # else 72 138 73 139 int fd = open(filename, O_RDONLY); … … 76 142 return NULL; 77 143 } 78 79 144 psString text = psSlurpFD(fd); 80 145 … … 84 149 return NULL; 85 150 } 151 # endif 86 152 87 153 return text; -
branches/czw_branch/20101203/psLib/src/sys/psSlurp.h
r15410 r30118 12 12 13 13 #include <psString.h> 14 15 # define PS_SLURP_GZIP 1 16 17 # if (PS_SLURP_GZIP) 18 # include <zlib.h> 19 # endif 14 20 15 21 /// @addtogroup FileIO Input/Output … … 31 37 ); 32 38 39 # if (PS_SLURP_GZIP) 40 psString psSlurpGZIP(gzFile fd); 41 # endif 42 33 43 /// @} 34 44 #endif -
branches/czw_branch/20101203/psLib/src/sys/psString.c
r19070 r30118 48 48 psString string = p_psAlloc(file, lineno, func, nChar + 1); 49 49 psMemSetDeallocator(string, (psFreeFunc)stringFree); 50 51 return string; 52 } 53 54 55 psString p_psStringRealloc(const char *file, 56 unsigned int lineno, 57 const char *func, 58 psString string, 59 size_t nChar) 60 { 61 if (!string) { 62 string = p_psAlloc(file, lineno, func, nChar + 1); 63 psMemSetDeallocator(string, (psFreeFunc)stringFree); 64 } else { 65 string = p_psRealloc(file, lineno, func, string, nChar + 1); 66 } 50 67 51 68 return string; -
branches/czw_branch/20101203/psLib/src/sys/psString.h
r15523 r30118 40 40 #define PS_FILE_LINE p_psFileLine(__FILE__,__LINE__) 41 41 42 43 42 /** Allocates a new psString. 44 43 * … … 60 59 #endif // ifdef DOXYGEN 61 60 61 /** Reallocate an existing psString (or alloc if not existent) 62 * 63 * @return psString: string of length n. 64 */ 65 #ifdef DOXYGEN 66 psString psStringRealloc( 67 psString string, 68 size_t nChar ///< Size of psString to allocate. 69 ); 70 #else // ifdef DOXYGEN 71 psString p_psStringRealloc( 72 const char *file, ///< File of caller 73 unsigned int lineno, ///< Line number of caller 74 const char *func, ///< Function name of caller 75 psString string, ///< supplied string or NULL 76 size_t nChar ///< Size of psString to allocate. 77 ) PS_ATTR_MALLOC; 78 #define psStringRealloc(string, nChar) \ 79 p_psStringRealloc(__FILE__, __LINE__, __func__, string, nChar) 80 #endif // ifdef DOXYGEN 62 81 63 82 /** Checks the type of a particular pointer. -
branches/czw_branch/20101203/psLib/src/types/psMetadata.c
r29833 r30118 1371 1371 break; 1372 1372 case PS_DATA_S64: 1373 fprintf(fd, "% jd\n", item->data.S64);1373 fprintf(fd, "%" PRId64 "\n", item->data.S64); 1374 1374 break; 1375 1375 case PS_DATA_U8: … … 1383 1383 break; 1384 1384 case PS_DATA_U64: 1385 fprintf(fd, "% ju\n", item->data.U64);1385 fprintf(fd, "%" PRIu64 "\n", item->data.U64); 1386 1386 break; 1387 1387 case PS_DATA_F32: … … 1458 1458 fprintf(fd, "U64 "); 1459 1459 for (int i = 0; i < vector->n; i++) { 1460 fprintf(fd, "% ju ", vector->data.U64[i]);1460 fprintf(fd, "%" PRIu64, vector->data.U64[i]); 1461 1461 } 1462 1462 fprintf(fd, "\n"); … … 1486 1486 fprintf(fd, "S64 "); 1487 1487 for (int i = 0; i < vector->n; i++) { 1488 fprintf(fd, "% jd ", vector->data.S64[i]);1488 fprintf(fd, "%" PRId64, vector->data.S64[i]); 1489 1489 } 1490 1490 fprintf(fd, "\n"); -
branches/czw_branch/20101203/psLib/src/types/psMetadataConfig.c
r27056 r30118 1630 1630 } 1631 1631 1632 1633 bool psMetadataConfigWrite(psMetadata *md, 1634 const char *filename) 1635 { 1636 PS_ASSERT_METADATA_NON_NULL(md, NULL); 1637 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 1638 FILE *file; 1639 if ( !(file = fopen(filename, "w")) ) { 1640 psError(PS_ERR_IO, true, 1641 "Failed to open specified file, %s\n", filename); 1642 return false; 1643 } 1644 psString fileString = NULL; 1645 fileString = psMetadataConfigFormat(md); 1646 if (fileString == NULL) { 1647 psError(PS_ERR_BAD_PARAMETER_NULL, false, 1648 "psMetadataConfigFormat returned NULL.\n"); 1649 return false; 1650 } 1651 if (fprintf(file, "%s", fileString) != strlen(fileString)) { 1652 psError(PS_ERR_IO, true, "Failed to write contents of configuration file %s", filename); 1653 psFree(fileString); 1654 fclose(file); 1655 return false; 1632 bool psMetadataConfigWrite(psMetadata *md, const char *filename, const char *compress) 1633 { 1634 PS_ASSERT_METADATA_NON_NULL(md, NULL); 1635 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 1636 1637 psString fileString = NULL; 1638 fileString = psMetadataConfigFormat(md); 1639 if (fileString == NULL) { 1640 psError(PS_ERR_BAD_PARAMETER_NULL, false, "psMetadataConfigFormat returned NULL.\n"); 1641 return false; 1642 } 1643 1644 if (compress) { 1645 if (strlen(compress) > 2) { 1646 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "invalid compression options %s", compress); 1647 psFree(fileString); 1648 return false; 1649 } 1650 char modeString[4]; 1651 snprintf (modeString, 4, "w%s", compress); 1652 1653 gzFile file = gzopen(filename, modeString); 1654 if (file == Z_NULL) { 1655 psError(PS_ERR_IO, true, "Failed to open specified file, %s\n", filename); 1656 psFree(fileString); 1657 return false; 1658 } 1659 1660 int nbytes = gzwrite (file, fileString, strlen(fileString)); 1661 if (nbytes != strlen(fileString)) { 1662 psError(PS_ERR_IO, true, "Failed to write contents of configuration file %s", filename); 1663 psFree(fileString); 1664 gzclose(file); 1665 return false; 1666 } 1667 psFree(fileString); 1668 if (gzclose(file) != Z_OK) { 1669 psError(PS_ERR_IO, true, "Failed to close file, %s\n", filename); 1670 return false; 1671 } 1672 } else { 1673 FILE *file = fopen(filename, "w"); 1674 if (file == NULL) { 1675 psError(PS_ERR_IO, true, "Failed to open specified file, %s\n", filename); 1676 psFree(fileString); 1677 return false; 1678 } 1679 1680 int nbytes = fwrite(fileString, 1, strlen(fileString), file); 1681 if (nbytes != strlen(fileString)) { 1682 psError(PS_ERR_IO, true, "Failed to write contents of configuration file %s", filename); 1683 psFree(fileString); 1684 fclose(file); 1685 return false; 1656 1686 } 1657 1687 psFree(fileString); 1658 1688 if (fclose(file) == EOF) { 1659 psError(PS_ERR_IO, true,1660 "Failed to close file, %s\n", filename);1661 return false;1662 }1663 return true;1689 psError(PS_ERR_IO, true, "Failed to close file, %s\n", filename); 1690 return false; 1691 } 1692 } 1693 return true; 1664 1694 } 1665 1695 -
branches/czw_branch/20101203/psLib/src/types/psMetadataConfig.h
r11248 r30118 33 33 * a string, the formatting command must also be for a string. If the 34 34 * metadata type is any other data type, printing is not allowed. 35 * Currently, this function does not compress the output file 35 36 * 36 37 * @return psMetadataItem* : Pointer metadata item. … … 85 86 bool psMetadataConfigWrite( 86 87 psMetadata *md, ///< The metadata to convert 87 const char *filename ///< Name of file to write 88 const char *filename, ///< Name of file to write 89 const char *compress ///< Output compression options 88 90 ); 89 91 90 92 /** Converts a psMetadata structure (including any nested psMetadata) into a 91 93 * configuration file formatted string that is written a file stream. 94 * Currently, this function does not compress the output file 92 95 * 93 96 * @return bool: True if successful, otherwise false. -
branches/czw_branch/20101203/psLib/test/imageops
- Property svn:ignore
-
old new 27 27 convolutionBench 28 28 tap_psImageInterpolate2 29 tap_psImageInterpolate3 29 30 tap_psImageGeomManip 30 31 tap_psImageMaskOps
-
- Property svn:ignore
-
branches/czw_branch/20101203/psLib/test/imageops/Makefile.am
r14926 r30118 22 22 tap_psImagePixelExtract \ 23 23 tap_psImageInterpolate2 \ 24 tap_psImageInterpolate3 \ 24 25 tap_psImageMap \ 25 26 tap_psImageMapFit \ -
branches/czw_branch/20101203/psLib/test/math
-
Property svn:mergeinfo
set to
/branches/eam_branches/ipp-20101103/psLib/test/math merged eligible /branches/eam_branches/ipp-20101205/psLib/test/math merged eligible /trunk/psLib/test/math merged eligible
-
Property svn:mergeinfo
set to
-
branches/czw_branch/20101203/psLib/test/math/tap_psStats_Sample_01.c
r12513 r30118 487 487 }; 488 488 489 static float yraw_04[] = { 490 -1.000000, 0.000000, 0.000000, 0.000000, 0.000000, -1.000000, -1.000000, -1.000000, 491 0.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, 492 -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -0.963289, 493 -1.000000, 0.000000, -1.000000, -1.000000, -0.915174, -1.000000, -1.000000, -1.000000, 494 -1.000000, -1.000000, 0.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, 495 -1.000000, -1.000000, -1.000000, -0.853025, 0.000000, -1.000000, -1.000000, -1.000000, 496 -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -0.989926, -1.000000, -1.000000, 497 -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -0.834902, -1.000000, -1.000000, 498 -0.942985, -1.000000, -1.000000, 0.000000, -1.000000, -1.000000, -1.000000, -1.000000, 499 -1.000000, -1.000000, -0.990081, -1.000000, -0.990456, -0.814654, -1.000000, -1.000000, 500 -1.000000, -1.000000, 0.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, 501 -0.968021, -1.000000, -1.000000, 0.000000, -1.000000, -1.000000, -0.993967, -0.957540, 502 -0.894533, -0.958363, -1.000000, -1.000000, -1.000000, -0.988915, -1.000000, -1.000000, 503 -1.000000, -1.000000, -1.000000, -1.000000, -0.985367, -1.000000, -0.972040, -1.000000, 504 -1.000000, -1.000000, 0.000000, -1.000000, -0.882278, -1.000000, -1.000000, -1.000000, 505 -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, 506 -1.000000, -0.962575, -0.976843, -0.998926, -1.000000, -0.914090, 0.000000, -0.957808, 507 -1.000000, -1.000000, -1.000000, 0.000000, -0.902593, -1.000000, -1.000000, -1.000000, 508 -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -0.975404, 509 -1.000000, 0.000000, -0.984627, -1.000000, -0.969547, -0.851295, -1.000000, -0.988146, 510 -1.000000, 0.000000, -1.000000, -0.993753, -0.861851, -1.000000, -0.980836, -0.979644, 511 -1.000000, -1.000000, -1.000000, -0.995401, -1.000000, -1.000000, -1.000000, -1.000000, 512 -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, 513 0.000000, -1.000000, -0.990123, -0.944934, -1.000000, 0.000000, -1.000000, -0.952198, 514 -1.000000, -1.000000, -0.960814, -1.000000, -1.000000, -1.000000, -0.956806, -1.000000, 515 0.000000, -0.991778, -1.000000, -1.000000, -1.000000, -1.000000, 0.000000, -1.000000, 516 -0.977640, -1.000000, -1.000000, 0.000000, -1.000000, -0.977630, -1.000000, -0.974242, 517 -1.000000, -1.000000, -0.940085, -0.930729, -1.000000, -1.000000, 0.000000, -1.000000, 518 -1.000000, -0.933695, -1.000000, -0.932306, -1.000000, -1.000000, -1.000000, -0.836774, 519 -0.931762, -0.926990, -0.861895, -1.000000, -0.922505, -1.000000, -0.956420, -0.998768, 520 -0.974626, -0.964573, -1.000000, -0.933995, -1.000000, -0.995117, -1.000000, -1.000000, 521 0.000000, 0.000000, -1.000000, -0.955537, -0.996360, -0.988015, -1.000000, -1.000000, 522 -0.963953, -0.920429, -0.955252, -0.950946, -1.000000, -1.000000, -1.000000, -0.979526, 523 -1.000000, -1.000000, -0.997193, -1.000000, -1.000000, 0.000000, -1.000000, -1.000000, 524 -1.000000, -0.893445, -1.000000, -1.000000, -0.997704, -1.000000, -1.000000, -0.952295, 525 -1.000000, 0.000000, -0.928042, -1.000000, -1.000000, -0.994029, -0.919350, -1.000000, 526 -1.000000, -1.000000, -1.000000, -0.958966, -0.806458, -0.903843, -1.000000, -1.000000, 527 -1.000000, -1.000000, -1.000000, -1.000000, 0.000000, -0.989002, 0.000000, -0.999874, 528 -1.000000, 0.000000, -1.000000, 0.000000, -0.923556, -0.906242, -0.923497, -0.997873, 529 -1.000000, -1.000000, 0.000000, -0.960376, -0.998760, -1.000000, 0.000000, -1.000000, 530 -0.852141, -1.000000, -0.957442, -0.942000, -1.000000, -1.000000, -1.000000, -1.000000, 531 -1.000000, -1.000000, -0.996748, -0.997676, -0.976159, -0.951572, -1.000000, -0.993083, 532 -0.715375, -0.997984, -1.000000, -0.962484, -0.996733, -1.000000, -1.000000, -0.953423, 533 -1.000000, -0.882232, -1.000000, -1.000000, -0.944493, -1.000000, -0.979617, -1.000000, 534 -0.990002, -1.000000, -0.844745, -0.945080, -1.000000, -1.000000, -0.904816, -1.000000, 535 -0.986999, -1.000000, -0.854941, -1.000000, -0.946096, -0.977678, -1.000000, -0.955933, 536 -0.979545, -1.000000, -1.000000, -0.863616, -0.973953, -0.996599, -0.990304, -0.978263, 537 -1.000000, -0.967798, -0.912566, 0.000000, -1.000000, -1.000000, -0.990321, -0.995921, 538 -1.000000, -1.000000, -1.000000, -0.927030, -0.886393, -0.987297, -1.000000, -1.000000, 539 -0.987206, -0.978084, -1.000000, -0.923876, -0.957539, -0.991587, -0.819295, -1.000000, 540 -0.985077, -1.000000, 0.000000, -1.000000, -1.000000, -0.822353, -1.000000, -1.000000, 541 -0.987783, -1.000000, -0.909520, -1.000000, -0.932334, -0.991847, -1.000000, -0.885318, 542 -0.945695, -0.977144, -0.989444, -0.887085, -0.891662, -0.894193, -1.000000, 0.000000, 543 -1.000000, -0.917484, -1.000000, -0.892801, -1.000000, -0.963580, -0.869279, -0.965420, 544 -0.906966, -0.929646, -0.981315, -1.000000, -1.000000, -0.749674, -1.000000, -0.886804, 545 -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -0.970826, -0.909766, 546 -1.000000, -0.910406, -0.983636, -1.000000, -0.961209, -0.935273, -1.000000, -0.989806, 547 0.000000, -0.981563, -0.989701, -0.915626, -0.997493, -0.981429, -1.000000, -0.964583, 548 -1.000000, -0.930216, -0.737797, -1.000000, -0.944314, -0.999998, -0.999611, -0.945788, 549 -0.773886, -0.848979, -0.980186, -1.000000, -1.000000, 0.000000, -0.951392, -0.993398, 550 -0.931889, -0.991680, -0.959021, -0.904240, -1.000000, -0.983561, -0.821324, 0.000000, 551 0.000000, -1.000000, -0.925782, -0.841267, -1.000000, -0.907313, -1.000000, -0.990704, 552 -1.000000, -1.000000, -0.936372, -0.885059 553 }; 554 489 555 int main (void) 490 556 { 491 557 plan_tests(21); 492 558 493 // diag("psStats Tests with sample SDSS data from RHL and Megacam from EAM");494 // diag("this file does not yet define a specific test"); 495 // diag("the fitted mean is currently wrong for these two data sets"); 496 497 { 559 // float **yraw = {yraw_01, yraw_02, yraw_03, yraw_04, NULL}; 560 561 if (1) { 562 diag("sample 1 : problem with integer-binned data driven to tiny sigma values"); 563 498 564 psMemId id = psMemGetId(); 499 565 500 // diag("sample 1 : problem with integer-binned data driven to tiny sigma values");501 566 psStats *stats = psStatsAlloc (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV | 502 567 PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV | … … 505 570 PS_STAT_SAMPLE_STDEV | PS_STAT_USE_BINSIZE); 506 571 stats->binsize = 1.0; 507 508 572 509 573 // copy data in static array … … 533 597 534 598 535 {599 if (1) { 536 600 psMemId id = psMemGetId(); 537 601 538 //diag("sample 2");602 diag("sample 2"); 539 603 psStats *stats = psStatsAlloc (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV | 540 604 PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV | … … 568 632 } 569 633 570 {634 if (1) { 571 635 psMemId id = psMemGetId(); 572 636 573 //diag("sample 3");637 diag("sample 3"); 574 638 psStats *stats = psStatsAlloc (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV | 575 639 PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV | 576 640 PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV | 577 641 PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_MEDIAN | 578 PS_STAT_SAMPLE_STDEV | PS_STAT_USE_BINSIZE); 579 stats->binsize = 1.0; 580 642 PS_STAT_SAMPLE_STDEV); 581 643 582 644 // copy data in static array … … 605 667 } 606 668 669 { 670 psMemId id = psMemGetId(); 671 672 // psTraceSetLevel("psLib.math.vectorRobustStats", 6); 673 674 diag("sample 4"); 675 psStats *stats = psStatsAlloc (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV | 676 PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV | 677 PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV | 678 PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_MEDIAN | 679 PS_STAT_SAMPLE_STDEV); 680 681 // copy data in static array 682 int nPts = sizeof(yraw_04) / sizeof (float); 683 psVector *y = psVectorAlloc (nPts, PS_TYPE_F32); 684 for (int i = 0; i < y->n; i++) { 685 y->data.F32[i] = yraw_04[i]; 686 } 687 688 psVectorStats (stats, y, NULL, NULL, 1); 689 ok (1, "sample mean %f, stdev %f", stats->sampleMean, stats->sampleStdev); 690 ok (1, "sample median %f, stdev %f", stats->sampleMedian, stats->sampleStdev); 691 ok (1, "clipped mean %f, stdev %f", stats->clippedMean, stats->clippedStdev); 692 ok (1, "robust median %f, stdev %f", stats->robustMedian, stats->robustStdev); 693 ok (1, "fitted mean %f, stdev %f", stats->fittedMean, stats->fittedStdev); 694 psFree (stats); 695 696 stats = psStatsAlloc (PS_STAT_FITTED_MEAN_V2 | PS_STAT_FITTED_STDEV_V2 | PS_STAT_USE_BINSIZE); 697 stats->binsize = 1.0; 698 psVectorStats (stats, y, NULL, NULL, 1); 699 ok (1, "fitted mean v2 %f, stdev %f", stats->fittedMean, stats->fittedStdev); 700 psFree (stats); 701 702 psFree (y); 703 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 704 } 705 607 706 return exit_status(); 608 707 } 708 -
branches/czw_branch/20101203/psLib/test/types/tap_psMetadataConfigWrite.c
r17515 r30118 25 25 { 26 26 psMemId id = psMemGetId(); 27 ok( !psMetadataConfigWrite(NULL, "mdcfg.wrt" ),27 ok( !psMetadataConfigWrite(NULL, "mdcfg.wrt", NULL), 28 28 "return false for NULL metadata input."); 29 29 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); … … 35 35 psMemId id = psMemGetId(); 36 36 psMetadata *md = psMetadataAlloc(); 37 ok( !psMetadataConfigWrite(md, NULL ),37 ok( !psMetadataConfigWrite(md, NULL, NULL), 38 38 "return false for NULL filename input."); 39 39 psFree(md); … … 46 46 psMemId id = psMemGetId(); 47 47 psMetadata *md = psMetadataAlloc(); 48 ok( !psMetadataConfigWrite(md, "." ),48 ok( !psMetadataConfigWrite(md, ".", NULL), 49 49 "return false for invalid filename input."); 50 50 psFree(md); … … 57 57 psMemId id = psMemGetId(); 58 58 psMetadata *md = psMetadataAlloc(); 59 ok(psMetadataConfigWrite(md, "mdcfg.wrt" ), "return false for empty metadata input.");59 ok(psMetadataConfigWrite(md, "mdcfg.wrt", NULL), "return false for empty metadata input."); 60 60 psFree(md); 61 61 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); … … 68 68 psMetadata *md = psMetadataAlloc(); 69 69 psMetadataAddBool(md, PS_LIST_TAIL, "item1-1", 0, "I am a boolean", true); 70 ok( psMetadataConfigWrite(md, "mdcfg.wrt" ),70 ok( psMetadataConfigWrite(md, "mdcfg.wrt", NULL), 71 71 "return true for valid inputs."); 72 72 char configTest[61];
Note:
See TracChangeset
for help on using the changeset viewer.
