IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 9, 2007, 3:09:20 PM (19 years ago)
Author:
eugene
Message:

updating all changes from from eam_branch_20071023

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotIsophotal.c

    r13983 r15562  
    33bool psphotIsophotal (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
    44
    5   psLogMsg ("psphot", PS_LOG_INFO, "not implemented\n");
     5  assert (source->extpars);
     6  assert (source->extpars->profile);
     7  assert (source->extpars->profile->radius);
     8  assert (source->extpars->profile->flux);
     9
     10  bool status;
     11
     12  psVector *radius = source->extpars->profile->radius;
     13  psVector *flux = source->extpars->profile->flux;
     14
     15  // flux at which to measure isophotal parameters
     16  // XXX cache this?
     17  float ISOPHOT_FLUX = psMetadataLookupF32 (&status, recipe, "ISOPHOTAL_FLUX");
     18
     19  // find the first bin below the flux level and the last above the level
     20  // XXX can this be done faster with disection?
     21  // XXX do I need to worry about crazy outliers? 
     22  // XXX should i be smoothing or fitting the curve?
     23  int firstBelow = -1;
     24  int lastAbove = -1;
     25  for (int i = 0; i < flux->n; i++) {
     26    if (flux->data.F32[i] > ISOPHOT_FLUX) lastAbove = i;
     27    if ((firstBelow < 0) && (flux->data.F32[i] < ISOPHOT_FLUX)) firstBelow = i;
     28  }
     29
     30  // need to examine pixels in this vicinity
     31  float isophotalFluxFirst = 0;
     32  float isophotalFluxLast = 0;
     33  for (int i = 0; i <= PS_MAX(firstBelow, lastAbove); i++) {
     34    if (i <= firstBelow) {
     35      isophotalFluxFirst += flux->data.F32[i];
     36    }
     37    if (i <= lastAbove) {
     38      isophotalFluxLast += flux->data.F32[i];
     39    }
     40  }
     41  float isophotalFlux    = 0.5*(isophotalFluxLast + isophotalFluxFirst);
     42  float isophotalFluxErr = 0.5*fabs(isophotalFluxLast - isophotalFluxFirst);
     43
     44  float isophotalRad     = 0.5*(radius->data.F32[firstBelow] + radius->data.F32[lastAbove]);
     45  float isophotalRadErr  = 0.5*fabs(radius->data.F32[firstBelow] - radius->data.F32[lastAbove]);
     46
     47  if (!source->extpars->isophot) {
     48    source->extpars->isophot = pmSourceIsophotalValuesAlloc ();
     49  }
     50 
     51  // these are uncalibrated: instrumental mags and pixel units
     52  source->extpars->isophot->mag    = -2.5*log10(isophotalFlux);
     53  source->extpars->isophot->magErr = isophotalFluxErr / isophotalFlux;
     54
     55  source->extpars->isophot->rad    = isophotalRad;
     56  source->extpars->isophot->radErr = isophotalRadErr;
     57
    658  return true;
    759
Note: See TracChangeset for help on using the changeset viewer.