IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38057


Ignore:
Timestamp:
Mar 29, 2015, 5:55:41 AM (11 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20150112/psphot
Files:
17 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150112/psphot

  • branches/eam_branches/ipp-20150112/psphot/src

    • Property svn:ignore
      •  

        old new  
        2727psmakecff
        2828psphotFullForceSummary
         29psphotVersionDefinitions.h.tmp
  • branches/eam_branches/ipp-20150112/psphot/src/Makefile.am

    r37466 r38057  
    11lib_LTLIBRARIES = libpsphot.la
    2 
    3 if HAVE_SVNVERSION
    4 PSPHOT_VERSION=`$(SVNVERSION) ..`
    5 else
    6 PSPHOT_VERSION="UNKNOWN"
    7 endif
    8 
    9 if HAVE_SVN
    10 PSPHOT_BRANCH=`$(SVN) info .. | $(SED) -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'`
    11 PSPHOT_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'`
    12 else
    13 PSPHOT_BRANCH="UNKNOWN"
    14 PSPHOT_SOURCE="UNKNOWN"
    15 endif
    162
    173# Force recompilation of psphotVersion.c, since it gets the version information
    184psphotVersion.c: psphotVersionDefinitions.h
    195psphotVersionDefinitions.h: psphotVersionDefinitions.h.in FORCE
    20         -$(RM) psphotVersionDefinitions.h
    21         $(SED) -e "s|@PSPHOT_VERSION@|\"$(PSPHOT_VERSION)\"|" -e "s|@PSPHOT_BRANCH@|\"$(PSPHOT_BRANCH)\"|" -e "s|@PSPHOT_SOURCE@|\"$(PSPHOT_SOURCE)\"|" psphotVersionDefinitions.h.in > psphotVersionDefinitions.h
     6        pslib-setsvnversion.pl PSPHOT psphotVersionDefinitions.h.in psphotVersionDefinitions.h
    227FORCE: ;
    238
     
    230215        psphotLoadSRCTEXT.c            \
    231216        psphotReadoutCleanup.c         \
     217        psphotStatsFile.c              \
    232218        psphotSourcePlots.c            \
    233219        psphotRadialPlot.c             \
  • branches/eam_branches/ipp-20150112/psphot/src/psphot.h

    r37767 r38057  
    4545bool            psphotReadoutCleanup (pmConfig *config, const pmFPAview *view, const char *filerule);
    4646bool            psphotReadoutCleanupReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe);
     47bool            psphotReadoutCleanupMinimal (pmConfig *config, const pmFPAview *view, const char *filerule);
     48bool            psphotReadoutCleanupReadoutMinimal (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe);
    4749
    4850bool            psphotDefineFiles (pmConfig *config, pmFPAfile *input);
  • branches/eam_branches/ipp-20150112/psphot/src/psphotCleanup.c

    r37609 r38057  
    1010        (void)pmConfigRecipesCull(config,NULL);
    1111        pmConfigDump(config, dump_file);
     12    }
     13
     14    // if the program has stats write it out
     15    psphotStatsFile *statsFile = psphotStatsFileGet();
     16    if (statsFile) {
     17        psphotStatsFileSave(config, statsFile);
    1218    }
    1319
  • branches/eam_branches/ipp-20150112/psphot/src/psphotExtendedSourceFits.c

    r37624 r38057  
    534534              Nconvolve ++;
    535535              if (!(modelFit->flags & badModel)) {
     536                  float *PAR = modelFit->params->data.F32;
     537                  psEllipseAxes axes = pmPSF_ModelToAxes (PAR, modelFit->class->useReff);
     538                  if (axes.major >= 100) {
     539                      Nfail ++;
     540                      source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_FAIL;
     541                      psFree(modelFit);
     542                      continue;
     543                  }
    536544                  NconvolvePass ++;
    537545                  source->mode |= PM_SOURCE_MODE_EXTENDED_FIT;
  • branches/eam_branches/ipp-20150112/psphot/src/psphotFitSourcesLinear.c

    r37555 r38057  
    688688    assert (modelVar);
    689689
    690     psMetadataRemoveKey (readout->analysis, "PSPHOT.MODEL.VAR");
     690    if (modelVar) {
     691      psMetadataRemoveKey (readout->analysis, "PSPHOT.MODEL.VAR");
     692    }
    691693
    692694    // clear modelVar pointers for all of the source models
  • branches/eam_branches/ipp-20150112/psphot/src/psphotFullForce.c

    r36375 r38057  
    1010    pmConfig *config = psphotFullForceArguments (argc, argv);
    1111    assert(config);
     12
     13    if (!psphotStatsFileOpen(config)) {
     14        psErrorStackPrint(stderr, "Error creating statsFile\n");
     15        exit (psphotGetExitStatus());
     16    }
    1217
    1318    psphotVersionPrint();
     
    2530    }
    2631
    27     psLogMsg ("psphot", 3, "complete psphot run: %f sec\n", psTimerMark ("complete"));
     32    psLogMsg ("psphot", 3, "complete psphotFullForce run: %f sec\n", psTimerMark ("complete"));
    2833
    2934    psErrorCode exit_status = psphotGetExitStatus();
  • branches/eam_branches/ipp-20150112/psphot/src/psphotFullForceArguments.c

    r36375 r38057  
    6565        psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING, "", argv[N]);
    6666        psArgumentRemove (N, &argc, argv);
     67    }
     68
     69    if ((N = psArgumentGet(argc, argv, "-stats"))) {
     70        psArgumentRemove(N, &argc, argv);
     71        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "STATS", PS_DATA_STRING,
     72                         "Filename for statistics of output file", argv[N]);
     73        psArgumentRemove(N, &argc, argv);
    6774    }
    6875
  • branches/eam_branches/ipp-20150112/psphot/src/psphotGalaxyParams.c

    r37811 r38057  
    152152
    153153// set this to 0 to run without threading
    154 # if (0)           
     154# if (1)           
    155155            if (!psThreadJobAddPending(job)) {
    156156                psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     
    270270    badModel |= PM_MODEL_PCM_FAIL_GUESS;
    271271
     272    badModel |= PM_MODEL_STATUS_LIMITS;
     273
    272274    pmModelType sersicModelType = pmModelClassGetType("PS_MODEL_SERSIC");
    273275
     
    334336        if (!sersicModel) SKIP (Nskip8);
    335337        if (sersicModel->flags & badModel) SKIP (Nskip8);
     338
     339        // check out the model params and skip those that are too large
     340        psF32 *PAR = sersicModel->params->data.F32;
     341        psF32 Xo = PAR[PM_PAR_XPOS];
     342        psF32 Yo = PAR[PM_PAR_YPOS];
     343        psF32 Io = PAR[PM_PAR_I0];
     344        //
     345        // The half light radius to the major axis of the model
     346        psEllipseAxes axes = pmPSF_ModelToAxes (PAR, sersicModel->class->useReff);
     347        if (axes.major >= 100) SKIP (Nskip8);
     348
     349        source->extpars->ghalfLightRadius = axes.major;
    336350        Next ++;
    337351
     
    353367            // do we need this?
    354368            source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT;
    355 #ifdef notdef
    356 #endif
    357         }
    358 
    359 
    360         psF32 *PAR = sersicModel->params->data.F32;
    361         psF32 Xo = PAR[PM_PAR_XPOS];
    362         psF32 Yo = PAR[PM_PAR_YPOS];
    363         psF32 Io = PAR[PM_PAR_I0];
    364         // For now: set the half light radius to the major axis of the model
    365         psEllipseAxes axes = pmPSF_ModelToAxes (PAR, sersicModel->class->useReff);
    366         source->extpars->ghalfLightRadius = axes.major;
     369        }
     370
     371
    367372        // and we will integrate out to 2 * half light radius
    368373        psF32 R = 2 * axes.major;
  • branches/eam_branches/ipp-20150112/psphot/src/psphotInternal.h

    r12805 r38057  
    1414#include <psmodules.h>
    1515#include "psphot.h"
     16#include "psphotStatsFile.h"
    1617
    1718#endif
  • branches/eam_branches/ipp-20150112/psphot/src/psphotLensing.c

    r36865 r38057  
    138138    psVector *psf_e1sh = psVectorAllocEmpty (300, PS_TYPE_F32);
    139139    psVector *psf_e2sh = psVectorAllocEmpty (300, PS_TYPE_F32);
     140    psVector *psf_e1   = psVectorAllocEmpty (300, PS_TYPE_F32);
     141    psVector *psf_e2   = psVectorAllocEmpty (300, PS_TYPE_F32);
    140142    psVector *xPos     = psVectorAllocEmpty (300, PS_TYPE_F32);
    141143    psVector *yPos     = psVectorAllocEmpty (300, PS_TYPE_F32);
     
    178180
    179181        pmModel *model = source->modelPSF;
     182
     183        float R  = source->moments->Mxx + source->moments->Myy;
     184        source->lensingOBJ->e1 = (source->moments->Mxx - source->moments->Myy) / R;
     185        source->lensingOBJ->e2 = 2*source->moments->Mxy / R;
    180186
    181187        psVectorAppend (xPos, model->params->data.F32[PM_PAR_XPOS]);
     
    191197        psVectorAppend (psf_e1sh, source->lensingOBJ->shear->e1);
    192198        psVectorAppend (psf_e2sh, source->lensingOBJ->shear->e2);
     199        psVectorAppend (psf_e1,   source->lensingOBJ->e1);
     200        psVectorAppend (psf_e2,   source->lensingOBJ->e2);
    193201        Npsf ++;
    194202    }
     
    247255    pmTrend2D *trend_e2sh = pmTrend2DAlloc (PM_TREND_MAP, readout->image, Nx, Ny, stats);
    248256
     257    pmTrend2D *trend_e1   = pmTrend2DAlloc (PM_TREND_MAP, readout->image, Nx, Ny, stats);
     258    pmTrend2D *trend_e2   = pmTrend2DAlloc (PM_TREND_MAP, readout->image, Nx, Ny, stats);
     259
    249260    bool goodFit = false;
    250261    if (!pmTrend2DFit (&goodFit, trendX11sm, NULL, 0xff, xPos, yPos, psfX11sm, NULL)) { psWarning ("failed to measure X11 smear trend"); }
     
    259270    if (!pmTrend2DFit (&goodFit, trend_e1sh, NULL, 0xff, xPos, yPos, psf_e1sh, NULL)) { psWarning ("failed to measure  e1 shear trend"); }
    260271    if (!pmTrend2DFit (&goodFit, trend_e2sh, NULL, 0xff, xPos, yPos, psf_e2sh, NULL)) { psWarning ("failed to measure  e2 shear trend"); }
     272
     273    if (!pmTrend2DFit (&goodFit, trend_e1,   NULL, 0xff, xPos, yPos, psf_e1,   NULL)) { psWarning ("failed to measure  e1 trend"); }
     274    if (!pmTrend2DFit (&goodFit, trend_e2,   NULL, 0xff, xPos, yPos, psf_e2,   NULL)) { psWarning ("failed to measure  e2 trend"); }
    261275
    262276    // evaluate the PSF trend maps at the location of all sources
     
    295309        smear->e1  = pmTrend2DEval (trend_e1sm, xPos, yPos);
    296310        smear->e2  = pmTrend2DEval (trend_e2sm, xPos, yPos);
     311
     312        lensing->e1  = pmTrend2DEval (trend_e1, xPos, yPos);
     313        lensing->e2  = pmTrend2DEval (trend_e2, xPos, yPos);
    297314    }
    298315
     
    309326    psFree (trend_e2sh);
    310327
     328    psFree (trend_e1);
     329    psFree (trend_e2);
     330
    311331    psFree (psfX11sm);
    312332    psFree (psfX12sm);
     
    314334    psFree (psf_e1sm);
    315335    psFree (psf_e2sm);
     336
    316337    psFree (psfX11sh);
    317338    psFree (psfX12sh);
     
    319340    psFree (psf_e1sh);
    320341    psFree (psf_e2sh);
     342
     343    psFree (psf_e1);
     344    psFree (psf_e2);
     345
    321346    psFree (xPos    );
    322347    psFree (yPos    );
  • branches/eam_branches/ipp-20150112/psphot/src/psphotModelBackground.c

    r35769 r38057  
    277277        psFree(binning);
    278278        psFree(rng);
     279        psFree(dQ);
    279280        return false;
    280281    }
     
    386387
    387388    if (!psphotModelBackgroundReadout(model->image, modelStdev->image, model->analysis, readout, binning, config, false)) {
    388         psError(PS_ERR_UNKNOWN, false, "Unable to generate background model");
     389        int lastError = psErrorCodeLast();
     390        if (lastError == PSPHOT_ERR_DATA) {
     391            // depending on context this value may or may not be used
     392            psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "PSPHOT_QUALITY", PS_META_REPLACE, "quality error due to poor data", lastError);
     393        }
     394        psError(lastError, false, "Unable to generate background model");
    389395        return false;
    390396    }
     
    404410    for (int i = 0; i < num; i++) {
    405411        if (!psphotModelBackgroundReadoutFileIndex(config, view, filerule, i)) {
    406             psError (PSPHOT_ERR_CONFIG, false, "failed to model background for %s entry %d", filerule, i);
     412            int lastError = psErrorCodeLast();
     413            psError (lastError ? lastError : PSPHOT_ERR_CONFIG, false, "failed to model background for %s entry %d", filerule, i);
    407414            return false;
    408415        }
  • branches/eam_branches/ipp-20150112/psphot/src/psphotReadoutCleanup.c

    r37767 r38057  
    5454    psArray      *sources    = detections ? detections->allSources : NULL;
    5555    // XXX where do we free these, in here (psMetadataRemove?)
     56
     57    int quality = psMetadataLookupS32 (&status, readout->analysis, "PSPHOT_QUALITY");
     58    if (quality) {
     59        // if there is no stats file this will be a no-op
     60        psphotStatsFileSetQuality(quality);
     61    }
    5662
    5763    // use the psf-model to measure FWHM stats
     
    111117    return true;
    112118}
     119
     120// for now, let's store the detections on the readout->analysis for each readout
     121bool psphotReadoutCleanupMinimal (pmConfig *config, const pmFPAview *view, const char *filerule)
     122{
     123    bool status = true;
     124
     125    // remove internal pmFPAfiles, if created
     126    if (psErrorCodeLast() == (psErrorCode) PSPHOT_ERR_DATA) {
     127        psErrorStackPrint(stderr, "Error in the psphot readout analysis");
     128        psErrorClear();
     129    }
     130    if (psErrorCodeLast() != PS_ERR_NONE) {
     131        return false;
     132    }
     133
     134    // select the appropriate recipe information
     135    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     136    psAssert (recipe, "missing recipe?");
     137
     138    int num = psphotFileruleCount(config, filerule);
     139
     140    // loop over the available readouts
     141    for (int i = 0; i < num; i++) {
     142        if (!psphotReadoutCleanupReadoutMinimal (config, view, filerule, i, recipe)) {
     143            psError (PSPHOT_ERR_CONFIG, false, "failed on psphotReadoutCleanupMinimal for %s entry %d", filerule, i);
     144            return false;
     145        }
     146    }
     147
     148    // XXX move this to top of loop?
     149    pmKapaClose ();
     150
     151    return true;
     152}
     153
     154// psphotReadoutCleanupMinimal is called on exit from psphotReadoutMinimal.  If the last raised error is
     155// not a DATA error, then there was a serious problem.  Only in this case, or if the fail
     156// on the stats measurement, do we return false
     157bool psphotReadoutCleanupReadoutMinimal (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe) {
     158
     159    bool status = true;
     160
     161    // find the currently selected readout
     162    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest
     163    psAssert (file, "missing file?");
     164
     165    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     166    psAssert (readout, "missing readout?");
     167
     168    // when psphotReadoutCleanupMinimal is called, these are not necessarily defined
     169    pmPSF        *psf        = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
     170    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     171    psArray      *sources    = detections ? detections->allSources : NULL;
     172    // XXX where do we free these, in here (psMetadataRemove?)
     173
     174    // create an output header with stats results currently saved on readout->analysis
     175    psMetadata *header = psphotDefineHeader (readout->analysis);
     176
     177    // write NSTARS to the image header
     178    psphotSetHeaderNstars (header, sources);
     179
     180    // save the results of the analysis
     181    // this should happen way up stream (when needed?)
     182    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER",  PS_DATA_METADATA | PS_META_REPLACE, "header stats", header);
     183
     184    if (psf) {
     185        // XXX this seems a little silly : we saved the psf on readout->analysis above, but now
     186        // we are moving it to chip->analysis.
     187        // save the psf for possible output.  if there was already an entry, it was loaded from external sources
     188        // the new one may have been updated or modified, so replace the existing entry.  We
     189        // are required to save it on the chip, but this will cause problems if we ever want to
     190        // run psphot on an unmosaiced image
     191        pmCell *cell = readout->parent;
     192        pmChip *chip = cell->parent;
     193        psMetadataAdd (chip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE,  "psphot psf", psf);
     194    }
     195
     196    if (psErrorCodeLast() != PS_ERR_NONE) {
     197        psErrorStackPrint(stderr, "unexpected remaining errors");
     198        abort();
     199    }
     200
     201    psFree (header);
     202    return true;
     203}
  • branches/eam_branches/ipp-20150112/psphot/src/psphotReadoutMinimal.c

    r34317 r38057  
    9090    psphotKronIterate(config, view, filerule, 1);
    9191
     92    psphotChipParams (config, view, filerule);
     93
    9294    // measure source size for the remaining sources
    9395    psphotSourceSize (config, view, filerule, false);
     
    112114
    113115    // create the exported-metadata and free local data
    114     return psphotReadoutCleanup (config, view, filerule);
     116    return psphotReadoutCleanupMinimal (config, view, filerule);
    115117}
  • branches/eam_branches/ipp-20150112/psphot/src/psphotStandAlone.h

    r31154 r38057  
    1010#include <psmodules.h>
    1111#include "psphot.h"
     12#include "psphotStatsFile.h"
    1213
    1314// Top level functions
  • branches/eam_branches/ipp-20150112/psphot/src/psphotSubtractBackground.c

    r34528 r38057  
    2929    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    3030    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    31     assert (maskVal);
     31    psAssert (maskVal, "MASK.PSPHOT missing from recipe");
    3232
    3333    psImageBinning *binning = psMetadataLookupPtr(&status, model->analysis, "PSPHOT.BACKGROUND.BINNING");
Note: See TracChangeset for help on using the changeset viewer.