IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 6, 2012, 6:32:19 PM (14 years ago)
Author:
watersc1
Message:

merge from trunk. Preliminary versions of stacktool/warptool updates and regenerate_background.pl script. The warp code is finished and tested, and I still need to get the stack version resolved.

Location:
branches/czw_branch/20120906/psphot
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20120906/psphot

  • branches/czw_branch/20120906/psphot/src

  • branches/czw_branch/20120906/psphot/src/psphotBlendFit.c

    r34404 r34772  
    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
     
    256258
    257259        int TEST_ON = false;
    258 # if (1)
     260# if (0)
    259261# define TEST_X 653
    260262# define TEST_Y 466
    261263        if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
    262264            fprintf (stderr, "test object\n");
    263             //  psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);
     265            psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);
    264266            TEST_ON = true;
    265267        }
     
    377379    if (!source) return false;
    378380    if (!source->peak) return false; // XXX how can we have a peak-less source?
     381
     382# if (0)
     383# define TEST_X 653
     384# define TEST_Y 466
     385        if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
     386            fprintf (stderr, "test object\n");
     387        }
     388# undef TEST_X
     389# undef TEST_Y
     390# endif
     391
    379392    if (!source->moments) return false;
    380393    if (source->type == PM_SOURCE_TYPE_DEFECT) return false;
     
    385398    if (source->mode2 & PM_SOURCE_MODE2_SATSTAR_PROFILE) {
    386399        // find the radius at which we hit something like 0.1*SATURATION
    387         return false;
     400        psphotBlendSetSourceSatstar (IDimage, source);
     401        return true;
    388402    }
    389403
     
    431445    float rMxx = 0.5 / PS_SQR(shape.sx);
    432446    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?
     447    float Sxy = shape.sxy;    // factor of -1 is included to match the previous window function
     448    // implementation. XXX: Is this correct?
    435449
    436450    int ID = source->id;
     
    443457
    444458            float z = rMxx * PS_SQR(dX) + rMyy * PS_SQR(dY) + Sxy*dX*dY;
     459            if (z > 2.311) continue;
    445460
    446461            float f = Io*exp(-z);
     
    453468    return true;
    454469}
     470
     471bool psphotBlendSetSourceSatstar (psImage *IDimage, pmSource *source) {
     472
     473    float Xo = source->satstar->Xo;
     474    float Yo = source->satstar->Yo;
     475    psVector *logRmodel = source->satstar->logRmodel;
     476    psVector *logFmodel = source->satstar->logFmodel;
     477
     478    float lPeak = logFmodel->data.F32[0];
     479    float fPeak = pow(10.0, lPeak);
     480    float threshold = 0.1*fPeak;
     481    float logThresh = log10(threshold);
     482
     483    float radius = NAN;
     484
     485    // what is the radius for a specific peak fraction?
     486    for (int i = 1; i < logFmodel->n; i++) {
     487        float logF = logFmodel->data.F32[i];
     488        if (!isfinite(logF)) continue;
     489
     490        float flux = pow(10.0, logF);
     491        if (flux > threshold) continue;
     492       
     493        float logF0 = logFmodel->data.F32[i - 1];
     494        float logR0 = logRmodel->data.F32[i - 1];
     495
     496        float logF1 = logFmodel->data.F32[i];
     497        float logR1 = logRmodel->data.F32[i];
     498
     499        float logR = InterpolateValues (logF0, logR0, logF1, logR1, logThresh);
     500        radius = pow(10.0, logR);
     501        break;
     502    }
     503
     504    if (!isfinite(radius)) {
     505        for (int i = logFmodel->n - 1; i >= 0; i--) {
     506            if (!isfinite(logFmodel->data.F32[i])) continue;
     507            float logR = logRmodel->data.F32[i];
     508            radius = pow(10.0, logR);
     509            break;
     510        }
     511    }
     512
     513    if (!isfinite(radius)) return false;
     514
     515    int Nx = IDimage->numCols;
     516    int Ny = IDimage->numRows;
     517
     518    // region to mask
     519    int minX = PS_MIN(PS_MAX(Xo - radius, 0), Nx - 1);
     520    int maxX = PS_MIN(PS_MAX(Xo + radius, 0), Nx - 1);
     521    int minY = PS_MIN(PS_MAX(Yo - radius, 0), Ny - 1);
     522    int maxY = PS_MIN(PS_MAX(Yo + radius, 0), Ny - 1);
     523
     524    int ID = source->id;
     525
     526    fprintf (stderr, "Xo,Yo: %f,%f; radius: %f\n", Xo, Yo, radius);
     527
     528    for (int iy = minY; iy < maxY; iy++) {
     529        for (int ix = minX; ix < maxX; ix++) {
     530
     531            float dX = (ix - Xo);
     532            float dY = (iy - Yo);
     533            float R = hypot (dX, dY) ;
     534            if (R > radius) continue;
     535
     536            IDimage->data.S32[iy][ix] = ID;
     537        }
     538    }
     539    return true;
     540}
     541
Note: See TracChangeset for help on using the changeset viewer.