IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30107


Ignore:
Timestamp:
Dec 17, 2010, 10:08:25 AM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20101205/psModules/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/psModules/src/camera/pmFPAfile.c

    r29833 r30107  
    3636        return;
    3737    }
    38     psTrace ("pmFPAfileFree", 5, "freeing %s %ld\n", file->name,(psU64) file->fits);
     38    psTrace ("pmFPAfileFree", 5, "freeing %s %p\n", file->name, file->fits);
    3939    psAssert(!fpaFileFreeStrict || file->fits == NULL, "File %s wasn't closed.", file->name);
    4040
  • branches/eam_branches/ipp-20101205/psModules/src/concepts/pmConcepts.c

    r28552 r30107  
    249249CONCEPT_REGISTER_FUNCTION(S32, Enum, -1); // For enums: set default to -1
    250250CONCEPT_REGISTER_FUNCTION(S32, S32, 0); // For values: set default to 0
    251 //CONCEPT_REGISTER_FUNCTION(Bool, Bool, NULL); // For values: set default to 0
     251CONCEPT_REGISTER_FUNCTION(Bool, Bool, NULL); // For values: set default to 0
    252252
    253253static void conceptRegisterTime(const char *name, /* Name of concept */ \
     
    353353        conceptRegisterStr("CHIP.ID", "Chip identifier", NULL, NULL, NULL, false, PM_FPA_LEVEL_CHIP);
    354354        conceptRegisterF32("CHIP.SEEING", "Seeing FWHM (pixels)", NULL, NULL, NULL, false, PM_FPA_LEVEL_CHIP);
     355        conceptRegisterBool("CHIP.VIDEOCELL", "Does this OTA have any video cells", p_pmConceptParse_VideoCell,NULL,NULL,false,PM_FPA_LEVEL_CHIP);
    355356    }
    356357
  • branches/eam_branches/ipp-20101205/psModules/src/concepts/pmConceptsAverage.c

    r29603 r30107  
    136136    return average;
    137137}
     138float medianWithDropouts (psList *sources, char *name) {
     139
     140    bool status;
     141
     142    psListIterator *sourcesIter = psListIteratorAlloc(sources, PS_LIST_HEAD, false); // Iterator for sources
     143    pmCell *cell = NULL;                // Source cell from iteration
     144
     145    psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
     146    psVector *values = psVectorAlloc(sources->n, PS_TYPE_F32);
     147    int nvalues = 0;
     148    while ((cell = psListGetAndIncrement(sourcesIter))) {
     149        if (!cell) {
     150            continue;
     151        }
     152
     153        float value = psMetadataLookupF32(&status, cell->concepts, name);
     154        if (!status) continue;
     155        if (!isfinite(value)) continue;
     156
     157        values->data.F32[nvalues++] = value;
     158    }
     159    psFree (sourcesIter);
     160    if (!nvalues) {
     161        psWarning("no valid values found for %s\n", name);
     162        psFree(values);
     163        psFree(stats);
     164        return INFINITY;
     165    }
     166    if (!(values = psVectorRealloc(values, nvalues))) {
     167        psWarning("failed to reallocate values vector for %s\n", name);
     168        psFree(stats);
     169        return INFINITY;
     170    }
     171    if (!psVectorStats(stats, values, NULL, NULL, 0)) {
     172        psWarning("psVectorStats failed for %s\n", name);
     173        psFree(values);
     174        psFree(stats);
     175        return INFINITY;
     176    }
     177
     178    psF32 median = psStatsGetValue(stats, PS_STAT_SAMPLE_MEDIAN);
     179
     180    psFree(values);
     181    psFree(stats);
     182
     183    return median;
     184}
    138185
    139186// Set a variety of concepts in a cell by averaging over several
     
    145192    PS_ASSERT_INT_POSITIVE(sources->n, false);
    146193
    147     float saturation = INFINITY;        // Saturation level
    148194    float bad        = -INFINITY;       // Bad level
    149195    double time      = 0.0;             // Time of observation
     
    158204    float exposure  = averageWithDropouts (sources, "CELL.EXPOSURE");
    159205    float darktime  = averageWithDropouts (sources, "CELL.DARKTIME");
     206    float saturation = medianWithDropouts(sources, "CELL.SATURATION");
    160207
    161208    // other concepts are a bit more "special"
     
    221268        }
    222269
    223         float cellSaturation = psMetadataLookupF32(NULL, cell->concepts, "CELL.SATURATION");
    224         if (cellSaturation > 10000) {
    225             // do not allow invalid values to polute this calculation
    226             // XXX really need to do this on the basis of the fraction of the cell that contributes..
    227             // if a cell is completely masked, it should not be included.
    228             if (cellSaturation < saturation) {
    229                 saturation = cellSaturation;
    230             }
    231         }
    232270        float cellBad = psMetadataLookupF32(NULL, cell->concepts, "CELL.BAD");
    233271        if (cellBad > bad) {
  • branches/eam_branches/ipp-20101205/psModules/src/concepts/pmConceptsStandard.c

    r28690 r30107  
    737737    return psMetadataItemAllocS32(pattern->name, pattern->comment, binning);
    738738}
     739
     740// VIDEOCELLS
     741psMetadataItem *p_pmConceptParse_VideoCell(const psMetadataItem *concept,
     742                                          const psMetadataItem *pattern,
     743                                          pmConceptSource source,
     744                                          const psMetadata *cameraFormat,
     745                                          const pmFPA *fpa,
     746                                          const pmChip *chip,
     747                                          const pmCell *cell)
     748{
     749  assert(concept);
     750  assert(pattern);
     751  bool has_video_cell = false;
     752
     753  if (concept->type != PS_DATA_STRING) {
     754    psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Type for %s (%x) is not string\n",
     755            concept->name, concept->type);
     756    return NULL;
     757  }
     758
     759  char *Vptr = strchr(concept->data.V,'V');
     760  if (Vptr) {
     761    has_video_cell = true;
     762  }
     763
     764  return psMetadataItemAllocBool(pattern->name, pattern->comment, has_video_cell);
     765}
     766 
     767   
    739768
    740769// BTOOLAPP
  • branches/eam_branches/ipp-20101205/psModules/src/concepts/pmConceptsStandard.h

    r25930 r30107  
    136136    );
    137137
     138// Parse the CHIP.VIDEOCELL concept
     139psMetadataItem *p_pmConceptParse_VideoCell(
     140   const psMetadataItem *concept, ///< Concept to parse
     141   const psMetadataItem *pattern, ///< Pattern to use in parsing
     142   pmConceptSource source, ///< Source for concept
     143   const psMetadata *cameraFormat, ///< Camera format definition
     144   const pmFPA *fpa, ///< FPA for concept, or NULL
     145   const pmChip *chip, ///< Chip for concept, or NULL
     146   const pmCell *cell ///< Cell for concept, or NULL
     147   );
     148
    138149/// Format for the BTOOLAPP conceptn
    139150psMetadataItem *p_pmConceptParse_BTOOLAPP(
  • branches/eam_branches/ipp-20101205/psModules/src/objects/pmPSFtry.h

    r30029 r30107  
    100100bool pmPSFtryFitEXT (pmPSFtry *psfTry, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal);
    101101
    102 bool pmPSFtryMakePSF (bool *goodFit, pmPSFtry *psfTry);
     102bool pmPSFtryMakePSF (bool *pGoodFit, pmPSFtry *psfTry);
    103103
    104104bool pmPSFtryFitPSF (pmPSFtry *psfTry, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal);
     
    123123);
    124124
    125 bool pmPSFFitShapeParams (bool *goodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask);
     125bool pmPSFFitShapeParams (bool *pGoodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask);
    126126
    127127float psVectorSystematicError (psVector *residuals, psVector *errors, float clipFraction);
  • branches/eam_branches/ipp-20101205/psModules/src/objects/pmPSFtryMakePSF.c

    r30029 r30107  
    5050Note: some of the array entries may be NULL (failed fits); ignore them.
    5151 *****************************************************************************/
    52 bool pmPSFtryMakePSF (bool *goodFit, pmPSFtry *psfTry)
     52bool pmPSFtryMakePSF (bool *pGoodFit, pmPSFtry *psfTry)
    5353{
    5454    PS_ASSERT_PTR_NON_NULL(psfTry, false);
     
    7474
    7575    // fit the shape parameters (SXX, SYY, SXY) as a function of position
    76     if (!pmPSFFitShapeParams (goodFit, psf, psfTry->sources, x, y, srcMask)) {
     76    if (!pmPSFFitShapeParams (pGoodFit, psf, psfTry->sources, x, y, srcMask)) {
    7777        psFree(x);
    7878        psFree(y);
    7979        return false;
    8080    }
    81     if (!goodFit) {
     81    if (!*pGoodFit) {
    8282        psWarning ("poor fit to PSF shape parameters for trend order %d, %d, skipping\n", psf->trendNx, psf->trendNy);
    8383        psFree(x);
     
    121121        // the mask is carried from previous steps and updated with this operation
    122122        // the weight is either the flux error or NULL, depending on 'psf->poissonErrorParams'
    123         if (!pmTrend2DFit (goodFit, trend, srcMask, 0xff, x, y, z, NULL)) {
     123        if (!pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, z, NULL)) {
    124124            psError(PS_ERR_UNKNOWN, false, "failed to build psf model for parameter %d", i);
    125125            psFree(x);
     
    128128            return false;
    129129        }
    130         if (!goodFit) {
     130        if (!*pGoodFit) {
    131131            // if we do not get a good fit (but do not actually hit an error),
    132132            // tell the calling program to try something else
     
    154154
    155155            pmModel *modelPSF = pmModelFromPSF (source->modelEXT, psf);
     156            if (!modelPSF) {
     157                fprintf(f, "modelPSF is NULL\n");
     158                break;
     159            }
     160            if (!source->modelEXT) {
     161                fprintf(f, "source->modelEXT is NULL\n");
     162                break;
     163            }
    156164
    157165            fprintf (f, "%f %f : ", source->modelEXT->params->data.F32[PM_PAR_XPOS], source->modelEXT->params->data.F32[PM_PAR_YPOS]);
     
    178186
    179187// fit the shape parameters using the supplied order (pmPSF->trendNx,trendNy)
    180 bool pmPSFFitShapeParams (bool *goodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask) {
     188bool pmPSFFitShapeParams (bool *pGoodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask) {
    181189
    182190    // we are doing a robust fit.  after each pass, we drop points which are more deviant than
     
    234242        trend = psf->params->data[PM_PAR_E0];
    235243        trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here
    236         status &= pmTrend2DFit (goodFit, trend, srcMask, 0xff, x, y, e0, NULL);
    237         if (!goodFit) {
     244        status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e0, NULL);
     245        if (!*pGoodFit) {
    238246            psFree (e0);
    239247            psFree (e1);
     
    249257        trend = psf->params->data[PM_PAR_E1];
    250258        trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here
    251         status &= pmTrend2DFit (goodFit, trend, srcMask, 0xff, x, y, e1, NULL);
    252         if (!goodFit) {
     259        status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e1, NULL);
     260        if (!*pGoodFit) {
    253261            psFree (e0);
    254262            psFree (e1);
     
    264272        trend = psf->params->data[PM_PAR_E2];
    265273        trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here
    266         status &= pmTrend2DFit (goodFit, trend, srcMask, 0xff, x, y, e2, NULL);
    267         if (!goodFit) {
     274        status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e2, NULL);
     275        if (!*pGoodFit) {
    268276            psFree (e0);
    269277            psFree (e1);
  • branches/eam_branches/ipp-20101205/psModules/src/objects/pmTrend2D.c

    r30029 r30107  
    179179}
    180180
    181 bool pmTrend2DFit(bool *goodFit, pmTrend2D *trend, psVector *mask, psVectorMaskType maskVal, const psVector *x,
     181bool pmTrend2DFit(bool *pGoodFit, pmTrend2D *trend, psVector *mask, psVectorMaskType maskVal, const psVector *x,
    182182                  const psVector *y, const psVector *f, const psVector *df)
    183183{
     
    189189
    190190    bool status = false;
    191     *goodFit = false;
     191    *pGoodFit = false;
    192192    // for the psImageMap fit, it is possible to have valid data but no valid solution for
    193193    // example, an isolated cell may not be reached from other cells, making the solution
    194194    // degenerate.  psImageMapFit should probably handle this case, but until it does, we allow
    195     // it to fail on the result, but not yield an error (goodFit = false).
    196     // psVectorClipFitPolynomial2D can not fail in this way (really?), so goodFit is always
     195    // it to fail on the result, but not yield an error (pGoodFit = false).
     196    // psVectorClipFitPolynomial2D can not fail in this way (really?), so pGoodFit is always
    197197    // true
    198198
     
    204204        // of points in the image, and potentially based on the fractional range of the
    205205        // data?
    206         *goodFit = true;
     206        *pGoodFit = true;
    207207        break;
    208208
     
    210210        // XXX supply fraction from trend elements
    211211        // XXX need to add the API which adjusts the scale
    212         status = psImageMapClipFit(goodFit, trend->map, trend->stats, mask, maskVal, x, y, f, df);
     212        status = psImageMapClipFit(pGoodFit, trend->map, trend->stats, mask, maskVal, x, y, f, df);
    213213        break;
    214214
Note: See TracChangeset for help on using the changeset viewer.