IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29914


Ignore:
Timestamp:
Dec 5, 2010, 2:23:08 PM (15 years ago)
Author:
eugene
Message:

support for ppSub forced photometry

Location:
branches/eam_branches/ipp-20101103/psphot
Files:
1 added
9 edited

Legend:

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

  • branches/eam_branches/ipp-20101103/psphot/src/Makefile.am

    r29904 r29914  
    125125        psphotReadoutFindPSF.c         \
    126126        psphotReadoutKnownSources.c    \
     127        psphotReadoutForcedKnownSources.c    \
    127128        psphotReadoutMinimal.c         \
    128129        psphotModelBackground.c        \
  • branches/eam_branches/ipp-20101103/psphot/src/psphot.h

    r29904 r29914  
    2727bool            psphotReadoutFindPSF(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
    2828bool            psphotReadoutKnownSources(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
     29bool            psphotReadoutForcedKnownSources(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
    2930bool            psphotReadoutMinimal(pmConfig *config, const pmFPAview *view, const char *filerule);
    3031
     
    312313int psphotFileruleCount(const pmConfig *config, const char *filerule);
    313314
     315bool psphotAddKnownSources (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
     316
     317
    314318/**** psphotStack prototypes ****/
    315319
     
    434438pmModel *psphotFitPCM (pmReadout *readout, pmSource *source, pmSourceFitOptions *fitOptions, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal, int psfSize);
    435439
     440bool psphotCleanInputs (pmConfig *config, const pmFPAview *view, const char *filerule);
     441
    436442#endif
  • branches/eam_branches/ipp-20101103/psphot/src/psphotEfficiency.c

    r29904 r29914  
    511511    psMetadataAddPtr(readout->analysis, PS_LIST_TAIL, PM_DETEFF_ANALYSIS, PS_META_REPLACE | PS_DATA_UNKNOWN,
    512512                     "Detection efficiency", de);
     513    psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "DETEFF.MAGREF",
     514        PS_META_REPLACE, "Magnitude reference", magLim);
     515
    513516    psFree(de);
    514517
  • branches/eam_branches/ipp-20101103/psphot/src/psphotMergeSources.c

    r29904 r29914  
    163163}
    164164
     165// copy the known sources (as external) to the detection list of the given filerule
     166bool psphotAddKnownSources (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources) {
     167
     168    bool status = false;
     169
     170    // select the appropriate recipe information
     171    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     172    psAssert (recipe, "missing recipe?");
     173
     174    // determine properties (sky, moments) of initial sources
     175    float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS");
     176    psAssert (status, "missing SKY_OUTER_RADIUS in recipe?");
     177
     178    // XXX this seems like an arbitrary number...
     179    OUTER = PS_MAX(OUTER, 20.0); // XXX Guarantee that we can encompass the max moments radius
     180
     181    // find the currently selected readout
     182    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, 0); // File of interest
     183    psAssert (file, "missing file?");
     184
     185    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     186    psAssert (readout, "missing readout?");
     187
     188    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     189    if (!detections) {
     190        detections = pmDetectionsAlloc();
     191        detections->newSources = psArrayAllocEmpty (100);
     192        // save detections on the readout->analysis
     193        if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detections)) {
     194            psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     195            return false;
     196        }
     197    } else {
     198        psMemIncrRefCounter(detections); // so we can free the detections below
     199    }
     200
     201    // copy the sources from inSources to the new detection structure
     202    for (int i = 0; i < inSources->n; i++) {
     203      pmSource *inSource = inSources->data[i];
     204
     205      pmSource *newSource = pmSourceCopy(inSource);
     206      newSource->mode |= PM_SOURCE_MODE_EXTERNAL;
     207     
     208      // drop the loaded source modelPSF
     209      psFree (newSource->modelPSF);
     210      // source->modelPSF = NULL;  check this!
     211
     212      // drop the references to the original image pixels:
     213      pmSourceFreePixels (newSource);
     214
     215      // allocate image, weight, mask for the new image for each peak (square of radius OUTER)
     216      pmSourceDefinePixels (newSource, readout, newSource->peak->x, newSource->peak->y, OUTER);
     217
     218      newSource->imageID = 0;
     219      // XXX reset the source ID? raised questions about the meaning of this ID...
     220      // P_PM_SOURCE_SET_ID(source, i);
     221
     222      psArrayAdd (detections->newSources, 100, newSource);
     223    }
     224    psLogMsg ("psphot", 3, "%ld known sources supplied", detections->newSources->n);
     225
     226    psFree (detections);
     227    return true;
     228}
     229
    165230// extract the input sources corresponding to this readout
    166231// XXX this function needs to be updated to work with the new context of psphot inputs
  • branches/eam_branches/ipp-20101103/psphot/src/psphotOutput.c

    r29904 r29914  
    99    psStringAppend(&name, "%s.NUM", filerule);
    1010    int num = psMetadataLookupS32 (&status, config->arguments, name);
    11     psAssert (status, "programming error: must define %s", name);
     11    if (!status) {
     12      // we only explicitly define (filerule.NUM) if we have more than 1
     13      num = 1;
     14    }
    1215    psFree (name);
    1316    return num;
     
    125128    }
    126129    fclose (f);
     130    return true;
     131}
     132
     133bool psphotCleanInputsReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index);
     134bool psphotCleanInputs (pmConfig *config, const pmFPAview *view, const char *filerule) {
     135
     136    int num = psphotFileruleCount(config, filerule);
     137
     138    // loop over the available readouts
     139    for (int i = 0; i < num; i++) {
     140        if (!psphotCleanInputsReadout (config, view, filerule, i)) {
     141          psError (PSPHOT_ERR_CONFIG, false, "failed to clean inputs for %s entry %d", filerule, i);
     142            return false;
     143        }
     144    }
     145    return true;
     146}
     147
     148bool psphotCleanInputsReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index) {
     149
     150    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest
     151    PS_ASSERT (file, false);
     152
     153    pmReadout  *readout = pmFPAviewThisReadout (view, file->fpa);
     154
     155    // XXX anything else to remove?
     156    if (psMetadataLookup(readout->analysis, "PSPHOT.DETECTIONS")) {
     157        psMetadataRemoveKey(readout->analysis, "PSPHOT.DETECTIONS");
     158    }
     159
    127160    return true;
    128161}
     
    282315    psMetadataItemSupplement (&status, header, analysis, "MSKY_NY");
    283316
     317    psMetadataItemSupplement (&status, header, analysis, "DETEFF.MAGREF");
     318
    284319    psMetadataAddF32 (header, PS_LIST_TAIL, "DT_PHOT", PS_META_REPLACE, "elapsed psphot time", psTimerMark ("psphotReadout"));
    285320
  • branches/eam_branches/ipp-20101103/psphot/src/psphotParseCamera.c

    r26894 r29914  
    3939        return NULL;
    4040    }
    41     // specify the number of psphot input images
    42     psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
    4341
    4442    // define the additional input/output files associated with psphot
  • branches/eam_branches/ipp-20101103/psphot/src/psphotRadiusChecks.c

    r29004 r29914  
    135135    EXT_FIT_MAX_RADIUS = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MAX_RADIUS");
    136136
    137     float skyMean  = psMetadataLookupF32 (&status, readout->analysis, "SKY_MEAN");
    138137    float skyStdev = psMetadataLookupF32 (&status, readout->analysis, "SKY_STDEV");
    139 
    140     fprintf (stderr, "sky: %f +/- %f\n", skyMean, skyStdev);
    141138
    142139    EXT_FIT_SKY_SIG = skyStdev;
  • branches/eam_branches/ipp-20101103/psphot/src/psphotReadout.c

    r29904 r29914  
    2727    psAssert (breakPt, "configuration error: set BREAK_POINT");
    2828
     29    // remove cruft from the input analysis structure
     30    if (!psphotCleanInputs (config, view, filerule)) {
     31        psError (PSPHOT_ERR_PROG, false, "trouble setting up the inputs");
     32        return false;
     33    }
     34
    2935    // set the photcode for this image
    3036    if (!psphotAddPhotcode (config, view, filerule)) {
Note: See TracChangeset for help on using the changeset viewer.