Changeset 24557 for branches/eam_branches/20090522/psLib
- Timestamp:
- Jun 25, 2009, 2:00:56 PM (17 years ago)
- Location:
- branches/eam_branches/20090522
- Files:
-
- 2 deleted
- 14 edited
- 4 copied
-
. (modified) (1 prop)
-
psLib/configure.ac (modified) (1 diff)
-
psLib/src/fits/psFits.c (modified) (1 diff)
-
psLib/src/fits/psFitsTable.c (modified) (6 diffs)
-
psLib/src/fits/psFitsTable.h (modified) (2 diffs)
-
psLib/src/imageops/psImageBackground.c (modified) (1 diff)
-
psLib/src/imageops/psImageConvolve.c (modified) (1 diff)
-
psLib/src/imageops/psImageConvolve.h (modified) (1 diff)
-
psLib/src/imageops/psImageUnbin.c (modified) (16 diffs)
-
psLib/src/sys/psAbort.c (modified) (3 diffs)
-
psLib/test/Makefile.am (modified) (1 diff)
-
psLib/test/astro/tap_psTime_01.c (modified) (18 diffs)
-
psLib/test/astro/tap_psTime_03.c (modified) (3 diffs)
-
psLib/test/math/Makefile.am (modified) (1 diff)
-
psLib/test/math/tap_psStatsTiming.c (deleted)
-
psLib/test/math/tap_psStatsTiming.txt (deleted)
-
psLib/test/optime (copied) (copied from trunk/psLib/test/optime )
-
psLib/test/optime/Makefile.am (copied) (copied from trunk/psLib/test/optime/Makefile.am )
-
psLib/test/optime/tap_psStatsTiming.c (copied) (copied from trunk/psLib/test/optime/tap_psStatsTiming.c )
-
psLib/test/optime/tap_psStatsTiming.txt (copied) (copied from trunk/psLib/test/optime/tap_psStatsTiming.txt )
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090522
- Property svn:mergeinfo changed
-
branches/eam_branches/20090522/psLib/configure.ac
r24024 r24557 392 392 test/sys/Makefile 393 393 test/types/Makefile 394 test/optime/Makefile 394 395 utils/Makefile 395 396 ]) -
branches/eam_branches/20090522/psLib/src/fits/psFits.c
r21431 r24557 931 931 } 932 932 933 // use strncmp so that we can resolve the string valuves that cfitsio puts into headers (RICE_1 GZIP_1) 934 // into psFitsCompressionType 933 935 if (strcmp(string, "NONE") == 0) return PS_FITS_COMPRESS_NONE; 934 if (str cmp(string, "GZIP") == 0) return PS_FITS_COMPRESS_GZIP;935 if (str cmp(string, "RICE") == 0) return PS_FITS_COMPRESS_RICE;936 if (str cmp(string, "HCOMPRESS") == 0) return PS_FITS_COMPRESS_HCOMPRESS;937 if (str cmp(string, "PLIO") == 0) return PS_FITS_COMPRESS_PLIO;936 if (strncmp(string, "GZIP", 4) == 0) return PS_FITS_COMPRESS_GZIP; 937 if (strncmp(string, "RICE", 4) == 0) return PS_FITS_COMPRESS_RICE; 938 if (strncmp(string, "HCOMPRESS", 9) == 0) return PS_FITS_COMPRESS_HCOMPRESS; 939 if (strncmp(string, "PLIO", 4) == 0) return PS_FITS_COMPRESS_PLIO; 938 940 939 941 psWarning("Unable to identify compression type (%s) --- none set.", string); -
branches/eam_branches/20090522/psLib/src/fits/psFitsTable.c
r18421 r24557 390 390 391 391 392 bool psFitsInsertTable(psFits* fits, 393 const psMetadata* header, 394 const psArray* table, 395 const char *extname, 396 bool after) 392 static bool fitsInsertTable(psFits* fits, // FITS file 393 const psMetadata* header, // FITS header to write 394 const psArray* table, // Table to write 395 const char *extname, // Extension name to give table 396 bool after, // Write table after current extension? 397 bool writeData // Write data? 398 ) 397 399 { 398 400 PS_ASSERT_FITS_NON_NULL(fits, false); … … 403 405 404 406 long numRows = table->n; 405 if ( numRows < 1) {407 if (writeData && numRows < 1) { 406 408 // no table data, what can I do? 407 409 psError(PS_ERR_BAD_PARAMETER_SIZE, true, … … 504 506 fits_create_tbl(fits->fd, 505 507 BINARY_TBL, 506 table->n, // number of rows in table508 writeData ? numRows : 0, // number of rows in table 507 509 numColumns, // number of columns in table 508 510 (char**)columnNames->data, // names of the columns … … 524 526 // Insert the table 525 527 fits_insert_btbl(fits->fd, 526 table->n, // number of rows in table528 writeData ? numRows : 0, // number of rows in table 527 529 numColumns, // number of columns in table 528 530 (char**)columnNames->data, // names of the columns … … 562 564 563 565 // cfitsio requires that we write the data by columns --- urgh! 564 psMetadataIteratorSet(colSpecsIter, PS_LIST_HEAD); 565 for (long colNum = 1; (colSpecItem = psMetadataGetAndIncrement(colSpecsIter)); colNum++) { 566 // Note: colNum is unit-indexed, because it's for cfitsio 567 colSpec *spec = colSpecItem->data.V; // The specification 568 if (PS_DATA_IS_PRIMITIVE(spec->type)) { 569 size_t dataSize = PSELEMTYPE_SIZEOF(spec->type); // Size (in bytes) of this type 570 psVector *columnData = psVectorAlloc(table->n, spec->type); // The raw row data, to be written 571 psVectorInit(columnData, 0); 572 for (long i = 0; i < table->n; i++) { 573 psMetadata *row = table->data[i]; // The row of interest 574 psMetadataItem *dataItem = psMetadataLookup(row, colSpecItem->name); // The value of interest 575 memcpy(&columnData->data.U8[i * dataSize], &dataItem->data, dataSize); 566 if (writeData) { 567 psMetadataIteratorSet(colSpecsIter, PS_LIST_HEAD); 568 for (long colNum = 1; (colSpecItem = psMetadataGetAndIncrement(colSpecsIter)); colNum++) { 569 // Note: colNum is unit-indexed, because it's for cfitsio 570 colSpec *spec = colSpecItem->data.V; // The specification 571 if (PS_DATA_IS_PRIMITIVE(spec->type)) { 572 size_t dataSize = PSELEMTYPE_SIZEOF(spec->type); // Size (in bytes) of this type 573 psVector *columnData = psVectorAlloc(table->n, spec->type); // The raw row data, to be written 574 psVectorInit(columnData, 0); 575 for (long i = 0; i < table->n; i++) { 576 psMetadata *row = table->data[i]; // The row of interest 577 psMetadataItem *dataItem = psMetadataLookup(row, colSpecItem->name); // Value of interest 578 memcpy(&columnData->data.U8[i * dataSize], &dataItem->data, dataSize); 579 } 580 581 int fitsDataType; // Data type for cfitsio 582 p_psFitsTypeToCfitsio(spec->type, NULL, NULL, &fitsDataType); 583 fits_write_col(fits->fd, 584 fitsDataType, 585 colNum, // column number 586 1, // first row 587 1, // first element 588 table->n, // number of rows 589 columnData->data.U8, // the data 590 &status); 591 psFree(columnData); 592 } else { 593 switch (spec->type) { 594 case PS_DATA_STRING: { 595 psArray *strings = psArrayAlloc(table->n); // Array of strings 596 for (long i = 0; i < table->n; i++) { 597 psMetadata *row = table->data[i]; // The row of interest 598 strings->data[i] = psMemIncrRefCounter(psMetadataLookupStr(NULL, row, 599 colSpecItem->name)); 600 } 601 fits_write_col_str(fits->fd, colNum, 1, 1, table->n, (char**)strings->data, &status); 602 psFree(strings); 603 break; 604 } 605 case PS_DATA_VECTOR: { 606 size_t dataSize = PSELEMTYPE_SIZEOF(spec->vectorType); // Size of data, in bytes 607 psVector *columnData = psVectorAlloc(spec->size * table->n * dataSize, PS_TYPE_U8); 608 psVectorInit(columnData, 0); 609 for (long i = 0; i < table->n; i++) { 610 psMetadata *row = table->data[i]; // The row of interest 611 psMetadataItem* dataItem = psMetadataLookup(row, colSpecItem->name); 612 if (dataItem->type != PS_DATA_VECTOR) { 613 // Just in case --- get a zero instead of some weird result 614 continue; 615 } 616 psVector *vector = dataItem->data.V; 617 memcpy(&columnData->data.U8[i * dataSize * spec->size], vector->data.U8, 618 vector->n * dataSize); 619 } 620 621 int fitsDataType; // Data type for cfitsio 622 p_psFitsTypeToCfitsio(spec->vectorType, NULL, NULL, &fitsDataType); 623 fits_write_col(fits->fd, fitsDataType, colNum, 1, 1, table->n * spec->size, 624 columnData->data.U8, &status); 625 psFree(columnData); 626 break; 627 } 628 default: 629 psAbort("Should never get here.\n"); 630 } 576 631 } 577 632 578 int fitsDataType; // Data type for cfitsio 579 p_psFitsTypeToCfitsio(spec->type, NULL, NULL, &fitsDataType); 580 fits_write_col(fits->fd, 581 fitsDataType, 582 colNum, // column number 583 1, // first row 584 1, // first element 585 table->n, // number of rows 586 columnData->data.U8, // the data 587 &status); 588 psFree(columnData); 589 } else { 590 switch (spec->type) { 591 case PS_DATA_STRING: { 592 psArray *strings = psArrayAlloc(table->n); // Array of strings 593 for (long i = 0; i < table->n; i++) { 594 psMetadata *row = table->data[i]; // The row of interest 595 strings->data[i] = psMemIncrRefCounter(psMetadataLookupStr(NULL, row, 596 colSpecItem->name)); 597 } 598 fits_write_col_str(fits->fd, colNum, 1, 1, table->n, (char**)strings->data, &status); 599 psFree(strings); 600 break; 601 } 602 case PS_DATA_VECTOR: { 603 size_t dataSize = PSELEMTYPE_SIZEOF(spec->vectorType); // Size of data, in bytes 604 psVector *columnData = psVectorAlloc(spec->size * table->n * dataSize, PS_TYPE_U8); 605 psVectorInit(columnData, 0); 606 for (long i = 0; i < table->n; i++) { 607 psMetadata *row = table->data[i]; // The row of interest 608 psMetadataItem* dataItem = psMetadataLookup(row, colSpecItem->name); 609 if (dataItem->type != PS_DATA_VECTOR) { 610 // Just in case --- get a zero instead of some weird result 611 continue; 612 } 613 psVector *vector = dataItem->data.V; 614 memcpy(&columnData->data.U8[i * dataSize * spec->size], vector->data.U8, 615 vector->n * dataSize); 616 } 617 618 int fitsDataType; // Data type for cfitsio 619 p_psFitsTypeToCfitsio(spec->vectorType, NULL, NULL, &fitsDataType); 620 fits_write_col(fits->fd, fitsDataType, colNum, 1, 1, table->n * spec->size, 621 columnData->data.U8, &status); 622 psFree(columnData); 623 break; 624 } 625 default: 626 psAbort("Should never get here.\n"); 633 // Check error status from writing column 634 if (status != 0) { 635 psFitsError(status, true, "Unable to write column %ld of FITS table", colNum); 636 psFree(colSpecsIter); 637 psFree(colSpecs); 638 return false; 627 639 } 628 }629 630 // Check error status from writing column631 if (status != 0) {632 psFitsError(status, true, "Unable to write column %ld of FITS table", colNum);633 psFree(colSpecsIter);634 psFree(colSpecs);635 return false;636 640 } 637 641 } … … 650 654 return true; 651 655 } 656 657 658 bool psFitsInsertTable(psFits* fits, const psMetadata* header, const psArray* table, const char *extname, 659 bool after) 660 { 661 PS_ASSERT_FITS_NON_NULL(fits, false); 662 PS_ASSERT_FITS_WRITABLE(fits, false); 663 return fitsInsertTable(fits, header, table, extname, after, true); 664 } 665 666 bool psFitsWriteTableEmpty(psFits *fits, const psMetadata *header, const psMetadata *columns, 667 const char *extname) 668 { 669 PS_ASSERT_FITS_NON_NULL(fits, false); 670 PS_ASSERT_FITS_WRITABLE(fits, false); 671 if (!psFitsMoveLast(fits)) { 672 psError(PS_ERR_UNKNOWN, false, "Unable to move to last extension to write table"); 673 return false; 674 } 675 psArray *table = psArrayAlloc(1); // Dummy table carrying column definitions 676 table->data[0] = psMemIncrRefCounter((psPtr)columns); // Casting away const 677 bool status = fitsInsertTable(fits, header, table, extname, true, false); // Status of insertion 678 psFree(table); 679 return status; 680 } 681 682 bool psFitsInsertTableEmpty(psFits *fits, const psMetadata *header, const psMetadata *columns, 683 const char *extname, bool after) 684 { 685 PS_ASSERT_FITS_NON_NULL(fits, false); 686 PS_ASSERT_FITS_WRITABLE(fits, false); 687 psArray *table = psArrayAlloc(1); // Dummy table carrying column definitions 688 table->data[0] = psMemIncrRefCounter((psPtr)columns); // Casting away const 689 bool status = fitsInsertTable(fits, header, table, extname, after, false); // Status of insertion 690 psFree(table); 691 return status; 692 } 693 652 694 653 695 bool psFitsUpdateTable(psFits* fits, -
branches/eam_branches/20090522/psLib/src/fits/psFitsTable.h
r15248 r24557 90 90 ); 91 91 92 /// Write an empty table 93 bool psFitsWriteTableEmpty( 94 psFits *fits, ///< FITS file pointer 95 const psMetadata *header, ///< Header to write 96 const psMetadata *columns, ///< Column definitions; no data used except name,type 97 const char *extname ///< Extension name for table 98 ); 99 92 100 /** Inserts a whole FITS table. A new HDU of the type BINTABLE is inserted either 93 101 * before or after, depending on the AFTER parameter, the current HDU. … … 104 112 bool after ///< TRUE if insert is done after CHDU, otherwise table is inserted before CHDU 105 113 ); 114 115 /// Insert an empty table 116 bool psFitsInsertTableEmpty( 117 psFits *fits, ///< FITS file pointer 118 const psMetadata *header, ///< Header to write 119 const psMetadata *columns, ///< Column definitions; no data used except name,type 120 const char *extname, ///< Extension name for table 121 bool after ///< Insert after current HDU? 122 ); 123 106 124 107 125 /** Updates a FITS table. The current HDU type must be either -
branches/eam_branches/20090522/psLib/src/imageops/psImageBackground.c
r21183 r24557 52 52 53 53 // Minimum and maximum values 54 float min = values->data.F32[0];55 float max = values->data.F32[0];54 float min = +PS_MAX_F32; 55 float max = -PS_MAX_F32; 56 56 57 57 // select a subset of the image pixels to measure the stats 58 58 long n = 0; // Number of actual pixels in subset 59 for (long i = 0; i < Nsubset; i++) { 60 double frnd = psRandomUniform(rng); 61 int pixel = Npixels * frnd; 62 int ix = pixel % nx; 63 int iy = pixel / nx; 59 if (Nsubset >= Npixels) { 60 // if we have an image smaller than Nsubset, just loop over the image pixels 61 for (int iy = 0; iy < ny; iy++) { 62 for (int ix = 0; ix < nx; ix++) { 63 if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskValue)) { 64 continue; 65 } 64 66 65 if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskValue)) { 66 continue; 67 } 67 float value = image->data.F32[iy][ix]; 68 min = PS_MIN(value, min); 69 max = PS_MAX(value, max); 70 values->data.F32[n] = value; 71 n++; 72 } 73 } 74 } else { 75 for (long i = 0; i < Nsubset; i++) { 76 double frnd = psRandomUniform(rng); 77 int pixel = Npixels * frnd; 78 int ix = pixel % nx; 79 int iy = pixel / nx; 68 80 69 float value = image->data.F32[iy][ix]; 70 min = PS_MIN(value, min); 71 max = PS_MIN(value, max); 72 values->data.F32[n] = value; 73 n++; 81 if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskValue)) { 82 continue; 83 } 84 85 float value = image->data.F32[iy][ix]; 86 min = PS_MIN(value, min); 87 max = PS_MAX(value, max); 88 values->data.F32[n] = value; 89 n++; 90 } 74 91 } 75 92 if (n < 0.01*Nsubset) { -
branches/eam_branches/20090522/psLib/src/imageops/psImageConvolve.c
r21337 r24557 122 122 123 123 return kernel; 124 } 125 126 psKernel *psKernelCopy(const psKernel *in) 127 { 128 PS_ASSERT_KERNEL_NON_NULL(in, NULL); 129 130 psKernel *out = psAlloc(sizeof(psKernel)); // The copied kernel, to be returned 131 psMemSetDeallocator(out,(psFreeFunc)kernelFree); 132 133 out->image = psImageCopy(NULL, in->image, PS_TYPE_KERNEL); 134 out->xMin = in->xMin; 135 out->xMax = in->xMax; 136 out->yMin = in->yMin; 137 out->yMax = in->yMax; 138 139 kernelRedirects(out, out->image->numRows); 140 141 return out; 124 142 } 125 143 -
branches/eam_branches/20090522/psLib/src/imageops/psImageConvolve.h
r21335 r24557 96 96 ); 97 97 98 /// Copy a kernel 99 /// 100 /// Performs a deep copy of the input kernel 101 psKernel *psKernelCopy( 102 const psKernel *in ///< Kernel to be copied 103 ); 104 98 105 /// Checks the type of a particular pointer. 99 106 /// -
branches/eam_branches/20090522/psLib/src/imageops/psImageUnbin.c
r21040 r24557 30 30 // DX, DY are the binning factor 31 31 // dx, dy is the distance is high-res pixels to the 0,0 corner of the first 32 // binned pixel. 32 // binned pixel. 33 33 // XXX check that this is still consistent with psphotImageMedian... 34 34 psImage *psImageUnbin(psImage *out, const psImage *in, const psImageBinning *binning) … … 69 69 // (Xs,Ys) : (Xe,Ye) : binned pixel centers in unbinned coords 70 70 // corresponding to (Ix,Iy), (Ix+1,Iy+1) 71 // XXX should this be "+ dx" and + dy?71 // XXX should this be "+ dx" and + dy? 72 72 int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, Ix + 0.5))); 73 73 int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, Iy + 0.5))); … … 76 76 77 77 for (int iy = Ys; (iy < Ye) && (iy < Ny); iy++) { 78 float dY = (iy - Ys) / (float) DY;79 float rY = 1.0 - dY;78 float dY = (iy - Ys) / (float) DY; 79 float rY = 1.0 - dY; 80 80 float Vxs = V10*dY + V00*rY; 81 81 float Vxe = V11*dY + V01*rY; 82 82 83 // Vxs = (V10 - V00)*(iy - Ys) / DY + V00; 84 // Vxe = (V11 - V01)*(iy - Ys) / DY + V01; 85 86 // dVx = Vxs_1 - Vxs_187 // dVx = (V10*dY_1 + V00*rY_1) - (V10*dY_0 + V00*rY_0);88 // dY_0 = (iy - Ys)/DY = iy/DY - Ys/DY;89 // dY_1 = (iy + 1 - Ys)/DY = iy/DY - Ys/DY + 1/DY;90 // rY_0 = 1 - dY_0;91 // rY_1 = 1 - dY_1;92 // dVx = V10*(ddY) + V00*(drY);93 // ddY = 1/DY;94 // drY = -1/DY;95 96 // dVxs = (V10 - V00)/DY;97 // dVxe = (V11 - V01)/DY;98 99 // ddV = (Vxe_1 - Vxs_1)/DX - (Vxe_0 - Vxs_0)/DX;100 // ddV = (Vxe_1 - Vxe_0)/DX - (Vxs_1 - Vxs_0)/DX;101 // ddV = (V11 - V01 - V10 + V00)/(DX*DY);83 // Vxs = (V10 - V00)*(iy - Ys) / DY + V00; 84 // Vxe = (V11 - V01)*(iy - Ys) / DY + V01; 85 86 // dVx = Vxs_1 - Vxs_1 87 // dVx = (V10*dY_1 + V00*rY_1) - (V10*dY_0 + V00*rY_0); 88 // dY_0 = (iy - Ys)/DY = iy/DY - Ys/DY; 89 // dY_1 = (iy + 1 - Ys)/DY = iy/DY - Ys/DY + 1/DY; 90 // rY_0 = 1 - dY_0; 91 // rY_1 = 1 - dY_1; 92 // dVx = V10*(ddY) + V00*(drY); 93 // ddY = 1/DY; 94 // drY = -1/DY; 95 96 // dVxs = (V10 - V00)/DY; 97 // dVxe = (V11 - V01)/DY; 98 99 // ddV = (Vxe_1 - Vxs_1)/DX - (Vxe_0 - Vxs_0)/DX; 100 // ddV = (Vxe_1 - Vxe_0)/DX - (Vxs_1 - Vxs_0)/DX; 101 // ddV = (V11 - V01 - V10 + V00)/(DX*DY); 102 102 103 103 float dV = (Vxe - Vxs) / DX; … … 128 128 for (int ix = 0; ix < Xs; ix++) { 129 129 vOut[iy][ix] = V; 130 // assert (fabs(V - psImageUnbinPixel(ix, iy, in, binning)) < UNBIN_TOL*fabs(V));130 // assert (fabs(V - psImageUnbinPixel(ix, iy, in, binning)) < UNBIN_TOL*fabs(V)); 131 131 } 132 132 V += dV; … … 141 141 for (int ix = Xe; ix < Nx; ix++) { 142 142 vOut[iy][ix] = V; 143 // assert (fabs(V - psImageUnbinPixel(ix, iy, in, binning)) < UNBIN_TOL*fabs(V));143 // assert (fabs(V - psImageUnbinPixel(ix, iy, in, binning)) < UNBIN_TOL*fabs(V)); 144 144 } 145 145 V += dV; … … 163 163 for (int ix = Xs; (ix < Xe) && (ix < Nx); ix++) { 164 164 vOut[iy][ix] = V; 165 // assert (fabs(V - psImageUnbinPixel(ix, iy, in, binning)) < UNBIN_TOL*fabs(V));165 // assert (fabs(V - psImageUnbinPixel(ix, iy, in, binning)) < UNBIN_TOL*fabs(V)); 166 166 V += dV; 167 167 } … … 176 176 for (int ix = Xs; (ix < Xe) && (ix < Nx); ix++) { 177 177 vOut[iy][ix] = V; 178 // assert (fabs(V - psImageUnbinPixel(ix, iy, in, binning)) < UNBIN_TOL*fabs(V));178 // assert (fabs(V - psImageUnbinPixel(ix, iy, in, binning)) < UNBIN_TOL*fabs(V)); 179 179 V += dV; 180 180 } … … 186 186 { 187 187 float V; 188 // center of last pixel 189 int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, 0 + 0.5)));190 int Xe = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, nx - 0.5)));191 int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, 0 + 0.5)));192 int Ye = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, ny - 0.5)));188 // center of last pixel 189 int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, 0 + 0.5))); 190 int Xe = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, nx - 0.5))); 191 int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, 0 + 0.5))); 192 int Ye = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, ny - 0.5))); 193 193 194 194 // 0,0 195 195 V = vIn[0][0]; 196 // assert (fabs(V - psImageUnbinPixel(0, 0, in, binning)) < UNBIN_TOL*fabs(V));196 // assert (fabs(V - psImageUnbinPixel(0, 0, in, binning)) < UNBIN_TOL*fabs(V)); 197 197 198 198 for (int iy = 0; iy < Ys; iy++) … … 204 204 // Nx,0 205 205 V = vIn[0][nx-1]; 206 // assert (fabs(V - psImageUnbinPixel(Nx-1, 0, in, binning)) < UNBIN_TOL*fabs(V));206 // assert (fabs(V - psImageUnbinPixel(Nx-1, 0, in, binning)) < UNBIN_TOL*fabs(V)); 207 207 208 208 for (int iy = 0; iy < Ys; iy++) … … 214 214 // 0,Ny 215 215 V = vIn[ny-1][0]; 216 // assert (fabs(V - psImageUnbinPixel(0, Ny-1, in, binning)) < UNBIN_TOL*fabs(V));216 // assert (fabs(V - psImageUnbinPixel(0, Ny-1, in, binning)) < UNBIN_TOL*fabs(V)); 217 217 218 218 for (int iy = Ye; iy < Ny; iy++) … … 224 224 // Nx,Ny 225 225 V = vIn[ny-1][nx-1]; 226 // assert (fabs(V - psImageUnbinPixel(Nx-1, Ny-1, in, binning)) < UNBIN_TOL*fabs(V));226 // assert (fabs(V - psImageUnbinPixel(Nx-1, Ny-1, in, binning)) < UNBIN_TOL*fabs(V)); 227 227 228 228 for (int iy = Ye; iy < Ny; iy++) … … 243 243 244 244 double psImageUnbinPixel(const double xFine, const double yFine, // desired Unbinned point (parent coords) 245 const psImage *in, // binned image246 const psImageBinning *binning) //!< Overhang245 const psImage *in, // binned image 246 const psImageBinning *binning) //!< Overhang 247 247 { 248 248 PS_ASSERT_IMAGE_NON_NULL(in, NAN); … … 273 273 274 274 if ((x < -nXedge) || (x > in->numCols + nXedge) || (y < -nYedge) || (y > in->numRows + nYedge)) { 275 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Point (% f,%f) lies outside binned image", x, y);275 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Point (%lf,%lf) lies outside binned image", x, y); 276 276 return NAN; 277 277 } … … 281 281 // if we have a single pixel, there is no spatial information 282 282 if ((in->numCols == 1) && (in->numRows == 1)) { 283 const double value = in->data.F32[0][0];284 return value;283 const double value = in->data.F32[0][0]; 284 return value; 285 285 } 286 286 … … 306 306 // if Nx == 1, we have no x-dir spatial information 307 307 if (in->numCols == 1) { 308 double V0 = in->data.F32[Ys][Xs];309 double V1 = in->data.F32[Ye][Xs];310 311 const double value = V0*ry + V1*dy;312 return value;313 } 308 double V0 = in->data.F32[Ys][Xs]; 309 double V1 = in->data.F32[Ye][Xs]; 310 311 const double value = V0*ry + V1*dy; 312 return value; 313 } 314 314 315 315 // if Ny == 1, we have no y-dir spatial information 316 316 if (in->numRows == 1) { 317 double V0 = in->data.F32[Ys][Xs];318 double V1 = in->data.F32[Ys][Xe];319 320 const double value = V0*rx + V1*dx;321 return value;322 } 323 324 // Vxy 317 double V0 = in->data.F32[Ys][Xs]; 318 double V1 = in->data.F32[Ys][Xe]; 319 320 const double value = V0*rx + V1*dx; 321 return value; 322 } 323 324 // Vxy 325 325 double V00 = in->data.F32[Ys][Xs]; 326 326 double V01 = in->data.F32[Ye][Xs]; … … 332 332 // corners 333 333 if ((dx < 0.0) && (dy < 0.0)) { 334 return V00;335 } 334 return V00; 335 } 336 336 if ((dx > 1.0) && (dy < 0.0)) { 337 return V10;338 } 337 return V10; 338 } 339 339 if ((dx < 0.0) && (dy > 1.0)) { 340 return V01;341 } 340 return V01; 341 } 342 342 if ((dx > 1.0) && (dy > 1.0)) { 343 return V11;344 } 343 return V11; 344 } 345 345 346 346 // sides 347 347 if (dx < 0.0) { 348 value = V00*ry + V01*dy;349 return value;350 } 348 value = V00*ry + V01*dy; 349 return value; 350 } 351 351 if (dy < 0.0) { 352 value = V00*rx + V10*dx;353 return value;354 } 352 value = V00*rx + V10*dx; 353 return value; 354 } 355 355 if (dx > 1.0) { 356 value = V10*ry + V11*dy;357 return value;358 } 356 value = V10*ry + V11*dy; 357 return value; 358 } 359 359 if (dy > 1.0) { 360 value = V01*rx + V11*dx;361 return value;362 } 360 value = V01*rx + V11*dx; 361 return value; 362 } 363 363 364 364 // bilinear interpolation -
branches/eam_branches/20090522/psLib/src/sys/psAbort.c
r17446 r24557 10 10 * @author Eric Van Alst, MHPCC 11 11 * @author Joshua Hoblitt, University of Hawaii 12 * 12 * 13 13 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 14 14 * @date $Date: 2008-04-13 08:18:27 $ … … 34 34 ...) 35 35 { 36 psErrorStackPrint(stderr, "Aborting . Error stack:");36 psErrorStackPrint(stderr, "Aborting in function %s at %s:%d. Error stack:", func, file, lineno); 37 37 38 38 va_list argPtr; // variable list arguement pointer … … 51 51 52 52 void p_psAssert(const char *file, 53 unsigned int lineno,54 const char *func,55 const bool value,56 const char *format,57 ...)53 unsigned int lineno, 54 const char *func, 55 const bool value, 56 const char *format, 57 ...) 58 58 { 59 59 if (value) return; 60 psErrorStackPrint(stderr, "A borting. Error stack:");60 psErrorStackPrint(stderr, "Assertion failed in function %s at %s:%d. Error stack:", func, file, lineno); 61 61 62 62 va_list argPtr; // variable list arguement pointer -
branches/eam_branches/20090522/psLib/test/Makefile.am
r11547 r24557 1 SUBDIRS = tap pstap $(SRCDIRS)1 SUBDIRS = tap pstap optime $(SRCDIRS) 2 2 3 3 TESTS = test.pl -
branches/eam_branches/20090522/psLib/test/astro/tap_psTime_01.c
r24023 r24557 842 842 { 843 843 psMemId id = psMemGetId(); 844 bool status = psTimeConvert(NULL, PS_TIME_TAI); 845 846 ok(status == false, "psTimeConvert(NULL, PS_TIME_TAI) returned NULL"); 847 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 848 849 psFree(time2); 844 bool status= psTimeConvert(NULL, PS_TIME_TAI); 845 846 ok(status== false, "psTimeConvert(NULL, PS_TIME_TAI) returned NULL"); 847 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 850 848 } 851 849 … … 858 856 psMemId id = psMemGetId(); 859 857 psTime *time1 = psTimeAlloc(PS_TIME_TAI); 860 psTime *time2 = psTimeConvert(time1,-100); 861 ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL"); 862 psFree(time1); 863 psFree(time2); 858 bool status = psTimeConvert(time1,-100); 859 ok(status == false, "psTimeConvert(time1, -100) returned false"); 860 psFree(time1); 864 861 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 865 862 } … … 873 870 psMemId id = psMemGetId(); 874 871 psTime *time1 = psTimeAlloc(PS_TIME_UTC); 875 psTime *time2 = psTimeConvert(time1,-100); 876 ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL"); 877 psFree(time1); 878 psFree(time2); 872 bool status = psTimeConvert(time1,-100); 873 ok(status == false, "psTimeConvert(time1, -100) returned false"); 874 psFree(time1); 879 875 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 880 876 } … … 888 884 psMemId id = psMemGetId(); 889 885 psTime *time1 = psTimeAlloc(PS_TIME_TT); 890 psTime *time2 = psTimeConvert(time1,-100); 891 ok(time2 == NULL, "psTimeConvert(time1, -100) returned NULL"); 892 psFree(time1); 893 psFree(time2); 886 bool status = psTimeConvert(time1,-100); 887 ok(status == false, "psTimeConvert(time1, -100) returned false"); 888 psFree(time1); 894 889 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 895 890 } … … 903 898 psTime *time1 = psTimeAlloc(PS_TIME_TAI); 904 899 time1->type = -100; 905 psTime *time2 = psTimeConvert(time1,PS_TIME_TAI); 906 ok(time2 == NULL, "psTimeConvert(time1, PS_TIME_TAI) returned NULL"); 907 psFree(time1); 908 psFree(time2); 900 bool status = psTimeConvert(time1,PS_TIME_TAI); 901 ok(status == false, "psTimeConvert(time1, PS_TIME_TAI) returned false"); 902 psFree(time1); 909 903 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 910 904 } … … 919 913 psTime *time1 = psTimeAlloc(PS_TIME_TAI); 920 914 time1->nsec = 2e9; 921 psTime *time2 = psTimeConvert(time1, PS_TIME_TAI); 922 ok(time2 == NULL, "psTimeConvert(time1, PS_TIME_TAI) returns NULL for incorrect psTime object"); 923 psFree(time1); 924 psFree(time2); 915 bool status = psTimeConvert(time1, PS_TIME_TAI); 916 ok(status == false, "psTimeConvert(time1, PS_TIME_TAI) returns NULL for incorrect psTime object"); 917 psFree(time1); 925 918 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 926 919 } … … 929 922 // psTimeConvert() 930 923 //Attempt to convert a time to the same type 924 //Should return true because time->type == type 931 925 { 932 926 psMemId id = psMemGetId(); … … 936 930 time1->type = PS_TIME_TAI; 937 931 time1->leapsecond = false; 938 psTime *time2 = psTimeConvert(time1, PS_TIME_TAI); 939 ok(time2 == time1, "psTimeConvert(time, ...) returns time for conversion to same type"); 940 is_long(time2->sec, 1, "time->sec"); 941 is_long(time2->nsec, 2, "time->nsec"); 942 ok(time2->type == PS_TIME_TAI, "time->type"); 943 is_bool(time2->leapsecond, false, "time->leapsecond"); 932 bool status = psTimeConvert(time1, PS_TIME_TAI); 933 ok(status == true, "psTimeConvert(time, ...) returns true for conversion to same type"); 944 934 945 935 psFree(time1); … … 957 947 time1->leapsecond = false; 958 948 959 psTime *time2= psTimeConvert(time1,PS_TIME_TAI);960 ok( time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");961 is_long(time 2->sec, testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");962 is_long(time 2->nsec, testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");963 ok(time 2->type == PS_TIME_TAI, "psTimeConvert() returned the correct type");964 is_bool(time 2->leapsecond, false, "time->leapsecond");949 bool status = psTimeConvert(time1,PS_TIME_TAI); 950 ok(status == true, "psTimeConvert(time, ...) returns true after conversion to a different type"); 951 is_long(time1->sec, testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec"); 952 is_long(time1->nsec, testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec"); 953 ok(time1->type == PS_TIME_TAI, "psTimeConvert() returned the correct type"); 954 is_bool(time1->leapsecond, false, "time->leapsecond"); 965 955 966 956 psFree(time1); … … 978 968 time1->leapsecond = false; 979 969 980 psTime *time2= psTimeConvert(time1,PS_TIME_TT);981 ok( time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");982 is_long(time 2->sec, testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");983 is_long(time 2->nsec, testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");984 ok(time 2->type == PS_TIME_TT, "psTimeConvert() returned the correct type");985 is_bool(time 2->leapsecond, false, "time->leapsecond");970 bool status = psTimeConvert(time1,PS_TIME_TT); 971 ok(status == true, "psTimeConvert(time, ...) returns true after conversion to a different type"); 972 is_long(time1->sec, testTime1SecondsTT, "psTimeConvert() returned the correct ->sec"); 973 is_long(time1->nsec, testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec"); 974 ok(time1->type == PS_TIME_TT, "psTimeConvert() returned the correct type"); 975 is_bool(time1->leapsecond, false, "time->leapsecond"); 986 976 987 977 psFree(time1); … … 999 989 time1->leapsecond = false; 1000 990 1001 psTime *time2= psTimeConvert(time1,PS_TIME_UT1);1002 ok( time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");1003 is_long(time 2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");1004 is_long(time 2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");1005 ok(time 2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");1006 is_bool(time 2->leapsecond, false, "time->leapsecond");991 bool status = psTimeConvert(time1,PS_TIME_UT1); 992 ok(status == true, "psTimeConvert(time, ...) returns true after conversion to a different type"); 993 is_long(time1->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec"); 994 is_long(time1->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec"); 995 ok(time1->type == PS_TIME_UT1, "psTimeConvert() returned the correct type"); 996 is_bool(time1->leapsecond, false, "time->leapsecond"); 1007 997 1008 998 psFree(time1); … … 1019 1009 time1->leapsecond = false; 1020 1010 1021 psTime *time2= psTimeConvert(time1,PS_TIME_UTC);1022 ok( time2 == time1, "psTimeConvert(time, ...) returns time after conversion to a different type");1023 is_long(time 2->sec, testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");1024 is_long(time 2->nsec, testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");1025 ok(time 2->type == PS_TIME_UTC, "psTimeConvert() returned the correct type");1026 is_bool(time 2->leapsecond, false, "time->leapsecond");1011 bool status = psTimeConvert(time1,PS_TIME_UTC); 1012 ok(status == true, "psTimeConvert(time, ...) returns true after conversion to a different type"); 1013 is_long(time1->sec, testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec"); 1014 is_long(time1->nsec, testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec"); 1015 ok(time1->type == PS_TIME_UTC, "psTimeConvert() returned the correct type"); 1016 is_bool(time1->leapsecond, false, "time->leapsecond"); 1027 1017 1028 1018 psFree(time1); … … 1041 1031 time1->leapsecond = false; 1042 1032 1043 psTime *time2= psTimeConvert(time1,PS_TIME_TT);1044 ok( time2 == time1, "psTimeConvert() returned time for conversion to same type");1045 is_long(time 2->sec, testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");1046 is_long(time 2->nsec, testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");1047 ok(time 2->type == PS_TIME_TT, "psTimeConvert() returned the correct type");1048 is_bool(time 2->leapsecond, false, "time->leapsecond");1033 bool status = psTimeConvert(time1,PS_TIME_TT); 1034 ok(status == true, "psTimeConvert() returned true for conversion to same type"); 1035 is_long(time1->sec, testTime1SecondsTT, "psTimeConvert() returned the correct ->sec"); 1036 is_long(time1->nsec, testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec"); 1037 ok(time1->type == PS_TIME_TT, "psTimeConvert() returned the correct type"); 1038 is_bool(time1->leapsecond, false, "time->leapsecond"); 1049 1039 1050 1040 psFree(time1); … … 1062 1052 time1->leapsecond = false; 1063 1053 1064 psTime *time2= psTimeConvert(time1,PS_TIME_UT1);1065 ok( time1 == time2, "psTimeConvert() returned time for conversion to same type");1066 is_long(time 2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");1067 is_long(time 2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");1068 ok(time 2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");1069 is_bool(time 2->leapsecond, false, "time->leapsecond");1054 bool status = psTimeConvert(time1,PS_TIME_UT1); 1055 ok(status == true, "psTimeConvert() returned true for conversion to same type"); 1056 is_long(time1->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec"); 1057 is_long(time1->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec"); 1058 ok(time1->type == PS_TIME_UT1, "psTimeConvert() returned the correct type"); 1059 is_bool(time1->leapsecond, false, "time->leapsecond"); 1070 1060 1071 1061 psFree(time1); … … 1083 1073 time1->leapsecond = false; 1084 1074 1085 psTime *time2= psTimeConvert(time1,PS_TIME_UTC);1086 ok( time2 == time1, "psTimeConvert() returned time for conversion to same type");1087 is_long(time 2->sec, testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");1088 is_long(time 2->nsec, testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");1089 ok(time 2->type == PS_TIME_UTC, "psTimeConvert() returned the correct type");1090 is_bool(time 2->leapsecond, false, "time->leapsecond");1075 bool status = psTimeConvert(time1,PS_TIME_UTC); 1076 ok(status == true, "psTimeConvert() returned true for conversion to same type"); 1077 is_long(time1->sec, testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec"); 1078 is_long(time1->nsec, testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec"); 1079 ok(time1->type == PS_TIME_UTC, "psTimeConvert() returned the correct type"); 1080 is_bool(time1->leapsecond, false, "time->leapsecond"); 1091 1081 1092 1082 psFree(time1); … … 1104 1094 time1->leapsecond = false; 1105 1095 1106 psTime *time2= psTimeConvert(time1,PS_TIME_TAI);1107 ok( time2 == time1, "psTimeConvert() returned time for conversion to same type");1108 is_long(time 2->sec, testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");1109 is_long(time 2->nsec, testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");1110 ok(time 2->type == PS_TIME_TAI, "psTimeConvert() returned the correct type");1111 is_bool(time 2->leapsecond, false, "time->leapsecond");1096 bool status = psTimeConvert(time1,PS_TIME_TAI); 1097 ok(status == true, "psTimeConvert() returned true for conversion to same type"); 1098 is_long(time1->sec, testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec"); 1099 is_long(time1->nsec, testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec"); 1100 ok(time1->type == PS_TIME_TAI, "psTimeConvert() returned the correct type"); 1101 is_bool(time1->leapsecond, false, "time->leapsecond"); 1112 1102 1113 1103 psFree(time1); … … 1125 1115 time1->leapsecond = false; 1126 1116 1127 psTime *time2= psTimeConvert(time1,PS_TIME_UT1);1128 ok( time1 == time2, "psTimeConvert() returned time for conversion to same type");1129 is_long(time 2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");1130 is_long(time 2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");1131 ok(time 2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");1132 is_bool(time 2->leapsecond, false, "time->leapsecond");1117 bool status = psTimeConvert(time1,PS_TIME_UT1); 1118 ok(status == true, "psTimeConvert() returned true for conversion to same type"); 1119 is_long(time1->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec"); 1120 is_long(time1->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec"); 1121 ok(time1->type == PS_TIME_UT1, "psTimeConvert() returned the correct type"); 1122 is_bool(time1->leapsecond, false, "time->leapsecond"); 1133 1123 1134 1124 psFree(time1); … … 1147 1137 time1->leapsecond = false; 1148 1138 1149 psTime *time2 = psTimeConvert(time1, PS_TIME_UTC); 1150 ok(time2 == NULL, "psTimeConvert() returned NULL for conversion from UT1"); 1151 psFree(time1); 1152 psFree(time2); 1139 bool status = psTimeConvert(time1, PS_TIME_UTC); 1140 ok(status == false, "psTimeConvert() returned false for conversion from UT1"); 1141 psFree(time1); 1153 1142 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 1154 1143 } -
branches/eam_branches/20090522/psLib/test/astro/tap_psTime_03.c
r13936 r24557 494 494 psFree(timeStr); 495 495 496 time= psTimeConvert(time, PS_TIME_TT);496 bool status = psTimeConvert(time, PS_TIME_TT); 497 497 timeStr = psTimeToISO(time); 498 498 is_str(timeStr, testTimeBStrTT[i], "TT ISO string"); … … 500 500 501 501 // Verify UTC ISO string 502 time= psTimeConvert(time, PS_TIME_UTC);502 status = psTimeConvert(time, PS_TIME_UTC); 503 503 time->leapsecond = testTimeBLeapsecond[i]; 504 504 timeStr = psTimeToISO(time); … … 506 506 psFree(timeStr); 507 507 508 time= psTimeConvert(time, PS_TIME_UT1);508 status = psTimeConvert(time, PS_TIME_UT1); 509 509 timeStr = psTimeToISO(time); 510 510 is_str(timeStr, testTimeBStrUT1[i], "UT1 ISO string"); -
branches/eam_branches/20090522/psLib/test/math/Makefile.am
r24087 r24557 43 43 tap_psStats08 \ 44 44 tap_psStats09 \ 45 tap_psStatsTiming \46 45 tap_psFunc01 \ 47 46 tap_psStats_Sample_01 \
Note:
See TracChangeset
for help on using the changeset viewer.
