IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 23, 2007, 4:39:12 PM (19 years ago)
Author:
magnier
Message:

changing CrossProduct functions to DataDotModel and ModelDotModel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_02_branch/psModules/src/objects/pmSourcePhotometry.c

    r12958 r12977  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.22.4.5 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-04-23 18:04:18 $
     5 *  @version $Revision: 1.22.4.6 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-04-24 02:39:04 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    369369}
    370370
     371# if (0)
    371372double pmSourceCrossProduct (const pmSource *Mi,
    372373                             const pmSource *Mj,
     
    527528    return flux;
    528529}
     530# endif
    529531
    530532bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight)
     
    549551}
    550552
     553
     554double pmSourceModelWeight(const pmSource *Mi,
     555                      int term,
     556                      const bool unweighted_sum) // should the cross product be weighted?
     557{
     558    double flux = 0, wt = 0, factor = 0;
     559
     560    const psImage *Pi = Mi->modelFlux;
     561    const psImage *Wi = Mi->weight;
     562    const psImage *Ti = Mi->maskObj;
     563
     564    for (int yi = 0; yi < Pi->numRows; yi++) {
     565        for (int xi = 0; xi < Pi->numCols; xi++) {
     566            if (Ti->data.U8[yi][xi])
     567                continue;
     568            if (!unweighted_sum) {
     569                wt = Wi->data.F32[yi][xi];
     570                if (wt == 0)
     571                    continue;
     572            }
     573
     574            switch (term) {
     575            case 0:
     576                factor = 1;
     577                break;
     578            case 1:
     579                factor = xi + Pi->col0;
     580                break;
     581            case 2:
     582                factor = yi + Pi->row0;
     583                break;
     584            default:
     585                psAbort("invalid term for pmSourceWeight");
     586            }
     587
     588            if (unweighted_sum) {
     589                flux += (factor * Pi->data.F32[yi][xi]);
     590            } else {
     591                flux += (factor * Pi->data.F32[yi][xi]) / wt;
     592            }
     593        }
     594    }
     595    return flux;
     596}
     597
     598double pmSourceModelDotModel (const pmSource *Mi,
     599                              const pmSource *Mj,
     600                              const bool unweighted_sum) // should the cross product be weighted?
     601{
     602    int Xs, Xe, Ys, Ye;
     603    int xi, xj, yi, yj;
     604    int xIs, xJs, yIs, yJs;
     605    int xIe, yIe;
     606    double flux, wt;
     607
     608    const psImage *Pi = Mi->modelFlux;
     609    const psImage *Pj = Mj->modelFlux;
     610
     611    const psImage *Wi = Mi->weight;
     612
     613    const psImage *Ti = Mi->maskObj;
     614    const psImage *Tj = Mj->maskObj;
     615
     616    Xs = PS_MAX (Pi->col0, Pj->col0);
     617    Xe = PS_MIN (Pi->col0 + Pi->numCols, Pj->col0 + Pj->numCols);
     618
     619    Ys = PS_MAX (Pi->row0, Pj->row0);
     620    Ye = PS_MIN (Pi->row0 + Pi->numRows, Pj->row0 + Pj->numRows);
     621
     622    xIs = Xs - Pi->col0;
     623    xJs = Xs - Pj->col0;
     624    yIs = Ys - Pi->row0;
     625    yJs = Ys - Pj->row0;
     626
     627    xIe = Xe - Pi->col0;
     628    yIe = Ye - Pi->row0;
     629
     630    // note that weight is addressing the same image pixels
     631    flux = 0;
     632    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
     633        for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
     634            if (Ti->data.U8[yi][xi])
     635                continue;
     636            if (Tj->data.U8[yj][xj])
     637                continue;
     638
     639            // XXX skip the nonsense weight pixels?
     640            if (unweighted_sum) {
     641                flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
     642            } else {
     643                wt = Wi->data.F32[yi][xi];
     644                if (wt > 0) {
     645                    flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
     646                }
     647            }
     648        }
     649    }
     650    return flux;
     651}
     652
     653double pmSourceDataDotModel (const pmSource *Mi,
     654                             const pmSource *Mj,
     655                             const bool unweighted_sum) // should the cross product be weighted?
     656{
     657
     658    int Xs, Xe, Ys, Ye;
     659    int xi, xj, yi, yj;
     660    int xIs, xJs, yIs, yJs;
     661    int xIe, yIe;
     662    double flux, wt;
     663
     664    const psImage *Pi = Mi->pixels;
     665    const psImage *Pj = Mj->modelFlux;
     666
     667    const psImage *Wi = Mi->weight;
     668
     669    const psImage *Ti = Mi->maskObj;
     670    const psImage *Tj = Mj->maskObj;
     671
     672    Xs = PS_MAX (Pi->col0, Pj->col0);
     673    Xe = PS_MIN (Pi->col0 + Pi->numCols, Pj->col0 + Pj->numCols);
     674
     675    Ys = PS_MAX (Pi->row0, Pj->row0);
     676    Ye = PS_MIN (Pi->row0 + Pi->numRows, Pj->row0 + Pj->numRows);
     677
     678    xIs = Xs - Pi->col0;
     679    xJs = Xs - Pj->col0;
     680    yIs = Ys - Pi->row0;
     681    yJs = Ys - Pj->row0;
     682
     683    xIe = Xe - Pi->col0;
     684    yIe = Ye - Pi->row0;
     685
     686    // note that weight is addressing the same image pixels,
     687    flux = 0;
     688    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
     689        for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
     690            if (Ti->data.U8[yi][xi])
     691                continue;
     692            if (Tj->data.U8[yj][xj])
     693                continue;
     694
     695            // XXX skip the nonsense weight pixels?
     696            if (unweighted_sum) {
     697                flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
     698            } else {
     699                wt = Wi->data.F32[yi][xi];
     700                if (wt > 0) {
     701                    flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
     702                }
     703            }
     704        }
     705    }
     706    return flux;
     707}
     708
Note: See TracChangeset for help on using the changeset viewer.