IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 7, 2007, 5:15:37 PM (18 years ago)
Author:
eugene
Message:

adding FPA.COMMENT, FPA.TELTEMP.* concepts and TELTEMP parse function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r15416 r15770  
    4545    psAbort("Should never ever get here.\n");
    4646    return NAN;
     47}
     48
     49// TELTEMPS : parse a list of the form 'X1 X2 X3 X4 X5 ...' : for now use median
     50psMetadataItem *p_pmConceptParse_TELTEMPS(const psMetadataItem *concept,
     51                                          const psMetadataItem *pattern,
     52                                          pmConceptSource source,
     53                                          const psMetadata *cameraFormat,
     54                                          const pmFPA *fpa,
     55                                          const pmChip *chip,
     56                                          const pmCell *cell)
     57{
     58    assert(concept);
     59    assert(pattern);
     60
     61    double value = NAN;
     62    switch (concept->type) {
     63      case PS_TYPE_F32:
     64        value = concept->data.F32;
     65        break;
     66      case PS_TYPE_F64:
     67        value = concept->data.F64;
     68        break;
     69      case PS_DATA_STRING: {
     70          // parse the list of values into an array of substrings
     71          psArray *strValues = psStringSplitArray (concept->data.V, " ,;", false);
     72          assert (strValues);
     73
     74          // convert the substrings into a vector
     75          psVector *fltValues = psVectorAlloc (strValues->n, PS_DATA_F32);
     76          for (int i = 0; i < strValues->n; i++) {
     77              fltValues->data.F32[i] = atof(strValues->data[i]);
     78          }
     79
     80          // take the (for now) MEDIAN of the data
     81          psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN);
     82
     83          if (!psVectorStats (stats, fltValues, NULL, NULL, 0)) {
     84              psAbort ("how can this stats function fail?");
     85          }
     86   
     87          value = stats->sampleMedian;
     88          psFree (stats);
     89          psFree (fltValues);
     90          psFree (strValues);
     91          break;
     92      }
     93
     94      default:
     95        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid type for %s (%x)\n", pattern->name, concept->type);
     96        return NULL;
     97    }
     98
     99    psMetadataItem *item = psMetadataItemAllocF32(pattern->name, pattern->comment, value);
     100    return (item);
    47101}
    48102
Note: See TracChangeset for help on using the changeset viewer.