IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17335


Ignore:
Timestamp:
Apr 6, 2008, 10:11:39 AM (18 years ago)
Author:
eugene
Message:

fix algorithms

Location:
branches/eam_branch_20080324/psphot/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080324/psphot/src/psphotAnnuli.c

    r15562 r17335  
    1 # include "psphot.h"
     1# include "psphotInternal.h"
    22
    33bool psphotAnnuli (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
     
    5555  source->extpars->annuli->fluxVar = fluxSquare;
    5656
     57  psFree (pixelCount);
     58
    5759  return true;
    5860}
  • branches/eam_branch_20080324/psphot/src/psphotIsophotal.c

    r15562 r17335  
    1 # include "psphot.h"
     1# include "psphotInternal.h"
     2
     3static float ISOPHOT_FLUX = NAN;
    24
    35bool psphotIsophotal (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
     
    1416
    1517  // flux at which to measure isophotal parameters
    16   // XXX cache this?
    17   float ISOPHOT_FLUX = psMetadataLookupF32 (&status, recipe, "ISOPHOTAL_FLUX");
     18  if (!isfinite(ISOPHOT_FLUX)) {
     19    // XXX ISOPHOTAL_FLUX should be specified in mags, need the zero point to get counts/sec
     20    ISOPHOT_FLUX = psMetadataLookupF32 (&status, recipe, "ISOPHOTAL_FLUX");
     21    assert (status);
     22  }
    1823
    1924  // find the first bin below the flux level and the last above the level
    20   // XXX can this be done faster with disection?
     25  // XXX can this be done faster with bisection?
    2126  // XXX do I need to worry about crazy outliers? 
    2227  // XXX should i be smoothing or fitting the curve?
     
    2732    if ((firstBelow < 0) && (flux->data.F32[i] < ISOPHOT_FLUX)) firstBelow = i;
    2833  }
    29 
     34  // if we don't go out far enough, we have a problem...
     35  if (lastAbove == flux->n - 1) {
     36    psTrace ("psphot", 5, "did not go out far enough to reach isophotal magnitude");
     37    // XXX raise a flag ?
     38    return false;
     39  }
     40  if (firstBelow < 0) {
     41    psTrace ("psphot", 5, "did not go out far enough to bound isophotal magnitude: error unmeasured");
     42    // XXX raise a flag ?
     43    lastAbove = firstBelow;
     44    return false;
     45  }
     46 
    3047  // need to examine pixels in this vicinity
    3148  float isophotalFluxFirst = 0;
     
    5673  source->extpars->isophot->radErr = isophotalRadErr;
    5774
     75  psTrace ("psphot", 5, "Isophot flux:%f +/- %f @ %f +/- %f for %f, %f\n",
     76           source->extpars->isophot->mag, source->extpars->isophot->magErr,
     77           source->extpars->isophot->rad, source->extpars->isophot->radErr,
     78           source->peak->xf, source->peak->yf);
     79
    5880  return true;
    5981
  • branches/eam_branch_20080324/psphot/src/psphotKron.c

    r13983 r17335  
    1 # include "psphot.h"
     1# include "psphotInternal.h"
    22
    33bool psphotKron (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
  • branches/eam_branch_20080324/psphot/src/psphotPetrosian.c

    r15800 r17335  
    1 # include "psphot.h"
     1# include "psphotInternal.h"
     2
     3static float PETROSIAN_R0 = NAN;
     4static float PETROSIAN_RF = NAN;
    25
    36bool psphotPetrosian (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
     
    1417
    1518  // flux at which to measure isophotal parameters
    16   // XXX cache this?
    17   float PETROSIAN_R0 = psMetadataLookupF32 (&status, recipe, "PETROSIAN_R0");
    18   float PETROSIAN_RF = psMetadataLookupF32 (&status, recipe, "PETROSIAN_FLUX_RATIO");
     19  if (!isfinite(PETROSIAN_R0)) {
     20    PETROSIAN_R0 = psMetadataLookupF32 (&status, recipe, "PETROSIAN_R0");
     21    PETROSIAN_RF = psMetadataLookupF32 (&status, recipe, "PETROSIAN_FLUX_RATIO");
     22    assert (status);
     23  }
    1924
    2025  // first find flux at R0
    21   int firstBelow = -1;
    22   int lastAbove = -1;
     26  int firstAbove = -1;
     27  int lastBelow = -1;
    2328  for (int i = 0; i < radius->n; i++) {
    24     if (radius->data.F32[i] > PETROSIAN_R0) lastAbove = i;
    25     if ((firstBelow < 0) && (flux->data.F32[i] < PETROSIAN_R0)) firstBelow = i;
     29    if (radius->data.F32[i] < PETROSIAN_R0) lastBelow = i;
     30    if ((firstAbove < 0) && (radius->data.F32[i] > PETROSIAN_R0)) firstAbove = i;
     31  }
     32  // if we don't go out far enough, we have a problem...
     33  if (lastBelow == radius->n - 1) {
     34    psTrace ("psphot", 5, "did not go out far enough to reach petrosian reference radius...");
     35    // XXX skip object? raise a flag ?
     36    return false;
     37  }
     38  if (firstAbove < 0) {
     39    psTrace ("psphot", 5, "did not go out far enough to bound petrosian reference radius");
     40    // XXX raise a flag ?
     41    return false;
    2642  }
    2743
     
    2945  float fluxR0 = 0.0;
    3046  int fluxRn = 0;
    31   for (int i = PS_MIN(firstBelow, lastAbove); i <= PS_MAX(firstBelow, lastAbove); i++) {
     47  for (int i = PS_MIN(firstAbove, lastBelow); i <= PS_MAX(firstAbove, lastBelow); i++) {
    3248    fluxR0 += flux->data.F32[i];
    3349    fluxRn ++;
     
    4258  // XXX do I need to worry about crazy outliers? 
    4359  // XXX should i be smoothing or fitting the curve?
    44   firstBelow = -1;
    45   lastAbove = -1;
     60  int firstBelow = -1;
     61  int lastAbove = -1;
    4662  for (int i = 0; i < flux->n; i++) {
    4763    if (flux->data.F32[i] > fluxRP) lastAbove = i;
    4864    if ((firstBelow < 0) && (flux->data.F32[i] < fluxRP)) firstBelow = i;
     65  }
     66  // if we don't go out far enough, we have a problem...
     67  if (lastAbove == radius->n - 1) {
     68    psTrace ("psphot", 5, "did not go out far enough to reach petrosian radius...");
     69    // XXX skip object? raise a flag ?
     70    return false;
     71  }
     72  if (firstBelow < 0) {
     73    psTrace ("psphot", 5, "did not go out far enough to bound petrosian radius");
     74    // XXX raise a flag ?
     75    return false;
    4976  }
    5077
     
    78105  source->extpars->petrosian->radErr = radErr;
    79106
     107  psTrace ("psphot", 5, "Petrosian flux:%f +/- %f @ %f +/- %f for %f, %f\n",
     108           source->extpars->petrosian->mag, source->extpars->petrosian->magErr,
     109           source->extpars->petrosian->rad, source->extpars->petrosian->radErr,
     110           source->peak->xf, source->peak->yf);
     111
    80112  return true;
    81113
  • branches/eam_branch_20080324/psphot/src/psphotRadialProfile.c

    r15819 r17335  
    4141
    4242    int n = 0;
    43     float Xo = source->modelEXT->params->data.F32[PM_PAR_XPOS] - source->pixels->col0;
    44     float Yo = source->modelEXT->params->data.F32[PM_PAR_YPOS] - source->pixels->row0;
     43   
     44    float Xo = 0.0;
     45    float Yo = 0.0;
     46
     47    if (source->modelEXT) {
     48      Xo = source->modelEXT->params->data.F32[PM_PAR_XPOS] - source->pixels->col0;
     49      Yo = source->modelEXT->params->data.F32[PM_PAR_YPOS] - source->pixels->row0;
     50    } else {
     51      Xo = source->peak->xf - source->pixels->col0;
     52      Yo = source->peak->yf - source->pixels->row0;
     53    }
    4554    for (int iy = 0; iy < source->pixels->numRows; iy++) {
    4655        for (int ix = 0; ix < source->pixels->numCols; ix++) {
Note: See TracChangeset for help on using the changeset viewer.