IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34258


Ignore:
Timestamp:
Jul 31, 2012, 3:58:10 PM (14 years ago)
Author:
eugene
Message:

add TRAIL models (and some trace test output); create psphotMinimal to test the psphotReadoutMinimal variant

Location:
trunk/psphot
Files:
12 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/psphot

  • trunk/psphot/src

  • trunk/psphot/src/Makefile.am

    r34086 r34258  
    2525libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    2626
    27 bin_PROGRAMS = psphot psphotForced psphotMakePSF psphotStack psphotModelTest
     27bin_PROGRAMS = psphot psphotForced psphotMinimal psphotMakePSF psphotStack psphotModelTest
    2828# bin_PROGRAMS = psphotPetrosianStudy psphotTest psphotMomentsStudy
    2929
     
    3535psphotForced_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    3636psphotForced_LDADD = libpsphot.la
     37
     38psphotMinimal_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     39psphotMinimal_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
     40psphotMinimal_LDADD = libpsphot.la
    3741
    3842psphotMakePSF_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     
    7377        psphotForced.c             \
    7478        psphotForcedArguments.c    \
     79        psphotParseCamera.c        \
     80        psphotImageLoop.c          \
     81        psphotMosaicChip.c         \
     82        psphotCleanup.c
     83
     84# forced photometry of specified positions given a specified psf
     85psphotMinimal_SOURCES = \
     86        psphotMinimal.c            \
     87        psphotMinimalArguments.c           \
    7588        psphotParseCamera.c        \
    7689        psphotImageLoop.c          \
  • trunk/psphot/src/psphot.h

    r34226 r34258  
    2020    PSPHOT_MAKE_PSF,
    2121    PSPHOT_MODEL_TEST,
     22    PSPHOT_MINIMAL,
    2223} psphotImageLoopMode;
    2324
     
    332333bool psphotForcedReadout(pmConfig *config, const pmFPAview *view, const char *filerule);
    333334
     335pmConfig *psphotMinimalArguments(int argc, char **argv);
     336bool psphotReadoutMinimal(pmConfig *config, const pmFPAview *view, const char *filerule);
     337
    334338pmConfig *psphotMakePSFArguments(int argc, char **argv);
    335339bool psphotMakePSFReadout(pmConfig *config, const pmFPAview *view, const char *filerule);
  • trunk/psphot/src/psphotBlendFit.c

    r33089 r34258  
    6161    if (!status) {
    6262        nThreads = 0;
     63    }
     64
     65    // do not thread if we are trying to study the fitting process
     66    if (psTraceGetLevel ("psphot.psphotFitEXT") >= 6) {
     67      nThreads = 0;
    6368    }
    6469
  • trunk/psphot/src/psphotExtendedSourceFits.c

    r34218 r34258  
    7777    if (!status) {
    7878        nThreads = 0;
     79    }
     80    // do not thread if we are trying to study the fitting process
     81    if (psTraceGetLevel ("psphot.psphotFitEXT") >= 6) {
     82      nThreads = 0;
    7983    }
    8084
     
    468472        psFree (source->modelEXT);
    469473        source->modelEXT = psMemIncrRefCounter (source->modelFits->data[minModel]);
     474        source->type = PM_SOURCE_TYPE_EXTENDED;
     475        source->mode |= PM_SOURCE_MODE_EXTMODEL;
     476        source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT;
    470477
    471478        // adjust the window so the subtraction covers the faint wings
  • trunk/psphot/src/psphotForced.c

    r31154 r34258  
    11# include "psphotStandAlone.h"
    2 # define FORCED_PHOTOMETRY 1
    32
    43int main (int argc, char **argv) {
  • trunk/psphot/src/psphotImageLoop.c

    r34086 r34258  
    118118                    }
    119119                    break;
     120                  case PSPHOT_MINIMAL:
     121                    if (!psphotReadoutMinimal (config, view, "PSPHOT.INPUT")) {
     122                        psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
     123                        psFree (view);
     124                        return false;
     125                    }
     126                    break;
    120127                  case PSPHOT_FORCED:
    121128                    if (!psphotForcedReadout (config, view, "PSPHOT.INPUT")) {
  • trunk/psphot/src/psphotReadoutMinimal.c

    r34215 r34258  
    2525    // Generate the mask and weight images, including the user-defined analysis region of interest
    2626    psphotSetMaskAndVariance (config, view, filerule);
     27
     28    // only subtract background if needed?
     29    // activate this for a clean test with psphotMinimal. (add to recipe!)
     30    if (0) {
     31      // generate a background model (median, smoothed image)
     32      if (!psphotModelBackground (config, view, filerule)) {
     33        return psphotReadoutCleanup (config, view, filerule);
     34      }
     35      if (!psphotSubtractBackground (config, view, filerule)) {
     36        return psphotReadoutCleanup (config, view, filerule);
     37      }
     38    }
    2739
    2840    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved on readout->analysis
     
    7284    psphotFitSourcesLinear (config, view, filerule, false, false);
    7385
    74 // XXX eventually, add the extended source fits here
    75 # if (0)
     86    // measure the radial profiles to the sky
     87    psphotRadialProfileWings (config, view, filerule);
     88
     89    // re-measure the kron mags with models subtracted and more appropriate windows
     90    psphotKronIterate(config, view, filerule);
     91
    7692    // measure source size for the remaining sources
    77     psphotSourceSize (config, view, filerule);
     93    psphotSourceSize (config, view, filerule, false);
    7894
    79     psphotExtendedSourceAnalysis (config, view, filerule);
     95    // NOTE: Petrosian and Isophotal mags are not relevant at this time
     96    // psphotExtendedSourceAnalysis (config, view, filerule);
    8097
     98    // in ppSub context, this is used to fit TRAILs (and maybe EXP for comets)
    8199    psphotExtendedSourceFits (config, view, filerule);
    82 # endif
    83100
    84101    // calculate source magnitudes
  • trunk/psphot/src/psphotSourceFits.c

    r34086 r34258  
    463463    }
    464464
     465# if (PS_TRACE_ON)
     466    if (psTraceGetLevel ("psphot") >= 6) {
     467
     468      // Moments-based shapes parameters
     469      psEllipseMoments moments;
     470      moments.x2 = source->moments->Mxx;
     471      moments.xy = source->moments->Mxy;
     472      moments.y2 = source->moments->Myy;
     473      // force the axis ratio to be < 20.0
     474      psEllipseAxes axes = psEllipseMomentsToAxes (moments, 20.0);
     475
     476      // PSF shape parameters
     477      psEllipseShape psfShape;
     478      psfShape.sx  = source->modelPSF->params->data.F32[PM_PAR_SXX] / M_SQRT2;
     479      psfShape.sxy = source->modelPSF->params->data.F32[PM_PAR_SXY];
     480      psfShape.sy  = source->modelPSF->params->data.F32[PM_PAR_SYY] / M_SQRT2;
     481      psEllipseAxes psfAxes = psEllipseShapeToAxes (psfShape, 20.0);
     482
     483      fprintf (stderr, "--- guess values ---\n");
     484      fprintf (stderr, "(x,y): %f, %f  Mxx: %f, Myy: %f, Mxy: %f -> major: %f, minor: %f, theta: %f (%f deg)\n", source->peak->xf, source->peak->yf, source->moments->Mxx, source->moments->Myy, source->moments->Mxy, axes.major, axes.minor, axes.theta, axes.theta*PS_DEG_RAD);
     485      fprintf (stderr, "psf: major: %f, minor: %f, theta: %f (%f deg)\n", psfAxes.major, psfAxes.minor, psfAxes.theta, psfAxes.theta*PS_DEG_RAD);
     486      for (int i = 0; i < model->params->n; i++) {
     487        fprintf (stderr, "par %d: %f\n", i, model->params->data.F32[i]);
     488      }
     489    }
     490    if (psTraceGetLevel ("psphot") >= 7) {
     491      psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);
     492    }
     493# endif
     494
    465495    // for sersic models, use a grid search to choose an index, then float the params there
    466496    if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) {
     
    468498    }
    469499
     500    options.mode = PM_SOURCE_FIT_EXT;
    470501    if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) {
    471502        options.mode = PM_SOURCE_FIT_NO_INDEX;
    472     } else {
    473         options.mode = PM_SOURCE_FIT_EXT;
    474     }
    475 
    476     // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);
     503    }
     504    if (modelType == pmModelClassGetType("PS_MODEL_TRAIL")) {
     505        options.mode = PM_SOURCE_FIT_TRAIL;
     506    }
     507
    477508    pmSourceFitModel (source, model, &options, maskVal);
    478     // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix);
    479     // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 0);
     509
     510# if (PS_TRACE_ON)
     511    if (psTraceGetLevel ("psphot") >= 5) {
     512      if (psTraceGetLevel ("psphot") >= 6) {
     513        fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix);
     514      }
     515      fprintf (stderr, "--- fitted values ---\n");
     516      for (int i = 0; i < model->params->n; i++) {
     517        fprintf (stderr, "par %d: %f\n", i, model->params->data.F32[i]);
     518      }
     519      psTraceSetLevel("psLib.math.psMinimizeLMChi2", 0);
     520    }
     521# endif
    480522
    481523    return (model);
  • trunk/psphot/src/psphotSourceSize.c

    r34201 r34258  
    462462    psImageMaskType maskVal = options->maskVal | options->markVal;
    463463
     464    // in the ppSub context, do we get sensible values for ApResid?
     465    float ApResidPSF = options->ApResid;
     466    if (!isfinite(ApResidPSF)) {
     467      ApResidPSF = 0.0;
     468    }
     469    float ApSysErrPSF = options->ApSysErr;
     470    if (!isfinite(ApSysErrPSF)) {
     471      ApSysErrPSF = 0.0;
     472    }
     473
    464474    for (psS32 i = 0 ; i < sources->n ; i++) {
    465475
     
    529539        // set nSigmaMAG to include both systematic and poisson error terms.  we include a hard
    530540        // floor on the Ap Sys Err (to be a bit generous).  XXX put the floor in the recipe...
    531         float nSigmaMAG = (dMag - options->ApResid) / hypot(source->psfMagErr, hypot(options->ApSysErr, 0.02));
     541        float nSigmaMAG = (dMag - ApResidPSF) / hypot(source->psfMagErr, hypot(ApSysErrPSF, 0.02));
    532542        source->extNsigma = nSigmaMAG;
    533543
  • trunk/psphot/src/psphotStackImageLoop.c

Note: See TracChangeset for help on using the changeset viewer.