IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15562


Ignore:
Timestamp:
Nov 9, 2007, 3:09:20 PM (19 years ago)
Author:
eugene
Message:

updating all changes from from eam_branch_20071023

Location:
trunk
Files:
4 added
1 deleted
69 edited

Legend:

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

    r12519 r15562  
    88        pmAstrometryDistortion.c \
    99        pmAstrometryUtils.c \
     10        pmAstrometryTable.c \
    1011        pmAstrometryWCS.c
    1112
     
    1516        pmAstrometryDistortion.h \
    1617        pmAstrometryUtils.h \
     18        pmAstrometryTable.h \
    1719        pmAstrometryWCS.h
    1820
  • trunk/psModules/src/astrom/pmAstrometryTable.c

    r15357 r15562  
    11/** @file  pmAstrometryObjects.c
    2 *
    3 *  @brief This file defines the basic types for matching objects
    4 *  based on their astrometry.
    5 *
    6 *  @ingroup AstroImage
    7 *
    8 *  @author EAM, IfA
    9 *
    10 *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2007-10-23 20:52:42 $
    12 *
    13 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    14 */
     2 *
     3 *  @brief This file defines the basic types for matching objects
     4 *  based on their astrometry.
     5 *
     6 *  @ingroup AstroImage
     7 *
     8 *  @author EAM, IfA
     9 *
     10 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2007-11-10 01:09:20 $
     12 *
     13 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     14 */
    1515
    1616#ifdef HAVE_CONFIG_H
     
    2929#include <pslib.h>
    3030
     31#include "pmConfig.h"
     32#include "pmDetrendDB.h"
    3133#include "pmHDU.h"
    3234#include "pmFPA.h"
    33 #include "pmAstrometryObjects.h"
     35#include "pmFPALevel.h"
     36#include "pmFPAview.h"
     37#include "pmFPAfile.h"
     38#include "pmAstrometryTable.h"
     39
    3440
    3541/********************* CheckDataStatus functions *****************************/
     
    179185bool pmAstromWriteChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    180186{
    181     // define the EXTNAME values used for the table data, and residual image segments
    182     {
    183         // lookup the EXTNAME values used for table data and image header segments
    184         char *rule = NULL;
    185 
    186         // Menu of EXTNAME rules
    187         psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
    188         if (!menu) {
    189             psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
    190             return false;
    191         }
    192 
    193         // EXTNAME for image header
    194         rule = psMetadataLookupStr(&status, menu, "ASTROMETRY");
    195         if (!rule) {
    196             psError(PS_ERR_UNKNOWN, false, "missing entry for ASTROMETRY in EXTNAME.RULES in camera.config");
    197             return false;
    198         }
    199         extname = pmFPAfileNameFromRule (rule, file, view);
    200     }
     187    bool status;
     188    // *** define the EXTNAME values used for the table data, and residual image segments ***
     189
     190    // lookup the EXTNAME values used for table data and image header segments
     191    char *rule = NULL;
     192
     193    // Menu of EXTNAME rules
     194    psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
     195    if (!menu) {
     196        psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
     197        return false;
     198    }
     199
     200    // EXTNAME for image header
     201    rule = psMetadataLookupStr(&status, menu, "ASTROMETRY");
     202    if (!rule) {
     203        psError(PS_ERR_UNKNOWN, false, "missing entry for ASTROMETRY in EXTNAME.RULES in camera.config");
     204        return false;
     205    }
     206
     207    // XXX need to finish this: uncomment when used
     208    # if (0)
     209    char *extname = pmFPAfileNameFromRule (rule, file, view);
     210    # endif
    201211
    202212    // write the chip elements in the following form:
     
    244254bool pmAstromReadChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    245255{
    246     // define the EXTNAME values used for the table data, and residual image segments
    247     {
    248         // lookup the EXTNAME values used for table data and image header segments
    249         char *rule = NULL;
    250 
    251         // Menu of EXTNAME rules
    252         psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
    253         if (!menu) {
    254             psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
    255             return false;
    256         }
    257 
    258         // EXTNAME for image header
    259         rule = psMetadataLookupStr(&status, menu, "ASTROMETRY");
    260         if (!rule) {
    261             psError(PS_ERR_UNKNOWN, false, "missing entry for ASTROMETRY in EXTNAME.RULES in camera.config");
    262             return false;
    263         }
    264         extname = pmFPAfileNameFromRule (rule, file, view);
    265     }
     256    bool status;
     257
     258    // lookup the EXTNAME values used for table data and image header segments
     259    char *rule = NULL;
     260
     261    // Menu of EXTNAME rules
     262    psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
     263    if (!menu) {
     264        psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
     265        return false;
     266    }
     267
     268    // EXTNAME for image header
     269    rule = psMetadataLookupStr(&status, menu, "ASTROMETRY");
     270    if (!rule) {
     271        psError(PS_ERR_UNKNOWN, false, "missing entry for ASTROMETRY in EXTNAME.RULES in camera.config");
     272        return false;
     273    }
     274
     275    // XXX finish this: uncomment when used
     276    # if (0)
     277    char *extname = pmFPAfileNameFromRule (rule, file, view);
     278    # endif
    266279
    267280    // read the chip elements in the following form:
  • trunk/psModules/src/camera/pmFPAfile.h

    r15180 r15562  
    44 * @author EAM, IfA
    55 *
    6  * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-10-03 21:32:43 $
     6 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-11-10 01:09:20 $
    88 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
    99 */
     
    3535    PM_FPA_FILE_FRINGE,
    3636    PM_FPA_FILE_HEADER,
     37    PM_FPA_FILE_ASTROM,
    3738} pmFPAfileType;
    3839
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r15217 r15562  
    438438                return NULL;
    439439            }
     440            // EXTWORD (fits->extword) is not relevant to the PHU
    440441            fits = psFitsOpen (realName, "r");
    441442            if (!fits) {
     
    556557            return NULL;
    557558        }
     559        // EXTWORD (fits->extword) is not relevant to the PHU
    558560        fits = psFitsOpen (realName, "r");
    559561        if (!fits) {
     
    665667    // associated each filename with an element of the FPA
    666668    // save the association on file->names
     669    // EXTWORD (fits->extword) is not relevant to the PHU
    667670    fits = psFitsOpen (infiles->data[entry], "r");
    668671    phu = psFitsReadHeader (NULL, fits);
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r15333 r15562  
    3434#include "pmResiduals.h"
    3535#include "pmPSF_IO.h"
     36#include "pmAstrometryTable.h"
    3637#include "pmFPA_JPEG.h"
    3738#include "pmSourcePlots.h"
     
    192193        status = pmPSFmodelReadForView (view, file, config);
    193194        break;
     195      case PM_FPA_FILE_ASTROM:
     196        status = pmAstromReadForView (view, file, config);
     197        break;
    194198      case PM_FPA_FILE_JPEG:
    195199      case PM_FPA_FILE_KAPA:
     
    273277    case PM_FPA_FILE_CMF:
    274278    case PM_FPA_FILE_PSF:
     279    case PM_FPA_FILE_ASTROM:
    275280    case PM_FPA_FILE_JPEG:
    276281    case PM_FPA_FILE_KAPA:
     
    336341    // have their data stored on the readout->analysis metadata structure of another
    337342    // (existing) fpa
     343    if (file->type == PM_FPA_FILE_CMF) {
     344      if (!pmFPAviewCheckDataStatusForSources (view, file)) {
     345        psTrace("psModules.camera", 6, "skip write for %s, no data for this entry", file->name);
     346        return true;
     347      }
     348    }
    338349    if (file->type == PM_FPA_FILE_PSF) {
    339350      if (!pmPSFmodelCheckDataStatusForView (view, file)) {
     
    342353      }
    343354    }
    344     if (file->type == PM_FPA_FILE_CMF) {
    345       if (!pmFPAviewCheckDataStatusForSources (view, file)) {
     355    if (file->type == PM_FPA_FILE_ASTROM) {
     356      if (!pmAstromCheckDataStatusForView (view, file)) {
    346357        psTrace("psModules.camera", 6, "skip write for %s, no data for this entry", file->name);
    347358        return true;
     
    449460      case PM_FPA_FILE_PSF:
    450461        status = pmPSFmodelWriteForView (view, file, config);
     462        break;
     463
     464      case PM_FPA_FILE_ASTROM:
     465        status = pmAstromWriteForView (view, file, config);
    451466        break;
    452467
     
    508523      case PM_FPA_FILE_CMF:
    509524      case PM_FPA_FILE_PSF:
     525      case PM_FPA_FILE_ASTROM:
    510526        psTrace ("psModules.camera", 5, "closing %s (%s) (%d:%d:%d)\n", file->filename, file->name, view->chip, view->cell, view->readout);
    511527        status = psFitsClose (file->fits);
     
    574590      case PM_FPA_FILE_CMF:
    575591      case PM_FPA_FILE_PSF:
     592      case PM_FPA_FILE_ASTROM:
    576593        psTrace ("psModules.camera", 5, "NOT freeing %s (%s) : save for further analysis\n", file->filename, file->name);
    577594        return true;
     
    712729      case PM_FPA_FILE_CMF:
    713730      case PM_FPA_FILE_PSF:
     731      case PM_FPA_FILE_ASTROM:
    714732        psTrace ("psModules.camera", 5, "opening %s (%s) (%d:%d:%d)\n",
    715733                 file->filename, file->name, view->chip, view->cell, view->readout);
     
    861879        status = pmPSFmodelWritePHU (view, file, config);
    862880        break;
     881      case PM_FPA_FILE_ASTROM:
     882        status = pmAstromWritePHU (view, file, config);
     883        break;
    863884      case PM_FPA_FILE_SX:
    864885      case PM_FPA_FILE_RAW:
  • trunk/psModules/src/detrend/pmDetrendDB.c

    r13775 r15562  
    101101        DETREND_STRING_CASE (SHUTTER);
    102102        DETREND_STRING_CASE (FRINGE);
     103        DETREND_STRING_CASE (ASTROM);
    103104    default:
    104105        return NULL;
  • trunk/psModules/src/detrend/pmDetrendDB.h

    r13775 r15562  
    99 * @author EAM, IfA
    1010 *
    11  * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    12  * @date $Date: 2007-06-13 03:42:33 $
     11 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     12 * @date $Date: 2007-11-10 01:09:20 $
    1313 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
    1414 */
     
    2929    PM_DETREND_TYPE_FRINGE,
    3030    PM_DETREND_TYPE_BACKGROUND,
     31    PM_DETREND_TYPE_ASTROM,
    3132} pmDetrendType;
    3233
  • trunk/psModules/src/imcombine/pmStack.c

    r15396 r15562  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2007-10-26 23:15:06 $
    12  *
     10 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2007-11-10 01:09:20 $
    1312 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
    1413 *
  • trunk/psModules/src/imcombine/pmSubtraction.h

    r15443 r15562  
    66 * @author GLG, MHPCC
    77 *
    8  * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-11-03 02:28:24 $
    10  *
     8 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-11-10 01:09:20 $
    1110 * Copyright 2004-207 Institute for Astronomy, University of Hawaii
    1211 */
  • trunk/psModules/src/objects/Makefile.am

    r15039 r15562  
    1010     pmModelUtils.c \
    1111     pmSource.c \
     12     pmSourceExtendedPars.c \
    1213     pmSourceUtils.c \
    1314     pmSourceSky.c \
     
    5051     pmModelUtils.h \
    5152     pmSource.h \
     53     pmSourceExtendedPars.h \
    5254     pmSourceUtils.h \
    5355     pmSourceSky.h \
  • trunk/psModules/src/objects/pmGrowthCurve.h

    r11253 r15562  
    44 * @author EAM, IfA
    55 *
    6  * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-01-24 02:54:15 $
     6 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-11-10 01:09:20 $
    88 * Copyright 2006 Institute for Astronomy, University of Hawaii
    99 */
     
    2727pmGrowthCurve;
    2828
     29bool psMemCheckGrowthCurve(psPtr ptr);
     30
    2931pmGrowthCurve *pmGrowthCurveAlloc (psF32 minRadius, psF32 maxRadius, psF32 refRadius);
    3032psF32 pmGrowthCurveCorrect (pmGrowthCurve *growth, psF32 radius);
  • trunk/psModules/src/objects/pmModel.c

    r14938 r15562  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-09-21 00:04:07 $
     8 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-11-10 01:09:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4646    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
    4747
    48     pmModel *tmp = (pmModel *) psAlloc(sizeof(pmModel));
    49     psMemSetDeallocator(tmp, (psFreeFunc) modelFree);
    50 
    5148    pmModelClass *class = pmModelClassSelect (type);
    5249    if (class == NULL) {
     
    5451        return(NULL);
    5552    }
     53
     54    pmModel *tmp = (pmModel *) psAlloc(sizeof(pmModel));
     55    psMemSetDeallocator(tmp, (psFreeFunc) modelFree);
    5656
    5757    tmp->type = type;
     
    8989}
    9090
     91bool psMemCheckModel(psPtr ptr)
     92{
     93    PS_ASSERT_PTR(ptr, false);
     94    return ( psMemGetDeallocator(ptr) == (psFreeFunc) modelFree);
     95}
     96
    9197// copy model to a new structure
    9298pmModel *pmModelCopy (pmModel *model)
    9399{
     100    PS_ASSERT_PTR_NON_NULL(model, NULL);
    94101
    95102    pmModel *new = pmModelAlloc (model->type);
     
    217224        Ro = psImageInterpolateOptionsAlloc(
    218225            PS_INTERPOLATE_BILINEAR,
    219             model->residuals->Ro, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
     226            model->residuals->Ro, NULL, mask, 0, 0.0, 0.0, 1, 0, 0.0);
    220227        Rx = psImageInterpolateOptionsAlloc(
    221228            PS_INTERPOLATE_BILINEAR,
     
    257264                float oy = yBin*(imageRow + 0.5 - yCenter) + yResidCenter;
    258265
     266                psU8 mflux = 0;
    259267                if (mode & PM_MODEL_OP_RES0) {
    260                     psU8 mflux = 0;
    261268                    double Fo = 0.0;
    262269                    psImageInterpolate (&Fo, NULL, &mflux, ox, oy, Ro);
     
    265272                    }
    266273                }
    267                 if (mode & PM_MODEL_OP_RES1) {
    268                     psU8 mflux = 0;
     274                // skip Rx,Ry if Ro is masked
     275                if (!mflux && (mode & PM_MODEL_OP_RES1)) {
    269276                    double Fx = 0.0;
    270277                    double Fy = 0.0;
  • trunk/psModules/src/objects/pmModel.h

    r14652 r15562  
    55 * @author EAM, IfA
    66 *
    7  * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-08-24 00:11:02 $
     7 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2007-11-10 01:09:20 $
    99 *
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    122122 */
    123123pmModel *pmModelAlloc(pmModelType type);
     124bool psMemCheckModel(psPtr ptr);
    124125
    125126// copy model to a new structure
  • trunk/psModules/src/objects/pmModelClass.c

    r14938 r15562  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-09-21 00:09:05 $
     8 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-11-10 01:09:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5757static void ModelClassFree (pmModelClass *modelClass)
    5858{
    59 
    6059    if (modelClass == NULL)
    6160        return;
     
    7069}
    7170
     71bool psMemCheckModelClass(psPtr ptr)
     72{
     73    PS_ASSERT_PTR(ptr, false);
     74    return ( psMemGetDeallocator(ptr) == (psFreeFunc) ModelClassFree);
     75}
     76
    7277void pmModelClassAdd (pmModelClass *model)
    7378{
    7479    if (models == NULL) {
    75         pmModelClassInit ();
     80        pmModelClassInit();
    7681    }
    7782
     
    8590{
    8691    // if we do not need to init, return false;
    87     if (models != NULL)
     92    if (models != NULL) {
    8893        return false;
     94    }
    8995
    9096    int Nnew = sizeof (defaultModels) / sizeof (pmModelClass);
     
    100106pmModelClass *pmModelClassSelect (pmModelType type)
    101107{
     108    if (models == NULL) {
     109        pmModelClassInit();
     110    }
     111
    102112    if ((type < 0) || (type >= Nmodels)) {
    103113        psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType");
     
    111121    psFree (models);
    112122    models = NULL;
     123    Nmodels = 0;
    113124    return;
    114125}
     
    116127psS32 pmModelClassParameterCount (pmModelType type)
    117128{
     129    if (models == NULL) {
     130        pmModelClassInit();
     131    }
     132
    118133    if ((type < 0) || (type >= Nmodels)) {
    119134        psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType");
     
    125140psS32 pmModelClassGetType (char *name)
    126141{
     142    if (models == NULL) {
     143        pmModelClassInit();
     144    }
     145
    127146    for (int i = 0; i < Nmodels; i++) {
    128147        if (!strcmp(models[i].name, name)) {
     
    135154char *pmModelClassGetName (pmModelType type)
    136155{
     156    if (models == NULL) {
     157        pmModelClassInit();
     158    }
     159
    137160    if ((type < 0) || (type >= Nmodels)) {
    138161        psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType");
  • trunk/psModules/src/objects/pmModelClass.h

    r14652 r15562  
    2121 * @author EAM, IfA
    2222 *
    23  * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    24  * @date $Date: 2007-08-24 00:11:02 $
     23 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     24 * @date $Date: 2007-11-10 01:09:20 $
    2525 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    2626 */
     
    4949pmModelClass *pmModelClassAlloc (int nModels);
    5050
     51//
     52bool psMemCheckModelClass(psPtr ptr);
     53
    5154// initialize the internal (static) model class with the default models
    5255bool pmModelClassInit (void);
  • trunk/psModules/src/objects/pmModelGroup.c

    r14652 r15562  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-24 00:11:02 $
     8 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-11-10 01:09:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6868}
    6969
     70bool psMemCheckModelGroup(psPtr ptr)
     71{
     72    PS_ASSERT_PTR(ptr, false);
     73    return ( psMemGetDeallocator(ptr) == (psFreeFunc) ModelGroupFree);
     74}
     75
    7076void pmModelGroupAdd (pmModelGroup *model)
    7177{
  • trunk/psModules/src/objects/pmModelGroup.h

    r14652 r15562  
    2121 * @author EAM, IfA
    2222 *
    23  * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    24  * @date $Date: 2007-08-24 00:11:02 $
     23 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     24 * @date $Date: 2007-11-10 01:09:20 $
    2525 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    2626 */
     
    7878pmModelGroup *pmModelGroupAlloc (int nModels);
    7979
     80bool psMemCheckModelGroup(psPtr ptr);
     81
    8082// initialize the internal (static) model group with the default models
    8183bool pmModelGroupInit (void);
  • trunk/psModules/src/objects/pmModelUtils.c

    r14938 r15562  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-09-21 00:04:30 $
     7 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-11-10 01:09:20 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3636pmModel *pmModelFromPSF (pmModel *modelEXT, pmPSF *psf)
    3737{
     38    PS_ASSERT_PTR_NON_NULL(psf, NULL);
     39    PS_ASSERT_PTR_NON_NULL(modelEXT, NULL);
     40
    3841    // allocate a new pmModel to hold the PSF version
    3942    pmModel *modelPSF = pmModelAlloc (psf->type);
     
    5356// instantiate a model for the PSF at this location with peak flux
    5457// NOTE: psf and (Xo,Yo) are defined wrt chip coordinates
    55 pmModel *pmModelFromPSFforXY (pmPSF *psf, float Xo, float Yo, float Io) {
    56 
    57     assert (psf);
     58pmModel *pmModelFromPSFforXY (pmPSF *psf, float Xo, float Yo, float Io)
     59{
     60    PS_ASSERT_PTR_NON_NULL(psf, NULL);
    5861
    5962    // allocate a new pmModel to hold the PSF version
     
    7578// set this model to have the requested flux
    7679bool pmModelSetFlux (pmModel *model, float flux) {
     80    PS_ASSERT_PTR_NON_NULL(model, NULL);
     81    PS_ASSERT_PTR_NON_NULL(model->params, NULL);
    7782
    7883    // set Io to be 1.0
  • trunk/psModules/src/objects/pmPSF.c

    r15089 r15562  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-09-29 00:15:32 $
     8 *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-11-10 01:09:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7676}
    7777
     78bool psMemCheckPSFOptions(psPtr ptr)
     79{
     80    PS_ASSERT_PTR(ptr, false);
     81    return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmPSFOptionsFree);
     82}
     83
    7884/*****************************************************************************
    7985pmPSFFree(psf): function to free a pmPSF structure
     
    8187static void pmPSFFree (pmPSF *psf)
    8288{
    83 
    84     if (psf == NULL)
     89    if (psf == NULL) {
    8590        return;
     91    }
    8692
    8793    psFree (psf->ChiTrend);
     
    98104 pmPSFAlloc (type): allocate a pmPSF.
    99105
    100  NOTE: PSF model parameters which are not modeled on an image are set to NULL in psf->params.
     106 NOTE: PSF model parameters which are not modeled on an image are set to NULL
     107 in psf->params.
    101108
    102109 These are normally:
     
    109116pmPSF *pmPSFAlloc (pmPSFOptions *options)
    110117{
     118    PS_ASSERT_PTR_NON_NULL(options, NULL);
    111119    int Nparams;
    112120
     
    205213}
    206214
     215bool psMemCheckPSF(psPtr ptr)
     216{
     217    PS_ASSERT_PTR(ptr, false);
     218    return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmPSFFree);
     219}
     220
    207221// the PSF models the \sigma_{xy} variation of the elliptical contour as a function of position in the image with a
    208222// polynomial.  an individual object has a contour of the form (x^2/2sx^2) + (y^2/2sy^2) + sxy*x*y
     
    217231double pmPSF_SXYfromModel (psF32 *modelPar)
    218232{
     233    PS_ASSERT_PTR_NON_NULL(modelPar, NAN);
    219234
    220235    double SXX = modelPar[PM_PAR_SXX];
     
    229244double pmPSF_SXYtoModel (psF32 *fittedPar)
    230245{
     246    PS_ASSERT_PTR_NON_NULL(fittedPar, NAN);
    231247
    232248    double SXX = fittedPar[PM_PAR_SXX];
     
    247263bool pmPSF_FitToModel (psF32 *fittedPar, float minMinorAxis)
    248264{
     265    PS_ASSERT_PTR_NON_NULL(fittedPar, false);
     266
    249267    psEllipsePol pol;
    250268
     
    272290psEllipsePol pmPSF_ModelToFit (psF32 *modelPar)
    273291{
     292//   XXX: must assert non-NULL input parameter
     293//    PS_ASSERT_PTR_NON_NULL(modelPar, NAN);
     294
    274295    psEllipseShape shape;
    275296
     
    289310    psEllipseShape shape;
    290311    psEllipseAxes axes;
     312//   XXX: must assert non-NULL input parameter
     313//    PS_ASSERT_PTR_NON_NULL(modelPar, axes);
    291314
    292315    shape.sx  = modelPar[PM_PAR_SXX] / M_SQRT2;
     
    310333bool pmPSF_AxesToModel (psF32 *modelPar, psEllipseAxes axes)
    311334{
     335    PS_ASSERT_PTR_NON_NULL(modelPar, false);
     336
    312337    if ((axes.major <= 0) || (axes.minor <= 0)) {
    313338        modelPar[PM_PAR_SXX] = 0.0;
     
    374399bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType mark)
    375400{
     401    PS_ASSERT_PTR_NON_NULL(readout, false);
     402    PS_ASSERT_PTR_NON_NULL(readout->image, false);
    376403
    377404    // bool status;
  • trunk/psModules/src/objects/pmPSF.h

    r15016 r15562  
    66 * @author EAM, IfA
    77 *
    8  * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-09-25 22:05:05 $
     8 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-11-10 01:09:20 $
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    8787 *
    8888 */
     89
    8990pmPSF *pmPSFAlloc (pmPSFOptions *options);
    90 pmPSFOptions *pmPSFOptionsAlloc ();
     91bool psMemCheckPSF(psPtr ptr);
     92pmPSFOptions *pmPSFOptionsAlloc();
     93bool psMemCheckPSFOptions(psPtr ptr);
    9194
    9295double pmPSF_SXYfromModel (psF32 *modelPar);
  • trunk/psModules/src/objects/pmPSF_IO.c

    r15254 r15562  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-10-09 19:26:25 $
     8 *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-11-10 01:09:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5050bool pmPSFmodelCheckDataStatusForView (const pmFPAview *view, const pmFPAfile *file)
    5151{
     52    PS_ASSERT_PTR_NON_NULL(view, false);
     53    PS_ASSERT_PTR_NON_NULL(file, false);
     54    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
     55    PS_ASSERT_PTR_NON_NULL(file->fpa->chips, false);
     56
    5257    pmFPA *fpa = file->fpa;
    5358
     
    6166    }
    6267    pmChip *chip = fpa->chips->data[view->chip];
     68    PS_ASSERT_PTR_NON_NULL(chip, false);
     69    PS_ASSERT_PTR_NON_NULL(chip->cells, false);
    6370
    6471    if (view->cell == -1) {
     
    7582
    7683bool pmPSFmodelCheckDataStatusForFPA (const pmFPA *fpa) {
     84
     85    PS_ASSERT_PTR_NON_NULL(fpa, false);
     86    PS_ASSERT_PTR_NON_NULL(fpa->chips, false);
    7787
    7888    for (int i = 0; i < fpa->chips->n; i++) {
     
    8595
    8696bool pmPSFmodelCheckDataStatusForChip (const pmChip *chip) {
     97    PS_ASSERT_PTR_NON_NULL(chip, false);
    8798
    8899    bool status;
     
    95106bool pmPSFmodelWriteForView (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    96107{
     108    PS_ASSERT_PTR_NON_NULL(view, false);
     109    PS_ASSERT_PTR_NON_NULL(file, false);
     110    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
     111    PS_ASSERT_PTR_NON_NULL(file->fpa->chips, false);
    97112
    98113    pmFPA *fpa = file->fpa;
     
    126141bool pmPSFmodelWriteFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    127142{
     143    PS_ASSERT_PTR_NON_NULL(view, false);
     144    PS_ASSERT_PTR_NON_NULL(fpa, false);
     145    PS_ASSERT_PTR_NON_NULL(fpa->chips, false);
    128146    pmFPAview *thisView = pmFPAviewAlloc (view->nRows);
    129147    *thisView = *view;
     
    145163bool pmPSFmodelWriteChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    146164{
     165    PS_ASSERT_PTR_NON_NULL(view, false);
     166    PS_ASSERT_PTR_NON_NULL(chip, false);
     167
    147168    if (!pmPSFmodelWrite (chip->analysis, view, file, config)) {
    148169        psError(PS_ERR_IO, false, "Failed to write PSF for chip");
     
    162183bool pmPSFmodelWrite (psMetadata *analysis, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    163184{
     185    PS_ASSERT_PTR_NON_NULL(view, false);
     186    PS_ASSERT_PTR_NON_NULL(file, false);
     187    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
    164188    bool status;
    165189    pmHDU *hdu;
     
    450474
    451475// if this file needs to have a PHU written out, write one
    452 bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config) {
    453 
     476bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     477{
     478    PS_ASSERT_PTR_NON_NULL(view, false);
     479    PS_ASSERT_PTR_NON_NULL(file, false);
     480    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
    454481    // not needed if already written
    455482    if (file->wrote_phu) return true;
     
    494521bool pmPSFmodelReadForView (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    495522{
     523    PS_ASSERT_PTR_NON_NULL(view, false);
     524    PS_ASSERT_PTR_NON_NULL(file, false);
     525    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
    496526
    497527    pmFPA *fpa = file->fpa;
     
    517547bool pmPSFmodelReadFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    518548{
     549    PS_ASSERT_PTR_NON_NULL(view, false);
     550    PS_ASSERT_PTR_NON_NULL(file, false);
     551    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
     552
    519553    bool success = true;                // Was everything successful?
    520554    for (int i = 0; i < fpa->chips->n; i++) {
     
    528562bool pmPSFmodelReadChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    529563{
     564    PS_ASSERT_PTR_NON_NULL(view, false);
     565    PS_ASSERT_PTR_NON_NULL(file, false);
     566    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
     567
    530568    if (!pmPSFmodelRead (chip->analysis, view, file, config)) {
    531569        psError(PS_ERR_IO, false, "Failed to write PSF for chip");
     
    539577bool pmPSFmodelRead (psMetadata *analysis, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    540578{
     579    PS_ASSERT_PTR_NON_NULL(view, false);
     580    PS_ASSERT_PTR_NON_NULL(file, false);
     581    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
     582
    541583    bool status;
    542584    char *rule = NULL;
     
    763805}
    764806
    765 // create a psMetadata representation (human-readable) of a psf model
    766807// XXX pmPSF to/from Metadata functions were defined for 1.22 and earlier, but were dropped
  • trunk/psModules/src/objects/pmPSFtry.c

    r15254 r15562  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-10-09 19:26:25 $
     7 *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-11-10 01:09:20 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8181}
    8282
     83bool psMemCheckPSFtry(psPtr ptr)
     84{
     85    PS_ASSERT_PTR(ptr, false);
     86    return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmPSFtryFree);
     87}
     88
     89
    8390// build a pmPSFtry for the given model:
    8491// - fit each source with the free-floating model
     
    249256bool pmPSFtryMetric (pmPSFtry *psfTry, float RADIUS)
    250257{
     258    PS_ASSERT_PTR_NON_NULL(psfTry, false);
     259    PS_ASSERT_PTR_NON_NULL(psfTry->sources, false);
     260
    251261    // the measured (aperture - fit) magnitudes (dA == psfTry->metric)
    252262    //   depend on both the true ap-fit (dAo) and the bias in the sky measurement:
     
    346356bool pmPSFFromPSFtry (pmPSFtry *psfTry)
    347357{
     358    PS_ASSERT_PTR_NON_NULL(psfTry, false);
     359    PS_ASSERT_PTR_NON_NULL(psfTry->sources, false);
     360
    348361    pmPSF *psf = psfTry->psf;
    349362
  • trunk/psModules/src/objects/pmPSFtry.h

    r15016 r15562  
    66 * @author EAM, IfA
    77 *
    8  * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-09-25 22:05:05 $
     8 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-11-10 01:09:20 $
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    7878 *
    7979 */
     80
    8081pmPSFtry *pmPSFtryAlloc (psArray *sources, pmPSFOptions *options);
     82bool psMemCheckPSFtry(psPtr ptr);
    8183
    8284/** pmPSFtryModel()
  • trunk/psModules/src/objects/pmPeaks.c

    r15039 r15562  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-09-27 03:35:29 $
     8 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-11-10 01:09:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    150150}
    151151
     152// XXX: Get rid of this:
    152153bool pmPeakTest(const psPtr ptr)
    153154{
     
    155156}
    156157
     158bool psMemCheckPeak(psPtr ptr)
     159{
     160    PS_ASSERT_PTR(ptr, false);
     161    return ( psMemGetDeallocator(ptr) == (psFreeFunc) peakFree);
     162}
     163
     164
    157165// psSort comparison function for peaks
     166// XXX: Add error-checking for NULL args
    158167int pmPeaksCompareAscend (const void **a, const void **b)
    159168{
     
    177186
    178187// psSort comparison function for peaks
     188// XXX: Add error-checking for NULL args
    179189int pmPeaksCompareDescend (const void **a, const void **b)
    180190{
  • trunk/psModules/src/objects/pmPeaks.h

    r15039 r15562  
    1010 * @author GLG, MHPCC
    1111 *
    12  * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    13  * @date $Date: 2007-09-27 03:35:29 $
     12 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     13 * @date $Date: 2007-11-10 01:09:20 $
    1414 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1515 */
     
    7575
    7676bool pmPeakTest(const psPtr ptr);
     77bool psMemCheckPeak(psPtr ptr);
    7778
    7879/** pmPeaksInVector()
  • trunk/psModules/src/objects/pmResiduals.c

    r12949 r15562  
    44 *
    55 * @author EAM, IfA
    6  * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-04-21 19:47:14 $
     6 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-11-10 01:09:20 $
    88 * Copyright 2004 IfA, University of Hawaii
    99 */
     
    5151    return resid;
    5252}
     53
     54bool psMemCheckResiduals(psPtr ptr)
     55{
     56    PS_ASSERT_PTR(ptr, false);
     57    return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmResidualsFree);
     58}
     59
  • trunk/psModules/src/objects/pmResiduals.h

    r12949 r15562  
    44 *
    55 * @author EAM, IfA
    6  * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-04-21 19:47:14 $
     6 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-11-10 01:09:20 $
    88 * Copyright 2004 IfA, University of Hawaii
    99 */
     
    2929
    3030pmResiduals *pmResidualsAlloc (int xSize, int ySize, int xBin, int yBin);
     31bool psMemCheckResiduals(psPtr ptr);
    3132
    3233/// @}
  • trunk/psModules/src/objects/pmSource.c

    r15232 r15562  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-10-06 02:29:47 $
     8 *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-11-10 01:09:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7777}
    7878
     79bool psMemCheckSource(psPtr ptr)
     80{
     81    PS_ASSERT_PTR(ptr, false);
     82    return ( psMemGetDeallocator(ptr) == (psFreeFunc) sourceFree);
     83}
     84
    7985/******************************************************************************
    8086pmSourceAlloc(): Allocate the pmSource structure and initialize its members
    8187to NULL.
    8288*****************************************************************************/
     89
    8390pmSource *pmSourceAlloc()
    8491{
     
    132139pmSource *pmSourceCopy(pmSource *in)
    133140{
     141    if (in == NULL) {
     142        return(NULL);
     143    }
    134144    // this copy is used to allow multiple fit attempts on the
    135145    // same object.  the pixels, weight, and mask arrays all point to
     
    139149
    140150    // this is actually the same peak as the original, is this the correct way to handle this?
    141     source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->value, in->peak->type);
    142     source->peak->xf = in->peak->xf;
    143     source->peak->yf = in->peak->yf;
    144     source->peak->flux = in->peak->flux;
    145     source->peak->SN = in->peak->SN;
     151    if (in->peak != NULL) {
     152        source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->value, in->peak->type);
     153        source->peak->xf = in->peak->xf;
     154        source->peak->yf = in->peak->yf;
     155        source->peak->flux = in->peak->flux;
     156        source->peak->SN = in->peak->SN;
     157    }
    146158
    147159    // copy the values in the moments structure
    148     source->moments  =  pmMomentsAlloc();
    149     *source->moments = *in->moments;
     160    if (in->moments != NULL) {
     161        source->moments  =  pmMomentsAlloc();
     162        *source->moments = *in->moments;
     163    }
    150164
    151165    // These images are all views to the parent.
    152166    // We want a new view, but pointing at the same pixels.
    153     source->pixels   = psImageCopyView (NULL, in->pixels);
    154     source->weight   = psImageCopyView (NULL, in->weight);
    155     source->maskView = psImageCopyView (NULL, in->maskView);
     167    source->pixels   = psImageCopyView(NULL, in->pixels);
     168    source->weight   = psImageCopyView(NULL, in->weight);
     169    source->maskView = psImageCopyView(NULL, in->maskView);
    156170
    157171    // the maskObj is a unique mask array; create a new mask image
     
    173187                          psF32 Radius)
    174188{
     189    PS_ASSERT_PTR_NON_NULL(mySource, false);
     190    PS_ASSERT_PTR_NON_NULL(readout, false);
     191    PS_ASSERT_PTR_NON_NULL(readout->image, false);
     192    PS_ASSERT_INT_POSITIVE(Radius, false);
     193
    175194    psRegion srcRegion;
    176195
     
    200219                            psF32 Radius)
    201220{
     221    PS_ASSERT_PTR_NON_NULL(mySource, false);
     222    PS_ASSERT_PTR_NON_NULL(readout, false);
     223    PS_ASSERT_PTR_NON_NULL(readout->image, false);
     224    PS_ASSERT_INT_POSITIVE(Radius, false);
     225
    202226    bool extend;
    203227    psRegion newRegion;
    204 
    205     if (Radius == 0)
    206         return false;
    207228
    208229    // check to see if new region is completely contained within old region
     
    814835
    815836// should we call pmSourceCacheModel if it does not exist?
    816 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psMaskType maskVal, int dx, int dy) {
    817 
     837bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add,
     838                 psMaskType maskVal, int dx, int dy)
     839{
     840    PS_ASSERT_PTR_NON_NULL(source, false);
    818841    bool status;
    819842
     
    904927pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source)
    905928{
     929    PS_ASSERT_PTR_NON_NULL(source, NULL);
    906930
    907931    pmModel *model;
  • trunk/psModules/src/objects/pmSource.h

    r15039 r15562  
    33 * @author EAM, IfA; GLG, MHPCC
    44 *
    5  * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    6  * @date $Date: 2007-09-27 03:35:29 $
     5 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     6 * @date $Date: 2007-11-10 01:09:20 $
    77 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    88 */
     
    1010# ifndef PM_SOURCE_H
    1111# define PM_SOURCE_H
     12
     13# include "pmSourceExtendedPars.h"
    1214
    1315/// @addtogroup Objects Object Detection / Analysis Functions
     
    8486    psRegion region;                    ///< area on image covered by selected pixels
    8587    float sky, skyErr;                  ///< The sky and its error at the center of the object
     88    pmSourceExtendedPars *extpars;      ///< extended source parameters
    8689};
    8790
     
    111114 *
    112115 */
     116
     117bool psMemCheckSource(psPtr ptr);
     118
    113119pmSource  *pmSourceCopy(pmSource *source);
    114120
     
    178184 */
    179185pmPSFClump pmSourcePSFClump(
    180     psArray *source,   ///< The input pmSource
    181     psMetadata *metadata  ///< Contains classification parameters
    182 );
    183 
     186    psArray *source,                    ///< The input pmSource
     187    psMetadata *metadata                ///< Contains classification parameters
     188);
    184189
    185190/** pmSourceRoughClass()
     
    194199 */
    195200bool pmSourceRoughClass(
    196     psArray *source,   ///< The input pmSource
    197     psMetadata *metadata,  ///< Contains classification parameters
    198     pmPSFClump clump,   ///< Statistics about the PSF clump
     201    psArray *source,                    ///< The input pmSource
     202    psMetadata *metadata,               ///< Contains classification parameters
     203    pmPSFClump clump,                   ///< Statistics about the PSF clump
    199204    psMaskType maskSat                  ///< Mask value for saturated pixels
    200205);
  • trunk/psModules/src/objects/pmSourceContour.c

    r14938 r15562  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-09-21 00:09:05 $
     8 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-11-10 01:09:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    220220psArray *pmSourceContour (psImage *image, int xc, int yc, float threshold)
    221221{
     222    PS_ASSERT_PTR_NON_NULL(image, NULL);
    222223
    223224    int xR, yR, x0, x1, x0s, x1s;
  • trunk/psModules/src/objects/pmSourceFitSet.c

    r15055 r15562  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-09-28 00:39:41 $
     8 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-11-10 01:09:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7979}
    8080
     81bool psMemCheckSourceFitSetData(psPtr ptr)
     82{
     83    PS_ASSERT_PTR(ptr, false);
     84    return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmSourceFitSetDataFree);
     85}
     86
     87
    8188// this function is called with the full set of parameters and the beta values in a single vector
    82 bool pmSourceFitSetCheckLimits (psMinConstraintMode mode, int nParam, float *params, float *betas)
    83 {
    84     assert (thisSet);
     89bool pmSourceFitSetCheckLimits (psMinConstraintMode mode, int nParam, float *params,
     90                                float *betas)
     91{
     92    PS_ASSERT_PTR_NON_NULL(thisSet, false);
    8593
    8694    // nParam is the parameter in the full sequence.  determine which single model this comes from
     
    109117
    110118// merge parameters from FitSet models into single param and deriv vectors
    111 bool pmSourceFitSetJoin (psVector *deriv, psVector *param, pmSourceFitSetData *set) {
    112 
    113     assert (set);
     119bool pmSourceFitSetJoin (psVector *deriv, psVector *param, pmSourceFitSetData *set)
     120{
     121    PS_ASSERT_PTR_NON_NULL(set, false);
     122    PS_ASSERT_PTR_NON_NULL(param, false);
     123
    114124    assert (set->paramSet->n == set->derivSet->n);
    115125
     
    138148// distribute parameters from single param and deriv vectors into FitSet models
    139149bool pmSourceFitSetSplit (pmSourceFitSetData *set, const psVector *deriv, const psVector *param) {
    140 
    141     assert (set);
     150    PS_ASSERT_PTR_NON_NULL(set, false);
     151    PS_ASSERT_PTR_NON_NULL(param, false);
     152
    142153    assert (set->paramSet->n == set->derivSet->n);
    143154
     
    159170}
    160171
    161 bool pmSourceFitSetValues (pmSourceFitSetData *set, const psVector *dparam, const psVector *param, pmSource *source, psMinimization *myMin, int nPix, bool fitStatus) {
    162 
     172bool pmSourceFitSetValues (pmSourceFitSetData *set, const psVector *dparam,
     173                           const psVector *param, pmSource *source,
     174                           psMinimization *myMin, int nPix, bool fitStatus)
     175{
     176    PS_ASSERT_PTR_NON_NULL(set, false);
    163177    bool onPic = true;
    164 
    165     assert (set);
    166178
    167179    int n = 0;
     
    203215psF32 pmSourceFitSetFunction(psVector *deriv, const psVector *param, const psVector *x)
    204216{
     217    PS_ASSERT_PTR_NON_NULL(thisSet, NAN);
    205218    float chisqSum = 0.0;
    206219    float chisqOne = 0.0;
    207 
    208     assert (thisSet);
    209220    pmSourceFitSetSplit (thisSet, deriv, param);
    210221
     
    225236
    226237// XXX allow the mode to be a function of the object (eg, S/N)
    227 bool pmSourceFitSetMasks (psMinConstraint *constraint, pmSourceFitSetData *set, pmSourceFitMode mode) {
     238bool pmSourceFitSetMasks (psMinConstraint *constraint, pmSourceFitSetData *set,
     239                          pmSourceFitMode mode)
     240{
     241    PS_ASSERT_PTR_NON_NULL(set, false);
     242    PS_ASSERT_PTR_NON_NULL(constraint, false);
    228243
    229244    // unmask everyone
  • trunk/psModules/src/objects/pmSourceFitSet.h

    r15055 r15562  
    33 * @author EAM, IfA; GLG, MHPCC
    44 *
    5  * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    6  * @date $Date: 2007-09-28 00:39:47 $
     5 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     6 * @date $Date: 2007-11-10 01:09:20 $
    77 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    88 */
     
    2323// initialize data for a group of object models
    2424pmSourceFitSetData *pmSourceFitSetDataAlloc (psArray *modelSet);
     25bool psMemCheckSourceFitSetData(psPtr ptr);
    2526
    2627// function used to set limits for a group of models
  • trunk/psModules/src/objects/pmSourceIO.c

    r15227 r15562  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-10-05 22:46:34 $
     5 *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-11-10 01:09:20 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4747int pmSourceGetDophotType (pmSource *source)
    4848{
     49    PS_ASSERT_PTR_NON_NULL(source, -1);
     50
    4951    switch (source->type) {
    5052
     
    7476bool pmSourceSetDophotType (pmSource *source, int type)
    7577{
     78    PS_ASSERT_PTR_NON_NULL(source, false);
     79
    7680    if (type == 4) {
    7781        source->mode |= PM_SOURCE_MODE_FAIL;
     
    106110bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    107111{
     112    PS_ASSERT_PTR_NON_NULL(view, false);
     113    PS_ASSERT_PTR_NON_NULL(file, false);
     114    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
    108115
    109116    pmFPA *fpa = file->fpa;
     
    165172bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    166173{
     174    PS_ASSERT_PTR_NON_NULL(view, false);
     175    PS_ASSERT_PTR_NON_NULL(fpa, false);
     176    PS_ASSERT_PTR_NON_NULL(fpa->chips, false);
     177
    167178    pmFPAview *thisView = pmFPAviewAlloc (view->nRows);
    168179    *thisView = *view;
     
    184195bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    185196{
     197    PS_ASSERT_PTR_NON_NULL(chip, false);
     198    PS_ASSERT_PTR_NON_NULL(chip->cells, false);
     199    PS_ASSERT_PTR_NON_NULL(view, false);
     200
    186201    pmFPAview *thisView = pmFPAviewAlloc (view->nRows);
    187202    *thisView = *view;
     
    203218bool pmCellWriteObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    204219{
     220    PS_ASSERT_PTR_NON_NULL(cell, false);
     221    PS_ASSERT_PTR_NON_NULL(cell->readouts, false);
     222    PS_ASSERT_PTR_NON_NULL(view, false);
     223
    205224    pmFPAview *thisView = pmFPAviewAlloc (view->nRows);
    206225    *thisView = *view;
     
    222241bool pmReadoutWriteObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    223242{
     243    PS_ASSERT_PTR_NON_NULL(readout, false);
     244    PS_ASSERT_PTR_NON_NULL(view, false);
     245    PS_ASSERT_PTR_NON_NULL(file, false);
     246    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
    224247
    225248    bool status;
    226     char *exttype;
    227     char *dataname;
    228     char *headname;
    229249    pmHDU *hdu;
    230250    psMetadata *updates;
    231251    psMetadata *outhead;
     252
     253    char *exttype  = NULL;
     254    char *dataname = NULL;
     255    char *xsrcname = NULL;
     256    char *headname = NULL;
    232257
    233258    // XXX if sources is NULL, skip the cell or write out empty tables?
     
    284309        // get the current header
    285310        hdu = pmFPAviewThisHDU (view, file->fpa);
     311
     312        // determine the output table format
     313        psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
     314        if (!status) {
     315          psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
     316          return false;
     317        }
     318
     319        // if this is not TRUE, the output files only contain the psf measurements.
     320        bool XSRC_OUTPUT = psMetadataLookupBool(&status, recipe, "SAVE.XSRC");
    286321
    287322        // define the EXTNAME values for the different data segments:
     
    312347            }
    313348            dataname = pmFPAfileNameFromRule (rule, file, view);
     349
     350            if (XSRC_OUTPUT) {
     351              // EXTNAME for extended source data table
     352              rule = psMetadataLookupStr(&status, menu, "CMF.XSRC");
     353              if (!rule) {
     354                psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XSRC in EXTNAME.RULES in camera.config");
     355                return false;
     356              }
     357              xsrcname = pmFPAfileNameFromRule (rule, file, view);
     358            }
    314359        }
    315360
     
    350395            outhead = psMetadataAlloc ();
    351396
    352             // determine the output table format
    353             psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
    354             if (!status) {
    355                 psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
    356                 return false;
    357             }
    358397            exttype = psMemIncrRefCounter (psMetadataLookupStr(&status, recipe, "OUTPUT.FORMAT"));
    359398            if (!exttype) {
     
    375414            }
    376415            if (!strcmp (exttype, "PS1_DEV_1")) {
    377                 status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname);
     416                status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname, xsrcname);
    378417            }
    379 
    380418            if (!status) {
    381419                psError(PS_ERR_IO, false, "writing CMF data to %s with format %s\n", file->filename, exttype);
     
    403441
    404442// if this file needs to have a PHU written out, write one
    405 bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config) {
     443bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     444{
     445    PS_ASSERT_PTR_NON_NULL(view, false);
     446    PS_ASSERT_PTR_NON_NULL(file, false);
    406447
    407448    bool status;
     
    512553bool pmFPAviewReadObjects (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    513554{
     555    PS_ASSERT_PTR_NON_NULL(view, false);
     556    PS_ASSERT_PTR_NON_NULL(file, false);
     557    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
     558
    514559    pmFPA *fpa = file->fpa;
    515560
     
    551596bool pmFPAReadObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    552597{
     598    PS_ASSERT_PTR_NON_NULL(view, false);
     599    PS_ASSERT_PTR_NON_NULL(file, false);
     600    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
     601    PS_ASSERT_PTR_NON_NULL(file->fpa->chips, false);
     602
    553603    pmFPAview *thisView = pmFPAviewAlloc (view->nRows);
    554604    *thisView = *view;
     
    572622bool pmChipReadObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    573623{
     624    PS_ASSERT_PTR_NON_NULL(view, false);
     625    PS_ASSERT_PTR_NON_NULL(chip, false);
     626    PS_ASSERT_PTR_NON_NULL(chip->cells, false);
     627
    574628    pmFPAview *thisView = pmFPAviewAlloc (view->nRows);
    575629    *thisView = *view;
     
    596650bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    597651{
     652    PS_ASSERT_PTR_NON_NULL(view, false);
     653    PS_ASSERT_PTR_NON_NULL(cell, false);
     654    PS_ASSERT_PTR_NON_NULL(cell->readouts, false);
     655
    598656    pmFPAview *thisView = pmFPAviewAlloc (view->nRows);
    599657    *thisView = *view;
     
    637695bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    638696{
     697    PS_ASSERT_PTR_NON_NULL(view, false);
     698    PS_ASSERT_PTR_NON_NULL(file, false);
    639699
    640700    bool status;
     
    774834bool pmFPAviewCheckDataStatusForSources (const pmFPAview *view, const pmFPAfile *file)
    775835{
     836    PS_ASSERT_PTR_NON_NULL(view, false);
     837    PS_ASSERT_PTR_NON_NULL(file, false);
     838    PS_ASSERT_PTR_NON_NULL(file->fpa, false);
     839
    776840    pmFPA *fpa = file->fpa;
    777841
     
    811875}
    812876
    813 bool pmFPACheckDataStatusForSources (const pmFPA *fpa) {
     877bool pmFPACheckDataStatusForSources (const pmFPA *fpa)
     878{
     879    PS_ASSERT_PTR_NON_NULL(fpa, false);
     880    PS_ASSERT_PTR_NON_NULL(fpa->chips, false);
    814881
    815882    for (int i = 0; i < fpa->chips->n; i++) {
     
    821888}
    822889
    823 bool pmChipCheckDataStatusForSources (const pmChip *chip) {
     890bool pmChipCheckDataStatusForSources (const pmChip *chip)
     891{
     892    PS_ASSERT_PTR_NON_NULL(chip, false);
     893    PS_ASSERT_PTR_NON_NULL(chip->cells, false);
    824894
    825895    for (int i = 0; i < chip->cells->n; i++) {
     
    831901}
    832902
    833 bool pmCellCheckDataStatusForSources (const pmCell *cell) {
     903bool pmCellCheckDataStatusForSources (const pmCell *cell)
     904{
     905    PS_ASSERT_PTR_NON_NULL(cell, false);
     906    PS_ASSERT_PTR_NON_NULL(cell->readouts, false);
    834907
    835908    for (int i = 0; i < cell->readouts->n; i++) {
     
    841914}
    842915
    843 bool pmReadoutCheckDataStatusForSources (const pmReadout *readout) {
     916bool pmReadoutCheckDataStatusForSources (const pmReadout *readout)
     917{
     918    PS_ASSERT_PTR_NON_NULL(readout, false);
    844919
    845920    bool status;
  • trunk/psModules/src/objects/pmSourceIO.h

    r15039 r15562  
    44 * @author EAM, IfA; GLG, MHPCC
    55 *
    6  * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-09-27 03:35:29 $
     6 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-11-10 01:09:20 $
    88 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    99 *
     
    2626bool pmSourcesWrite_SMPDATA (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname);
    2727bool pmSourcesWrite_PS1_DEV_0 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname);
    28 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname);
     28bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname, char *xsrcname);
     29bool pmSourcesWrite_PS1_DEV_1_XSRC (psFits *fits, psArray *sources, char *extname);
    2930
    3031bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
  • trunk/psModules/src/objects/pmSourceIO_CMP.c

    r14938 r15562  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-09-21 00:09:05 $
     5 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-11-10 01:09:20 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4848bool pmSourcesWriteCMP (psArray *sources, char *filename, psMetadata *header)
    4949{
     50    PS_ASSERT_PTR_NON_NULL(sources, false);
     51    PS_ASSERT_PTR_NON_NULL(filename, false);
     52    PS_ASSERT_PTR_NON_NULL(header, false);
    5053
    5154    int i, type;
     
    5861    // find config information for output header
    5962    float ZERO_POINT = psMetadataLookupF32 (&status, header, "ZERO_PT");
    60     if (!status)
     63    if (!status) {
    6164        ZERO_POINT = 25.0;
     65    }
    6266
    6367    // MEF elements have XTENSION, not SIMPLE: remove this (replace with SIMPLE)
    6468    psMetadataLookupStr (&status, header, "XTENSION");
    65     if (status)
     69    if (status) {
    6670        psMetadataRemoveKey (header, "XTENSION");
     71    }
    6772
    6873    // create file, write-out header
     
    148153psArray *pmSourcesReadCMP (char *filename, psMetadata *header)
    149154{
     155    PS_ASSERT_PTR_NON_NULL(filename, false);
     156    PS_ASSERT_PTR_NON_NULL(header, false);
    150157
    151158    bool status;
  • trunk/psModules/src/objects/pmSourceIO_OBJ.c

    r14938 r15562  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-09-21 00:09:05 $
     5 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-11-10 01:09:20 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4242bool pmSourcesWriteOBJ (psArray *sources, char *filename)
    4343{
     44    PS_ASSERT_PTR_NON_NULL(sources, false);
     45    PS_ASSERT_PTR_NON_NULL(filename, false);
    4446
    4547    int type;
  • trunk/psModules/src/objects/pmSourceIO_PS1_DEV_0.c

    r14938 r15562  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-09-21 00:09:05 $
     5 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-11-10 01:09:20 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4646// values derived in the DVO database.
    4747// XXX how do I generate the source tables which I need to send to PSPS?
    48 
    49 bool pmSourcesWrite_PS1_DEV_0 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname)
     48// XXX: input parameter imageHeader is never used.
     49bool pmSourcesWrite_PS1_DEV_0 (psFits *fits, psArray *sources, psMetadata *imageHeader,
     50                               psMetadata *tableHeader, char *extname)
    5051{
     52    PS_ASSERT_PTR_NON_NULL(fits, false);
     53    PS_ASSERT_PTR_NON_NULL(sources, false);
     54    PS_ASSERT_PTR_NON_NULL(extname, false);
    5155
    5256    psArray *table;
     
    147151psArray *pmSourcesRead_PS1_DEV_0 (psFits *fits, psMetadata *header)
    148152{
     153    PS_ASSERT_PTR_NON_NULL(fits, false);
     154    PS_ASSERT_PTR_NON_NULL(header, false);
    149155
    150156    bool status;
  • trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c

    r15250 r15562  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-10-09 03:10:05 $
     5 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-11-10 01:09:20 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4747// XXX how do I generate the source tables which I need to send to PSPS?
    4848
    49 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname)
     49bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname, char *xsrcname)
    5050{
    5151
     
    5757    psF32 xPos, yPos;
    5858    psF32 xErr, yErr;
     59
     60    // if we request XSRC output, add the XSRC name to this header
     61    if (xsrcname) {
     62      psMetadataAddStr (tableHeader, PS_LIST_TAIL, "XSRCNAME", PS_META_REPLACE, "name of XSRC table extension", xsrcname);
     63    }
    5964
    6065    // let's write these out in S/N order
     
    144149        return false;
    145150    }
    146 
    147151    psFree (table);
     152
     153    if (xsrcname) {
     154      pmSourcesWrite_PS1_DEV_1_XSRC (fits, sources, xsrcname);
     155    }
     156
    148157    return true;
    149158}
     
    165174    }
    166175    assert (modelType > -1);
     176
     177    // XXX need to look up the XSRCNAME entries
    167178
    168179    // validate a single row of the table (must match SMP)
     
    241252    return sources;
    242253}
     254
     255bool pmSourcesWrite_PS1_DEV_1_XSRC (psFits *fits, psArray *sources, char *extname)
     256{
     257
     258    psArray *table;
     259    psMetadata *row;
     260    int i;
     261    psF32 *PAR, *dPAR;
     262    psEllipseAxes axes;
     263    psF32 xPos, yPos;
     264    psF32 xErr, yErr;
     265
     266    // create a header to hold the output data
     267    psMetadata *outhead = psMetadataAlloc ();
     268
     269    // write the links to the image header
     270    psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "xsrc table extension", extname);
     271
     272    // let's write these out in S/N order
     273    sources = psArraySort (sources, pmSourceSortBySN);
     274
     275    table = psArrayAllocEmpty (sources->n);
     276
     277    // we write out all sources, regardless of quality.  the source flags tell us the state
     278    for (i = 0; i < sources->n; i++) {
     279        pmSource *source = (pmSource *) sources->data[i];
     280        source->seq = i;
     281
     282        // skip source if it is not a ext sourc
     283
     284        // no difference between PSF and non-PSF model
     285        // XXX the PSF output should report the value for the psf, not the ext, model
     286        pmModel *model = source->modelEXT;
     287        if (model == NULL) continue;
     288
     289        PAR = model->params->data.F32;
     290        dPAR = model->dparams->data.F32;
     291        xPos = PAR[PM_PAR_XPOS];
     292        yPos = PAR[PM_PAR_YPOS];
     293        xErr = dPAR[PM_PAR_XPOS];
     294        yErr = dPAR[PM_PAR_YPOS];
     295
     296        axes = pmPSF_ModelToAxes (PAR, 20.0);
     297
     298        row = psMetadataAlloc ();
     299        // XXX we are not writing out the mode (flags) or the type (psf, ext, etc)
     300        psMetadataAdd (row, PS_LIST_TAIL, "IPP_IDET",         PS_DATA_U32, "IPP detection identifier index",             source->seq);
     301        psMetadataAdd (row, PS_LIST_TAIL, "X_EXT",            PS_DATA_F32, "PSF x coordinate",                           xPos);
     302        psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT",            PS_DATA_F32, "PSF y coordinate",                           yPos);
     303        psMetadataAdd (row, PS_LIST_TAIL, "X_EXT_SIG",        PS_DATA_F32, "Sigma in PSF x coordinate",                  xErr);
     304        psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT_SIG",        PS_DATA_F32, "Sigma in PSF y coordinate",                  yErr);
     305        psMetadataAdd (row, PS_LIST_TAIL, "EXT_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             PS_MIN (99.0, source->extMag));
     306        // XXX need to calculate psfMag, psfMagErr, extMag, extMagErr...
     307        psMetadataAdd (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        PS_MIN (99.0, source->errMag));
     308
     309        // XXX these should be major and minor, not 'x' and 'y'
     310        psMetadataAdd (row, PS_LIST_TAIL, "EXT_WIDTH_X",      PS_DATA_F32, "PSF width in x coordinate",                  axes.major);
     311        psMetadataAdd (row, PS_LIST_TAIL, "EXT_WIDTH_Y",      PS_DATA_F32, "PSF width in y coordinate",                  axes.minor);
     312        psMetadataAdd (row, PS_LIST_TAIL, "EXT_THETA",        PS_DATA_F32, "PSF orientation angle",                      axes.theta);
     313
     314        // other values that I need to report:
     315        // R, Mag Petrosian, .....
     316
     317        psArrayAdd (table, 100, row);
     318        psFree (row);
     319    }
     320
     321    if (table->n == 0) {
     322        psFitsWriteBlank (fits, outhead, extname);
     323        psFree (table);
     324        return true;
     325    }
     326
     327    psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname);
     328    if (!psFitsWriteTable (fits, outhead, table, extname)) {
     329        psError(PS_ERR_IO, false, "writing ext data %s\n", extname);
     330        psFree(table);
     331        return false;
     332    }
     333    psFree (table);
     334
     335    return true;
     336}
  • trunk/psModules/src/objects/pmSourceIO_RAW.c

    r14938 r15562  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-09-21 00:09:05 $
     5 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-11-10 01:09:20 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4444{
    4545
     46    PS_ASSERT_PTR_NON_NULL(sources, false);
     47    PS_ASSERT_PTR_NON_NULL(filename, false);
     48
    4649    char *name = (char *) psAlloc (strlen(filename) + 10);
    4750
     
    6568bool pmSourcesWritePSFs (psArray *sources, char *filename)
    6669{
     70    PS_ASSERT_PTR_NON_NULL(sources, false);
     71    PS_ASSERT_PTR_NON_NULL(filename, false);
    6772
    6873    double dPos;
     
    124129bool pmSourcesWriteEXTs (psArray *sources, char *filename, bool requireEXT)
    125130{
     131    PS_ASSERT_PTR_NON_NULL(sources, false);
     132    PS_ASSERT_PTR_NON_NULL(filename, false);
    126133
    127134    double dPos;
     
    184191bool pmSourcesWriteNULLs (psArray *sources, char *filename)
    185192{
     193    PS_ASSERT_PTR_NON_NULL(sources, false);
     194    PS_ASSERT_PTR_NON_NULL(filename, false);
    186195
    187196    int i;
     
    230239bool pmMomentsWriteText (psArray *sources, char *filename)
    231240{
     241    PS_ASSERT_PTR_NON_NULL(sources, false);
     242    PS_ASSERT_PTR_NON_NULL(filename, false);
    232243
    233244    int i;
  • trunk/psModules/src/objects/pmSourceIO_SMPDATA.c

    r14938 r15562  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-09-21 00:09:05 $
     5 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-11-10 01:09:20 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4242// this format consists of a header derived from the image header
    4343// followed by a zero-size matrix, followed by the table data
    44 bool pmSourcesWrite_SMPDATA (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname)
     44// XXX: input parameter imageHeader is never used
     45bool pmSourcesWrite_SMPDATA (psFits *fits, psArray *sources, psMetadata *imageHeader,
     46                             psMetadata *tableHeader, char *extname)
    4547{
     48    PS_ASSERT_PTR_NON_NULL(fits, false);
     49    PS_ASSERT_PTR_NON_NULL(sources, false);
     50    PS_ASSERT_PTR_NON_NULL(extname, false);
    4651
    4752    psArray *table;
     
    126131psArray *pmSourcesRead_SMPDATA (psFits *fits, psMetadata *header)
    127132{
     133    PS_ASSERT_PTR_NON_NULL(fits, false);
     134    PS_ASSERT_PTR_NON_NULL(header, false);
    128135
    129136    bool status;
  • trunk/psModules/src/objects/pmSourceIO_SX.c

    r14938 r15562  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-09-21 00:09:05 $
     5 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-11-10 01:09:20 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4242bool pmSourcesWriteSX (psArray *sources, char *filename)
    4343{
     44    PS_ASSERT_PTR_NON_NULL(sources, false);
     45    PS_ASSERT_PTR_NON_NULL(filename, false);
    4446
    4547    psF32 *PAR, *dPAR;
  • trunk/psModules/src/objects/pmSourcePhotometry.c

    r15107 r15562  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-09-29 03:14:55 $
     5 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-11-10 01:09:20 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3939bool pmSourceMagnitudesInit (psMetadata *config)
    4040{
    41 
     41    PS_ASSERT_PTR_NON_NULL(config, false);
    4242    bool status;
    4343
     
    6464
    6565// XXX masked region should be (optionally) elliptical
    66 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal, psMaskType mark)
    67 {
     66bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode,
     67                         psMaskType maskVal, psMaskType mark)
     68{
     69    PS_ASSERT_PTR_NON_NULL(source, false);
     70    PS_ASSERT_PTR_NON_NULL(psf, false);
    6871
    6972    int status = false;
     
    269272bool pmSourcePhotometryModel (float *fitMag, pmModel *model)
    270273{
     274    PS_ASSERT_PTR_NON_NULL(fitMag, false);
     275    if (model == NULL) {
     276        return false;
     277    }
    271278
    272279    float fitSum = 0;
    273280    *fitMag = NAN;
    274 
    275     if (model == NULL) {
    276         return false;
    277     }
    278281
    279282    // measure fitMag
     
    289292
    290293// return source aperture magnitude
    291 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal)
    292 {
     294bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask,
     295                             psMaskType maskVal)
     296{
     297    PS_ASSERT_PTR_NON_NULL(apMag, false);
     298    PS_ASSERT_PTR_NON_NULL(image, false);
     299    PS_ASSERT_PTR_NON_NULL(mask, false);
     300    PS_ASSERT_PTR_NON_NULL(model, false);
     301
    293302    float apSum = 0;
    294303    float sky = 0;
    295304    *apMag = NAN;
    296 
    297     if (model == NULL) {
    298         psError(PM_ERR_OBJECTS, true, "Model is NULL");
    299         return false;
    300     }
    301305
    302306    if (DO_SKY) {
     
    327331
    328332// return source aperture magnitude
    329 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal)
    330 {
     333bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask,
     334                          psMaskType maskVal)
     335{
     336    PS_ASSERT_PTR_NON_NULL(pixWeight, false);
     337    PS_ASSERT_PTR_NON_NULL(image, false);
     338    PS_ASSERT_PTR_NON_NULL(mask, false);
     339    PS_ASSERT_PTR_NON_NULL(model, false);
     340
    331341    float modelSum = 0;
    332342    float validSum = 0;
     
    339349
    340350    *pixWeight = 0.0;
    341 
    342     if (model == NULL)
    343         return false;
    344351
    345352    // we only care about the value of the object model, not the local sky
     
    412419                             const bool unweighted_sum) // should the cross product be weighted?
    413420{
     421    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     422    PS_ASSERT_PTR_NON_NULL(Mj, NAN);
    414423
    415424    int Xs, Xe, Ys, Ye;
     
    475484                           const bool unweighted_sum) // should the cross product be weighted?
    476485{
     486    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     487    PS_ASSERT_PTR_NON_NULL(Mj, NAN);
    477488
    478489    int Xs, Xe, Ys, Ye;
     
    538549                      const bool unweighted_sum) // should the cross product be weighted?
    539550{
     551    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
    540552    double flux = 0, wt = 0, factor = 0;
    541553
     
    587599# endif
    588600
    589 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psMaskType maskVal)
    590 {
     601bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight,
     602                    psMaskType maskVal)
     603{
     604    PS_ASSERT_PTR_NON_NULL(model, false);
     605    PS_ASSERT_PTR_NON_NULL(image, false);
     606    PS_ASSERT_PTR_NON_NULL(mask, false);
     607    PS_ASSERT_PTR_NON_NULL(weight, false);
    591608
    592609    double dC = 0.0;
     
    613630                      const bool unweighted_sum) // should the cross product be weighted?
    614631{
     632    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
    615633    double flux = 0, wt = 0, factor = 0;
    616634
     
    662680                              const bool unweighted_sum) // should the cross product be weighted?
    663681{
     682    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     683    PS_ASSERT_PTR_NON_NULL(Mj, NAN);
    664684    int Xs, Xe, Ys, Ye;
    665685    int xi, xj, yi, yj;
     
    724744                             const bool unweighted_sum) // should the cross product be weighted?
    725745{
    726 
     746    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     747    PS_ASSERT_PTR_NON_NULL(Mj, NAN);
    727748    int Xs, Xe, Ys, Ye;
    728749    int xi, xj, yi, yj;
  • trunk/psModules/src/objects/pmSourcePlotApResid.c

    r14938 r15562  
    44 *  @author EAM, IfA
    55 *
    6  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-09-21 00:09:05 $
     6 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-11-10 01:09:20 $
    88 *  Copyright 2006 IfA, University of Hawaii
    99 */
     
    4040    # include <kapa.h>
    4141
    42     // plot the sx, sy, sxy as vector field,
    43     // plot the PSF measured sx, sy, sxy as vector field
    44     // pull the sources from the config / file?
    45     bool pmSourcePlotApResid (const pmFPAview *view, pmFPAfile *file, const pmConfig *config, pmSourcePlotLayout *layout)
     42// plot the sx, sy, sxy as vector field,
     43// plot the PSF measured sx, sy, sxy as vector field
     44// pull the sources from the config / file?
     45bool pmSourcePlotApResid (const pmFPAview *view, pmFPAfile *file, const pmConfig *config,
     46                          pmSourcePlotLayout *layout)
    4647{
     48    PS_ASSERT_PTR_NON_NULL(view, false);
     49    PS_ASSERT_PTR_NON_NULL(file, false);
     50    PS_ASSERT_PTR_NON_NULL(config, false);
     51    PS_ASSERT_PTR_NON_NULL(layout, false);
    4752
    4853    Graphdata graphdata;
     
    150155# else
    151156
    152     bool pmSourcePlotApResid (const pmFPAview *view, pmFPAfile *file, const pmConfig *config, pmSourcePlotLayout *layout)
     157bool pmSourcePlotApResid (const pmFPAview *view, pmFPAfile *file, const pmConfig *config, pmSourcePlotLayout *layout)
    153158{
    154159    psLogMsg ("psphot", 3, "skipping ap-mag resid plot");
  • trunk/psModules/src/objects/pmSourcePlotMoments.c

    r14938 r15562  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-09-21 00:09:05 $
     7 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-11-10 01:09:20 $
    99 *
    1010 *  Copyright 2006 IfA, University of Hawaii
     
    4141// this variable is defined in psmodules.h if ohana-config is found
    4242# if (HAVE_KAPA)
    43     # include <kapa.h>
     43# include <kapa.h>
    4444
    45     // plot the sx, sy moments plane (faint and bright sources)
    46     bool pmSourcePlotMoments (const pmFPAview *view, pmFPAfile *file, const pmConfig *config, pmSourcePlotLayout *layout)
     45// plot the sx, sy moments plane (faint and bright sources)
     46bool pmSourcePlotMoments (const pmFPAview *view, pmFPAfile *file, const pmConfig *config,
     47                          pmSourcePlotLayout *layout)
    4748{
     49    PS_ASSERT_PTR_NON_NULL(view, false);
     50    PS_ASSERT_PTR_NON_NULL(file, false);
     51    PS_ASSERT_PTR_NON_NULL(config, false);
     52    PS_ASSERT_PTR_NON_NULL(layout, false);
    4853
    4954    Graphdata graphdata;
  • trunk/psModules/src/objects/pmSourcePlotPSFModel.c

    r14938 r15562  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-09-21 00:09:05 $
     7 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-11-10 01:09:20 $
    99 *
    1010 *  Copyright 2006 IfA, University of Hawaii
     
    4141// this variable is defined in psmodules.h if ohana-config is found
    4242# if (HAVE_KAPA)
    43     # include <kapa.h>
    44 
    45     // plot the sx, sy, sxy as vector field,
    46     // plot the PSF measured sx, sy, sxy as vector field
    47     // pull the sources from the config / file?
    48     bool pmSourcePlotPSFModel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config, pmSourcePlotLayout *layout)
     43# include <kapa.h>
     44
     45// plot the sx, sy, sxy as vector field,
     46// plot the PSF measured sx, sy, sxy as vector field
     47// pull the sources from the config / file?
     48bool pmSourcePlotPSFModel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config,
     49                           pmSourcePlotLayout *layout)
    4950{
     51    PS_ASSERT_PTR_NON_NULL(view, false);
     52    PS_ASSERT_PTR_NON_NULL(file, false);
     53    PS_ASSERT_PTR_NON_NULL(config, false);
     54    PS_ASSERT_PTR_NON_NULL(layout, false);
    5055
    5156    Graphdata graphdata;
  • trunk/psModules/src/objects/pmSourcePlots.c

    r13214 r15562  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-05-04 00:54:09 $
     7 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-11-10 01:09:20 $
    99 *
    1010 *  Copyright 2006 IfA, University of Hawaii
     
    3636    PS_ASSERT_PTR_NON_NULL(view, false);
    3737    PS_ASSERT_PTR_NON_NULL(file, false);
     38    PS_ASSERT_PTR_NON_NULL(config, false);
    3839
    3940    if ((view->readout != -1) || (view->cell != -1)) {
     
    149150}
    150151
     152bool psMemCheckSourcePlotLayout(psPtr ptr)
     153{
     154    PS_ASSERT_PTR(ptr, false);
     155    return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmSourcePlotLayoutFree);
     156}
     157
     158
    151159/* we have three types of plots to produce (maybe more?)
    152160 * for each plot, we need to supply the following information:
  • trunk/psModules/src/objects/pmSourcePlots.h

    r13214 r15562  
    44 * @author EAM, IfA
    55 *
    6  * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-05-04 00:54:09 $
     6 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-11-10 01:09:20 $
    88 * Copyright 2006 Institute for Astronomy, University of Hawaii
    99 */
     
    3030
    3131pmSourcePlotLayout *pmSourcePlotLayoutAlloc();
     32bool psMemCheckSourcePlotLayout(psPtr ptr);
    3233
    3334bool pmFPAviewWriteSourcePlot(const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
  • trunk/psModules/src/objects/pmSourceUtils.c

    r14938 r15562  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-09-21 00:09:05 $
     8 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-11-10 01:09:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6363}
    6464
    65 pmSource *pmSourceFromModel (pmModel *model, pmReadout *readout, float radius, pmSourceType type) {
     65pmSource *pmSourceFromModel (pmModel *model, pmReadout *readout, float radius,
     66                             pmSourceType type)
     67{
     68    PS_ASSERT_PTR_NON_NULL(model, NULL);
     69    PS_ASSERT_PTR_NON_NULL(readout, NULL);
    6670
    6771    pmSource *source = pmSourceAlloc ();
  • trunk/psModules/src/objects/pmTrend2D.c

    r15417 r15562  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-10-30 00:50:00 $
    7  *
     5 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-11-10 01:09:20 $
    87 *  Copyright 2004 Institute for Astronomy, University of Hawaii
    98 *
  • trunk/psModules/src/objects/pmTrend2D.h

    r15000 r15562  
    55 * @author EAM, IfA
    66 *
    7  * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-09-24 21:27:58 $
     7 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2007-11-10 01:09:20 $
    99 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1010 */
     
    3434pmTrend2D *pmTrend2DAlloc (pmTrend2DMode mode, psImage *image, int nXtrend, int nYtrend, psStats *stats);
    3535
     36bool psMemCheckTrend2D(psPtr ptr);
     37
    3638pmTrend2D *pmTrend2DNoImageAlloc (pmTrend2DMode mode, psImageBinning *binning, psStats *stats);
    3739
  • trunk/psastro/src/Makefile.am

    r12806 r15562  
    3333        psastroLuminosityFunction.c \
    3434        psastroRefstarSubset.c      \
     35        psastroEnforceChips.c       \
    3536        psastroMosaicAstrom.c       \
    3637        psastroMosaicGradients.c    \
  • trunk/psastro/src/psastro.h

    r15195 r15562  
    2727bool              psastroDataSave (pmConfig *config);
    2828bool              psastroDefineFiles (pmConfig *config, pmFPAfile *input);
     29bool              psastroDefineFile (pmConfig *config, pmFPA *input, char *filerule, char *argname, pmFPAfileType fileType, pmDetrendType detrendType);
    2930bool              psastroAnalysis (pmConfig *config);
    3031
     
    7475bool              psastroDumpStars (psArray *stars, char *filename);
    7576bool              psastroDumpMatchedStars (char *filename, psArray *rawstars, psArray *refstars, psArray *match);
     77bool              psastroDumpGradients (psArray *gradients, char *filename);
    7678
    7779bool              psastroMosaicSetAstrom_tmp (pmFPA *fpa);
    7880int               psastroSortByMag (const void *a, const void *b);
    7981
     82bool              psastroEnforceChips (pmConfig *config, pmFPA *fpa, psMetadata *recipe);
     83
     84psArray *psastroReadGetstarCatalog (psFits *fits);
     85psArray *psastroReadGetstar_PS1_DEV_0 (psFits *fits);
     86
    8087# endif /* PSASTRO_H */
  • trunk/psastro/src/psastroAnalysis.c

    r15245 r15562  
    1616        return true;
    1717    }
    18 
    19     // XXX test retrun
    20     // return true;
    2118
    2219    // load the reference stars overlapping the data stars
  • trunk/psastro/src/psastroArguments.c

    r12992 r15562  
    3636        psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_META_REPLACE, "", argv[N]);
    3737        psArgumentRemove (N, &argc, argv);
     38    }
     39   
     40    // apply the chip correction based on the reference astrometry?
     41    if ((N = psArgumentGet (argc, argv, "-fixchips"))) {
     42        psArgumentRemove (N, &argc, argv);
     43        psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.FIX.CHIPS", PS_META_REPLACE, "", true);
     44    }
     45    // define the reference astrometry file
     46    status = pmConfigFileSetsMD (config->arguments, &argc, argv, "REF.ASTROM", "-refastrom", "-refastromlist");
     47    if (status) {
     48        // if supplied, assume -fixchips is desired
     49        psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.FIX.CHIPS", PS_META_REPLACE, "", true);
    3850    }
    3951
  • trunk/psastro/src/psastroDefineFiles.c

    r14212 r15562  
    44
    55    // these calls bind the I/O handle to the specified fpa
    6     pmFPAfile *output = NULL;
     6    bool status;
    77
    8     output = pmFPAfileDefineOutput (config, input->fpa, "PSASTRO.OUTPUT");
     8    // select the current recipe
     9    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);
     10    if (!recipe) {
     11        psError(PSASTRO_ERR_CONFIG, false, "Can't find PSASTRO recipe!\n");
     12        return false;
     13    }
     14
     15    pmFPAfile *output = pmFPAfileDefineOutput (config, input->fpa, "PSASTRO.OUTPUT");
    916    if (!output) {
    1017        psError(PSASTRO_ERR_CONFIG, false, "Failed to build FPA from PSASTRO.INPUT");
     
    1219    }
    1320    output->save = true;
     21
     22    bool fixChips = psMetadataLookupBool (&status, recipe, "PSASTRO.FIX.CHIPS");
     23
     24    if (fixChips) {
     25        if (!psastroDefineFile (config, input->fpa, "PSASTRO.REF.ASTROM", "REF.ASTROM", PM_FPA_FILE_ASTROM, PM_DETREND_TYPE_ASTROM)) {
     26            psError (PS_ERR_IO, false, "Can't find a reference astrometry file");
     27            return NULL;
     28        }
     29    }
    1430
    1531# if (0)
     
    2541    return true;
    2642}
     43
     44bool psastroDefineFile (pmConfig *config, pmFPA *input, char *filerule, char *argname, pmFPAfileType fileType, pmDetrendType detrendType) {
     45
     46    bool status;
     47    pmFPAfile *file;
     48
     49    // look for the file on the argument list
     50    file = pmFPAfileDefineFromArgs  (&status, config, filerule, argname);
     51    if (!status) {
     52        psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
     53        return false;
     54    }
     55    if (file) {
     56        if (file->type != fileType) {
     57            psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType));
     58            return false;
     59        }
     60        return true;
     61    }
     62
     63    // look for the file in the camera config table
     64    file = pmFPAfileDefineFromConf  (&status, config, filerule);
     65    if (!status) {
     66        psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
     67        return false;
     68    }
     69    if (file) {
     70        if (file->type != fileType) {
     71            psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType));
     72            return false;
     73        }
     74        return true;
     75    }
     76
     77    // look for the file to be loaded from the detrend database
     78    file = pmFPAfileDefineFromDetDB (&status, config, filerule, input, detrendType);
     79    if (!status) {
     80        psError (PS_ERR_UNKNOWN, false, "failed to load file definition");
     81        return false;
     82    }
     83    if (file) {
     84        if (file->type != fileType) {
     85            psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType));
     86            return false;
     87        }
     88        return true;
     89    }
     90    return false;
     91}
     92
  • trunk/psastro/src/psastroDemoDump.c

    r15199 r15562  
    173173    return true;
    174174}
     175
     176// this function is used for test purposes (-trace psastro.dump 1)
     177bool psastroDumpGradients (psArray *gradients, char *filename) {
     178
     179    FILE *f = fopen (filename, "w");
     180
     181    for (int i = 0; i < gradients->n; i++) {
     182        pmAstromGradient *gradient = gradients->data[i];
     183
     184        // write out the refstar data
     185        fprintf (f, "%d  %f %f   %f %f  %f %f\n", i,
     186                 gradient->FP.x, gradient->FP.y,
     187                 gradient->dTPdL.x, gradient->dTPdL.y,
     188                 gradient->dTPdM.x, gradient->dTPdM.y);
     189    }
     190
     191    fclose (f);
     192    return true;
     193}
     194
  • trunk/psastro/src/psastroLoadRefstars.c

    r15538 r15562  
    1515    float DECmin = DEG_RAD*psMetadataLookupF32(NULL, recipe, "DEC_MIN");
    1616    float DECmax = DEG_RAD*psMetadataLookupF32(NULL, recipe, "DEC_MAX");
    17     // float MAGmax = psMetadataLookupF32(NULL, recipe, "MAG_MAX");
    1817
    1918    // XXX CATDIR needs to look up abstracted name from psastro.config
     
    2524    char *getstarCommand = psStringCopy(psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR"));
    2625    PS_ASSERT (getstarCommand, NULL);
     26
     27    char *outformat = psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR.OUTFORMAT");
     28    PS_ASSERT (outformat, NULL);
     29
     30    char *photcode = psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR.PHOTCODE");
     31    PS_ASSERT (photcode, NULL);
     32
     33    float MAGmax = psMetadataLookupF32(NULL, recipe, "DVO.GETSTAR.MAG.MAX");
    2734
    2835    // issue the following command:
     
    3946    psTimerStart ("psastro");
    4047
    41     // use fork to add timeout capability
     48    // supply a known output format (for CATALOG output) so the code below knows what to read
    4249    if (ELIXIR_MODE) {
    43         psStringAppend (&getstarCommand, " -D CATFORMAT elixir");
     50        psStringAppend (&getstarCommand, " -D CATMODE mef -D CATFORMAT elixir");
    4451    } else {
    45         psStringAppend (&getstarCommand, " -D CATFORMAT panstarrs");
     52        psStringAppend (&getstarCommand, " -D CATMODE mef -D CATFORMAT panstarrs");
    4653    }
    4754
     
    5259    psFree(CATDIR);
    5360
    54     // psStringAppend (&getstarCommand, " -D CATMODE mef -maglim %f -region %f %f %f %f -o %s", MAGmax, RAmin, DECmin, RAmax, DECmax, tempFile);
    55     // XXX TEST : no magnitude limit
    56     // XXX need to specify the desired photometry system
    57     psStringAppend (&getstarCommand, " -D CATMODE mef -region %f %f %f %f -o %s", RAmin, DECmin, RAmax, DECmax, tempFile);
     61    // supply the max magnitude, the output format, and the photcode
     62    psStringAppend (&getstarCommand, " -maglim %f -format %s -photcode %s", MAGmax, outformat, photcode);
     63
     64    // add region and output filename
     65    psStringAppend (&getstarCommand, " -region %f %f %f %f -o %s", RAmin, DECmin, RAmax, DECmax, tempFile);
    5866    psTrace ("psastro", 3, "%s\n", getstarCommand);
    5967
    6068    // XXX use psPipe: catch stderr, stdout, allow for Nsec timeout...
     69    // use fork to add timeout capability
    6170    status = system (getstarCommand);
    6271    if (status) {
     
    7180    psFits *fits = psFitsOpen (tempFile, "r");
    7281
     82    psTimerStart ("psastro");
     83
     84    psArray *refstars = NULL;
     85    if (!strcmp (outformat, "CATALOG")) {
     86      refstars = psastroReadGetstarCatalog (fits);
     87    }
     88    if (!strcmp (outformat, "PS1_DEV_0")) {
     89      refstars = psastroReadGetstar_PS1_DEV_0 (fits);
     90    }
     91    if (refstars == NULL) {
     92        psError(PSASTRO_ERR_REFSTARS, true, "error reading reference data\n");
     93        return NULL;
     94    }
     95    psLogMsg ("psastro", 3, "loaded %ld reference stars : %f sec\n", refstars->n, psTimerMark ("psastro"));
     96
     97    psTrace ("psastro", 3, "loaded %ld reference stars from (%10.6f,%10.6f) - (%10.6f,%10.6f)\n",
     98             refstars->n, RAmin, DECmin, RAmax, DECmax);
     99
     100    psFitsClose (fits);
     101    unlink (tempFile);
     102
     103    // dump or plot the available refstars
     104    if (psTraceGetLevel("psastro.dump") > 0) {
     105        psastroDumpRefstars (refstars, "refstars.dat");
     106    }
     107
     108    if (psTraceGetLevel("psastro.plot") > 0) {
     109        psastroPlotRefstars (refstars, recipe);
     110    }
     111
     112    return refstars;
     113}
     114
     115psArray *psastroReadGetstarCatalog (psFits *fits) {
     116
     117    bool status;
     118
    73119    if (ELIXIR_MODE) {
    74120        psFitsMoveExtName (fits, "DVO_AVERAGE_ELIXIR");
     
    77123    }
    78124
    79     psTimerStart ("psastro");
    80125    long numSources = psFitsTableSize(fits); // Number of sources in table
    81126
     
    102147        psFree (row);
    103148    }
    104     psLogMsg ("psastro", 3, "loaded %ld reference stars : %f sec\n", refstars->n, psTimerMark ("psastro"));
    105 
    106     psTrace ("psastro", 3, "loaded %ld reference stars from (%10.6f,%10.6f) - (%10.6f,%10.6f)\n",
    107              refstars->n, RAmin, DECmin, RAmax, DECmax);
    108 
    109     psFitsClose (fits);
    110     unlink (tempFile);
    111 
    112     // dump or plot the available refstars
    113     if (psTraceGetLevel("psastro.dump") > 0) {
    114         psastroDumpRefstars (refstars, "refstars.dat");
    115     }
    116 
    117     if (psTraceGetLevel("psastro.plot") > 0) {
    118         psastroPlotRefstars (refstars, recipe);
    119     }
    120 
    121149    return refstars;
    122150}
     151
     152psArray *psastroReadGetstar_PS1_DEV_0 (psFits *fits) {
     153
     154    bool status;
     155
     156    psFitsMoveExtName (fits, "GETSTAR_PS1_DEV_0");
     157
     158    long numSources = psFitsTableSize(fits); // Number of sources in table
     159
     160    // convert the Average table to the pmAstromObj entries
     161    psArray *refstars = psArrayAllocEmpty (numSources);
     162    for (int i = 0; i < numSources; i++) {
     163        pmAstromObj *ref = pmAstromObjAlloc ();
     164
     165        psMetadata *row = psFitsReadTableRow(fits, i); // Table row
     166
     167        ref->sky->r   = RAD_DEG*psMetadataLookupF32 (&status, row, "RA");
     168        ref->sky->d   = RAD_DEG*psMetadataLookupF32 (&status, row, "DEC");
     169        ref->Mag      = psMetadataLookupS32 (&status, row, "MAG");
     170
     171        psArrayAdd (refstars, 100, ref);
     172        psFree (ref);
     173        psFree (row);
     174    }
     175    return refstars;
     176}
  • trunk/psastro/src/psastroMosaicAstrom.c

    r15260 r15562  
    2121    pmFPA *fpa = input->fpa;
    2222
    23     // XXX before we do object matches, we need to fix failed chips
    24     // compare chips with supplied mosaic model
    25     // adjust significant outliers to match model
     23    // before we do object matches, we need to (optionally) fix failed chips.  We compare chips with
     24    // the supplied mosaic model.  Adjust significant outliers to match model. 
     25    if (!psastroEnforceChips (config, fpa, recipe)) {
     26        psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips");
     27        return false;
     28    }
    2629
    2730    // given the existing per-chip astrometry, determine matches between raw and ref stars
  • trunk/psastro/src/psastroMosaicGradients.c

    r15258 r15562  
    11# include "psastroInternal.h"
     2static int nPass = 0;
    23
    34bool psastroMosaicGradients (pmFPA *fpa, psMetadata *recipe) {
     
    5051    }
    5152
     53    // if desired, dump the gradients to a file
     54    if (psTraceGetLevel("psastro.dump") > 0) {
     55        char name[80];
     56        sprintf (name, "gradients.%d.dat", nPass);
     57        psastroDumpGradients (gradients, name);
     58        nPass ++;
     59    }
     60
    5261    // allocate mosaic-level polynomial transformation and set masks needed by DVO
    5362    int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.ORDER");
  • trunk/psastro/src/psastroMosaicOneChip.c

    r15259 r15562  
    5555        return false;
    5656    }
     57
     58    psLogMsg ("psastro", PS_LOG_DETAIL, "mosaic fit chip order %d", order);
    5759
    5860    // create output toFPA; set masks appropriate to the Elixir DVO astrometry format if we are
  • trunk/psastro/src/psastroMosaicSetMatch.c

    r12806 r15562  
    1515    if (!status) {
    1616        psError(PS_ERR_IO, false, "Failed to lookup matching radius: %s", radiusWord);
    17         return NULL;
     17        return false;
    1818    }
     19
     20    if (RADIUS <= 0.0) {
     21        if (iteration == 0) {
     22            psError(PS_ERR_IO, false, "Invalid match radius for first iteration: %s", radiusWord);
     23            return false;
     24        }
     25        psWarning ("skipping match for iteration %d\n", iteration);
     26        return true;
     27    }
    1928
    2029    // this loop selects the matched stars for all chips
  • trunk/psphot/src/Makefile.am

    r15040 r15562  
    4747        psphotModelWithPSF.c     \
    4848        psphotExtendedSources.c  \
     49        psphotRadialProfile.c    \
    4950        psphotPetrosian.c        \
    5051        psphotIsophotal.c        \
  • trunk/psphot/src/psphot.h

    r15040 r15562  
    116116psKernel       *psphotKernelFromPSF (pmSource *source, int nPix);
    117117
     118bool            psphotRadialProfile (pmSource *source, psMetadata *recipe, psMaskType maskVal);
    118119bool            psphotPetrosian (pmSource *source, psMetadata *recipe, psMaskType maskVal);
    119120bool            psphotIsophotal (pmSource *source, psMetadata *recipe, psMaskType maskVal);
  • trunk/psphot/src/psphotAnnuli.c

    r13983 r15562  
    33bool psphotAnnuli (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
    44
    5   psLogMsg ("psphot", PS_LOG_INFO, "not implemented\n");
     5  assert (source->extpars);
     6  assert (source->extpars->profile);
     7  assert (source->extpars->profile->radius);
     8  assert (source->extpars->profile->flux);
     9
     10  bool status;
     11
     12  psVector *radius = source->extpars->profile->radius;
     13  psVector *weight = source->extpars->profile->weight;
     14  psVector *flux = source->extpars->profile->flux;
     15
     16  // XXX how do I define the radii?  we can put a vector in the recipe...
     17  // radialBins defines the bounds or start and stop (we can skip some that way...
     18  psVector *radialBinsLower = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.LOWER");
     19  psVector *radialBinsUpper = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.UPPER");
     20  assert (radialBinsLower->n == radialBinsUpper->n);
     21
     22  psVector *fluxValues = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32);
     23  psVector *fluxSquare = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32);
     24  psVector *fluxWeight = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32);
     25  psVector *pixelCount = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32);
     26  psVectorInit (fluxValues, 0.0);
     27  psVectorInit (fluxSquare, 0.0);
     28  psVectorInit (fluxWeight, 0.0);
     29  psVectorInit (pixelCount, 0.0);
     30
     31  // XXX this code assumes the radii are in pixels.  convert from arcsec with plate scale
     32  // XXX assume the annulii above are not overlapping?  much faster...
     33  // XXX this might be must faster in the reverse order: loop over annulii and use disection to
     34  // skip to the start of the annulus.
     35  for (int i = 0; i < flux->n; i++) {
     36    for (int j = 0; j < radialBinsLower->n; j++) {
     37      if (radius->data.F32[i] < radialBinsLower->data.F32[j]) continue;
     38      if (radius->data.F32[i] > radialBinsUpper->data.F32[j]) continue;
     39      fluxValues->data.F32[j] += flux->data.F32[i];
     40      fluxSquare->data.F32[j] += PS_SQR(flux->data.F32[i]);
     41      fluxWeight->data.F32[j] += weight->data.F32[i];
     42      pixelCount->data.F32[j] += 1.0;
     43    }
     44  }
     45
     46  for (int j = 0; j < radialBinsLower->n; j++) {
     47    fluxValues->data.F32[j] /= pixelCount->data.F32[j];
     48    fluxSquare->data.F32[j] /= pixelCount->data.F32[j];
     49    fluxSquare->data.F32[j] -= PS_SQR(fluxValues->data.F32[j]);
     50  }
     51 
     52  source->extpars->annuli = pmSourceAnnuliAlloc ();
     53  source->extpars->annuli->flux    = fluxValues;
     54  source->extpars->annuli->fluxErr = fluxWeight;
     55  source->extpars->annuli->fluxVar = fluxSquare;
     56
    657  return true;
     58}
    759
    8 }
  • trunk/psphot/src/psphotExtendedSources.c

    r13983 r15562  
    6666            return false;
    6767        } else {
     68          // XXX why am I caching the model?
    6869            pmSourceCacheModel (source, maskVal); // XXX put this in the source model function?
    6970            psTrace ("psphot", 5, "psf-convolved model for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
    7071            Npsf ++;
     72        }
     73
     74        // all of these below require the radial profile
     75        // XXX push this as a test and call in each of the functions below?
     76        // XXX this constructs a pmSourceExtendedParameters element
     77        if (doPetrosian || doIsophotal || doAnnuli || doKron) {
     78          if (!psphotRadialProfile (source, recipe, maskVal)) {
     79            psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate radial profile");
     80            return false;
     81          }
    7182        }
    7283
  • trunk/psphot/src/psphotIsophotal.c

    r13983 r15562  
    33bool psphotIsophotal (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
    44
    5   psLogMsg ("psphot", PS_LOG_INFO, "not implemented\n");
     5  assert (source->extpars);
     6  assert (source->extpars->profile);
     7  assert (source->extpars->profile->radius);
     8  assert (source->extpars->profile->flux);
     9
     10  bool status;
     11
     12  psVector *radius = source->extpars->profile->radius;
     13  psVector *flux = source->extpars->profile->flux;
     14
     15  // flux at which to measure isophotal parameters
     16  // XXX cache this?
     17  float ISOPHOT_FLUX = psMetadataLookupF32 (&status, recipe, "ISOPHOTAL_FLUX");
     18
     19  // find the first bin below the flux level and the last above the level
     20  // XXX can this be done faster with disection?
     21  // XXX do I need to worry about crazy outliers? 
     22  // XXX should i be smoothing or fitting the curve?
     23  int firstBelow = -1;
     24  int lastAbove = -1;
     25  for (int i = 0; i < flux->n; i++) {
     26    if (flux->data.F32[i] > ISOPHOT_FLUX) lastAbove = i;
     27    if ((firstBelow < 0) && (flux->data.F32[i] < ISOPHOT_FLUX)) firstBelow = i;
     28  }
     29
     30  // need to examine pixels in this vicinity
     31  float isophotalFluxFirst = 0;
     32  float isophotalFluxLast = 0;
     33  for (int i = 0; i <= PS_MAX(firstBelow, lastAbove); i++) {
     34    if (i <= firstBelow) {
     35      isophotalFluxFirst += flux->data.F32[i];
     36    }
     37    if (i <= lastAbove) {
     38      isophotalFluxLast += flux->data.F32[i];
     39    }
     40  }
     41  float isophotalFlux    = 0.5*(isophotalFluxLast + isophotalFluxFirst);
     42  float isophotalFluxErr = 0.5*fabs(isophotalFluxLast - isophotalFluxFirst);
     43
     44  float isophotalRad     = 0.5*(radius->data.F32[firstBelow] + radius->data.F32[lastAbove]);
     45  float isophotalRadErr  = 0.5*fabs(radius->data.F32[firstBelow] - radius->data.F32[lastAbove]);
     46
     47  if (!source->extpars->isophot) {
     48    source->extpars->isophot = pmSourceIsophotalValuesAlloc ();
     49  }
     50 
     51  // these are uncalibrated: instrumental mags and pixel units
     52  source->extpars->isophot->mag    = -2.5*log10(isophotalFlux);
     53  source->extpars->isophot->magErr = isophotalFluxErr / isophotalFlux;
     54
     55  source->extpars->isophot->rad    = isophotalRad;
     56  source->extpars->isophot->radErr = isophotalRadErr;
     57
    658  return true;
    759
  • trunk/psphot/src/psphotMakeResiduals.c

    r14967 r15562  
    2828
    2929    float nSigma = psMetadataLookupF32(&status, recipe, "PSF.RESIDUALS.NSIGMA");
     30    PS_ASSERT (status, false);
     31
     32    float pixelSN = psMetadataLookupF32(&status, recipe, "PSF.RESIDUALS.PIX.SN");
    3033    PS_ASSERT (status, false);
    3134
     
    194197                resid->Rx->data.F32[oy][ox] = resid->Ry->data.F32[oy][ox] = 0.0;
    195198                //resid->weight->data.F32[oy][ox] = fluxStats->sampleStdev;
     199
     200                if (resid->Ro->data.F32[oy][ox] < pixelSN*fluxStats->sampleStdev) {
     201                  resid->mask->data.U8[oy][ox] = 1;
     202                }
     203
    196204            } else {
    197205                assert (SPATIAL_ORDER == 1);
     
    227235                resid->Rx->data.F32[oy][ox] = B->data.F64[1];
    228236                resid->Ry->data.F32[oy][ox] = B->data.F64[2];
     237
     238                float dRo = sqrt(A->data.F32[0][0]);
     239                if (resid->Ro->data.F32[oy][ox] < pixelSN*dRo) {
     240                  resid->mask->data.U8[oy][ox] = 1;
     241                }
    229242                //resid->weight->data.F32[oy][ox] = XXX;
    230243            }
  • trunk/psphot/src/psphotPetrosian.c

    r13983 r15562  
    33bool psphotPetrosian (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
    44
    5   psLogMsg ("psphot", PS_LOG_INFO, "not implemented\n");
     5  bool status;
     6
     7  assert (source->extpars);
     8  assert (source->extpars->profile);
     9  assert (source->extpars->profile->radius);
     10  assert (source->extpars->profile->flux);
     11
     12  psVector *radius = source->extpars->profile->radius;
     13  psVector *flux = source->extpars->profile->flux;
     14
     15  // flux at which to measure isophotal parameters
     16  // XXX cache this?
     17  float PETROSIAN_R0 = psMetadataLookupF32 (&status, recipe, "PETROSIAN_R0");
     18  float PETROSIAN_RF = psMetadataLookupF32 (&status, recipe, "PETROSIAN_FLUX_RATIO");
     19
     20  // first find flux at R0
     21  int firstBelow = -1;
     22  int lastAbove = -1;
     23  for (int i = 0; i < radius->n; i++) {
     24    if (radius->data.F32[i] > PETROSIAN_R0) lastAbove = i;
     25    if ((firstBelow < 0) && (flux->data.F32[i] < PETROSIAN_R0)) firstBelow = i;
     26  }
     27
     28  // average flux in this range
     29  float fluxR0 = 0.0;
     30  int fluxRn = 0;
     31  for (int i = PS_MIN(firstBelow, lastAbove); i <= PS_MAX(firstBelow, lastAbove); i++) {
     32    fluxR0 += flux->data.F32[i];
     33    fluxRn ++;
     34  }
     35  fluxR0 /= (float)(fluxRn);
     36 
     37  // target flux for petrosian radius
     38  float fluxRP = fluxR0 * PETROSIAN_RF;
     39
     40  // find the first bin below the flux level and the last above the level
     41  // XXX can this be done faster with disection?
     42  // XXX do I need to worry about crazy outliers? 
     43  // XXX should i be smoothing or fitting the curve?
     44  firstBelow = -1;
     45  lastAbove = -1;
     46  for (int i = 0; i < flux->n; i++) {
     47    if (flux->data.F32[i] > fluxRP) lastAbove = i;
     48    if ((firstBelow < 0) && (flux->data.F32[i] < fluxRP)) firstBelow = i;
     49  }
     50
     51  // need to examine pixels in this vicinity
     52  float fluxFirst = 0;
     53  float fluxLast = 0;
     54  for (int i = 0; i <= PS_MAX(firstBelow, lastAbove); i++) {
     55    if (i <= firstBelow) {
     56      fluxFirst += flux->data.F32[i];
     57    }
     58    if (i <= lastAbove) {
     59      fluxLast += flux->data.F32[i];
     60    }
     61  }
     62  float fluxRPSum    = 0.5*(fluxLast + fluxFirst);
     63  float fluxRPSumErr = 0.5*fabs(fluxLast - fluxFirst);
     64  // XXX need to use the weight appropriately here...
     65
     66  float rad     = 0.5*(radius->data.F32[firstBelow] + radius->data.F32[lastAbove]);
     67  float radErr  = 0.5*fabs(radius->data.F32[firstBelow] - radius->data.F32[lastAbove]);
     68
     69  if (!source->extpars->petrosian) {
     70    source->extpars->petrosian = pmSourcePetrosianValuesAlloc ();
     71  }
     72 
     73  // these are uncalibrated: instrumental mags and pixel units
     74  source->extpars->petrosian->mag    = -2.5*log10(fluxRPSum);
     75  source->extpars->petrosian->magErr = fluxRPSumErr / fluxRPSum;
     76
     77  source->extpars->petrosian->rad    = rad;
     78  source->extpars->petrosian->radErr = radErr;
     79
    680  return true;
    781
  • trunk/psphot/src/psphotRadialProfile.c

    r15357 r15562  
    55    // allocate pmSourceExtendedParameters, if not already defined
    66    if (!source->extpars) {
    7         source->extpars = pmSourceExtendedParametersAlloc ();
     7        source->extpars = pmSourceExtendedParsAlloc ();
    88    }
    99
    1010    if (!source->extpars->profile) {
    11         source->extpars->profile = pmSourceRadialProfile ();
     11        source->extpars->profile = pmSourceRadialProfileAlloc ();
    1212    }   
    1313   
     
    1919    psVector *radius = source->extpars->profile->radius;
    2020    psVector *flux   = source->extpars->profile->flux;
    21     psVector *weight = source->extpars->profile->radius;
     21    psVector *weight = source->extpars->profile->weight;
    2222
    2323    // XXX use the extended source model here for Xo, Yo?
     
    4040    flux->n = n;
    4141
    42     SortVectorsByRadius (radius, flux, weight);
     42    // XXX need to sort here
     43    // SortVectorsByRadius (radius, flux, weight);
    4344
    4445    return true;
Note: See TracChangeset for help on using the changeset viewer.