IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5659


Ignore:
Timestamp:
Dec 2, 2005, 11:27:57 AM (21 years ago)
Author:
magnier
Message:

adding MOMENTS_SX,Y_MAX; adding pmModelStatus, cleaning pmSourceFitModel results

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_rel8_b2/psModules/src/objects/pmObjects.c

    r5606 r5659  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.2.6.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-11-26 02:48:02 $
     8 *  @version $Revision: 1.2.6.1.2.1 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-12-02 21:27:57 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8181    tmp->chisq = 0.0;
    8282    tmp->nIter = 0;
     83    tmp->radius = 0;
     84    tmp->status = PM_MODEL_UNTRIED;
     85
    8386    psS32 Nparams = pmModelParameterCount(type);
    8487    if (Nparams == 0) {
     
    916919        psImage *splane = NULL;
    917920        int binX, binY;
     921        bool status;
     922
     923        psF32 SX_MAX = psMetadataLookupF32 (&status, metadata, "MOMENTS_SX_MAX");
     924        if (!status)
     925            SX_MAX = 10.0;
     926        psF32 SY_MAX = psMetadataLookupF32 (&status, metadata, "MOMENTS_SY_MAX");
     927        if (!status)
     928            SY_MAX = 10.0;
    918929
    919930        // construct a sigma-plane image
    920931        // psImageAlloc does zero the data
    921         splane = psImageAlloc (NPIX/SCALE, NPIX/SCALE, PS_TYPE_F32);
     932        splane = psImageAlloc (SX_MAX/SCALE, SY_MAX/SCALE, PS_TYPE_F32);
    922933        for (int i = 0; i < splane->numRows; i++)
    923934        {
     
    10311042        psfClump.dY = stats->clippedStdev;
    10321043
    1033         psTrace (".pmObjects.pmSourceRoughClass", 2, "clump  X,  Y: %f, %f\n", psfClump.X, psfClump.Y);
    1034         psTrace (".pmObjects.pmSourceRoughClass", 2, "clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY);
     1044        psLogMsg ("pmObjects", 4, "clump  X,  Y: %f, %f\n", psfClump.X, psfClump.Y);
     1045        psLogMsg ("pmObjects", 4, "clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY);
    10351046        // these values should be pushed on the metadata somewhere
    10361047
     
    11601171    }
    11611172
    1162     psTrace (".pmObjects.pmSourceRoughClass", 2, "Nstar:    %3d\n", Nstar);
    1163     psTrace (".pmObjects.pmSourceRoughClass", 2, "Npsf:     %3d\n", Npsf);
    1164     psTrace (".pmObjects.pmSourceRoughClass", 2, "Ngal:     %3d\n", Ngal);
    1165     psTrace (".pmObjects.pmSourceRoughClass", 2, "Nsatstar: %3d\n", Nsatstar);
    1166     psTrace (".pmObjects.pmSourceRoughClass", 2, "Nsat:     %3d\n", Nsat);
    1167     psTrace (".pmObjects.pmSourceRoughClass", 2, "Ncr:      %3d\n", Ncr);
     1173    psLogMsg ("pmObjects", 4, "Nstar:    %3d\n", Nstar);
     1174    psLogMsg ("pmObjects", 4, "Npsf:     %3d\n", Npsf);
     1175    psLogMsg ("pmObjects", 4, "Ngal:     %3d\n", Ngal);
     1176    psLogMsg ("pmObjects", 4, "Nsatstar: %3d\n", Nsatstar);
     1177    psLogMsg ("pmObjects", 4, "Nsat:     %3d\n", Nsat);
     1178    psLogMsg ("pmObjects", 4, "Ncr:      %3d\n", Ncr);
     1179
     1180    // optional dump of all rough source data
     1181    {
     1182        bool status;
     1183        char *output = psMetadataLookupPtr (&status, metadata, "MOMENTS_OUTPUT_FILE");
     1184        if (status && (output != NULL) && (output[0]))
     1185        {
     1186            pmMomentsWriteText (sources, output);
     1187            psFree (output);
     1188        }
     1189    }
    11681190
    11691191    psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc);
    11701192    return(rc);
     1193}
     1194
     1195// write the moments to an output file
     1196bool pmMomentsWriteText (psArray *sources, char *filename)
     1197{
     1198
     1199    int i;
     1200    FILE *f;
     1201    pmSource *source;
     1202
     1203    f = fopen (filename, "w");
     1204    if (f == NULL) {
     1205        psLogMsg ("pmMomentsWriteText", 3, "can't open output file for moments%s\n", filename);
     1206        return false;
     1207    }
     1208
     1209    for (i = 0; i < sources->n; i++) {
     1210        source = (pmSource *) sources->data[i];
     1211        if (source->moments == NULL)
     1212            continue;
     1213        fprintf (f, "%5d %5d  %7.1f  %7.1f %7.1f  %6.3f %6.3f  %8.1f %7.1f %7.1f %7.1f  %4d %2d\n",
     1214                 source->peak->x, source->peak->y, source->peak->counts,
     1215                 source->moments->x, source->moments->y,
     1216                 source->moments->Sx, source->moments->Sy,
     1217                 source->moments->Sum, source->moments->Peak,
     1218                 source->moments->Sky, source->moments->SN,
     1219                 source->moments->nPixels, source->type);
     1220    }
     1221    fclose (f);
     1222    return true;
    11711223}
    11721224
     
    15751627    psBool fitStatus = true;
    15761628    psBool onPic     = true;
    1577     psBool rc        = true;
    15781629
    15791630    // XXX EAM : is it necessary for the mask & weight to exist?  the
     
    16021653        psTrace (".pmObjects.pmSourceFitModel", 4, "insufficient valid pixels\n");
    16031654        psTrace(__func__, 3, "---- %s(false) end ----\n", __func__);
     1655        model->status = PM_MODEL_BADARGS;
    16041656        return(false);
    16051657    }
     
    16421694    }
    16431695
    1644     // XXX EAM : covar must be F64?
     1696    // covar must be F64
    16451697    psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F64);
    16461698
     
    16531705    }
    16541706
    1655     // XXX EAM: we need to do something (give an error?) if rc is false
    1656     // XXX EAM: psMinimizeLMChi2 does not check convergence
    1657 
    1658     // XXX models can go insane: reject these
    1659     onPic &= (params->data.F32[2] >= source->pixels->col0);
    1660     onPic &= (params->data.F32[2] <  source->pixels->col0 + source->pixels->numCols);
    1661     onPic &= (params->data.F32[3] >= source->pixels->row0);
    1662     onPic &= (params->data.F32[3] <  source->pixels->row0 + source->pixels->numRows);
    1663 
    1664     // XXX EAM: save the resulting chisq, nDOF, nIter
     1707    // save the resulting chisq, nDOF, nIter
    16651708    model->chisq = myMin->value;
    16661709    model->nIter = myMin->iter;
    16671710    model->nDOF  = y->n - nParams;
    16681711
    1669     // XXX EAM get the Gauss-Newton distance for fixed model parameters
     1712    // get the Gauss-Newton distance for fixed model parameters
    16701713    if (paramMask != NULL) {
    16711714        psVector *delta = psVectorAlloc (params->n, PS_TYPE_F64);
     
    16791722    }
    16801723
     1724    // set the model success or failure status
     1725    if (!fitStatus) {
     1726        model->status = PM_MODEL_NONCONVERGE;
     1727    } else {
     1728        model->status = PM_MODEL_SUCCESS;
     1729    }
     1730
     1731    // models can go insane: save this status instead
     1732    onPic &= (params->data.F32[2] >= source->pixels->col0);
     1733    onPic &= (params->data.F32[2] <  source->pixels->col0 + source->pixels->numCols);
     1734    onPic &= (params->data.F32[3] >= source->pixels->row0);
     1735    onPic &= (params->data.F32[3] <  source->pixels->row0 + source->pixels->numRows);
     1736    if (!onPic) {
     1737        model->status = PM_MODEL_OFFIMAGE;
     1738    }
     1739
    16811740    psFree(x);
    16821741    psFree(y);
     
    16861745    psFree(paramMask);
    16871746
    1688     rc = (onPic && fitStatus);
    16891747    psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc);
    1690     return(rc);
     1748    return(onPic && fitStatus);
    16911749}
    16921750
Note: See TracChangeset for help on using the changeset viewer.