IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 27, 2013, 3:47:04 PM (13 years ago)
Author:
eugene
Message:

updates for psphotFullForce I/O

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO_CFF.c

    r36152 r36154  
    7272    assert (modelType > -1);
    7373
     74    // how to deal with this?
     75    int galaxyModelType = pmModelClassGetType ("PS_MODEL_EXP");
     76
    7477    // We get the size of the table, and allocate the array of sources first because the table
    7578    // is large and ephemeral --- when the table gets blown away, whatever is allocated after
     
    8790        }
    8891
    89         // here are the things we read from the FITS table
    90 
    91         unsigned int ID = psMetadataLookupU32 (&status, row, "IPP_IDET");
    92         float X = psMetadataLookupF32 (&status, row, "X_PSF");
    93         float Y = psMetadataLookupF32 (&status, row, "Y_PSF");
     92        // here are the things we read from the FITS table (XXX modify names if needed)
     93
     94        unsigned int ID  = psMetadataLookupU32 (&status, row, "IPP_IDET");
     95        float X          = psMetadataLookupF32 (&status, row, "X_PSF");
     96        float Y          = psMetadataLookupF32 (&status, row, "Y_PSF");
    9497
    9598        float apRadius   = psMetadataLookupS32 (&status, row, "AP_RADIUS");
     
    97100        float petRadius  = psMetadataLookupU32 (&status, row, "PETRO_RADIUS");
    98101        bool fitGalaxy   = psMetadataLookupU32 (&status, row, "FIT_GALAXY");
     102        bool psfStar     = psMetadataLookupU32 (&status, row, "PSF_STAR");
    99103
    100104        float Rmajor     = psMetadataLookupU32 (&status, row, "R_MAJOR");
     
    108112        source->type = PM_SOURCE_TYPE_STAR; // XXX this should be added to the flags
    109113
     114        // XXX we can set this in general, but for a specific image, we need to weed out SATSTARS
     115        if (psfStar) {
     116            source->tmpFlags |= PM_SOURCE_TMPF_CANDIDATE_PSFSTAR;
     117        }
     118
    110119        // NOTE: A SEGV here because "model" is NULL is probably caused by not initialising the models.
    111120        psF32 *PAR = model->params->data.F32;
    112121        psF32 *dPAR = model->dparams->data.F32;
    113122
    114         source->seq          = ID;
    115         PAR[PM_PAR_XPOS]     = X;
    116         PAR[PM_PAR_YPOS]     = Y;
     123        source->seq       = ID;
     124        PAR[PM_PAR_XPOS]  = X;
     125        PAR[PM_PAR_YPOS]  = Y;
    117126
    118127        dPAR[PM_PAR_XPOS] = 0.0;
     
    129138
    130139        source->psfMag    = 0.0;
    131         source->psfMagErr    = 0.0;
     140        source->psfMagErr = 0.0;
    132141        source->apMag     = 0.0;
    133 
     142        source->apRadius  = apRadius;
     143
     144        // we generate a somewhat fake PSF model here --
     145        // in most (all?) contexts, we will replace this with a measured psf model
     146        // elsewhere
    134147        axes.major        = 1.0;
    135148        axes.minor        = 1.0;
     
    138151
    139152        float peakFlux    = 1.0;
    140 
    141         source->peak = pmPeakAlloc(PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], peakFlux, PM_PEAK_LONE);
     153        source->peak      = pmPeakAlloc(X, Y, peakFlux, PM_PEAK_LONE);
     154        source->peak->xf  = X; // more accurate position
     155        source->peak->yf  = Y; // more accurate position
     156        source->peak->dx  = 0.0;
     157        source->peak->dy  = 0.0;
    142158        source->peak->rawFlux = peakFlux;
    143159        source->peak->smoothFlux = peakFlux;
    144         source->peak->xf   = PAR[PM_PAR_XPOS]; // more accurate position
    145         source->peak->yf   = PAR[PM_PAR_YPOS]; // more accurate position
    146         source->peak->dx   = dPAR[PM_PAR_XPOS];
    147         source->peak->dy   = dPAR[PM_PAR_YPOS];
    148 
    149         assert (status);
     160
     161        source->moments = pmMomentsAlloc ();
     162        source->moments->Mx = X;
     163        source->moments->My = Y;
     164        source->moments->Mrf = kronRadius;
     165        source->tmpFlags |= PM_SOURCE_TMPF_MOMENTS_MEASURED;
     166        // XXX does the above cause a problem with pmSourceMoments (do we run it?)
     167
     168        if (isfinite(petRadius)) {
     169            source->extpars = pmSourceExtendedParsAlloc ();
     170            source->extpars->petrosianRadius = petRadius;
     171        }
     172
     173        if (fitGalaxy) {
     174            source->modelFits = psArrayAllocEmpty (models->list->n);
     175            pmModel *model = pmModelAlloc(modelType);
     176            psF32 *xPAR = model->params->data.F32;
     177
     178            xPAR[PM_PAR_SKY]  = 0.0;
     179            xPAR[PM_PAR_I0]   = 1.0;
     180            xPAR[PM_PAR_XPOS] = X;
     181            xPAR[PM_PAR_YPOS] = Y;
     182           
     183            psEllipseAxes galAxes;
     184            galAxes.major = Rmajor;
     185            galAxes.minor = Rminor;
     186            galAxes.theta = theta; // XXX degrees or radians?
     187
     188            pmPSF_AxesToModel (PAR, guessAxes, galModelType);
     189            xPAR[PM_PAR_7] = Sindex;
     190
     191            psArrayAdd (source->modelFits, 1, model);
     192            psFree (model);
     193           
     194        }
    150195
    151196        sources->data[i] = source;
Note: See TracChangeset for help on using the changeset viewer.