IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5768


Ignore:
Timestamp:
Dec 12, 2005, 11:52:24 AM (21 years ago)
Author:
desonia
Message:

merged post-release fixes from CVS main.

Location:
branches/rel9/psModules
Files:
4 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • branches/rel9/psModules/Makefile.am

    r5366 r5768  
    66pkgconfig_DATA= psmodule.pc
    77
    8 EXTRA_DIST = Doxyfile.in psmodule-config.in psmodule.pc.in
     8EXTRA_DIST = \
     9        Doxyfile.in \
     10        psmodule-config.in \
     11        psmodule.pc.in \
     12        autogen.sh
    913
    1014if DOXYGEN
  • branches/rel9/psModules/configure.ac

    r5693 r5768  
    11AC_PREREQ(2.59)
    22
    3 AC_INIT([psmodule],[0.9.0],[http://pan-starrs.ifa.hawaii.edu/bugzilla])
     3AC_INIT([psmodule],[0.9.1],[http://pan-starrs.ifa.hawaii.edu/bugzilla])
    44AC_CONFIG_SRCDIR([psmodule.pc.in])
    55
     
    3737AC_SUBST([AM_CFLAGS])
    3838
     39dnl ------------------- PERL options ---------------------
     40  AC_ARG_WITH(perl,
     41    [AS_HELP_STRING(--with-perl=FILE,Specify location of PERL executable.)],
     42    [AC_CHECK_PROG(PERL, $withval, $withval)],
     43    [AC_CHECK_PROG(PERL, perl, `which perl`)])
     44    if test "$PERL" == ""
     45    then
     46      AC_MSG_ERROR([PERL is required.  Use --with-perl to specify its install location.])
     47    fi
     48    AC_SUBST(PERL,$PERL)
     49
    3950SRCPATH='${top_srcdir}/src'
    40 SRCDIRS="astrom camera config detrend imcombine imsubtract objects photom"
    41 SRCINC=`echo "${SRCDIRS=}" | ${SED} "s|\(\\w\+\)|-I\${SRCPATH=}/\1|g"`
    42 SRCSUBLIBS=`echo "${SRCDIRS=}" | ${SED} "s|\(\\w\+\)|\1/libpsmodule\1.la|g"`
    43 AC_SUBST([SRCSUBLIBS],${SRCSUBLIBS=})
     51SRCDIRS="astrom config detrend imcombine imsubtract objects"
     52# escape two escapes at this level so \\ gets passed to the shell and \ to perl
     53SRCINC=`echo "${SRCDIRS=}" | ${PERL} -pe "s|(\w+)|-I\\\\${SRCPATH=}/\1|g"`
     54SRCINC="-I${SRCPATH=} ${SRCINC=}"
     55SRCSUBLIBS=`echo "${SRCDIRS=}" | ${PERL} -pe "s|(\w+)|\1/libpsmodule\1.la|g"`
     56AC_SUBST(SRCSUBLIBS,${SRCSUBLIBS=})
     57AC_SUBST(SRCINC,${SRCINC=})
    4458AC_SUBST([SRCDIRS],${SRCDIRS=})
    45 AC_SUBST([SRCINC],${SRCINC=})
    4659
    4760dnl doxygen -------------------------------------------------------------------
     
    5669
    5770if test -z ${PSLIB_CONFIG} ; then
    58   PKG_CHECK_MODULES([PSLIB], [pslib >= 0.8.0])
     71  PKG_CHECK_MODULES([PSLIB], [pslib >= 0.9.0])
    5972else
    6073  AC_CHECK_FILE($PSLIB_CONFIG,[],
     
    7992  src/Makefile
    8093  src/astrom/Makefile
    81   src/camera/Makefile
    8294  src/config/Makefile
    8395  src/detrend/Makefile
     
    8597  src/imsubtract/Makefile
    8698  src/objects/Makefile
    87   src/photom/Makefile
    8899  test/Makefile
    89100  test/astrom/Makefile
    90   test/camera/Makefile
    91101  test/config/Makefile
    92102  test/detrend/Makefile
     
    94104  test/imsubtract/Makefile
    95105  test/objects/Makefile
    96   test/photom/Makefile
    97106  Doxyfile
    98107  psmodule-config
  • branches/rel9/psModules/src/astrom/pmAstrometry.c

    r5681 r5768  
    1313* XXX: Should we implement non-linear cell->chip transforms?
    1414*
    15 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    16 *  @date $Date: 2005-12-05 21:28:55 $
     15*  @version $Revision: 1.10.2.1 $ $Name: not supported by cvs2svn $
     16*  @date $Date: 2005-12-12 21:52:17 $
    1717*
    1818*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    799799    return(cellCoord);
    800800}
     801
     802/*****************************************************************************
     803 *****************************************************************************/
     804bool pmFPASelectChip(
     805    pmFPA *fpa,
     806    int chipNum)
     807{
     808    PS_ASSERT_PTR_NON_NULL(fpa, false);
     809    if ((fpa->chips == NULL) || (chipNum >= fpa->chips->n)) {
     810        return(false);
     811    }
     812    psBool rc = true;
     813
     814    for (psS32 i = 0 ; i < fpa->chips->n ; i++) {
     815        pmChip *tmpChip = (pmChip *) fpa->chips->data[i];
     816        if (tmpChip == NULL) {
     817            rc = false;
     818        } else {
     819            if (i == chipNum) {
     820                tmpChip->valid = true;
     821            } else {
     822                tmpChip->valid = false;
     823            }
     824        }
     825    }
     826
     827    return(rc);
     828}
     829
     830
     831/*****************************************************************************
     832XXX: The SDRS is ambiguous on a few things:
     833    Whether or not the other chips should be set valid=true.
     834    Should we return the number of chip valid=true before or after they're set,
     835 *****************************************************************************/
     836/**
     837 *
     838 * pmFPAExcludeChip shall set valid to false only for the specified chip
     839 * number (chipNum). In the event that the specified chip number does not exist
     840 * within the fpa, the function shall generate a warning, and perform no action.
     841 * The function shall return the number of chips within the fpa that have valid
     842 * set to true.
     843 * 
     844 */
     845int pmFPAExcludeChip(
     846    pmFPA *fpa,
     847    int chipNum)
     848{
     849    PS_ASSERT_PTR_NON_NULL(fpa, false);
     850
     851    if (fpa->chips == NULL) {
     852        psLogMsg(__func__, PS_LOG_WARN, "WARNING: fpa->chips == NULL\n");
     853        return(0);
     854    }
     855    if ((chipNum >= fpa->chips->n) || (NULL == (pmChip *) fpa->chips->data[chipNum])) {
     856        psLogMsg(__func__, PS_LOG_WARN, "WARNING: the specified chip (%d) does not exist.\n", chipNum);
     857        return(0);
     858    }
     859
     860    psS32 numChips = 0;
     861    for (psS32 i = 0 ; i < fpa->chips->n ; i++) {
     862        pmChip *tmpChip = (pmChip *) fpa->chips->data[i];
     863        if (tmpChip != NULL) {
     864            if (i == chipNum) {
     865                tmpChip->valid = false;
     866            } else {
     867                tmpChip->valid = true;
     868                numChips++;
     869            }
     870        }
     871    }
     872
     873    return(numChips);
     874}
  • branches/rel9/psModules/src/astrom/pmAstrometry.h

    r5681 r5768  
    88*  @author GLG, MHPCC
    99*
    10 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-12-05 21:28:55 $
     10*  @version $Revision: 1.4.2.1 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2005-12-12 21:52:17 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    423423);
    424424
     425/**
     426 *
     427 * pmFPASelectChip shall set valid to true for the specified chip number
     428 * (chipNum), and all other chips shall have valid set to false. In the event
     429 * that the specified chip number does not exist within the fpa, the function
     430 * shall return false.
     431 * 
     432 */
     433bool pmFPASelectChip(
     434    pmFPA *fpa,
     435    int chipNum
     436);
     437
     438/**
     439 *
     440 * pmFPAExcludeChip shall set valid to false only for the specified chip
     441 * number (chipNum). In the event that the specified chip number does not exist
     442 * within the fpa, the function shall generate a warning, and perform no action.
     443 * The function shall return the number of chips within the fpa that have valid
     444 * set to true.
     445 * 
     446 */
     447int pmFPAExcludeChip(
     448    pmFPA *fpa,
     449    int chipNum
     450);
     451
     452
    425453#endif // #ifndef PS_ASTROMETRY_H
     454
  • branches/rel9/psModules/src/config/pmConfig.c

    r5516 r5768  
    33 *  @author PAP, IfA
    44 *
    5  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2005-11-15 20:09:03 $
     5 *  @version $Revision: 1.4.2.1 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2005-12-12 21:52:18 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828    const char *description)            // Description of file
    2929{
    30     int numBadLines = 0;
     30    unsigned int numBadLines = 0;
    3131
    3232    psLogMsg(__func__, PS_LOG_INFO, "Loading %s configuration from file %s\n",
     
    359359        } else if (cameraItem->type == PS_DATA_STRING) {
    360360            psTrace(__func__, 5, "Reading camera configuration for %s...\n", cameraItem->name);
    361             int badLines = 0;  // Number of bad lines in reading camera configuration
     361            unsigned int badLines = 0;  // Number of bad lines in reading camera configuration
    362362            camera = psMetadataConfigParse(NULL, &badLines, cameraItem->data.V, true);
    363363            if (badLines > 0) {
  • branches/rel9/psModules/src/imcombine/pmImageCombine.c

    r5170 r5768  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-09-28 20:43:52 $
     10 *  @version $Revision: 1.1.10.1 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-12-12 21:52:20 $
    1212 *
    1313 *  XXX: pmRejectPixels() has a known bug with the pmImageTransform() call.
     
    3535XXX: Allocate a dummy psStats structure so that we don't destroy away its data.
    3636 *****************************************************************************/
    37 psImage *pmCombineImages(psImage *combine,              ///< Combined image (output)
    38                          psArray **questionablePixels,  ///< Array of rejection masks
    39                          const psArray *images,         ///< Array of input images
    40                          const psArray *errors,         ///< Array of input error images
    41                          const psArray *masks,          ///< Array of input masks
    42                          psU32 maskVal,                 ///< Mask value
    43                          const psPixels *pixels,        ///< Pixels to combine
    44                          psS32 numIter,                 ///< Number of rejection iterations
    45                          psF32 sigmaClip,               ///< Number of standard deviations at which to reject
    46                          const psStats *stats           ///< Statistics to use in the combination
    47                         )
     37psImage *pmCombineImages(
     38    psImage *combine,                   ///< Combined image (output)
     39    psArray **questionablePixels,       ///< Array of rejection masks
     40    const psArray *images,              ///< Array of input images
     41    const psArray *errors,              ///< Array of input error images
     42    const psArray *masks,               ///< Array of input masks
     43    psU32 maskVal,                      ///< Mask value
     44    const psPixels *pixels,             ///< Pixels to combine
     45    psS32 numIter,                      ///< Number of rejection iterations
     46    psF32 sigmaClip,                    ///< Number of standard deviations at which to reject
     47    const psStats *stats)               ///< Statistics to use in the combination
    4848{
    4949
  • branches/rel9/psModules/src/objects/Makefile.am

    r5307 r5768  
    88    pmPSFtry.c \
    99    pmModelGroup.c \
    10     psModulesUtils.c \
    11     psLibUtils.c \
    1210    psEllipse.c
    1311
     
    2422    pmPSFtry.h \
    2523    pmModelGroup.h \
    26     psModulesUtils.h \
    27     psLibUtils.h \
    2824    psEllipse.h
  • branches/rel9/psModules/src/objects/pmObjects.c

    r5435 r5768  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-10-20 23:06:24 $
     8 *  @version $Revision: 1.3.2.1 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-12-12 21:52:22 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6868}
    6969
    70 /******************************************************************************
    71 pmModelAlloc(): Allocate the pmModel structure, along with its parameters,
    72 and initialize the type member.  Initialize the params to 0.0.
    73 XXX EAM: simplifying code with pmModelParameterCount
    74 *****************************************************************************/
    75 pmModel *pmModelAlloc(pmModelType type)
    76 {
    77     psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
    78     pmModel *tmp = (pmModel *) psAlloc(sizeof(pmModel));
    79 
    80     tmp->type = type;
    81     tmp->chisq = 0.0;
    82     tmp->nIter = 0;
    83     psS32 Nparams = pmModelParameterCount(type);
    84     if (Nparams == 0) {
    85         psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType");
    86         return(NULL);
    87     }
    88 
    89     tmp->params  = psVectorAlloc(Nparams, PS_TYPE_F32);
    90     tmp->dparams = psVectorAlloc(Nparams, PS_TYPE_F32);
    91 
    92     for (psS32 i = 0; i < tmp->params->n; i++) {
    93         tmp->params->data.F32[i] = 0.0;
    94         tmp->dparams->data.F32[i] = 0.0;
    95     }
    96 
    97     psMemSetDeallocator(tmp, (psFreeFunc) modelFree);
    98     psTrace(__func__, 3, "---- %s() end ----\n", __func__);
    99     return(tmp);
    100 }
    101 
    102 /******************************************************************************
    103 XXX EAM : we can now free these pixels - memory ref is incremented now
    104 *****************************************************************************/
    10570static void sourceFree(pmSource *tmp)
    10671{
     
    11580    psTrace(__func__, 4, "---- %s() end ----\n", __func__);
    11681}
     82
     83/******************************************************************************
     84getRowVectorFromImage(): a private function which simply returns a
     85psVector containing the specified row of data from the psImage.
     86 
     87XXX: Is there a better way to do this? 
     88XXX EAM: does this really need to alloc a new vector???
     89*****************************************************************************/
     90static psVector *getRowVectorFromImage(psImage *image,
     91                                       psU32 row)
     92{
     93    psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
     94    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
     95    PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL);
     96
     97    psVector *tmpVector = psVectorAlloc(image->numCols, PS_TYPE_F32);
     98    for (psU32 col = 0; col < image->numCols ; col++) {
     99        tmpVector->data.F32[col] = image->data.F32[row][col];
     100    }
     101    psTrace(__func__, 4, "---- %s() end ----\n", __func__);
     102    return(tmpVector);
     103}
     104
     105/******************************************************************************
     106myListAddPeak(): A private function which allocates a psArray, if the list
     107argument is NULL, otherwise it adds the peak to that list.
     108XXX EAM : changed the output to psArray
     109XXX EAM : Switched row, col args
     110XXX EAM : NOTE: this was changed in the call, so the new code is consistent
     111*****************************************************************************/
     112static psArray *myListAddPeak(psArray *list,
     113                              psS32 row,
     114                              psS32 col,
     115                              psF32 counts,
     116                              pmPeakType type)
     117{
     118    psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
     119    pmPeak *tmpPeak = pmPeakAlloc(col, row, counts, type);
     120
     121    if (list == NULL) {
     122        list = psArrayAlloc(100);
     123        list->n = 0;
     124    }
     125    psArrayAdd(list, 100, tmpPeak);
     126    psFree (tmpPeak);
     127    // XXX EAM : is this free appropriate?  (does psArrayAdd increment memory counter?)
     128
     129    psTrace(__func__, 4, "---- %s() end ----\n", __func__);
     130    return(list);
     131}
     132
     133
     134/******************************************************************************
     135bool checkRadius2(): private function which simply determines if the (x, y)
     136point is within the radius of the specified peak.
     137 
     138XXX: macro this for performance.
     139XXX: this is rather inefficient - at least compute and compare against radius^2
     140*****************************************************************************/
     141static bool checkRadius2(psF32 xCenter,
     142                         psF32 yCenter,
     143                         psF32 radius,
     144                         psF32 x,
     145                         psF32 y)
     146{
     147    psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
     148    /// XXX EAM should compare with hypot (x,y) for speed
     149    if ((PS_SQR(x - xCenter) + PS_SQR(y - yCenter)) < PS_SQR(radius)) {
     150        return(true);
     151    }
     152
     153    psTrace(__func__, 4, "---- %s(false) end ----\n", __func__);
     154    return(false);
     155}
     156
     157// XXX: Macro this.
     158static bool isItInThisRegion(const psRegion valid,
     159                             psS32 x,
     160                             psS32 y)
     161{
     162    psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
     163    if ((x >= valid.x0) &&
     164            (x <= valid.x1) &&
     165            (y >= valid.y0) &&
     166            (y <= valid.y1)) {
     167        psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
     168        return(true);
     169    }
     170    psTrace(__func__, 4, "---- %s(false) end ----\n", __func__);
     171    return(false);
     172}
     173
     174/******************************************************************************
     175findValue(source, level, row, col, dir): a private function which determines
     176the column coordinate of the model function which has the value "level".  If
     177dir equals 0, then you loop leftwards from the peak pixel, otherwise,
     178rightwards.
     179 
     180XXX: reverse order of row,col args?
     181 
     182XXX: Input row/col are in image coords.
     183 
     184XXX: The result is returned in image coords.
     185*****************************************************************************/
     186static psF32 findValue(pmSource *source,
     187                       psF32 level,
     188                       psU32 row,
     189                       psU32 col,
     190                       psU32 dir)
     191{
     192    psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
     193    //
     194    // Convert coords to subImage space.
     195    //
     196    psU32 subRow = row - source->pixels->row0;
     197    psU32 subCol = col - source->pixels->col0;
     198
     199    // Ensure that the starting column is allowable.
     200    if (!((0 <= subCol) && (subCol < source->pixels->numCols))) {
     201        psError(PS_ERR_UNKNOWN, true, "Starting column outside subImage range");
     202        psTrace(__func__, 4, "---- %s(NAN) end ----\n", __func__);
     203        return(NAN);
     204    }
     205    if (!((0 <= subRow) && (subRow < source->pixels->numRows))) {
     206        psTrace(__func__, 4, "---- %s(NAN) end ----\n", __func__);
     207        psError(PS_ERR_UNKNOWN, true, "Starting row outside subImage range");
     208        return(NAN);
     209    }
     210
     211    // XXX EAM : i changed this to match pmModelEval above, but see
     212    // XXX EAM   the note below in pmSourceContour
     213    psF32 oldValue = pmModelEval(source->modelFLT, source->pixels, subCol, subRow);
     214    if (oldValue == level) {
     215        psTrace(__func__, 4, "---- %s() end ----\n", __func__);
     216        return(((psF32) (subCol + source->pixels->col0)));
     217    }
     218
     219    //
     220    // We define variables incr and lastColumn so that we can use the same loop
     221    // whether we are stepping leftwards, or rightwards.
     222    //
     223    psS32 incr;
     224    psS32 lastColumn;
     225    if (dir == 0) {
     226        incr = -1;
     227        lastColumn = -1;
     228    } else {
     229        incr = 1;
     230        lastColumn = source->pixels->numCols;
     231    }
     232    subCol+=incr;
     233
     234    while (subCol != lastColumn) {
     235        psF32 newValue = pmModelEval(source->modelFLT, source->pixels, subCol, subRow);
     236        if (oldValue == level) {
     237            psTrace(__func__, 4, "---- %s() end ----\n", __func__);
     238            return((psF32) (subCol + source->pixels->col0));
     239        }
     240
     241        if ((newValue <= level) && (level <= oldValue)) {
     242            // This is simple linear interpolation.
     243            psTrace(__func__, 4, "---- %s() end ----\n", __func__);
     244            return( ((psF32) (subCol + source->pixels->col0)) + ((psF32) incr) * ((level - newValue) / (oldValue - newValue)) );
     245        }
     246
     247        if ((oldValue <= level) && (level <= newValue)) {
     248            // This is simple linear interpolation.
     249            psTrace(__func__, 4, "---- %s() end ----\n", __func__);
     250            return( ((psF32) (subCol + source->pixels->col0)) + ((psF32) incr) * ((level - oldValue) / (newValue - oldValue)) );
     251        }
     252
     253        subCol+=incr;
     254    }
     255
     256    psTrace(__func__, 4, "---- %s(NAN) end ----\n", __func__);
     257    return(NAN);
     258}
     259
     260/******************************************************************************
     261pmModelAlloc(): Allocate the pmModel structure, along with its parameters,
     262and initialize the type member.  Initialize the params to 0.0.
     263XXX EAM: simplifying code with pmModelParameterCount
     264*****************************************************************************/
     265pmModel *pmModelAlloc(pmModelType type)
     266{
     267    psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
     268    pmModel *tmp = (pmModel *) psAlloc(sizeof(pmModel));
     269
     270    tmp->type = type;
     271    tmp->chisq = 0.0;
     272    tmp->nIter = 0;
     273    psS32 Nparams = pmModelParameterCount(type);
     274    if (Nparams == 0) {
     275        psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType");
     276        return(NULL);
     277    }
     278
     279    tmp->params  = psVectorAlloc(Nparams, PS_TYPE_F32);
     280    tmp->dparams = psVectorAlloc(Nparams, PS_TYPE_F32);
     281
     282    for (psS32 i = 0; i < tmp->params->n; i++) {
     283        tmp->params->data.F32[i] = 0.0;
     284        tmp->dparams->data.F32[i] = 0.0;
     285    }
     286
     287    psMemSetDeallocator(tmp, (psFreeFunc) modelFree);
     288    psTrace(__func__, 3, "---- %s() end ----\n", __func__);
     289    return(tmp);
     290}
     291
     292/******************************************************************************
     293XXX EAM : we can now free these pixels - memory ref is incremented now
     294*****************************************************************************/
    117295
    118296/******************************************************************************
     
    240418}
    241419
    242 /******************************************************************************
    243 getRowVectorFromImage(): a private function which simply returns a
    244 psVector containing the specified row of data from the psImage.
    245  
    246 XXX: Is there a better way to do this? 
    247 XXX EAM: does this really need to alloc a new vector???
    248 *****************************************************************************/
    249 static psVector *getRowVectorFromImage(psImage *image,
    250                                        psU32 row)
    251 {
    252     psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
    253     PS_ASSERT_IMAGE_NON_NULL(image, NULL);
    254     PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL);
    255 
    256     psVector *tmpVector = psVectorAlloc(image->numCols, PS_TYPE_F32);
    257     for (psU32 col = 0; col < image->numCols ; col++) {
    258         tmpVector->data.F32[col] = image->data.F32[row][col];
    259     }
    260     psTrace(__func__, 4, "---- %s() end ----\n", __func__);
    261     return(tmpVector);
    262 }
    263 
    264 /******************************************************************************
    265 myListAddPeak(): A private function which allocates a psArray, if the list
    266 argument is NULL, otherwise it adds the peak to that list.
    267 XXX EAM : changed the output to psArray
    268 XXX EAM : Switched row, col args
    269 XXX EAM : NOTE: this was changed in the call, so the new code is consistent
    270 *****************************************************************************/
    271 static psArray *myListAddPeak(psArray *list,
    272                               psS32 row,
    273                               psS32 col,
    274                               psF32 counts,
    275                               pmPeakType type)
    276 {
    277     psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
    278     pmPeak *tmpPeak = pmPeakAlloc(col, row, counts, type);
    279 
    280     if (list == NULL) {
    281         list = psArrayAlloc(100);
    282         list->n = 0;
    283     }
    284     psArrayAdd(list, 100, tmpPeak);
    285     psFree (tmpPeak);
    286     // XXX EAM : is this free appropriate?  (does psArrayAdd increment memory counter?)
    287 
    288     psTrace(__func__, 4, "---- %s() end ----\n", __func__);
    289     return(list);
    290 }
    291420
    292421/******************************************************************************
     
    503632}
    504633
    505 // XXX: Macro this.
    506 static bool isItInThisRegion(const psRegion valid,
    507                              psS32 x,
    508                              psS32 y)
    509 {
    510     psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
    511     if ((x >= valid.x0) &&
    512             (x <= valid.x1) &&
    513             (y >= valid.y0) &&
    514             (y <= valid.y1)) {
    515         psTrace(__func__, 4, "---- %s(true) end ----\n", __func__);
    516         return(true);
    517     }
    518     psTrace(__func__, 4, "---- %s(false) end ----\n", __func__);
    519     return(false);
    520 }
    521 
    522634
    523635/******************************************************************************
     
    627739*****************************************************************************/
    628740
    629 
    630 
    631 
    632 
    633 
    634 
    635 
    636 
    637741bool pmSourceLocalSky(
    638742    pmSource *source,
     
    673777    psTrace(__func__, 3, "---- %s(true) end ----\n", __func__);
    674778    return (true);
    675 }
    676 
    677 /******************************************************************************
    678 bool checkRadius2(): private function which simply determines if the (x, y)
    679 point is within the radius of the specified peak.
    680  
    681 XXX: macro this for performance.
    682 XXX: this is rather inefficient - at least compute and compare against radius^2
    683 *****************************************************************************/
    684 static bool checkRadius2(psF32 xCenter,
    685                          psF32 yCenter,
    686                          psF32 radius,
    687                          psF32 x,
    688                          psF32 y)
    689 {
    690     psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
    691     /// XXX EAM should compare with hypot (x,y) for speed
    692     if ((PS_SQR(x - xCenter) + PS_SQR(y - yCenter)) < PS_SQR(radius)) {
    693         return(true);
    694     }
    695 
    696     psTrace(__func__, 4, "---- %s(false) end ----\n", __func__);
    697     return(false);
    698779}
    699780
     
    11071188        bool big = (sigX > (clump.X - clump.dX)) && (sigY > (clump.Y - clump.dY));
    11081189        if ((Nsatpix > 1) && big) {
    1109             tmpSrc->type |= PM_SOURCE_SATSTAR;
     1190            tmpSrc->type = PM_SOURCE_SATSTAR;
    11101191            Nsatstar ++;
    11111192            continue;
     
    11141195        // saturated object (not a star, eg bleed trails, hot pixels)
    11151196        if (Nsatpix > 1) {
    1116             tmpSrc->type |= PM_SOURCE_SATURATED;
     1197            tmpSrc->type = PM_SOURCE_SATURATED;
    11171198            Nsat ++;
    11181199            continue;
     
    11231204        // only set candidate defects if
    11241205        if ((sigX < 0.05) || (sigY < 0.05)) {
    1125             tmpSrc->type |= PM_SOURCE_DEFECT;
     1206            tmpSrc->type = PM_SOURCE_DEFECT;
    11261207            Ncr ++;
    11271208            continue;
     
    11301211        // likely unsaturated galaxy (too large to be stellar)
    11311212        if ((sigX > (clump.X + 3*clump.dX)) || (sigY > (clump.Y + 3*clump.dY))) {
    1132             tmpSrc->type |= PM_SOURCE_GALAXY;
     1213            tmpSrc->type = PM_SOURCE_GALAXY;
    11331214            Ngal ++;
    11341215            continue;
     
    11431224        psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY);
    11441225        if ((SN > PSF_SN_LIM) && (radius < 1.5)) {
    1145             tmpSrc->type |= PM_SOURCE_PSFSTAR;
     1226            tmpSrc->type = PM_SOURCE_PSFSTAR;
    11461227            Npsf ++;
    11471228            continue;
     
    11491230
    11501231        // random type of star
    1151         tmpSrc->type |= PM_SOURCE_OTHER;
     1232        tmpSrc->type = PM_SOURCE_OTHER;
    11521233    }
    11531234
     
    13501431
    13511432/******************************************************************************
    1352 findValue(source, level, row, col, dir): a private function which determines
    1353 the column coordinate of the model function which has the value "level".  If
    1354 dir equals 0, then you loop leftwards from the peak pixel, otherwise,
    1355 rightwards.
    1356  
    1357 XXX: reverse order of row,col args?
    1358  
    1359 XXX: Input row/col are in image coords.
    1360  
    1361 XXX: The result is returned in image coords.
    1362 *****************************************************************************/
    1363 static psF32 findValue(pmSource *source,
    1364                        psF32 level,
    1365                        psU32 row,
    1366                        psU32 col,
    1367                        psU32 dir)
    1368 {
    1369     psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
    1370     //
    1371     // Convert coords to subImage space.
    1372     //
    1373     psU32 subRow = row - source->pixels->row0;
    1374     psU32 subCol = col - source->pixels->col0;
    1375 
    1376     // Ensure that the starting column is allowable.
    1377     if (!((0 <= subCol) && (subCol < source->pixels->numCols))) {
    1378         psError(PS_ERR_UNKNOWN, true, "Starting column outside subImage range");
    1379         psTrace(__func__, 4, "---- %s(NAN) end ----\n", __func__);
    1380         return(NAN);
    1381     }
    1382     if (!((0 <= subRow) && (subRow < source->pixels->numRows))) {
    1383         psTrace(__func__, 4, "---- %s(NAN) end ----\n", __func__);
    1384         psError(PS_ERR_UNKNOWN, true, "Starting row outside subImage range");
    1385         return(NAN);
    1386     }
    1387 
    1388     // XXX EAM : i changed this to match pmModelEval above, but see
    1389     // XXX EAM   the note below in pmSourceContour
    1390     psF32 oldValue = pmModelEval(source->modelFLT, source->pixels, subCol, subRow);
    1391     if (oldValue == level) {
    1392         psTrace(__func__, 4, "---- %s() end ----\n", __func__);
    1393         return(((psF32) (subCol + source->pixels->col0)));
    1394     }
    1395 
    1396     //
    1397     // We define variables incr and lastColumn so that we can use the same loop
    1398     // whether we are stepping leftwards, or rightwards.
    1399     //
    1400     psS32 incr;
    1401     psS32 lastColumn;
    1402     if (dir == 0) {
    1403         incr = -1;
    1404         lastColumn = -1;
    1405     } else {
    1406         incr = 1;
    1407         lastColumn = source->pixels->numCols;
    1408     }
    1409     subCol+=incr;
    1410 
    1411     while (subCol != lastColumn) {
    1412         psF32 newValue = pmModelEval(source->modelFLT, source->pixels, subCol, subRow);
    1413         if (oldValue == level) {
    1414             psTrace(__func__, 4, "---- %s() end ----\n", __func__);
    1415             return((psF32) (subCol + source->pixels->col0));
    1416         }
    1417 
    1418         if ((newValue <= level) && (level <= oldValue)) {
    1419             // This is simple linear interpolation.
    1420             psTrace(__func__, 4, "---- %s() end ----\n", __func__);
    1421             return( ((psF32) (subCol + source->pixels->col0)) + ((psF32) incr) * ((level - newValue) / (oldValue - newValue)) );
    1422         }
    1423 
    1424         if ((oldValue <= level) && (level <= newValue)) {
    1425             // This is simple linear interpolation.
    1426             psTrace(__func__, 4, "---- %s() end ----\n", __func__);
    1427             return( ((psF32) (subCol + source->pixels->col0)) + ((psF32) incr) * ((level - oldValue) / (newValue - oldValue)) );
    1428         }
    1429 
    1430         subCol+=incr;
    1431     }
    1432 
    1433     psTrace(__func__, 4, "---- %s(NAN) end ----\n", __func__);
    1434     return(NAN);
    1435 }
    1436 
    1437 /******************************************************************************
    14381433pmSourceContour(src, img, level, mode): For an input subImage, and model, this
    14391434routine returns a psArray of coordinates that evaluate to the specified level.
     
    19331928}
    19341929
    1935 
     1930bool pmSourcePhotometry (float *fitMag, float *obsMag, pmModel *model, psImage *image, psImage *mask)
     1931{
     1932
     1933    float obsSum = 0;
     1934    float fitSum = 0;
     1935    float sky = model->params->data.F32[0];
     1936
     1937    pmModelFlux modelFluxFunc = pmModelFlux_GetFunction (model->type);
     1938    fitSum = modelFluxFunc (model->params);
     1939
     1940    for (int ix = 0; ix < image->numCols; ix++) {
     1941        for (int iy = 0; iy < image->numRows; iy++) {
     1942            if (mask->data.U8[iy][ix])
     1943                continue;
     1944            obsSum += image->data.F32[iy][ix] - sky;
     1945        }
     1946    }
     1947    if (obsSum <= 0)
     1948        return false;
     1949    if (fitSum <= 0)
     1950        return false;
     1951
     1952    *fitMag = -2.5*log10(fitSum);
     1953    *obsMag = -2.5*log10(obsSum);
     1954    return (true);
     1955}
     1956
  • branches/rel9/psModules/src/objects/pmObjects.h

    r5255 r5768  
    1010 *  @author GLG, MHPCC
    1111 *
    12  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-10-10 19:53:40 $
     12 *  @version $Revision: 1.2.8.1 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-12-12 21:52:22 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3636 * values with specific meanings that other functions can add to or define?
    3737 */
    38 enum {
     38typedef enum {
    3939    PSPHOT_MASK_CLEAR     = 0x00,
    4040    PSPHOT_MASK_INVALID   = 0x01,
     
    620620);
    621621
     622
     623/** pmSourcePhotometry()
     624 *
     625 * XXX: Need descriptions
     626 *
     627 */
     628bool pmSourcePhotometry(
     629    float *fitMag,
     630    float *obsMag,
     631    pmModel *model,
     632    psImage *image,
     633    psImage *mask
     634);
     635
     636/** pmModelEval()
     637 *
     638 *  XXX: Need descriptions
     639 *
     640 */
     641psF32 pmModelEval(
     642    pmModel *model,
     643    psImage *image,
     644    psS32 col,
     645    psS32 row
     646);
     647
    622648#endif
  • branches/rel9/psModules/src/objects/pmPSF.c

    r5255 r5768  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-10-10 19:53:40 $
     8 *  @version $Revision: 1.1.8.1 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-12-12 21:52:22 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1818
    1919#include <pslib.h>
    20 #include "psLibUtils.h"
    2120#include "pmObjects.h"
    2221#include "pmPSF.h"
     
    9493    for (int i = 0; i < psf->params->n; i++) {
    9594        // XXX EAM : make this a user-defined value?
    96         // XXX EAM : future version (0.7.0?) psf->params->data[i] = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, 1);
    97         psf->params->data[i] = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, 1);
     95        psf->params->data[i] = psPolynomial2DAlloc(1, 1, PS_POLYNOMIAL_ORD);
    9896    }
    9997
  • branches/rel9/psModules/src/objects/pmPSFtry.c

    r5255 r5768  
     1/** @file  pmPSFtry.c
     2 *
     3 *  XXX: need description of file purpose
     4 *
     5 *  @author EAM, IfA
     6 *
     7 *  @version $Revision: 1.1.8.1 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-12-12 21:52:22 $
     9 *
     10 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     11 *
     12 */
     13
    114# include <pslib.h>
    2 # include "psLibUtils.h"
    315# include "pmObjects.h"
    4 # include "psModulesUtils.h"
    516# include "pmPSF.h"
    617# include "pmPSFtry.h"
     
    4152    type           = pmModelSetType (modelName);
    4253    test->psf      = pmPSFAlloc (type);
    43     test->sources  = psMemCopy(sources);
     54    test->sources  = psMemIncrRefCounter(sources);
    4455    test->modelFLT = psArrayAlloc (sources->n);
    4556    test->modelPSF = psArrayAlloc (sources->n);
     
    7990    int Npsf = 0;
    8091
    81     pmPSFtry *try
    82     = pmPSFtryAlloc (sources, modelName);
     92    pmPSFtry *psfTry = pmPSFtryAlloc (sources, modelName);
    8393
    8494    // stage 1:  fit an independent model (freeModel) to all sources
    8595    psTimerStart ("fit");
    86     for (int i = 0; i < try
    87                 ->sources->n; i++) {
    88 
    89             pmSource *source = try
    90                                    ->sources->data[i];
    91             pmModel  *model  = pmSourceModelGuess (source, try
    92                                                        ->psf->type);
    93             x = source->peak->x;
    94             y = source->peak->y;
    95 
    96             // set temporary object mask and fit object
    97             // fit model as FLT, not PSF
    98             psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);
    99             status = pmSourceFitModel (source, model, false);
    100             psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);
    101 
    102             // exclude the poor fits
    103             if (!status) {
    104                 try
    105                     ->mask->data.U8[i] = PSFTRY_MASK_FLT_FAIL;
    106                 psFree (model);
    107                 continue;
    108             }
    109             try
    110                 ->modelFLT->data[i] = model;
    111             Nflt ++;
    112         }
     96    for (int i = 0; i < psfTry->sources->n; i++) {
     97
     98        pmSource *source = psfTry->sources->data[i];
     99        pmModel  *model  = pmSourceModelGuess (source, psfTry->psf->type);
     100        x = source->peak->x;
     101        y = source->peak->y;
     102
     103        // set temporary object mask and fit object
     104        // fit model as FLT, not PSF
     105        psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);
     106        status = pmSourceFitModel (source, model, false);
     107        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);
     108
     109        // exclude the poor fits
     110        if (!status) {
     111            psfTry->mask->data.U8[i] = PSFTRY_MASK_FLT_FAIL;
     112            psFree (model);
     113            continue;
     114        }
     115        psfTry->modelFLT->data[i] = model;
     116        Nflt ++;
     117    }
    113118    psLogMsg ("psphot.psftry", 4, "fit flt:   %f sec for %d sources\n", psTimerMark ("fit"), sources->n);
    114119    psTrace ("psphot.psftry", 3, "keeping %d of %d PSF candidates (FLT)\n", Nflt, sources->n);
    115120
    116121    // make this optional?
    117     // DumpModelFits (try->modelFLT, "modelsFLT.dat");
     122    // DumpModelFits (psfTry->modelFLT, "modelsFLT.dat");
    118123
    119124    // stage 2: construct a psf (pmPSF) from this collection of model fits
    120     pmPSFFromModels (try
    121                      ->psf, try
    122                          ->modelFLT, try
    123                              ->mask);
     125    pmPSFFromModels (psfTry->psf, psfTry->modelFLT, psfTry->mask);
    124126
    125127    // stage 3: refit with fixed shape parameters
    126128    psTimerStart ("fit");
    127     for (int i = 0; i < try
    128                 ->sources->n; i++) {
    129             // masked for: bad model fit, outlier in parameters
    130             if (try
    131                     ->mask->data.U8[i] & PSFTRY_MASK_ALL) continue;
    132 
    133             pmSource *source = try
    134                                    ->sources->data[i];
    135             pmModel  *modelFLT = try
    136                                      ->modelFLT->data[i];
    137 
    138             // set shape for this model based on PSF
    139             pmModel *modelPSF = pmModelFromPSF (modelFLT, try
    140                                                     ->psf);
    141             x = source->peak->x;
    142             y = source->peak->y;
    143 
    144             psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);
    145             status = pmSourceFitModel (source, modelPSF, true);
    146 
    147             // skip poor fits
    148             if (!status) {
    149                 try
    150                     ->mask->data.U8[i] = PSFTRY_MASK_PSF_FAIL;
    151                 psFree (modelPSF);
    152                 goto next_source;
    153             }
    154 
    155             // otherwise, save the resulting model
    156             try
    157                 ->modelPSF->data[i] = modelPSF;
    158 
    159             // XXX : use a different aperture radius from the fit radius?
    160             // XXX : use a different estimator for the local sky?
    161             // XXX : pass 'source' as input?
    162             if (!pmSourcePhotometry (&fitMag, &obsMag, modelPSF, source->pixels, source->mask)) {
    163                 try
    164                     ->mask->data.U8[i] = PSFTRY_MASK_BAD_PHOT;
    165                 goto next_source;
    166             }
    167 
    168             try
    169                 ->metric->data.F64[i] = obsMag - fitMag;
    170             try
    171                 ->fitMag->data.F64[i] = fitMag;
    172             Npsf ++;
     129    for (int i = 0; i < psfTry->sources->n; i++) {
     130        // masked for: bad model fit, outlier in parameters
     131        if (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL)
     132            continue;
     133
     134        pmSource *source = psfTry->sources->data[i];
     135        pmModel  *modelFLT = psfTry->modelFLT->data[i];
     136
     137        // set shape for this model based on PSF
     138        pmModel *modelPSF = pmModelFromPSF (modelFLT, psfTry->psf);
     139        x = source->peak->x;
     140        y = source->peak->y;
     141
     142        psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);
     143        status = pmSourceFitModel (source, modelPSF, true);
     144
     145        // skip poor fits
     146        if (!status) {
     147            psfTry->mask->data.U8[i] = PSFTRY_MASK_PSF_FAIL;
     148            psFree (modelPSF);
     149            goto next_source;
     150        }
     151
     152        // otherwise, save the resulting model
     153        psfTry->modelPSF->data[i] = modelPSF;
     154
     155        // XXX : use a different aperture radius from the fit radius?
     156        // XXX : use a different estimator for the local sky?
     157        // XXX : pass 'source' as input?
     158        if (!pmSourcePhotometry (&fitMag, &obsMag, modelPSF, source->pixels, source->mask)) {
     159            psfTry->mask->data.U8[i] = PSFTRY_MASK_BAD_PHOT;
     160            goto next_source;
     161        }
     162
     163        psfTry->metric->data.F64[i] = obsMag - fitMag;
     164        psfTry->fitMag->data.F64[i] = fitMag;
     165        Npsf ++;
    173166
    174167next_source:
    175             psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);
    176 
    177         }
     168        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);
     169
     170    }
    178171    psLogMsg ("psphot.psftry", 4, "fit psf:   %f sec for %d sources\n", psTimerMark ("fit"), sources->n);
    179172    psTrace ("psphot.psftry", 3, "keeping %d of %d PSF candidates (PSF)\n", Npsf, sources->n);
    180173
    181174    // make this optional
    182     // DumpModelFits (try->modelPSF, "modelsPSF.dat");
     175    // DumpModelFits (psfTry->modelPSF, "modelsPSF.dat");
    183176
    184177    // XXX this function wants aperture radius for pmSourcePhotometry
    185     pmPSFtryMetric (try
    186                     , RADIUS);
     178    pmPSFtryMetric (psfTry, RADIUS);
    187179    psLogMsg ("psphot.pspsf", 3, "try model %s, ap-fit: %f +/- %f, sky bias: %f\n",
    188               modelName, try
    189                   ->psf->ApResid, try
    190                       ->psf->dApResid, try
    191                           ->psf->skyBias);
    192 
    193     return (try
    194            );
     180              modelName,
     181              psfTry->psf->ApResid,
     182              psfTry->psf->dApResid,
     183              psfTry->psf->skyBias);
     184
     185    return (psfTry);
    195186}
    196187
    197188
    198 bool pmPSFtryMetric (pmPSFtry *try
    199                      , float RADIUS)
     189bool pmPSFtryMetric (pmPSFtry *psfTry, float RADIUS)
    200190{
    201191
     
    203193    int   nKeep, nSkip;
    204194
    205     // the measured (aperture - fit) magnitudes (dA == try->metric)
     195    // the measured (aperture - fit) magnitudes (dA == psfTry->metric)
    206196    //   depend on both the true ap-fit (dAo) and the bias in the sky measurement:
    207197    //     dA = dAo + dsky/flux
     
    213203
    214204    // rflux = ten(0.4*fitMag);
    215     psVector *rflux = psVectorAlloc (try
    216                                      ->sources->n, PS_TYPE_F64);
    217     for (int i = 0; i < try
    218                 ->sources->n; i++) {
    219             if (try
    220                     ->mask->data.U8[i] & PSFTRY_MASK_ALL) continue;
    221             rflux->data.F64[i] = pow(10.0, 0.4*try
    222                                      ->fitMag->data.F64[i]);
    223         }
     205    psVector *rflux = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
     206    for (int i = 0; i < psfTry->sources->n; i++) {
     207        if (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL)
     208            continue;
     209        rflux->data.F64[i] = pow(10.0, 0.4*psfTry->fitMag->data.F64[i]);
     210    }
    224211
    225212    // find min and max of (1/flux):
    226213    psStats *stats = psStatsAlloc (PS_STAT_MIN | PS_STAT_MAX);
    227     psVectorStats (stats, rflux, NULL, try
    228                        ->mask, PSFTRY_MASK_ALL);
     214    psVectorStats (stats, rflux, NULL, psfTry->mask, PSFTRY_MASK_ALL);
    229215
    230216    // build binned versions of rflux, metric
     
    240226    for (int i = 0; i < daBin->n; i++) {
    241227
    242         psVector *tmp = psVectorAlloc (try
    243                                        ->sources->n, PS_TYPE_F64);
     228        psVector *tmp = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
    244229        tmp->n = 0;
    245230
    246231        // accumulate data within bin range
    247         for (int j = 0; j < try
    248                     ->sources->n; j++) {
    249                 // masked for: bad model fit, outlier in parameters
    250                 if (try
    251                         ->mask->data.U8[j] & PSFTRY_MASK_ALL) continue;
    252 
    253                 // skip points with extreme dA values
    254                 if (fabs(try
    255                          ->metric->data.F64[j]) > 0.5) continue;
    256 
    257                 // skip points outside of this bin
    258                 if (rflux->data.F64[j] < rfBin->data.F64[i] - 0.5*dBin)
    259                     continue;
    260                 if (rflux->data.F64[j] > rfBin->data.F64[i] + 0.5*dBin)
    261                     continue;
    262 
    263                 tmp->data.F64[tmp->n] = try
    264                                             ->metric->data.F64[j];
    265                 tmp->n ++;
    266             }
     232        for (int j = 0; j < psfTry->sources->n; j++) {
     233            // masked for: bad model fit, outlier in parameters
     234            if (psfTry->mask->data.U8[j] & PSFTRY_MASK_ALL)
     235                continue;
     236
     237            // skip points with extreme dA values
     238            if (fabs(psfTry->metric->data.F64[j]) > 0.5)
     239                continue;
     240
     241            // skip points outside of this bin
     242            if (rflux->data.F64[j] < rfBin->data.F64[i] - 0.5*dBin)
     243                continue;
     244            if (rflux->data.F64[j] > rfBin->data.F64[i] + 0.5*dBin)
     245                continue;
     246
     247            tmp->data.F64[tmp->n] = psfTry->metric->data.F64[j];
     248            tmp->n ++;
     249        }
    267250
    268251        // is this a valid point?
     
    319302    stats = psVectorStats (stats, daResid, NULL, maskB, 1);
    320303
    321     try
    322         ->psf->ApResid = poly->coeff[0];
    323     try
    324         ->psf->dApResid = stats->clippedStdev;
    325     try
    326         ->psf->skyBias = poly->coeff[1] / (M_PI * PS_SQR(RADIUS));
     304    psfTry->psf->ApResid = poly->coeff[0];
     305    psfTry->psf->dApResid = stats->clippedStdev;
     306    psfTry->psf->skyBias = poly->coeff[1] / (M_PI * PS_SQR(RADIUS));
    327307
    328308    psFree (rflux);
  • branches/rel9/psModules/src/objects/pmPSFtry.h

    r5255 r5768  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-10-10 19:53:40 $
     8 *  @version $Revision: 1.1.8.1 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-12-12 21:52:22 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    105105 */
    106106bool pmPSFtryMetric(
    107     pmPSFtry *try
    108     ,                      ///< Add comment.
    109     float RADIUS                        ///< Add comment.
     107    pmPSFtry *psfTry,                  ///< Add comment.
     108    float RADIUS                       ///< Add comment.
    110109);
    111110
  • branches/rel9/psModules/test/astrom/tst_pmAstrometry01.c

    r5681 r5768  
    11/** @file  tst_psAstrometry01.c
    2 *
    3 *  @brief This code will test the pmFPA hierarchy transform code in psAstrometry.[ch]
    4 *
    5 *  @author GLG, MHPCC
    6 *
    7 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    8 *  @date $Date: 2005-12-05 21:28:55 $
    9 *
    10 * XXX: Add tests were the coordinate does not transform to any legitimate cell
    11 * or chip, or FPA, or whatever.
    12 *
    13 * XXX: For each function, add tests for bad input parameters, as well as failed transforms.
    14 *
    15 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    16 */
     2 *
     3 *  @brief This code will test the pmFPA hierarchy transform code in psAstrometry.[ch]
     4 *
     5 *  @author GLG, MHPCC
     6 *
     7 *  @version $Revision: 1.2.2.1 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-12-12 21:52:24 $
     9 *
     10 * XXX: Add tests were the coordinate does not transform to any legitimate cell
     11 * or chip, or FPA, or whatever.
     12 *
     13 * XXX: For each function, add tests for bad input parameters, as well as failed transforms.
     14 *
     15 * XXX: Must test pmFPASelectChip() and pmFPAExcludeChip().
     16 *
     17 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     18 */
     19
    1720#include "config.h"
    1821#include <math.h>
     
    2326static psS32 test3( void );
    2427static psS32 test4( void );
     28static psS32 test5( void );
    2529
    2630testDescription tests[] = {
    2731                              {test3, -3, "pmAstrometry focal plane transformations", 0, false},
    2832                              {test4, -3, "pmCheckParents()", 0, false},
     33                              {test5, -3, "pmFPASelectChip() and pmFPAExcludeChip()", 0, false},
    2934                              {NULL}
    3035                          };
     
    584589    return(testStatus);
    585590}
     591
     592/******************************************************************************
     593test5(): This routine wil test the pmFPASelectChip() and pmFPAExcludeChip()
     594functions.  We generate an pmFPA hierarchy, then set the ->valid members with
     595those routines, then verify.
     596 *****************************************************************************/
     597psS32 test5( void )
     598{
     599    psS32 testStatus = 0;
     600    pmChip *tmpChip = NULL;
     601
     602    //
     603    // Generate a pmFPA hierarchy.
     604    //
     605    pmFPA *tmpFPA = genSystem();
     606
     607    //
     608    // We test the ->valid member for each chip.
     609    //
     610    for (psS32 i = 0 ; i < tmpFPA->chips->n ; i++) {
     611        tmpChip = (pmChip *) tmpFPA->chips->data[i];
     612        if ((tmpChip == NULL) || (tmpChip->valid != false)) {
     613            printf("TEST ERROR: Could not properly generate an FPA hierarchy.\n");
     614            testStatus = 1;
     615        }
     616    }
     617
     618    //
     619    // Exclude chip number 0, include all others, then test return value
     620    //
     621    psS32 numChips = pmFPAExcludeChip(tmpFPA, 0);
     622    if (numChips != (NUM_CHIPS-1)) {
     623        printf("TEST ERROR: pmFPAExcludeChip() did not return the correct number of chips.\n");
     624        testStatus = 2;
     625    }
     626
     627    //
     628    // We test the ->valid member for each chip.
     629    //
     630    tmpChip = (pmChip *) tmpFPA->chips->data[0];
     631    if (tmpChip->valid != false) {
     632        printf("TEST ERROR: pmFPAExcludeChip() did not set the proper chip->valid to FALSE.\n");
     633        testStatus = 3;
     634    }
     635    for (psS32 i = 1 ; i < tmpFPA->chips->n ; i++) {
     636        pmChip *tmpChip = (pmChip *) tmpFPA->chips->data[i];
     637        if (tmpChip->valid != true) {
     638            printf("TEST ERROR: pmFPAExcludeChip() did not set the proper chip->valids to FALSE.\n");
     639            testStatus = 4;
     640        }
     641    }
     642
     643
     644    //
     645    // Include chip number 0, exclude all others, then test return value
     646    //
     647    psBool tmpBool = pmFPASelectChip(tmpFPA, 0);
     648    if (tmpBool != true) {
     649        printf("TEST ERROR: pmFPASelectChip() returned FALSE.\n");
     650        testStatus = 5;
     651    }
     652
     653    //
     654    // We test the ->valid member for each chip.
     655    //
     656    tmpChip = (pmChip *) tmpFPA->chips->data[0];
     657    if (tmpChip->valid != true) {
     658        printf("TEST ERROR: pmFPASelectChip() did not set the proper chip->valid to FALSE.\n");
     659        testStatus = 6;
     660    }
     661    for (psS32 i = 1 ; i < tmpFPA->chips->n ; i++) {
     662        pmChip *tmpChip = (pmChip *) tmpFPA->chips->data[i];
     663        if (tmpChip->valid != false) {
     664            printf("TEST ERROR: pmFPASelectChip() did not set the proper chip->valids to FALSE.\n");
     665            testStatus = 7;
     666        }
     667    }
     668
     669    psFree(tmpFPA);
     670    return(testStatus);
     671}
Note: See TracChangeset for help on using the changeset viewer.