IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 25, 2009, 2:00:56 PM (17 years ago)
Author:
eugene
Message:

merging changes from head

Location:
branches/eam_branches/20090522
Files:
2 deleted
14 edited
4 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090522

  • branches/eam_branches/20090522/psLib/configure.ac

    r24024 r24557  
    392392  test/sys/Makefile
    393393  test/types/Makefile
     394  test/optime/Makefile
    394395  utils/Makefile
    395396])
  • branches/eam_branches/20090522/psLib/src/fits/psFits.c

    r21431 r24557  
    931931    }
    932932
     933    // use strncmp so that we can resolve the string valuves that cfitsio puts into headers (RICE_1 GZIP_1)
     934    // into psFitsCompressionType
    933935    if (strcmp(string, "NONE") == 0) return PS_FITS_COMPRESS_NONE;
    934     if (strcmp(string, "GZIP") == 0) return PS_FITS_COMPRESS_GZIP;
    935     if (strcmp(string, "RICE") == 0) return PS_FITS_COMPRESS_RICE;
    936     if (strcmp(string, "HCOMPRESS") == 0) return PS_FITS_COMPRESS_HCOMPRESS;
    937     if (strcmp(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;
    938940
    939941    psWarning("Unable to identify compression type (%s) --- none set.", string);
  • branches/eam_branches/20090522/psLib/src/fits/psFitsTable.c

    r18421 r24557  
    390390
    391391
    392 bool psFitsInsertTable(psFits* fits,
    393                        const psMetadata* header,
    394                        const psArray* table,
    395                        const char *extname,
    396                        bool after)
     392static 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                            )
    397399{
    398400    PS_ASSERT_FITS_NON_NULL(fits, false);
    … …  
    403405
    404406    long numRows = table->n;
    405     if (numRows < 1) {
     407    if (writeData && numRows < 1) {
    406408        // no table data, what can I do?
    407409        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
    … …  
    504506        fits_create_tbl(fits->fd,
    505507                        BINARY_TBL,
    506                         table->n, // number of rows in table
     508                        writeData ? numRows : 0, // number of rows in table
    507509                        numColumns, // number of columns in table
    508510                        (char**)columnNames->data, // names of the columns
    … …  
    524526        // Insert the table
    525527        fits_insert_btbl(fits->fd,
    526                          table->n, // number of rows in table
     528                         writeData ? numRows : 0, // number of rows in table
    527529                         numColumns, // number of columns in table
    528530                         (char**)columnNames->data, // names of the columns
    … …  
    562564
    563565    // 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                }
    576631            }
    577632
    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;
    627639            }
    628         }
    629 
    630         // Check error status from writing column
    631         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;
    636640        }
    637641    }
    … …  
    650654    return true;
    651655}
     656
     657
     658bool 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
     666bool 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
     682bool 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
    652694
    653695bool psFitsUpdateTable(psFits* fits,
  • branches/eam_branches/20090522/psLib/src/fits/psFitsTable.h

    r15248 r24557  
    9090);
    9191
     92/// Write an empty table
     93bool 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
    92100/** Inserts a whole FITS table. A new HDU of the type BINTABLE is inserted either
    93101 *  before or after, depending on the AFTER parameter, the current HDU.
    … …  
    104112    bool after    ///< TRUE if insert is done after CHDU, otherwise table is inserted before CHDU
    105113);
     114
     115/// Insert an empty table
     116bool 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
    106124
    107125/** Updates a FITS table.  The current HDU type must be either
  • branches/eam_branches/20090522/psLib/src/imageops/psImageBackground.c

    r21183 r24557  
    5252
    5353    // 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;
    5656
    5757    // select a subset of the image pixels to measure the stats
    5858    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                }
    6466
    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;
    6880
    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        }
    7491    }
    7592    if (n < 0.01*Nsubset) {
  • branches/eam_branches/20090522/psLib/src/imageops/psImageConvolve.c

    r21337 r24557  
    122122
    123123    return kernel;
     124}
     125
     126psKernel *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;
    124142}
    125143
  • branches/eam_branches/20090522/psLib/src/imageops/psImageConvolve.h

    r21335 r24557  
    9696    );
    9797
     98/// Copy a kernel
     99///
     100/// Performs a deep copy of the input kernel
     101psKernel *psKernelCopy(
     102    const psKernel *in                  ///< Kernel to be copied
     103    );
     104
    98105/// Checks the type of a particular pointer.
    99106///
  • branches/eam_branches/20090522/psLib/src/imageops/psImageUnbin.c

    r21040 r24557  
    3030// DX, DY are the binning factor
    3131// dx, dy is the distance is high-res pixels to the 0,0 corner of the first
    32 // binned pixel. 
     32// binned pixel.
    3333// XXX check that this is still consistent with psphotImageMedian...
    3434psImage *psImageUnbin(psImage *out, const psImage *in, const psImageBinning *binning)
    … …  
    6969            // (Xs,Ys) : (Xe,Ye) : binned pixel centers in unbinned coords
    7070            // corresponding to (Ix,Iy), (Ix+1,Iy+1)
    71             // XXX should this be "+ dx" and + dy?
     71            // XXX should this be "+ dx" and + dy?
    7272            int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, Ix + 0.5)));
    7373            int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, Iy + 0.5)));
    … …  
    7676
    7777            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;
    8080                float Vxs = V10*dY + V00*rY;
    8181                float Vxe = V11*dY + V01*rY;
    8282
    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);
     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);
    102102
    103103                float dV = (Vxe - Vxs) / DX;
    … …  
    128128            for (int ix = 0; ix < Xs; ix++) {
    129129                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));
    131131            }
    132132            V += dV;
    … …  
    141141            for (int ix = Xe; ix < Nx; ix++) {
    142142                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));
    144144            }
    145145            V += dV;
    … …  
    163163            for (int ix = Xs; (ix < Xe) && (ix < Nx); ix++) {
    164164                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));
    166166                V += dV;
    167167            }
    … …  
    176176            for (int ix = Xs; (ix < Xe) && (ix < Nx); ix++) {
    177177                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));
    179179                V += dV;
    180180            }
    … …  
    186186    {
    187187        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)));
    193193
    194194        // 0,0
    195195        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));
    197197
    198198        for (int iy = 0; iy < Ys; iy++)
    … …  
    204204        // Nx,0
    205205        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));
    207207
    208208        for (int iy = 0; iy < Ys; iy++)
    … …  
    214214        // 0,Ny
    215215        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));
    217217
    218218        for (int iy = Ye; iy < Ny; iy++)
    … …  
    224224        // Nx,Ny
    225225        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));
    227227
    228228        for (int iy = Ye; iy < Ny; iy++)
    … …  
    243243
    244244double psImageUnbinPixel(const double xFine, const double yFine, // desired Unbinned point (parent coords)
    245                         const psImage *in, // binned image
    246                         const psImageBinning *binning)   //!< Overhang
     245                        const psImage *in, // binned image
     246                        const psImageBinning *binning)   //!< Overhang
    247247{
    248248    PS_ASSERT_IMAGE_NON_NULL(in, NAN);
    … …  
    273273
    274274    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);
    276276        return NAN;
    277277    }
    … …  
    281281    // if we have a single pixel, there is no spatial information
    282282    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;
    285285    }
    286286
    … …  
    306306    // if Nx == 1, we have no x-dir spatial information
    307307    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    }
    314314
    315315    // if Ny == 1, we have no y-dir spatial information
    316316    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
    325325    double V00 = in->data.F32[Ys][Xs];
    326326    double V01 = in->data.F32[Ye][Xs];
    … …  
    332332    // corners
    333333    if ((dx < 0.0) && (dy < 0.0)) {
    334         return V00;
    335     }   
     334        return V00;
     335    }
    336336    if ((dx > 1.0) && (dy < 0.0)) {
    337         return V10;
    338     }   
     337        return V10;
     338    }
    339339    if ((dx < 0.0) && (dy > 1.0)) {
    340         return V01;
    341     }   
     340        return V01;
     341    }
    342342    if ((dx > 1.0) && (dy > 1.0)) {
    343         return V11;
    344     }   
     343        return V11;
     344    }
    345345
    346346    // sides
    347347    if (dx < 0.0) {
    348         value = V00*ry + V01*dy;
    349         return value;
    350     }   
     348        value = V00*ry + V01*dy;
     349        return value;
     350    }
    351351    if (dy < 0.0) {
    352         value = V00*rx + V10*dx;
    353         return value;
    354     }   
     352        value = V00*rx + V10*dx;
     353        return value;
     354    }
    355355    if (dx > 1.0) {
    356         value = V10*ry + V11*dy;
    357         return value;
    358     }   
     356        value = V10*ry + V11*dy;
     357        return value;
     358    }
    359359    if (dy > 1.0) {
    360         value = V01*rx + V11*dx;
    361         return value;
    362     }   
     360        value = V01*rx + V11*dx;
     361        return value;
     362    }
    363363
    364364    // bilinear interpolation
  • branches/eam_branches/20090522/psLib/src/sys/psAbort.c

    r17446 r24557  
    1010 *  @author Eric Van Alst, MHPCC
    1111 *  @author Joshua Hoblitt, University of Hawaii
    12  *   
     12 *
    1313 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    1414 *  @date $Date: 2008-04-13 08:18:27 $
    … …  
    3434               ...)
    3535{
    36     psErrorStackPrint(stderr, "Aborting. Error stack:");
     36    psErrorStackPrint(stderr, "Aborting in function %s at %s:%d. Error stack:", func, file, lineno);
    3737
    3838    va_list argPtr;             // variable list arguement pointer
    … …  
    5151
    5252void 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                ...)
    5858{
    5959    if (value) return;
    60     psErrorStackPrint(stderr, "Aborting. Error stack:");
     60    psErrorStackPrint(stderr, "Assertion failed in function %s at %s:%d. Error stack:", func, file, lineno);
    6161
    6262    va_list argPtr;             // variable list arguement pointer
  • branches/eam_branches/20090522/psLib/test/Makefile.am

    r11547 r24557  
    1 SUBDIRS = tap pstap $(SRCDIRS)
     1SUBDIRS = tap pstap optime $(SRCDIRS)
    22
    33TESTS = test.pl
  • branches/eam_branches/20090522/psLib/test/astro/tap_psTime_01.c

    r24023 r24557  
    842842    {
    843843        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");
    850848    }
    851849
    … …  
    858856        psMemId id = psMemGetId();
    859857        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);
    864861        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    865862    }
    … …  
    873870        psMemId id = psMemGetId();
    874871        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);
    879875        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    880876    }
    … …  
    888884        psMemId id = psMemGetId();
    889885        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);
    894889        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    895890    }
    … …  
    903898        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
    904899        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);
    909903        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    910904    }
    … …  
    919913        psTime *time1 = psTimeAlloc(PS_TIME_TAI);
    920914        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);
    925918        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    926919    }
    … …  
    929922    // psTimeConvert()
    930923    //Attempt to convert a time to the same type
     924    //Should return true because time->type == type
    931925    {
    932926        psMemId id = psMemGetId();
    … …  
    936930        time1->type = PS_TIME_TAI;
    937931        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");
    944934
    945935        psFree(time1);
    … …  
    957947        time1->leapsecond = false;
    958948
    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(time2->sec, testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");
    962         is_long(time2->nsec, testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");
    963         ok(time2->type == PS_TIME_TAI, "psTimeConvert() returned the correct type");
    964         is_bool(time2->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");
    965955
    966956        psFree(time1);
    … …  
    978968        time1->leapsecond = false;
    979969
    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(time2->sec, testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");
    983         is_long(time2->nsec, testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");
    984         ok(time2->type == PS_TIME_TT, "psTimeConvert() returned the correct type");
    985         is_bool(time2->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");
    986976
    987977        psFree(time1);
    … …  
    999989        time1->leapsecond = false;
    1000990
    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(time2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
    1004         is_long(time2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
    1005         ok(time2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");
    1006         is_bool(time2->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");
    1007997
    1008998        psFree(time1);
    … …  
    10191009        time1->leapsecond = false;
    10201010
    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(time2->sec, testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");
    1024         is_long(time2->nsec, testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");
    1025         ok(time2->type == PS_TIME_UTC, "psTimeConvert() returned the correct type");
    1026         is_bool(time2->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");
    10271017
    10281018        psFree(time1);
    … …  
    10411031        time1->leapsecond = false;
    10421032
    1043         psTime *time2 = psTimeConvert(time1,PS_TIME_TT);
    1044         ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
    1045         is_long(time2->sec, testTime1SecondsTT, "psTimeConvert() returned the correct ->sec");
    1046         is_long(time2->nsec, testTime1NanosecondsTT, "psTimeConvert() returned the correct ->nsec");
    1047         ok(time2->type == PS_TIME_TT, "psTimeConvert() returned the correct type");
    1048         is_bool(time2->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");
    10491039
    10501040        psFree(time1);
    … …  
    10621052        time1->leapsecond = false;
    10631053
    1064         psTime *time2 = psTimeConvert(time1,PS_TIME_UT1);
    1065         ok(time1 == time2, "psTimeConvert() returned time for conversion to same type");
    1066         is_long(time2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
    1067         is_long(time2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
    1068         ok(time2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");
    1069         is_bool(time2->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");
    10701060
    10711061        psFree(time1);
    … …  
    10831073        time1->leapsecond = false;
    10841074
    1085         psTime *time2 = psTimeConvert(time1,PS_TIME_UTC);
    1086         ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
    1087         is_long(time2->sec, testTime1SecondsUTC, "psTimeConvert() returned the correct ->sec");
    1088         is_long(time2->nsec, testTime1NanosecondsUTC, "psTimeConvert() returned the correct ->nsec");
    1089         ok(time2->type == PS_TIME_UTC, "psTimeConvert() returned the correct type");
    1090         is_bool(time2->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");
    10911081
    10921082        psFree(time1);
    … …  
    11041094        time1->leapsecond = false;
    11051095
    1106         psTime *time2 = psTimeConvert(time1,PS_TIME_TAI);
    1107         ok(time2 == time1, "psTimeConvert() returned time for conversion to same type");
    1108         is_long(time2->sec, testTime1SecondsTAI, "psTimeConvert() returned the correct ->sec");
    1109         is_long(time2->nsec, testTime1NanosecondsTAI, "psTimeConvert() returned the correct ->nsec");
    1110         ok(time2->type == PS_TIME_TAI, "psTimeConvert() returned the correct type");
    1111         is_bool(time2->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");
    11121102
    11131103        psFree(time1);
    … …  
    11251115        time1->leapsecond = false;
    11261116
    1127         psTime *time2 = psTimeConvert(time1,PS_TIME_UT1);
    1128         ok(time1 == time2, "psTimeConvert() returned time for conversion to same type");
    1129         is_long(time2->sec, testTime1SecondsUT1, "psTimeConvert() returned the correct ->sec");
    1130         is_long(time2->nsec, testTime1NanosecondsUT1, "psTimeConvert() returned the correct ->nsec");
    1131         ok(time2->type == PS_TIME_UT1, "psTimeConvert() returned the correct type");
    1132         is_bool(time2->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");
    11331123
    11341124        psFree(time1);
    … …  
    11471137        time1->leapsecond = false;
    11481138
    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);
    11531142        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    11541143    }
  • branches/eam_branches/20090522/psLib/test/astro/tap_psTime_03.c

    r13936 r24557  
    494494            psFree(timeStr);
    495495
    496             time = psTimeConvert(time, PS_TIME_TT);
     496            bool status = psTimeConvert(time, PS_TIME_TT);
    497497            timeStr = psTimeToISO(time);
    498498            is_str(timeStr, testTimeBStrTT[i], "TT ISO string");
    … …  
    500500
    501501            // Verify UTC ISO string
    502             time = psTimeConvert(time, PS_TIME_UTC);
     502            status = psTimeConvert(time, PS_TIME_UTC);
    503503            time->leapsecond = testTimeBLeapsecond[i];
    504504            timeStr = psTimeToISO(time);
    … …  
    506506            psFree(timeStr);
    507507
    508             time = psTimeConvert(time, PS_TIME_UT1);
     508            status = psTimeConvert(time, PS_TIME_UT1);
    509509            timeStr = psTimeToISO(time);
    510510            is_str(timeStr, testTimeBStrUT1[i], "UT1 ISO string");
  • branches/eam_branches/20090522/psLib/test/math/Makefile.am

    r24087 r24557  
    4343        tap_psStats08 \
    4444        tap_psStats09 \
    45         tap_psStatsTiming \
    4645        tap_psFunc01 \
    4746        tap_psStats_Sample_01 \
Note: See TracChangeset for help on using the changeset viewer.