IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 5, 2013, 2:20:46 PM (13 years ago)
Author:
eugene
Message:

stats is basically working now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarpOverlaps.c

    r35434 r35512  
    4545        if (!chip->process || !chip->file_exists) {
    4646            // this ensures one entry per chip (regardless of existence)
    47             // XXX maybe not? pswarpBoundsAppend (bounds, NAN, NAN, NAN, NAN);
     47            pswarpBoundsAppend (bounds, NAN, NAN, NAN, NAN);
    4848            continue;
    4949        }
     
    8383            }
    8484        }
    85         fprintf (stderr, "bounds %d : %f - %f, %f - %f\n", view->chip, Pmin, Pmax, Qmin, Qmax);
     85        // fprintf (stderr, "bounds %d : %f - %f, %f - %f\n", view->chip, Pmin, Pmax, Qmin, Qmax);
    8686        pswarpBoundsAppend (bounds, Pmin, Pmax, Qmin, Qmax);
    8787    }
     
    164164}
    165165
    166 bool pswarpFindOverlap (pmFPA *fpa, pswarpBounds *src, pswarpBounds *tgt) {
     166bool pswarpFindOverlap (pmFPA *input, pmFPA *output, pswarpBounds *src, pswarpBounds *tgt) {
    167167
    168168    // we have the source and target bounds.  loop over all output elements and check if any of the source
    169169    // elements overlap it.
    170170
    171     assert (fpa->chips->n == tgt->Pmin->n);
    172 
    173     for (int j = 0; j < fpa->chips->n; j++) {
    174         pmChip *chip = fpa->chips->data[j];
     171    // also add the list if input (src) cells which land on each output (tgt) chip we do this
     172    // by only identifying the input and output chips and adding all input chip cells to each
     173    // output cell
     174
     175    assert (output->chips->n == tgt->Pmin->n);
     176    assert (input->chips->n == src->Pmin->n);
     177
     178    for (int j = 0; j < output->chips->n; j++) {
     179        pmChip *chip = output->chips->data[j];
    175180
    176181        // we have src bounds
     
    180185        float Qmax = tgt->Qmax->data.F32[j];
    181186
    182         bool valid = false;
    183         for (int i = 0; !valid && (i < src->Pmin->n); i++) {
     187        psArray *inputChips = psArrayAllocEmpty(8);
     188
     189        bool hasOverlap = false;
     190        for (int i = 0; i < src->Pmin->n; i++) {
    184191            // overlaps in P?
    185             bool Pvalid = (Pmin < src->Pmax->data.F32[i]) && (Pmax > src->Pmin->data.F32[i]);
    186             bool Qvalid = (Qmin < src->Qmax->data.F32[i]) && (Qmax > src->Qmin->data.F32[i]);
    187             valid = Pvalid && Qvalid;
    188         }
    189         // if (valid) {
    190         //     fprintf (stderr, "chip %d is valid\n", j);
    191         // } else {
    192         //     fprintf (stderr, "chip %d is NOT valid\n", j);
    193         // }
    194         chip->process = valid;
     192            if (!isfinite(src->Pmin->data.F32[i])) continue;
     193            if (!isfinite(src->Pmax->data.F32[i])) continue;
     194            if (!isfinite(src->Qmin->data.F32[i])) continue;
     195            if (!isfinite(src->Qmax->data.F32[i])) continue;
     196
     197            if (Pmin > src->Pmax->data.F32[i]) continue;
     198            if (Pmax < src->Pmin->data.F32[i]) continue;
     199
     200            if (Qmin > src->Qmax->data.F32[i]) continue;
     201            if (Qmax < src->Qmin->data.F32[i]) continue;
     202
     203            hasOverlap = true;
     204            psArrayAdd (inputChips, 1, input->chips->data[i]);
     205        }
     206        chip->process = hasOverlap;
     207        if (hasOverlap) {
     208            // get the complete list of input cells for this set of input chips
     209            // pmConceptsAverageCells needs a psList (not a psArray)
     210            psList *inputCells = psListAlloc(NULL);
     211            for (int nChip = 0; nChip < inputChips->n; nChip++) {
     212                pmChip *inputChip = inputChips->data[nChip];
     213                for (int nCell = 0; nCell < inputChip->cells->n; nCell++) {
     214                    fprintf (stderr, "input %d, %d : output %d\n", nChip, nCell, j);
     215                    psListAdd (inputCells, PS_LIST_TAIL, inputChip->cells->data[nCell]);
     216                }
     217            }
     218           
     219            // place the inputCells on each of the output cells
     220            for (int nCell = 0; nCell < chip->cells->n; nCell++) {
     221                pmCell *outputCell = chip->cells->data[nCell];
     222                psMetadataAddPtr(outputCell->analysis, PS_LIST_TAIL, "INPUT.CELLS", PS_DATA_LIST , "input cells touching this output cell", inputCells);
     223            }
     224            psFree (inputCells);
     225        }
     226        psFree (inputChips);
    195227    }
    196228    return true;
Note: See TracChangeset for help on using the changeset viewer.