IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 15, 2013, 7:38:26 AM (13 years ago)
Author:
eugene
Message:

minor notes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130711/psModules/src/objects/pmModel_CentralPixel.c

    r35947 r35948  
    309309}
    310310
     311float pmModelCP_GetFlux_RotSqaure (pmModelCP *cp, float dx, float dy, float theta) {
     312
     313    // the cp data is defined for the central 3x3 pixels.  we allow dx,dy to have values of
     314    // -1.0 <= dx,dy <= +1.0
     315
     316    // Xsub = (Xim * cos(theta) - Yim * sin(theta) + 1.5) * Nsub
     317    // Ysub = (Yim * cos(theta) + Xim * sin(theta) + 1.5) * Nsub
     318   
     319    // integrate from (dx - 0.5 to dx + 0.5), (dy - 0.5 to dy + 0.5),
     320
     321    // get the Xsub,Ysub values for the 4 corners, find the Xmin,Xmax, Ymin,Ymax in the
     322    // subrastered image
     323
     324    float cs = cos(theta*PS_RAD_DEG);
     325    float sn = sin(theta*PS_RAD_DEG);
     326
     327    float Nsub = 11.0;
     328    int Xsub00 = ((dx - 0.5)*cs - (dy - 0.5)*sn + 1.5)*Nsub;
     329    int Ysub00 = ((dx - 0.5)*sn + (dy - 0.5)*cs + 1.5)*Nsub;
     330    int Xsub01 = ((dx - 0.5)*cs - (dy + 0.5)*sn + 1.5)*Nsub;
     331    int Ysub01 = ((dx - 0.5)*sn + (dy + 0.5)*cs + 1.5)*Nsub;
     332    int Xsub10 = ((dx + 0.5)*cs - (dy - 0.5)*sn + 1.5)*Nsub;
     333    int Ysub10 = ((dx + 0.5)*sn + (dy - 0.5)*cs + 1.5)*Nsub;
     334    int Xsub11 = ((dx + 0.5)*cs - (dy + 0.5)*sn + 1.5)*Nsub;
     335    int Ysub11 = ((dx + 0.5)*sn + (dy + 0.5)*cs + 1.5)*Nsub;
     336
     337    /* generic rotated square:
     338       
     339     */
     340
     341    int Xmin, Xmax, Ymin, Ymax;
     342
     343    Xmin = PS_MIN(Xsub00,Xsub01);
     344    Xmin = PS_MIN(Xsub10,Xmin);
     345    Xmin = PS_MIN(Xsub11,Xmin);
     346    Xmin = PS_MIN(Xmin, cp->flux->numCols - 1);
     347    Xmin = PS_MAX(Xmin, 0);
     348    Xmax = PS_MAX(Xsub00,Xsub01);
     349    Xmax = PS_MAX(Xsub10,Xmax);
     350    Xmax = PS_MAX(Xsub11,Xmax);
     351    Xmax = PS_MIN(Xmax, cp->flux->numCols - 1);
     352    Xmax = PS_MAX(Xmax, 0);
     353    Ymin = PS_MIN(Ysub00,Ysub01);
     354    Ymin = PS_MIN(Ysub10,Ymin);
     355    Ymin = PS_MIN(Ysub11,Ymin);
     356    Ymin = PS_MIN(Ymin, cp->flux->numRows - 1);
     357    Ymin = PS_MAX(Ymin, 0);
     358    Ymax = PS_MAX(Ysub00,Ysub01);
     359    Ymax = PS_MAX(Ysub10,Ymax);
     360    Ymax = PS_MAX(Ysub11,Ymax);
     361    Ymax = PS_MIN(Ymax, cp->flux->numRows - 1);
     362    Ymax = PS_MAX(Ymax, 0);
     363
     364    // integrate pixels from Xmin,Ymin to Xmax,Ymax, only include pixels contained in the
     365    // target pixel
     366
     367    float flux = 0.0;
     368    int   npix = 0;
     369    for (int i = Xmin; i < Xmax; i++) {
     370        float dX = i / Nsub - 1.5;
     371        for (int j = Ymin; j < Ymax; j++) {
     372            float dY = j / Nsub - 1.5;
     373
     374            float Xim =  dX*cs + dY*sn;
     375            if (Xim < (dx - 0.5)) continue;
     376            if (Xim > (dx + 0.5)) continue;
     377
     378            float Yim = -dX*sn + dY*cs;
     379            if (Yim < (dy - 0.5)) continue;
     380            if (Yim > (dy + 0.5)) continue;
     381
     382            flux += cp->flux->data.F32[j][i];
     383            npix ++;
     384        }
     385    }
     386           
     387    float normFlux = flux / npix;
     388    return normFlux;
     389}
     390
    311391float pmModelCP_GetFlux_Bresen (pmModelCP *cp, float dx, float dy, float theta) {
    312392
Note: See TracChangeset for help on using the changeset viewer.