IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6205


Ignore:
Timestamp:
Jan 26, 2006, 11:10:51 AM (20 years ago)
Author:
gusciora
Message:

Implemented the polynomial alloc argument changes.

Location:
trunk/psModules
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/astrom/Makefile.am

    r5674 r6205  
    55libpsmoduleastrom_la_SOURCES  = \
    66    pmAstrometry.c \
     7    pmFPAConstruct.c \
    78    pmAstrometryObjects.c
    89
    910psmoduleincludedir = $(includedir)
    1011psmoduleinclude_HEADERS = \
    11   pmAstrometry.h \
    12   pmAstrometryObjects.h
     12    pmAstrometry.h \
     13    pmFPAConstruct.h \
     14    pmAstrometryObjects.h
  • trunk/psModules/src/astrom/pmAstrometry.c

    r5739 r6205  
    1313* XXX: Should we implement non-linear cell->chip transforms?
    1414*
    15 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    16 *  @date $Date: 2005-12-08 00:00:57 $
     15*  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     16*  @date $Date: 2006-01-26 21:10:50 $
    1717*
    1818*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    101101        psFree(cell->readouts);
    102102        psFree(cell->parent);
    103         psFree(cell->private);
     103        psFree(cell->hdu);
    104104    }
    105105}
     
    125125        psFree(chip->cells);
    126126        psFree(chip->parent);
    127         psFree(chip->private);
     127        psFree(chip->hdu);
    128128    }
    129129}
     
    151151        }
    152152        psFree(fpa->chips);
    153         psFree(fpa->private);
     153        psFree(fpa->hdu);
    154154        psFree(fpa->phu);
    155155    }
     
    204204    }
    205205    tmpCell->valid = false;
    206     tmpCell->private = NULL;
     206    tmpCell->hdu = NULL;
    207207
    208208    psMemSetDeallocator(tmpCell, (psFreeFunc) cellFree);
     
    233233    }
    234234    tmpChip->valid = false;
    235     tmpChip->private = NULL;
     235    tmpChip->hdu = NULL;
    236236
    237237    psMemSetDeallocator(tmpChip, (psFreeFunc) chipFree);
     
    250250    tmpFPA->camera = camera;
    251251    tmpFPA->chips = psArrayAlloc(0);
    252     tmpFPA->private = NULL;
     252    tmpFPA->hdu = NULL;
    253253    tmpFPA->phu = NULL;
    254254
     
    873873    return(numChips);
    874874}
     875
  • trunk/psModules/src/astrom/pmAstrometry.h

    r5739 r6205  
    88*  @author GLG, MHPCC
    99*
    10 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-12-08 00:00:57 $
     10*  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2006-01-26 21:10:50 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3434}
    3535p_pmHDU;
     36
     37p_pmHDU *pmHDUAlloc();
     38void *pmHDUFree(p_pmHDU *hdu);
    3639
    3740/** Focal plane data structure
     
    6265    const psMetadata *camera;           ///< Camera configuration
    6366    psArray *chips;                     ///< The chips
    64     p_pmHDU *private;                   ///< FITS data
     67    p_pmHDU *hdu;                       ///< FITS data
    6568    psMetadata *phu;                    ///< Primary Header
    6669}
     
    9598    pmFPA *parent;                      ///< Parent FPA
    9699    bool valid;                         ///< Do we bother about reading and working with this chip?
    97     p_pmHDU *private;                   ///< FITS data
     100    p_pmHDU *hdu;                       ///< FITS data
    98101}
    99102pmChip;
     
    124127    pmChip *parent;                     ///< Parent chip
    125128    bool valid;                         ///< Do we bother about reading and working with this cell?
    126     p_pmHDU *private;                   ///< FITS data
     129    p_pmHDU *hdu;                       ///< FITS data
    127130}
    128131pmCell;
     
    436439);
    437440
     441
    438442/**
    439443 *
     
    451455
    452456
     457/**
     458 *
     459 * pmFPAConstruct shall construct a focal plane hierarchy from a camera
     460 * configuration. A db handle is also provided so that may be set in the pmFPA.
     461 * The resultant pmFPA and its lower-down components shall be ready for to read a
     462 * FITS file into it by setting the extname pointers at the appropriate levels to
     463 * the appropriate FITS extension name.
     464 * 
     465 */
     466pmFPA *pmFPAConstruct(
     467    const psMetadata *camera,
     468    psDB *db
     469);
     470
     471
    453472#endif // #ifndef PS_ASTROMETRY_H
    454473
  • trunk/psModules/src/astrom/pmAstrometryObjects.h

    r5674 r6205  
    88*  @author EAM, IfA
    99*
    10 *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-12-05 20:49:30 $
     10*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2006-01-26 21:10:50 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    183183 * the GRID.*.ANGLE entries (they will be ignored).
    184184 *
    185  * XXX: This function name is different in the SDRS.
    186  *
    187185 */
    188186/* in pmAstromGrid.c */
  • trunk/psModules/src/imcombine/pmReadoutCombine.c

    r5516 r6205  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-11-15 20:09:03 $
     7 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-01-26 21:10:50 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    461461}
    462462
     463
     464
     465/**
     466 *
     467 * The input array fluxLevels consists of Ni vectors, one per mosaic image.
     468 * Each vector consists of Nj elements, each a measurement of the input
     469 * flat-field image flux levels. All of these vectors must be constructed with
     470 * the same number of elements, or the function will return an error. If a chip
     471 * is missing from a particular image, that element should be set to NaN. The
     472 * vector chipGains supplies initial guesses for the chip gains. If the vector
     473 * contains the values 0.0 or NaN for any of the elements, the gain is set to the
     474 * mean of the valid values. If the vector length does not match the number of
     475 * chips, an warning is raised, all chip gain guesses will be set to 1.0, and the
     476 * vector length modified to match the number of chips defined by the supplied
     477 * fluxLevels. The sourceFlux input vector must be allocated (not NULL), but the
     478 * routine will set the vector length to the number of source images regardless
     479 * of the initial state of the vector. All vectors used by this function must be
     480 * of type PS_DATA_F64.
     481 *
     482 
     483fluxLevels(i, j): for each flat field image i, this psArray contains a vector
     484with an elemenmt for each chip j.  So, fluxLevels(i, j) corresponds to the
     485measured flux M_(i, j) for flat image i, chip j.
     486 
     487chipGains[]: has j elements, one for each chip.
     488 
     489 
     490They have the observed flux levels for each chip of each image.  They want to
     491solve for the actual flux levels and the gain of each chip.
     492 
     493Okay, they want to solve for source fluxes and chip gains.
     494 
     495 
     496 
     497 
     498 
     499 
     500 *
     501 */
     502bool pmFlatNormalization(
     503    psVector *sourceFlux,
     504    psVector *chipGains,
     505    psArray *fluxLevels)
     506{
     507    PS_ASSERT_PTR_NON_NULL(fluxLevels, false);
     508    psS32 numImages = fluxLevels->n;
     509    psS32 numChips = ((psVector *) fluxLevels->data[0])->n;
     510    for (psS32 i = 0 ; i < numImages ; i++) {
     511        psVector *tmpVec = (psVector *) fluxLevels->data[i];
     512        PS_ASSERT_VECTOR_NON_NULL(tmpVec, false);
     513        PS_ASSERT_VECTOR_TYPE(tmpVec, PS_TYPE_F64, false);
     514        PS_ASSERT_VECTOR_SIZE(tmpVec, numChips, false);
     515    }
     516
     517    //
     518    // Ensure that *localChipGains points to a vector of the same length as numImages.
     519    //
     520    PS_ASSERT_PTR_NON_NULL(chipGains, false);
     521    PS_ASSERT_VECTOR_TYPE(chipGains, PS_TYPE_F64, false);
     522    psVector *localChipGains = chipGains;
     523    if (numChips != chipGains->n) {
     524        psLogMsg(__func__, PS_LOG_WARN, "WARNING: the chipGains vector length does not match the number of chips.\n");
     525        localChipGains = psVectorAlloc(numChips, PS_TYPE_F64);
     526        psBool rc = psVectorInit(localChipGains, 1.0);
     527        if (rc == false) {
     528            printf("XXX: gen error\n");
     529        }
     530    }
     531
     532    //
     533    // If the chipGains vector contains the values 0.0 or NaN for any of the elements,
     534    // the gain is set to the mean of the valid values.
     535    //
     536    psBool meanFlag = false;
     537    psVector *chipGainsMask = psVectorAlloc(chipGains->n, PS_TYPE_U8);
     538    for (psS32 i = 0 ; i < chipGains->n ; i++) {
     539        if ((fabs(chipGains->data.F64[i]) < FLT_EPSILON) ||
     540                (isnan(chipGains->data.F64[i]))) {
     541            chipGainsMask->data.U8[i] = 1;
     542            meanFlag = true;
     543        }
     544    }
     545    // Must calculate the mean.
     546    if (meanFlag == true) {
     547        psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
     548        stats = psVectorStats(stats, chipGains, NULL, chipGainsMask, 1);
     549        if (stats == NULL) {
     550            printf("XXX: gen error\n");
     551        }
     552        psF64 mean;
     553        psBool rc = p_psGetStatValue(stats, &mean);
     554        if (rc == false) {
     555            printf("XXX: gen error\n");
     556        }
     557        // Set the gain to this mean for chips with a gain of 0.0 or NAN
     558
     559        for (psS32 i = 0 ; i < chipGains->n ; i++) {
     560            if ((fabs(chipGains->data.F64[i]) < FLT_EPSILON) ||
     561                    (isnan(chipGains->data.F64[i]))) {
     562                chipGains->data.F64[i] = mean;
     563            }
     564        }
     565    }
     566
     567    //
     568    // Assert that sourceFlux is non-NULL, correct type, correct size.
     569    //
     570    PS_ASSERT_PTR_NON_NULL(sourceFlux, false);
     571    PS_ASSERT_VECTOR_TYPE(sourceFlux, PS_TYPE_F64, false);
     572    psVectorRealloc(sourceFlux, numImages);
     573
     574
     575
     576
     577
     578
     579    psFree(psVector);
     580    if (numImages != chipGains->n) {
     581        psFree(localChipGains);
     582    }
     583}
  • trunk/psModules/src/imcombine/pmReadoutCombine.h

    r5516 r6205  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-11-15 20:09:03 $
     7 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-01-26 21:10:50 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7272pmFringePoint;
    7373
     74
     75/**
     76 *
     77 * The input array fluxLevels consists of Ni vectors, one per mosaic image.
     78 * Each vector consists of Nj elements, each a measurement of the input
     79 * flat-field image flux levels. All of these vectors must be constructed with
     80 * the same number of elements, or the function will return an error. If a chip
     81 * is missing from a particular image, that element should be set to NaN. The
     82 * vector chipGains supplies initial guesses for the chip gains. If the vector
     83 * contains the values 0.0 or NaN for any of the elements, the gain is set to the
     84 * mean of the valid values. If the vector length does not match the number of
     85 * chips, an warning is raised, all chip gain guesses will be set to 1.0, and the
     86 * vector length modified to match the number of chips defined by the supplied
     87 * fluxLevels. The sourceFlux input vector must be allocated (not NULL), but the
     88 * routine will set the vector length to the number of source images regardless
     89 * of the initial state of the vector. All vectors used by this function must be
     90 * of type PS_DATA_F64.
     91 *
     92 */
     93bool pmFlatNormalization(
     94    psVector *sourceFlux,
     95    psVector *chipGains,
     96    psArray *fluxLevels
     97);
     98
     99
    74100#endif
  • trunk/psModules/src/imsubtract/pmSubtractBias.c

    r5843 r6205  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-12-24 01:24:20 $
     8 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-01-26 21:10:51 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    274274    psPolynomial1D *in)
    275275{
    276     psPolynomial1D *out = psPolynomial1DAlloc(in->nX, in->type);
     276    psPolynomial1D *out = psPolynomial1DAlloc(in->type, in->nX);
    277277    Polynomial1DCopy(out, in);
    278278    return(out);
     
    11411141
    11421142
    1143 
    1144 
    1145 
    1146 
    1147 
    1148 
    1149 
    1150 
    1151 
    1152 
    1153 
    1154 
    1155 
    1156 
    1157 
    1158 
    11591143/******************************************************************************
    11601144pmSubtractBias(....): see SDRS for complete specification.
  • trunk/psModules/test/astrom/tst_pmAstrometry.c

    r5681 r6205  
    99 *  XXX: Create the pmHDU alloc/free function, test them here
    1010 *
    11  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-12-05 21:28:55 $
     11 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-01-26 21:10:51 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    137137
    138138    //
    139     // How to test the p_pmHDU *private member?
     139    // How to test the p_pmHDU *hdu member?
    140140    //
    141141
     
    208208    }
    209209
    210     if (fpa->private != NULL) {
    211         psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->private to NULL.");
     210    if (fpa->hdu != NULL) {
     211        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->hdu to NULL.");
    212212        return 9;
    213213    }
     
    258258
    259259    //
    260     // How to test the p_pmHDU *private member?
     260    // How to test the p_pmHDU *hdu member?
    261261    //
    262262
     
    325325    }
    326326
    327     if (chip->private != NULL) {
    328         psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->private set improperly.\n");
     327    if (chip->hdu != NULL) {
     328        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->hdu set improperly.\n");
    329329        return 25;
    330330    }
     
    395395
    396396    //
    397     // How to test the p_pmHDU *private member?
     397    // How to test the p_pmHDU *hdu member?
    398398    //
    399399
     
    473473    }
    474474
    475     if (cell->private != NULL) {
    476         psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->private set improperly.\n");
     475    if (cell->hdu != NULL) {
     476        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->hdu set improperly.\n");
    477477        return 27;
    478478    }
  • trunk/psModules/test/config/tst_pmConfig.c

    r5683 r6205  
    77 *  @author GLG, MHPCC
    88 *
    9  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-12-05 21:41:31 $
     9 * XXX: Untested:
     10 * pmConfigValidateCamera()
     11 * pmConfigCameraFromHeader()
     12 * pmConfigRecipeFromCamera()
     13 * pmConfigDB()
     14 *
     15 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2006-01-26 21:10:51 $
    1117 *
    1218 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4147
    4248/******************************************************************************
    43 test00(): Test the various allocators and deallocators.
     49test00():
    4450XXX: untested:
    4551    TIME:
     
    129135
    130136    printf("----------------------------------------------------------------\n");
     137    printf("Calling pmConfigRead() with acceptable arguments.\n");
    131138
    132139    rc = pmConfigRead(&site, &camera, &recipe, &argc, str, "RecipeName");
  • trunk/psModules/test/detrend/tst_pmNonLinear.c

    r5435 r6205  
    1919 *  and where the data is outside the pmReadout range.
    2020 *
    21  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    22  *  @date $Date: 2005-10-20 23:06:24 $
     21 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     22 *  @date $Date: 2006-01-26 21:10:51 $
    2323 *
    2424 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7171    pmReadout *myReadout = pmReadoutAlloc(NULL);
    7272    myReadout->image = myImage;
    73     psPolynomial1D *myPoly = psPolynomial1DAlloc(2, PS_POLYNOMIAL_ORD);
     73    psPolynomial1D *myPoly = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, 2);
    7474    myPoly->coeff[1] = 1.0;
    7575
     
    169169    pmReadout *rc = NULL;
    170170    myReadout->image = myImage;
    171     psPolynomial1D *myPoly = psPolynomial1DAlloc(2, PS_POLYNOMIAL_ORD);
     171    psPolynomial1D *myPoly = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, 2);
    172172    myPoly->coeff[1] = 1.0;
    173173
  • trunk/psModules/test/imsubtract/tst_pmSubtractBias.c

    r5844 r6205  
    2525 *  XXX: Memory leaks are not being detected.
    2626 *
    27  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    28  *  @date $Date: 2005-12-24 01:24:36 $
     27 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     28 *  @date $Date: 2006-01-26 21:10:51 $
    2929 *
    3030 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    643643
    644644    psStats *stat = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
    645     psPolynomial1D *myPoly = psPolynomial1DAlloc(POLYNOMIAL_FIT_ORDER, PS_POLYNOMIAL_ORD);
     645    psPolynomial1D *myPoly = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, POLYNOMIAL_FIT_ORDER);
    646646    psSpline1D *mySpline = NULL;
    647647
  • trunk/psModules/test/imsubtract/tst_pmSubtractSky.c

    r5516 r6205  
    77 *  @author GLG, MHPCC
    88 *
    9  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-11-15 20:09:03 $
     9 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-01-26 21:10:51 $
    1111 *
    1212 *  XXX: I added the CELL.TRIMSEC region code but there are not tests for it.
     
    5555    myReadout->image = tmpImageF32;
    5656    psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
    57     psPolynomial2D *myPoly = psPolynomial2DAlloc(POLY_X_ORDER, POLY_Y_ORDER, PS_POLYNOMIAL_ORD);
     57    psPolynomial2D *myPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, POLY_X_ORDER, POLY_Y_ORDER);
    5858
    5959    printPositiveTestHeader(stdout, "pmSubtractSky", "doSubtractSkySimple");
     
    9898    myReadout->image = tmpImageF32;
    9999    psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
    100     psPolynomial2D *myPoly = psPolynomial2DAlloc(POLY_X_ORDER, POLY_Y_ORDER, PS_POLYNOMIAL_ORD);
     100    psPolynomial2D *myPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, POLY_X_ORDER, POLY_Y_ORDER);
    101101    psImage *trueImage = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    102102    psF32 errorTolerance = ERROR_TOLERANCE * ((psF32) binFactor);
     
    208208    pmReadout *rc = NULL;
    209209    psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
    210     psPolynomial2D *myPoly = psPolynomial2DAlloc(POLY_X_ORDER, POLY_Y_ORDER, PS_POLYNOMIAL_ORD);
     210    psPolynomial2D *myPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, POLY_X_ORDER, POLY_Y_ORDER);
    211211
    212212    printPositiveTestHeader(stdout, "pmSubtractSky", "Testing bad input parameter conditions.");
Note: See TracChangeset for help on using the changeset viewer.