IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 9, 2010, 4:41:16 PM (16 years ago)
Author:
eugene
Message:

working on psphotStack (nearly done)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/stackphot.20100406/psphot/src/psphotFitSourcesLinearStack.c

    r27625 r27649  
    33// XXX define the 'good' / 'bad' flags?
    44
     5# define COVAR_FACTOR 1.0
     6
    57bool psphotFitSourcesLinearStack (pmConfig *config, psArray *objects, bool final) {
    68
    79    bool status;
    8     float x;
    9     float y;
    1010    float f;
    1111
     
    2929    // analysis is done in spatial order (to speed up overlap search)
    3030    // sort by first element in each source list
    31     objects = psArraySort (objects, pmPhotObjSortByY);
     31    objects = psArraySort (objects, pmPhotObjSortByX);
    3232
    3333    // storage array for fitSources
     
    6666        }
    6767    }
    68     psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "built fitSources: %f sec (%ld objects)\n", psTimerMark ("psphot.linear"), sources->n);
     68    psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "built fitSources: %f sec (%ld objects)\n", psTimerMark ("psphot.linear"), objects->n);
    6969
    7070    if (fitSources->n == 0) {
     
    8686
    8787        // diagonal elements of the sparse matrix (auto-cross-product)
    88         f = pmSourceModelDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);
     88        f = pmSourceModelDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, COVAR_FACTOR);
    8989        psSparseMatrixElement (sparse, i, i, f);
    9090
    9191        // the formal error depends on the weighting scheme
    9292        if (CONSTANT_PHOTOMETRIC_WEIGHTS) {
    93             float var = pmSourceModelDotModel (SRCi, SRCi, false, covarFactor);
     93            float var = pmSourceModelDotModel (SRCi, SRCi, false, COVAR_FACTOR);
    9494            errors->data.F32[i] = 1.0 / sqrt(var);
    9595        } else {
     
    9898
    9999        // find the image x model value
    100         f = pmSourceDataDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);
     100        f = pmSourceDataDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, COVAR_FACTOR);
    101101        psSparseVectorElement (sparse, i, f);
    102102
     
    109109
    110110            // skip over disjoint source images, break after last possible overlap
    111             if (SRCi->pixels->row0 + SRCi->pixels->numRows < SRCj->pixels->row0) break;
    112             if (SRCj->pixels->row0 + SRCj->pixels->numRows < SRCi->pixels->row0) continue;
    113             if (SRCi->pixels->col0 + SRCi->pixels->numCols < SRCj->pixels->col0) continue;
    114             if (SRCj->pixels->col0 + SRCj->pixels->numCols < SRCi->pixels->col0) continue;
     111            if (SRCj->pixels->row0 + SRCj->pixels->numRows < SRCi->pixels->row0) continue;  // source(i) is above source(j)
     112            if (SRCi->pixels->row0 + SRCi->pixels->numRows < SRCj->pixels->row0) continue;  // source(i) is below source(j)
     113            if (SRCj->pixels->col0 + SRCj->pixels->numCols < SRCi->pixels->col0) continue;  // source(i) is right of source(j)
     114            if (SRCi->pixels->col0 + SRCi->pixels->numCols < SRCj->pixels->col0) break;     // source(i) is left of source(j) [no other source(j) can overlap source(i)]
    115115
    116116            // got an overlap; calculate cross-product and add to output array
    117             f = pmSourceModelDotModel (SRCi, SRCj, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);
     117            f = pmSourceModelDotModel (SRCi, SRCj, CONSTANT_PHOTOMETRIC_WEIGHTS, COVAR_FACTOR);
    118118            psSparseMatrixElement (sparse, j, i, f);
    119119        }
     
    157157        if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) continue;
    158158        pmModel *model = pmSourceGetModel (NULL, source);
    159         pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal, covarFactor);
     159        pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal, COVAR_FACTOR);
    160160    }
    161161    psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "get chisqs: %f sec (%d elements)\n", psTimerMark ("psphot.linear"), sparse->Nelem);
     
    172172}
    173173
    174 // sort by Y (ascending)
    175 int pmPhotObjSortBySN (const void **a, const void **b)
     174// sort by X (ascending)
     175int pmPhotObjSortByX (const void **a, const void **b)
    176176{
    177177    pmPhotObj *objA = *(pmPhotObj **)a;
    178178    pmPhotObj *objB = *(pmPhotObj **)b;
    179179
    180     psAssert (objA->sources, "missing sources?");
    181     psAssert (objB->sources, "missing sources?");
    182 
    183     psAssert (objA->sources->n, "missing sources");
    184     psAssert (objB->sources->n, "missing sources");
    185 
    186     psAssert (objA->sources->data[0], "missing sources");
    187     psAssert (objB->sources->data[0], "missing sources");
    188 
    189     pmSource *A = objA->sources->data[0];
    190     pmSource *B = objB->sources->data[0];
    191 
    192     psF32 fA = (A->peak == NULL) ? 0 : A->peak->y;
    193     psF32 fB = (B->peak == NULL) ? 0 : B->peak->y;
     180    psF32 fA = objA->x;
     181    psF32 fB = objB->x;
    194182
    195183    psF32 diff = fA - fB;
     
    198186    return (0);
    199187}
    200 
Note: See TracChangeset for help on using the changeset viewer.