- Timestamp:
- Oct 23, 2007, 10:54:53 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20071023/psphot/src/psphotPetrosian.c
r13983 r15359 3 3 bool psphotPetrosian (pmSource *source, psMetadata *recipe, psMaskType maskVal) { 4 4 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 psVector *radius = source->extpars->profile->radius; 11 psVector *flux = source->extpars->profile->flux; 12 13 // flux at which to measure isophotal parameters 14 // XXX cache this? 15 float PETROSIAN_R0 = psMetadataLookupF32 (&status, recipe, "PETROSIAN_R0"); 16 float PETROSIAN_RF = psMetadataLookupF32 (&status, recipe, "PETROSIAN_FLUX_RATIO"); 17 18 // first find flux at R0 19 firstBelow = -1; 20 lastAbove = -1; 21 for (int i = 0; i < radius->n; i++) { 22 if (radius->data.F32[i] > PETROSIAN_R0) lastAbove = i; 23 if ((firstBelow < 0) && (flux->data.F32[i] < PETROSIAN_R0)) firstBelow = i; 24 } 25 26 // average flux in this range 27 fluxR0 = 0.0; 28 fluxRn = 0; 29 for (int i = PS_MIN(firstBelow, lastAbove); i <= PS_MAX(firstBelow, lastAbove); i++) { 30 fluxR0 += flux->data.F32[i]; 31 fluxRn ++; 32 } 33 fluxR0 = fluxR0 / (float)(fluxRn); 34 35 // target flux for petrosian radius 36 fluxRP = fluxR0 * PETROSIAN_RF; 37 38 // find the first bin below the flux level and the last above the level 39 // XXX can this be done faster with disection? 40 // XXX do I need to worry about crazy outliers? 41 // XXX should i be smoothing or fitting the curve? 42 firstBelow = -1; 43 lastAbove = -1; 44 for (int i = 0; i < flux->n; i++) { 45 if (flux->data.F32[i] > fluxRP) lastAbove = i; 46 if ((firstBelow < 0) && (flux->data.F32[i] < fluxRP)) firstBelow = i; 47 } 48 49 // need to examine pixels in this vicinity 50 float fluxFirst = 0; 51 float fluxLast = 0; 52 for (int i = 0; i <= PS_MAX(firstBelow, lastAbove); i++) { 53 if (i <= firstBelow) { 54 fluxFirst += flux->data.F32[i]; 55 } 56 if (i <= lastAbove) { 57 fluxLast += flux->data.F32[i]; 58 } 59 } 60 float flux = 0.5*(fluxLast + fluxFirst); 61 float fluxErr = 0.5*fabs(fluxLast - fluxFirst); 62 // XXX need to use the weight appropriately here... 63 64 float rad = 0.5*(radius->data.F32[firstBelow] + radius->data.F32[lastAbove]); 65 float radErr = 0.5*fabs(radius->data.F32[firstBelow] - radius->data.F32[lastAbove]); 66 67 if (!source->extpars->petrosian) { 68 source->extpars->petrosian = pmSourcePetrosianValuesAlloc (); 69 } 70 71 // these are uncalibrated: instrumental mags and pixel units 72 source->extpars->petrosian->mag = -2.5*log10(flux); 73 source->extpars->petrosian->magErr = fluxErr / flux; 74 75 source->extpars->petrosian->rad = rad; 76 source->extpars->petrosian->radErr = radErr; 77 6 78 return true; 7 79
Note:
See TracChangeset
for help on using the changeset viewer.
