IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30775


Ignore:
Timestamp:
Mar 2, 2011, 5:43:29 PM (15 years ago)
Author:
eugene
Message:

need to handle plain sources and sources with parents from psphotStack

Location:
branches/eam_branches/ipp-20110213/psModules/src/objects
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/psModules/src/objects/pmSource.c

    r30621 r30775  
    11661166}
    11671167
     1168// sort by SN (descending)
     1169int pmSourceSortByParentSN (const void **a, const void **b)
     1170{
     1171    pmSource *Ao = *(pmSource **)a;
     1172    pmSource *Bo = *(pmSource **)b;
     1173    pmSource *A  = Ao->parent;
     1174    pmSource *B  = Bo->parent;
     1175
     1176    psF32 fA = (A->peak == NULL) ? 0 : A->peak->SN;
     1177    psF32 fB = (B->peak == NULL) ? 0 : B->peak->SN;
     1178    if (isnan (fA)) fA = 0;
     1179    if (isnan (fB)) fB = 0;
     1180
     1181    psF32 diff = fA - fB;
     1182    if (diff > FLT_EPSILON) return (-1);
     1183    if (diff < FLT_EPSILON) return (+1);
     1184    return (0);
     1185}
     1186
    11681187// sort by Y (ascending)
    11691188int pmSourceSortByY (const void **a, const void **b)
     
    12011220    pmSource *A = *(pmSource **)a;
    12021221    pmSource *B = *(pmSource **)b;
     1222
     1223    int iA = A->seq;
     1224    int iB = B->seq;
     1225
     1226    int diff = iA - iB;
     1227    if (diff > 0) return (+1);
     1228    if (diff < 0) return (-1);
     1229    return (0);
     1230}
     1231
     1232// sort by Seq (ascending)
     1233int pmSourceSortByParentSeq (const void **a, const void **b)
     1234{
     1235    pmSource *Ao = *(pmSource **)a;
     1236    pmSource *Bo = *(pmSource **)b;
     1237    pmSource *A  = Ao->parent;
     1238    pmSource *B  = Bo->parent;
    12031239
    12041240    int iA = A->seq;
  • branches/eam_branches/ipp-20110213/psModules/src/objects/pmSource.h

    r30621 r30775  
    286286bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal);
    287287
    288 int  pmSourceSortBySN (const void **a, const void **b);
    289288int  pmSourceSortByY (const void **a, const void **b);
    290289int  pmSourceSortByX (const void **a, const void **b);
    291290int  pmSourceSortBySeq (const void **a, const void **b);
     291int  pmSourceSortByParentSeq (const void **a, const void **b);
     292int  pmSourceSortBySN (const void **a, const void **b);
     293int  pmSourceSortByParentSN (const void **a, const void **b);
    292294
    293295pmSourceMode pmSourceModeFromString (const char *name);
  • branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourceIO_CMF_PS1_SV1.c

    r30763 r30775  
    7070    pmChip *chip = readout->parent->parent;
    7171
    72     // if the sequence is defined, write these in seq order; otherwise
    73     // write them in S/N order:
     72    // if the sequence is defined, write these in seq order; otherwise write them in S/N order.
     73    // Careful: if we are working with child sources, then we need to sort by the parent info,
     74    // not our info
    7475    if (sources->n > 0) {
    75         pmSource *source = (pmSource *) sources->data[0];
     76        pmSource *source = sources->data[0];
    7677        if (source->seq == -1) {
    77             // let's write these out in S/N order
    7878            sources = psArraySort (sources, pmSourceSortBySN);
    7979        } else {
     
    9494    // by the time we call this function, all values should be assigned.  let's use asserts to be sure in some cases.
    9595    for (int i = 0; i < sources->n; i++) {
    96         pmSource *source = (pmSource *) sources->data[i];
    97 
    98         // If source->seq is -1, source was generated in this analysis.  If source->seq is
    99         // not -1, source was read from elsewhere: in the latter case, preserve the source
    100         // ID.  source.seq is used instead of source.id since the latter is a const
    101         // generated on Alloc, and would thus be wrong for read in sources.
     96        // this is the source associated with this image
     97        pmSource *thisSource = sources->data[i];
     98
     99        // this is the "real" version of this source
     100        pmSource *source = thisSource->parent ? thisSource->parent : thisSource;
     101
     102        // If source->seq is -1, source is unique and generated in this analysis.  If
     103        // source->seq is not -1, source was read from elsewhere or tied to other source (eg
     104        // from another image): in the latter case, preserve the source ID.  source.seq is used
     105        // instead of source.id since the latter is a const generated on Alloc, and would thus
     106        // be wrong for read in sources.
    102107        if (source->seq == -1) {
    103108            source->seq = i;
     
    398403    // we write out all sources, regardless of quality.  the source flags tell us the state
    399404    for (int i = 0; i < sources->n; i++) {
    400         pmSource *source = sources->data[i];
     405        // this is the source associated with this image
     406        pmSource *thisSource = sources->data[i];
     407
     408        // this is the "real" version of this source
     409        pmSource *source = thisSource->parent ? thisSource->parent : thisSource;
    401410
    402411        // skip sources without measurements
     
    555564    int nParamMax = 0;
    556565    for (int i = 0; i < sources->n; i++) {
    557         pmSource *source = sources->data[i];
     566        // this is the source associated with this image
     567        pmSource *thisSource = sources->data[i];
     568
     569        // this is the "real" version of this source
     570        pmSource *source = thisSource->parent ? thisSource->parent : thisSource;
     571
    558572        if (source->modelFits == NULL) continue;
    559573        for (int j = 0; j < source->modelFits->n; j++) {
     
    569583    for (int i = 0; i < sources->n; i++) {
    570584
    571         pmSource *source = sources->data[i];
     585        pmSource *thisSource = sources->data[i];
     586
     587        // this is the "real" version of this source
     588        pmSource *source = thisSource->parent ? thisSource->parent : thisSource;
    572589
    573590        // XXX if no model fits are saved, write out modelEXT?
     
    719736    for (int i = 0; i < sources->n; i++) {
    720737
    721         pmSource *source = sources->data[i];
     738        // this is the source associated with this image
     739        pmSource *thisSource = sources->data[i];
     740
     741        // this is the "real" version of this source
     742        pmSource *source = thisSource->parent ? thisSource->parent : thisSource;
    722743
    723744        // skip sources without radial aper measurements (or insufficient)
    724         if (source->radialAper == NULL) continue;
     745        if (source->radialAper == NULL) continue;
     746
    725747        // psAssert (source->radialAper->n == fwhmValues->n, "inconsistent radial aperture set");
    726748
Note: See TracChangeset for help on using the changeset viewer.