IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35468 for trunk/psphot


Ignore:
Timestamp:
May 1, 2013, 4:10:17 PM (13 years ago)
Author:
eugene
Message:

min radial aperture; do not unflag satstar; delete 2 smallest aps

Location:
trunk/psphot/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotEvalPSF.c

    r29606 r35468  
    6767            psTrace ("psphot", 5, "satstar failed fit");
    6868        }
     69        return false;
     70    }
     71
     72    // unless we prove otherwise, this object is a star.
     73    source->type = PM_SOURCE_TYPE_STAR;
     74
     75    // the following source->mode information pertains to modelPSF:
     76    source->mode |= PM_SOURCE_MODE_PSFMODEL;
     77
     78    // if the object has fitted peak above saturation, label as SATSTAR
     79    // this is a valid PSF object, but ignore the other quality tests
     80    // remember: fit does not use saturated pixels (masked)
     81    // XXX no extended object can saturate and stay extended...
     82
     83    // XXX this test is wrong : it should add back in the local sky from the model to test
     84    // against saturation the local sky is saved in source->sky after psphotMagnitudes is called
     85    if (model->params->data.F32[PM_PAR_I0] >= SATURATION) {
     86        if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
     87            psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");
     88        }
     89        source->mode |=  PM_SOURCE_MODE_SATSTAR;
     90        return true;
     91    }
     92
     93    // if the object has a fitted peak below 0.02, the source is not viable
     94    // perhaps the fit did not converge cleanly
     95    if (model->params->data.F32[PM_PAR_I0] <= 0.02) {
     96        source->mode |= PM_SOURCE_MODE_FAIL;
     97        if (source->mode & PM_SOURCE_MODE_SATSTAR) {
     98            psTrace ("psphot", 5, "satstar failed fit (peak below 0)");
     99        }
     100        return false;
     101    }
     102
     103    // if the source was predicted to be a SATSTAR, but it fitted below saturation,
     104    // make a note to the user.
     105    // XXX do not do this until we have a local measure of the sky in place
     106    if (false && (source->mode & PM_SOURCE_MODE_SATSTAR)) {
     107        psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");
     108        source->mode &= ~PM_SOURCE_MODE_SATSTAR;
     109    }
     110
     111    SN  = model->params->data.F32[PM_PAR_I0]/model->dparams->data.F32[PM_PAR_I0];
     112    Chi = model->chisqNorm / model->nDOF;
     113
     114    // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[]
     115    keep = TRUE;
     116    keep &= (SN > PSF_MIN_SN);
     117    keep &= (Chi < PSF_MAX_CHI);
     118
     119    if (source->mode & PM_SOURCE_MODE_SATSTAR) {
     120        psTrace ("psphot", 5, "satstar fit results: %f, %f  %d :  SN: %f  Chisq: %f\n",
     121                     model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], keep, SN, Chi);
     122    }
     123
     124    if (keep) {
     125        if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
     126            psTrace ("psphot", 7, "PSFSTAR kept (%f, %f  :  SN: %f Chisq: %f)\n",
     127                     model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
     128        }
     129        return true;
     130    }
     131
     132    // this source is not a star, warn if it was a PSFSTAR
     133    if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
     134        psTrace ("psphot", 5, "PSFSTAR demoted based on fit quality   (%f, %f  :  SN: %f  Chisq: %f)\n",
     135                  model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
     136    } else {
     137        psTrace ("psphot", 5, "fails PSF fit (%f, %f  :  SN: %f  Chisq: %f)\n",
     138                  model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
     139    }
     140
     141    // poor-quality fit; only keep if nothing else works...
     142    source->mode |= PM_SOURCE_MODE_POOR;
     143    return false;
     144}       
     145
     146// examine the model->status, fit parameters, etc and decide if the model succeeded
     147// set the source->type and source->mode appropriately
     148bool psphotEvalDBL (pmSource *source, pmModel *model) {
     149
     150    // do we actually have a valid PSF model?
     151    if (model == NULL) {
     152        source->mode &= ~PM_SOURCE_MODE_FITTED;
     153        return false;
     154    }
     155
     156    // was the model actually fitted?
     157    if (!(model->flags & PM_MODEL_STATUS_FITTED)) {
     158        source->mode &= ~PM_SOURCE_MODE_FITTED;
     159        return false;
     160    }
     161    // did the model fit fail for one or another reason?
     162    if (model->flags & (PM_MODEL_STATUS_BADARGS |
     163                        PM_MODEL_STATUS_NONCONVERGE |
     164                        PM_MODEL_STATUS_OFFIMAGE)) {
     165        source->mode |= PM_SOURCE_MODE_FAIL;
    69166        return false;
    70167    }
     
    88185    }
    89186
    90     // if the object has a fitted peak below 0.02, the source is not viable
    91     // perhaps the fit did not converge cleanly
     187    // if the object has a fitted peak below 0, the fit did not converge cleanly
    92188    if (model->params->data.F32[PM_PAR_I0] <= 0.02) {
    93189        source->mode |= PM_SOURCE_MODE_FAIL;
    94         if (source->mode & PM_SOURCE_MODE_SATSTAR) {
    95             psTrace ("psphot", 5, "satstar failed fit (peak below 0)");
    96         }
    97190        return false;
    98191    }
     
    104197        source->mode &= ~PM_SOURCE_MODE_SATSTAR;
    105198    }
    106 
    107     SN  = model->params->data.F32[PM_PAR_I0]/model->dparams->data.F32[PM_PAR_I0];
    108     Chi = model->chisqNorm / model->nDOF;
    109 
    110     // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[]
    111     keep = TRUE;
    112     keep &= (SN > PSF_MIN_SN);
    113     keep &= (Chi < PSF_MAX_CHI);
    114 
    115     if (source->mode & PM_SOURCE_MODE_SATSTAR) {
    116         psTrace ("psphot", 5, "satstar fit results: %f, %f  %d :  SN: %f  Chisq: %f\n",
    117                      model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], keep, SN, Chi);
    118     }
    119 
    120     if (keep) {
    121         if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    122             psTrace ("psphot", 7, "PSFSTAR kept (%f, %f  :  SN: %f Chisq: %f)\n",
    123                      model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
    124         }
    125         return true;
    126     }
    127 
    128     // this source is not a star, warn if it was a PSFSTAR
    129     if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    130         psTrace ("psphot", 5, "PSFSTAR demoted based on fit quality   (%f, %f  :  SN: %f  Chisq: %f)\n",
    131                   model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
    132     } else {
    133         psTrace ("psphot", 5, "fails PSF fit (%f, %f  :  SN: %f  Chisq: %f)\n",
    134                   model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
    135     }
    136 
    137     // poor-quality fit; only keep if nothing else works...
    138     source->mode |= PM_SOURCE_MODE_POOR;
    139     return false;
    140 }       
    141 
    142 // examine the model->status, fit parameters, etc and decide if the model succeeded
    143 // set the source->type and source->mode appropriately
    144 bool psphotEvalDBL (pmSource *source, pmModel *model) {
    145 
    146     // do we actually have a valid PSF model?
    147     if (model == NULL) {
    148         source->mode &= ~PM_SOURCE_MODE_FITTED;
    149         return false;
    150     }
    151 
    152     // was the model actually fitted?
    153     if (!(model->flags & PM_MODEL_STATUS_FITTED)) {
    154         source->mode &= ~PM_SOURCE_MODE_FITTED;
    155         return false;
    156     }
    157     // did the model fit fail for one or another reason?
    158     if (model->flags & (PM_MODEL_STATUS_BADARGS |
    159                         PM_MODEL_STATUS_NONCONVERGE |
    160                         PM_MODEL_STATUS_OFFIMAGE)) {
    161         source->mode |= PM_SOURCE_MODE_FAIL;
    162         return false;
    163     }
    164 
    165     // unless we prove otherwise, this object is a star.
    166     source->type = PM_SOURCE_TYPE_STAR;
    167 
    168     // the following source->mode information pertains to modelPSF:
    169     source->mode |= PM_SOURCE_MODE_PSFMODEL;
    170 
    171     // if the object has fitted peak above saturation, label as SATSTAR
    172     // this is a valid PSF object, but ignore the other quality tests
    173     // remember: fit does not use saturated pixels (masked)
    174     // XXX no extended object can saturate and stay extended...
    175     if (model->params->data.F32[PM_PAR_I0] >= SATURATION) {
    176         if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    177             psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");
    178         }
    179         source->mode |=  PM_SOURCE_MODE_SATSTAR;
    180         return true;
    181     }
    182 
    183     // if the object has a fitted peak below 0, the fit did not converge cleanly
    184     if (model->params->data.F32[PM_PAR_I0] <= 0.02) {
    185         source->mode |= PM_SOURCE_MODE_FAIL;
    186         return false;
    187     }
    188 
    189     // if the source was predicted to be a SATSTAR, but it fitted below saturation,
    190     // make a note to the user
    191     if (source->mode & PM_SOURCE_MODE_SATSTAR) {
    192         psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");
    193         source->mode &= ~PM_SOURCE_MODE_SATSTAR;
    194     }
    195199    return true;
    196200}       
  • trunk/psphot/src/psphotRadialApertures.c

    r34404 r35468  
    4747static float outerRadius = NAN;
    4848static float SN_LIM = NAN;
     49static int RADIAL_AP_MIN = 5;
    4950static psImageMaskType maskVal = 0;
    5051
     
    115116    // S/N limit to perform full non-linear fits
    116117    SN_LIM = psMetadataLookupF32 (&status, recipe, "RADIAL_APERTURES_SN_LIM");
     118
     119    // S/N limit to perform full non-linear fits
     120    RADIAL_AP_MIN = psMetadataLookupS32 (&status, recipe, "RADIAL.ANNULAR.BINS.MIN");
     121    if (!status) {
     122      RADIAL_AP_MIN = 5;
     123    }
    117124
    118125    // source analysis is done in S/N order (brightest first)
     
    310317
    311318    // find the largest aperture of interest (use only apertures with inner radii <=
    312     // source->skyRadius)
     319    // source->skyRadius, as long as i >= RADIAL_AP_MIN
    313320    int lastAp = aperRadii->n;
    314     for (int i = 0; i < aperRadii->n; i++) {
    315         if (aperRadii->data.F32[i] < source->skyRadius) continue;
     321    for (int i = RADIAL_AP_MIN; i < aperRadii->n; i++) {
     322        if (aperRadii->data.F32[i] < source->skyRadius) continue; // measure out to this radius
    316323        lastAp = i + 1;
    317324        break;
Note: See TracChangeset for help on using the changeset viewer.