IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 24, 2013, 12:09:27 PM (13 years ago)
Author:
eugene
Message:

first version of psphotFullForce which builds

Location:
branches/eam_branches/ipp-20130904/psphot/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130904/psphot/src

    • Property svn:ignore
      •  

        old new  
        2424psphotModelTest
        2525psphotMinimal
         26psphotFullForce
  • branches/eam_branches/ipp-20130904/psphot/src/psphotPetroFlux.c

    r36146 r36148  
    11# include "psphotInternal.h"
    22
    3 bool psphotPetroFlux (pmConfig *config, const pmFPAview *view, const char *filerule, int pass)
     3bool psphotPetroFlux (pmConfig *config, const pmFPAview *view, const char *filerule)
    44{
    55    bool status = true;
     
    3535        psAssert (sources, "missing sources?");
    3636
    37         pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
    38         // psAssert (psf, "missing psf?");
    39 
    40         if (!psphotPetroFluxReadout (config, recipe, view, filerule, readout, sources, psf, i, pass)) {
     37        if (!psphotPetroFluxReadout (config, recipe, view, filerule, readout, sources)) {
    4138            psError (PSPHOT_ERR_CONFIG, false, "failed to measure magnitudes for %s entry %d", filerule, i);
    4239            return false;
     
    4643}
    4744
    48 bool psphotPetroFluxReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources, pmPSF *psf, int index, int pass) {
     45bool psphotPetroFluxReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources) {
    4946
    5047    bool status = false;
    5148
    5249    if (!sources->n) {
    53         psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping kron fluxes");
     50        psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping petrosian fluxes");
    5451        return true;
    5552    }
    5653
    57     psTimerStart ("psphot.kron");
     54    psTimerStart ("psphot.petro");
    5855
    5956    // determine the number of allowed threads
     
    6158    if (!status) {
    6259        nThreads = 0;
    63     }
    64 
    65     bool KRON_APPLY_WEIGHT = psMetadataLookupBool (&status, recipe, "KRON_APPLY_WEIGHT");
    66     if (!status) {
    67         KRON_APPLY_WEIGHT = true;
    68     }
    69 
    70     bool KRON_APPLY_WINDOW = psMetadataLookupBool (&status, recipe, "KRON_APPLY_WINDOW");
    71     if (!status) {
    72         KRON_APPLY_WINDOW = false;
    7360    }
    7461
     
    10592
    10693            // allocate a job -- if threads are not defined, this just runs the job
    107             psThreadJob *job = psThreadJobAlloc ("PSPHOT_KRON_ITERATE");
     94            psThreadJob *job = psThreadJobAlloc ("PSPHOT_PETRO_FLUX");
    10895
    10996            psArrayAdd(job->args, 1, readout);
     
    11198            PS_ARRAY_ADD_SCALAR(job->args, markVal,            PS_TYPE_IMAGE_MASK);
    11299            PS_ARRAY_ADD_SCALAR(job->args, maskVal,            PS_TYPE_IMAGE_MASK);
    113             PS_ARRAY_ADD_SCALAR(job->args, pass,               PS_TYPE_S32);
    114100
    115101// set this to 0 to run without threading
     
    146132    psFree (cellGroups);
    147133
    148     psLogMsg ("psphot.kron", PS_LOG_WARN, "measure kron fluxes : %f sec for %ld objects\n", psTimerMark ("psphot.kron"), sources->n);
     134    psLogMsg ("psphot.petro", PS_LOG_WARN, "measure petro fluxes : %f sec for %ld objects\n", psTimerMark ("psphot.petro"), sources->n);
    149135    return true;
    150136}
     
    153139
    154140    pmReadout *readout              = job->args->data[0];
    155     psArray *sources                = job->args->data[2];
    156     psImageMaskType markVal         = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
    157     psImageMaskType maskVal         = PS_SCALAR_VALUE(job->args->data[5],PS_TYPE_IMAGE_MASK_DATA);
     141    psArray *sources                = job->args->data[1];
     142    psImageMaskType markVal         = PS_SCALAR_VALUE(job->args->data[2],PS_TYPE_IMAGE_MASK_DATA);
     143    psImageMaskType maskVal         = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA);
    158144
    159145    for (int i = 0; i < sources->n; i++) {
    160 
    161         // XXX what do i need for the kron flux (given a supplied kron radius?)
    162146
    163147        pmSource *source = sources->data[i];
     
    169153        if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue;
    170154
    171         // XXX where are we storing the supplied kron radius?
     155        // XXX where are we storing the supplied petro radius?
    172156        if (!isfinite(source->moments->Mrf)) continue;
    173157
     
    180164        }
    181165
    182         // is the right??
    183         float windowRadius = 6.0*source->moments->Mrf ;
     166        // is the right??  XXX need the correct location for Rpet
     167        float windowRadius = 2.0*source->moments->Mrf ;
    184168
    185169        // re-allocate image, weight, mask arrays for each peak with box big enough to fit BIG_RADIUS
    186         bool extend = pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2);
     170        pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2);
    187171        psAssert (source->pixels, "WTF?");
    188172
     
    211195    float Yo = (dR < 2.0) ? source->moments->My : source->peak->yf;
    212196
     197    // center of mass in subimage.  Note: the calculation below uses pixel index, so we correct
     198    // xCM, yCM from pixel coords to pixel index here.
     199    psF32 xCM = Xo - 0.5 - source->pixels->col0; // coord of peak in subimage
     200    psF32 yCM = Yo - 0.5 - source->pixels->row0; // coord of peak in subimage
     201
    213202    // Calculate the Petro magnitude (make this block optional?)
    214203    // XXX set the aperture here
    215     float radPetro  = 2.5*Mrf;
     204    float radPetro  = 2.0*source->moments->Mrf;
    216205    float radPetro2 = radPetro*radPetro;
    217206
     
    222211    // set vPix to the source pixels (it may have been set to the
    223212    // smoothed image above)
    224     vPix = source->pixels->data.F32;
    225     vWgt = source->variance->data.F32;
    226     vMsk = source->mask->data.F32;
     213    psF32 **vPix = source->pixels->data.F32;
     214    psF32 **vWgt = source->variance->data.F32;
     215    psImageMaskType **vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA;
    227216
    228217    for (psS32 row = 0; row < source->pixels->numRows ; row++) {
     
    253242
    254243    // return the flux and error to parameters?
    255     source->moments->PetroFlux    = Sum;
    256     source->moments->PetroFluxErr = sqrt(Var);
    257 
    258     return true;
    259 }
     244    // source->moments->PetroFlux    = Sum;
     245    // source->moments->PetroFluxErr = sqrt(Var);
     246
     247    fprintf (stderr, "petro flux: %f +/- %f\n", Sum, sqrt(Var));
     248
     249    return true;
     250}
Note: See TracChangeset for help on using the changeset viewer.