IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42093 for trunk/psModules


Ignore:
Timestamp:
Feb 28, 2022, 2:52:56 PM (4 years ago)
Author:
eugene
Message:

plug a memory leak in FITS table I/O; fix error in PSF fit map scale calculation; add options to use reweighted errors in non-linear source fitting; change concept for source size parameter guess from using the KRON radius to a size based on the second moments

Location:
trunk/psModules
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules

  • trunk/psModules/src/objects/models/pmModel_GAUSS.c

    r36857 r42093  
    203203
    204204    // set the shape parameters
    205     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
     205    // the last parameter is the scaling factor for Moments to shape parameter radius guess
     206    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false, 1.0)) {
    206207      return false;
    207208    }
  • trunk/psModules/src/objects/models/pmModel_HSC_V1.c

    r40491 r42093  
    223223
    224224    // set the shape parameters
    225     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
     225    // the last parameter is the scaling factor for Moments to shape parameter radius guess
     226    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false, 1.0)) {
    226227      return false;
    227228    }
  • trunk/psModules/src/objects/models/pmModel_PGAUSS.c

    r36857 r42093  
    204204
    205205    // set the shape parameters
    206     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
     206    // the last parameter is the scaling factor for Moments to shape parameter radius guess
     207    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false, 1.0)) {
    207208      return false;
    208209    }
  • trunk/psModules/src/objects/models/pmModel_PS1_V1.c

    r38280 r42093  
    223223
    224224    // set the shape parameters
    225     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
     225    // the last parameter is the scaling factor for Moments to shape parameter radius guess
     226    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false, 1.0)) {
    226227      return false;
    227228    }
  • trunk/psModules/src/objects/models/pmModel_QGAUSS.c

    r38280 r42093  
    224224
    225225    // set the shape parameters
    226     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
     226    // the last parameter is the scaling factor for Moments to shape parameter radius guess
     227    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false, 1.5)) {
    227228      return false;
    228229    }
  • trunk/psModules/src/objects/models/pmModel_RGAUSS.c

    r36857 r42093  
    213213
    214214    // set the shape parameters
    215     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
     215    // the last parameter is the scaling factor for Moments to shape parameter radius guess
     216    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false, 2.0)) {
    216217      return false;
    217218    }
  • trunk/psModules/src/objects/pmModelUtils.c

    r36859 r42093  
    179179// Reff says if this is a model which uses R_eff (like exp or dev) instead of Sigma
    180180// set the parameter values SXX, SXY, SYY
    181 bool pmModelSetShape (float *Sxx, float *Sxy, float *Syy, pmMoments *moments, bool useReff) {
     181// Scale allows some models to increase the guess size relative to Mxx,Myy
     182bool pmModelSetShape (float *Sxx, float *Sxy, float *Syy, pmMoments *moments, bool useReff, float Scale) {
    182183
    183184    psEllipseMoments emoments;
     
    190191
    191192    if (!isfinite(axes.major)) return false;
    192     if (axes.major == 0) return false;
    193193    if (!isfinite(axes.minor)) return false;
    194194    if (!isfinite(axes.theta)) return false;
    195     if (axes.major == 0) return false;
    196 
     195
     196    // set a lower limit to avoid absurd solutions..
     197    // NOTE: I should set the lower limit based on the PSF size, if known
     198    float Rmajor = PS_MAX(1.0, Scale * axes.major);
     199    float Rminor = Rmajor * (axes.minor / axes.major);
     200    axes.major = Rmajor;
     201    axes.minor = Rminor;
     202
     203    // EAM 2022.02.05 : Mrf is often much too large, disable this for now
    197204    // Mxx, Mxy, Myy define the elliptical shape, but Mrf defines the width
    198     float scale = (isfinite(moments->Mrf) && (moments->Mrf > 0.0)) ? moments->Mrf / axes.major : 1.0;
    199     axes.major *= scale;
    200     axes.minor *= scale;
     205    // float scale = (isfinite(moments->Mrf) && (moments->Mrf > 0.0)) ? moments->Mrf / axes.major : 1.0;
     206    // axes.major *= scale;
     207    // axes.minor *= scale;
    201208
    202209    pmModelAxesToParams (Sxx, Sxy, Syy, axes, useReff);
  • trunk/psModules/src/objects/pmModelUtils.h

    r35768 r42093  
    4444bool pmModelSetPosition (float *Xo, float *Yo, pmSource *source);
    4545bool pmModelSetNorm (float *Io, pmSource *source);
    46 bool pmModelSetShape (float *Sxx, float *Sxy, float *Syy, pmMoments *moments, bool useReff);
     46bool pmModelSetShape (float *Sxx, float *Sxy, float *Syy, pmMoments *moments, bool useReff, float Scale);
    4747
    4848bool pmModelUseReff (pmModelType type);
  • trunk/psModules/src/objects/pmPSFtryModel.c

    r36856 r42093  
    151151        if (Nx > Ny) {
    152152            options->psfTrendNx = i;
    153             options->psfTrendNy = PS_MAX (orderMin, (int)(i * (Ny / Nx) + 0.5));
     153            options->psfTrendNy = PS_MAX (orderMin, (int)(i * (Ny / (float) Nx) + 0.5));
    154154        } else {
    155155            options->psfTrendNy = i;
    156             options->psfTrendNx = PS_MAX (orderMin, (int)(i * (Nx / Ny) + 0.5));
    157         }
     156            options->psfTrendNx = PS_MAX (orderMin, (int)(i * (Nx / (float) Ny) + 0.5));
     157        }
     158
     159        fprintf (stderr, "fitting %d x %d model for PSF\n", options->psfTrendNx, options->psfTrendNy);
    158160
    159161        // free existing data, if any
  • trunk/psModules/src/objects/pmSourceFitModel.c

    r36859 r42093  
    6969    opt->chisqConvergence = true;
    7070    opt->isInteractive = false;
     71    opt->useReweighting = false;
    7172
    7273    return opt;
     
    251252    myMin->chisqConvergence = options->chisqConvergence;
    252253    myMin->isInteractive = options->isInteractive;
     254    myMin->useReweighting = options->useReweighting;
    253255
    254256    psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32);
  • trunk/psModules/src/objects/pmSourceFitModel.h

    r36375 r42093  
    4040    bool chisqConvergence;
    4141    bool isInteractive;
     42    bool useReweighting;
    4243} pmSourceFitOptions;
    4344
  • trunk/psModules/src/objects/pmSourceIO_CMF.c.in

    r41892 r42093  
    296296    // generate an FITS table using the array of columns defined above, with space for all rows
    297297    psFitsTable *table = psFitsTableCreate (tableColumns, sources->n);
     298    psFree (tableColumns); // we are now done with the definition of the table columns
    298299
    299300    /************ write the data to the table *****************/
Note: See TracChangeset for help on using the changeset viewer.