IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36218


Ignore:
Timestamp:
Oct 15, 2013, 11:40:28 AM (13 years ago)
Author:
eugene
Message:

galaxy shape grid defined in recipe

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

Legend:

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

    r36213 r36218  
    421421} psphotStackOptions;
    422422
     423typedef struct {
     424    float fRmajorMin;
     425    float fRmajorMax;
     426    float fRmajorDel;
     427    float fRminorMin;
     428    float fRminorMax;
     429    float fRminorDel;
     430} psphotGalaxyShapeOptions;
     431
    423432/*** psphotStackMatchPSF prototypes ***/
    424433bool psphotStackMatchPSFs (pmConfig *config, const pmFPAview *view);
     
    517526bool psphotGalaxyShapeReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources, pmPSF *psf);
    518527bool psphotGalaxyShape_Threaded (psThreadJob *job);
    519 bool psphotGalaxyShapeGrid (pmSource *source, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, int psfSize);
     528bool psphotGalaxyShapeGrid (pmSource *source, pmSourceFitOptions *fitOptions, psphotGalaxyShapeOptions *opt, psImageMaskType maskVal, int psfSize);
    520529bool psphotGalaxyShapeSource (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal, int psfSize);
     530psphotGalaxyShapeOptions *psphotGalaxyShapeOptionsAlloc();
    521531
    522532bool psphotRadialProfileWings (pmConfig *config, const pmFPAview *view, const char *filerule);
  • branches/eam_branches/ipp-20130904/psphot/src/psphotGalaxyShape.c

    r36216 r36218  
    8383    maskVal |= markVal;
    8484
     85    // bit-mask to mark pixels not used in analysis
     86    psphotGalaxyShapeOptions *opt = psphotGalaxyShapeOptionsAlloc();
     87    opt->fRmajorMin = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MAJOR_MIN"); if (!status) opt->fRmajorMin = 0.5;
     88    opt->fRmajorMax = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MAJOR_MAX"); if (!status) opt->fRmajorMax = 2.0;
     89    opt->fRmajorDel = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MAJOR_DEL"); if (!status) opt->fRmajorDel = 0.1;
     90    opt->fRminorMin = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MINOR_MIN"); if (!status) opt->fRminorMin = 0.5;
     91    opt->fRminorMax = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MINOR_MAX"); if (!status) opt->fRminorMax = 2.0;
     92    opt->fRminorDel = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MINOR_DEL"); if (!status) opt->fRminorDel = 0.1;
     93
    8594    // what fraction of the PSF is used? (radius in pixels : 2 -> 5x5 box)
     95    // NOTE: this is only used if we are NOT smoothing with a 1D Gaussian
    8696    int psfSize = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE");
    8797    assert (status);
     
    119129            psArrayAdd(job->args, 1, cells->data[j]); // sources
    120130            psArrayAdd(job->args, 1, fitOptions);
     131            psArrayAdd(job->args, 1, opt);
    121132            PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK);
    122133            PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);
     
    156167    psFree (cellGroups);
    157168    psFree (fitOptions);
     169    psFree (opt);
    158170
    159171    psLogMsg ("psphot.galaxy", PS_LOG_WARN, "measure galaxy shapes : %f sec for %ld objects\n", psTimerMark ("psphot.galaxy"), sources->n);
     
    166178    psArray *sources               = job->args->data[1];
    167179    pmSourceFitOptions *fitOptions = job->args->data[2];
    168     psImageMaskType markVal        = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA);
    169     psImageMaskType maskVal        = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
    170     int psfSize                    = PS_SCALAR_VALUE(job->args->data[5],S32);
     180    psphotGalaxyShapeOptions *opt  = job->args->data[3];
     181    psImageMaskType markVal        = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
     182    psImageMaskType maskVal        = PS_SCALAR_VALUE(job->args->data[5],PS_TYPE_IMAGE_MASK_DATA);
     183    int psfSize                    = PS_SCALAR_VALUE(job->args->data[6],S32);
    171184
    172185    float fitRadius;
     
    202215        // this function populates moments->Mrf,GalaxyShape,GalaxyShapeErr
    203216        // do the following for a set of shapes (Ex,Ey)
    204         psphotGalaxyShapeGrid (source, fitOptions, maskVal, psfSize);
     217        psphotGalaxyShapeGrid (source, fitOptions, opt, maskVal, psfSize);
     218
    205219        psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal));
    206220
     
    211225}
    212226
    213 bool psphotGalaxyShapeGrid (pmSource *source, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, int psfSize) {
     227bool psphotGalaxyShapeGrid (pmSource *source, pmSourceFitOptions *fitOptions, psphotGalaxyShapeOptions *opt, psImageMaskType maskVal, int psfSize) {
    214228
    215229    // we use the 0th model to define the initial guess shape
     
    230244    // I have some source guess (e0, e1, e2)
    231245    psEllipseAxes guessAxes = pmPSF_ModelToAxes (PAR, modelType);
    232     psEllipsePol guessPol = psEllipseAxesToPol (guessAxes);
    233 
    234     // I am going to retain the value of e0, and grid search around e1,e2
    235     // I need to study a valid range (and distribution?) for e1,e2)
    236246
    237247    if (!source->galaxyFits) {
    238       source->galaxyFits = pmSourceGalaxyFitsAlloc();
    239     }
    240 
    241     for (float de1 = -0.2; de1 <= +0.2; de1 += 0.1) {
    242         for (float de2 = -0.2; de2 <= +0.2; de2 += 0.1) {
     248        source->galaxyFits = pmSourceGalaxyFitsAlloc();
     249    }
     250
     251    for (float fRmajor = opt->fRmajorMin; fRmajor < opt->fRmajorMax + 0.5*opt->fRmajorDel; fRmajor += opt->fRmajorDel) {
     252        for (float fRminor = opt->fRminorMin; fRminor < opt->fRminorMax + 0.5*opt->fRminorDel; fRminor += opt->fRminorDel) {
    243253 
    244             psEllipsePol testPol = guessPol;
    245             testPol.e1 += de1;
    246             testPol.e2 += de2;
    247 
    248             psEllipseAxes axes = psEllipsePolToAxes (testPol, 0.1);
    249 
    250             pmPSF_AxesToModel (PAR, axes, modelType);
    251 
     254            psEllipseAxes testAxes = guessAxes;
     255            testAxes.major = guessAxes.major * fRmajor;
     256            testAxes.minor = guessAxes.minor * fRminor;
     257           
     258            pmPSF_AxesToModel (PAR, testAxes, modelType);
     259           
    252260            // where do the results go??
    253261            psphotGalaxyShapeSource (pcm, source, maskVal, psfSize);
    254262        }
    255263    }
     264
    256265    psFree (pcm);
    257266    return true;
     
    267276
    268277    // generate the modelFlux
     278    // need to reset here each time since we assign below to calculate the flux
    269279    pmPCMMakeModel (source, pcm->modelConv, maskVal, psfSize);
     280    pcm->modelConv->params->data.F32[PM_PAR_I0] = 1.0;
    270281       
    271282    int nPix = 0;
     
    273284    float YM = 0.0;
    274285    float MM = 0.0;
    275     bool usePoisson = false;
     286    bool usePoisson = true;
    276287
    277288    for (int iy = 0; iy < source->pixels->numRows; iy++) {
     
    306317    float Chisq = (YY - 2 * Io * YM + Io * Io * MM) / (float) nPix;
    307318
    308     // fprintf (stderr, "Io: %f, Chisq: %f\n", Io, Chisq);
    309 
    310     psVectorAppend (source->galaxyFits->Io, Io);
    311     psVectorAppend (source->galaxyFits->dIo, dIo);
     319    pcm->modelConv->params->data.F32[PM_PAR_I0] = Io;
     320    float flux = pcm->modelConv->modelFlux (pcm->modelConv->params);
     321    float dflux = flux * (dIo / Io);
     322
     323    psVectorAppend (source->galaxyFits->Flux, flux);
     324    psVectorAppend (source->galaxyFits->dFlux, dflux);
    312325    psVectorAppend (source->galaxyFits->chisq, Chisq);
    313326    source->galaxyFits->nPix = nPix;
     
    315328    return true;
    316329}
     330
     331/**** support functions ****/
     332
     333void psphotGalaxyShapeOptionsFree (psphotGalaxyShapeOptions *opt) {
     334    return;
     335}
     336
     337psphotGalaxyShapeOptions *psphotGalaxyShapeOptionsAlloc()
     338{
     339    psphotGalaxyShapeOptions *opt = (psphotGalaxyShapeOptions *) psAlloc(sizeof(psphotGalaxyShapeOptions));
     340    psMemSetDeallocator(opt, (psFreeFunc) psphotGalaxyShapeOptionsFree);
     341   
     342    opt->fRmajorMin = 0.5;
     343    opt->fRmajorMax = 2.0;
     344    opt->fRmajorDel = 0.1;
     345    opt->fRminorMin = 0.5;
     346    opt->fRminorMax = 2.0;
     347    opt->fRminorDel = 0.1;
     348
     349    return opt;
     350}
     351
  • branches/eam_branches/ipp-20130904/psphot/src/psphotSetThreads.c

    r36213 r36218  
    5757    psFree(task);
    5858
    59     task = psThreadTaskAlloc("PSPHOT_GALAXY_SHAPES", 6);
     59    task = psThreadTaskAlloc("PSPHOT_GALAXY_SHAPES", 7);
    6060    task->function = &psphotGalaxyShape_Threaded;
    6161    psThreadTaskAdd(task);
Note: See TracChangeset for help on using the changeset viewer.