IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34409


Ignore:
Timestamp:
Sep 6, 2012, 6:40:26 AM (14 years ago)
Author:
eugene
Message:

fixing model id image, adding satstars

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120905/psphot/src/psphotBlendFit.c

    r34408 r34409  
    11# include "psphotInternal.h"
    22bool psphotBlendFitSetSource(pmSource *source, psImage *IDimage, float sigSigma);
     3bool psphotBlendSetSourceSatstar (psImage *image, pmSource *source);
     4float InterpolateValues (float X0, float Y0, float X1, float Y1, float X);
    35
    46// for now, let's store the detections on the readout->analysis for each readout
     
    385387    if (source->mode2 & PM_SOURCE_MODE2_SATSTAR_PROFILE) {
    386388        // find the radius at which we hit something like 0.1*SATURATION
    387         return false;
     389        psphotBlendSetSourceSatstar (IDimage, source);
     390        return true;
    388391    }
    389392
     
    431434    float rMxx = 0.5 / PS_SQR(shape.sx);
    432435    float rMyy = 0.5 / PS_SQR(shape.sy);
    433     float Sxy = -1. * shape.sxy;    // factor of -1 is included to match the previous window function
    434                                     // implementation. XXX: Is this correct?
     436    float Sxy = shape.sxy;    // factor of -1 is included to match the previous window function
     437    // implementation. XXX: Is this correct?
    435438
    436439    int ID = source->id;
     
    443446
    444447            float z = rMxx * PS_SQR(dX) + rMyy * PS_SQR(dY) + Sxy*dX*dY;
     448            if (z > 2.311) continue;
    445449
    446450            float f = Io*exp(-z);
     
    453457    return true;
    454458}
     459
     460bool psphotBlendSetSourceSatstar (psImage *IDimage, pmSource *source) {
     461
     462    float Xo = source->satstar->Xo;
     463    float Yo = source->satstar->Yo;
     464    psVector *logRmodel = source->satstar->logRmodel;
     465    psVector *logFmodel = source->satstar->logFmodel;
     466
     467    float lPeak = logFmodel->data.F32[0];
     468    float fPeak = pow(10.0, lPeak);
     469    float threshold = 0.1*fPeak;
     470    float logThresh = log10(threshold);
     471
     472    float radius = NAN;
     473
     474    // what is the radius for a specific peak fraction?
     475    for (int i = 0; i < logFmodel->n; i++) {
     476        float logF = logFmodel->data.F32[i];
     477        float flux = pow(10.0, logF);
     478        if (flux > threshold) continue;
     479        if (i == 0) continue;
     480       
     481        float logF0 = logFmodel->data.F32[i - 1];
     482        float logR0 = logRmodel->data.F32[i - 1];
     483
     484        float logF1 = logFmodel->data.F32[i];
     485        float logR1 = logRmodel->data.F32[i];
     486
     487        float logR = InterpolateValues (logF0, logR0, logF1, logR1, logThresh);
     488        radius = pow(10.0, logR);
     489        break;
     490    }
     491
     492    if (!isfinite(radius)) {
     493        for (int i = logFmodel->n - 1; i >= 0; i--) {
     494            if (!isfinite(logFmodel->data.F32[i])) continue;
     495            float logR = logRmodel->data.F32[i];
     496            radius = pow(10.0, logR);
     497            break;
     498        }
     499    }
     500
     501    if (!isfinite(radius)) return false;
     502
     503    int Nx = IDimage->numCols;
     504    int Ny = IDimage->numRows;
     505
     506    // region to mask
     507    int minX = PS_MIN(PS_MAX(Xo - radius, 0), Nx - 1);
     508    int maxX = PS_MIN(PS_MAX(Xo + radius, 0), Nx - 1);
     509    int minY = PS_MIN(PS_MAX(Yo - radius, 0), Ny - 1);
     510    int maxY = PS_MIN(PS_MAX(Yo + radius, 0), Ny - 1);
     511
     512    int ID = source->id;
     513
     514    for (int iy = minY; iy < maxY; iy++) {
     515        for (int ix = minX; ix < maxX; ix++) {
     516
     517            float dX = (ix - Xo);
     518            float dY = (iy - Yo);
     519            float R = hypot (dX, dY) ;
     520            if (R > radius) continue;
     521
     522            IDimage->data.S32[iy][ix] = ID;
     523        }
     524    }
     525    return true;
     526}
     527
Note: See TracChangeset for help on using the changeset viewer.