IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 4, 2011, 4:44:43 PM (15 years ago)
Author:
eugene
Message:

explicitly include the reference aperture in the growth curve; add some debugging output to pmGrowthCurveGenerate.c; use the reference aperture magnitude when using sources for the growth curve; extend the model integration to 150 sigmas2 (not just 50); re-generate modelFlux pixels if at all deviant from source

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110404/psModules/src/objects/pmGrowthCurveGenerate.c

    r31361 r31438  
    226226}
    227227
     228# define DEBUG 0
     229# if (DEBUG)
     230static FILE *fgr = NULL;
     231# endif
     232
    228233// we generate the growth curve for the center of the image with the specified psf model
    229234bool pmGrowthCurveGenerateFromSources (pmReadout *readout, pmPSF *psf, psArray *sources, bool INTERPOLATE_AP, psImageMaskType maskVal, psImageMaskType markVal)
     
    240245    psArray *growths = psArrayAllocEmpty (100);
    241246
     247# if (DEBUG)
     248    fgr = fopen ("growth.mags.dat", "w");
     249# endif
     250
    242251    for (int i = 0; i < sources->n; i++) {
    243252
     
    254263    psAssert (growths->n, "cannot build growth curve (no valid PSF stars?)");
    255264
    256 # if (0)
    257     FILE *f = fopen ("growth.dat", "w");
    258     assert (f);
    259 
    260     for (int j = 0; j < psf->growth->radius->n; j++) {
    261 
    262         fprintf (f, "%f : ", psf->growth->radius->data.F32[j]);
    263 
    264         // XXX dump the growth curves:
    265         for (int i = 0; i < growths->n; i++) {
    266            
    267             pmGrowthCurve *growth = growths->data[i];
    268             if (!growth) continue;
    269 
    270             fprintf (f, "%8.4f ", growth->apMag->data.F32[j]);
    271         }
    272         fprintf (f, "\n");
    273     }
    274     fclose (f);
     265# if (DEBUG)
     266    fclose (fgr);
    275267# endif
    276268
     
    290282            pmGrowthCurve *growth = growths->data[j];
    291283            if (!isfinite(growth->apMag->data.F32[i])) continue;
    292             psVectorAppend (values, growth->apMag->data.F32[i] - growth->fitMag);
     284            psVectorAppend (values, growth->apMag->data.F32[i] - growth->refMag);
    293285        }
    294286        if (values->n == 0) {
     
    354346        growth->apMag->data.F32[i] = source->apMag;
    355347    }
     348    psAssert(growth->refBin >= 0, "invalid growth reference bin");
     349    psAssert(growth->refBin < growth->apMag->n, "invalid growth reference bin");
     350    growth->refMag = growth->apMag->data.F32[growth->refBin];
     351
     352    // Loop over the range of radii
     353# if (DEBUG)
     354    for (int i = 0; i < growth->radius->n; i++) {
     355        fprintf (fgr, "%f %f  %f %f %f %f\n", xc, yc, growth->radius->data.F32[i], growth->apMag->data.F32[i], growth->fitMag, growth->refMag);
     356    }
     357# endif
     358
    356359    return growth;
    357360}
    358 
    359 # if (0)
    360     // solve for the best growth and the offsets per star to minimize the scatter
    361 
    362     // generate the per-star and per-radius sums
    363     int Nradius = psf->growth->radius->n;
    364     int Nstar = growths->n;
    365 
    366     psVector *Mstar   = psVectorAlloc (Nstar, PS_DATA_F32);
    367     psVector *Mradius = psVectorAlloc (Nradius, PS_DATA_F32);
    368 
    369     psVectorInit (Mstar, 0.0);
    370     psVectorInit (Mradius, 0.0);
    371 
    372     for (int i = 0; i < Nstar; i++) {
    373         pmGrowthCurve *growth = growths->data[i];
    374         for (int j = 0; j < Nradius; j++) {
    375             Mstar->data.F32[i] += growth->apMag->data.F32[j];
    376             Mradius->data.F32[j] += growth->apMag->data.F32[j];
    377         }
    378     }
    379 
    380     psImage *A = psImageAlloc(Nstar + Nradius, Nstar + Nradius, PS_DATA_F32);
    381     psVector *B = psVectorAlloc(Nstar + Nradius, PS_DATA_F32);
    382 
    383     psImageInit (A, 0.0);
    384     psVectorInit (B, 0.0);
    385 
    386     for (int i = 0; i < Nstar; i++) {
    387         A->data.F32[i][i] = Nradius;
    388         B->data.F32[i] = Mstar->data.F32[i];
    389     }
    390     for (int i = 0; i < Nradius; i++) {
    391         int j = i + Nstar;
    392         A->data.F32[j][j] = Nstar;
    393         B->data.F32[j] = Mradius->data.F32[i];
    394     }
    395    
    396     if (!psMatrixGJSolve(A, B)) {
    397         psAbort("GJ failure");
    398     }
    399 
    400     for (int i = 0; i < Nradius; i++) {
    401         psf->growth->apMag->data.F32[i] = B->data.F32[Nstar+i];
    402     }
    403 
    404     // XXX this analysis produces a biased growth curve: points with small radius are more
    405     // likely to err on the side of being too faint (bacause of mis-aligned aperture), while on
    406     // the bright side the tend to be too bright (because of contaminating neighbors).  Bright
    407     // stars are less likely to be biased,
    408 
    409     // XXX at this point, we could iterate and exclude some of the stars with low data quality
    410     // XXX we could also weight the above by flux or something
    411 
    412 # endif
Note: See TracChangeset for help on using the changeset viewer.