- Timestamp:
- Sep 24, 2013, 12:09:27 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130904/psphot/src
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psphotPetroFlux.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psphot/src
- Property svn:ignore
-
old new 24 24 psphotModelTest 25 25 psphotMinimal 26 psphotFullForce
-
- Property svn:ignore
-
branches/eam_branches/ipp-20130904/psphot/src/psphotPetroFlux.c
r36146 r36148 1 1 # include "psphotInternal.h" 2 2 3 bool psphotPetroFlux (pmConfig *config, const pmFPAview *view, const char *filerule , int pass)3 bool psphotPetroFlux (pmConfig *config, const pmFPAview *view, const char *filerule) 4 4 { 5 5 bool status = true; … … 35 35 psAssert (sources, "missing sources?"); 36 36 37 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 38 // psAssert (psf, "missing psf?"); 39 40 if (!psphotPetroFluxReadout (config, recipe, view, filerule, readout, sources, psf, i, pass)) { 37 if (!psphotPetroFluxReadout (config, recipe, view, filerule, readout, sources)) { 41 38 psError (PSPHOT_ERR_CONFIG, false, "failed to measure magnitudes for %s entry %d", filerule, i); 42 39 return false; … … 46 43 } 47 44 48 bool psphotPetroFluxReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources , pmPSF *psf, int index, int pass) {45 bool psphotPetroFluxReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources) { 49 46 50 47 bool status = false; 51 48 52 49 if (!sources->n) { 53 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping kron fluxes");50 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping petrosian fluxes"); 54 51 return true; 55 52 } 56 53 57 psTimerStart ("psphot. kron");54 psTimerStart ("psphot.petro"); 58 55 59 56 // determine the number of allowed threads … … 61 58 if (!status) { 62 59 nThreads = 0; 63 }64 65 bool KRON_APPLY_WEIGHT = psMetadataLookupBool (&status, recipe, "KRON_APPLY_WEIGHT");66 if (!status) {67 KRON_APPLY_WEIGHT = true;68 }69 70 bool KRON_APPLY_WINDOW = psMetadataLookupBool (&status, recipe, "KRON_APPLY_WINDOW");71 if (!status) {72 KRON_APPLY_WINDOW = false;73 60 } 74 61 … … 105 92 106 93 // allocate a job -- if threads are not defined, this just runs the job 107 psThreadJob *job = psThreadJobAlloc ("PSPHOT_ KRON_ITERATE");94 psThreadJob *job = psThreadJobAlloc ("PSPHOT_PETRO_FLUX"); 108 95 109 96 psArrayAdd(job->args, 1, readout); … … 111 98 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 112 99 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 113 PS_ARRAY_ADD_SCALAR(job->args, pass, PS_TYPE_S32);114 100 115 101 // set this to 0 to run without threading … … 146 132 psFree (cellGroups); 147 133 148 psLogMsg ("psphot. kron", PS_LOG_WARN, "measure kron fluxes : %f sec for %ld objects\n", psTimerMark ("psphot.kron"), sources->n);134 psLogMsg ("psphot.petro", PS_LOG_WARN, "measure petro fluxes : %f sec for %ld objects\n", psTimerMark ("psphot.petro"), sources->n); 149 135 return true; 150 136 } … … 153 139 154 140 pmReadout *readout = job->args->data[0]; 155 psArray *sources = job->args->data[ 2];156 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[ 4],PS_TYPE_IMAGE_MASK_DATA);157 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[ 5],PS_TYPE_IMAGE_MASK_DATA);141 psArray *sources = job->args->data[1]; 142 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[2],PS_TYPE_IMAGE_MASK_DATA); 143 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA); 158 144 159 145 for (int i = 0; i < sources->n; i++) { 160 161 // XXX what do i need for the kron flux (given a supplied kron radius?)162 146 163 147 pmSource *source = sources->data[i]; … … 169 153 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue; 170 154 171 // XXX where are we storing the supplied kronradius?155 // XXX where are we storing the supplied petro radius? 172 156 if (!isfinite(source->moments->Mrf)) continue; 173 157 … … 180 164 } 181 165 182 // is the right?? 183 float windowRadius = 6.0*source->moments->Mrf ;166 // is the right?? XXX need the correct location for Rpet 167 float windowRadius = 2.0*source->moments->Mrf ; 184 168 185 169 // re-allocate image, weight, mask arrays for each peak with box big enough to fit BIG_RADIUS 186 bool extend =pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2);170 pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2); 187 171 psAssert (source->pixels, "WTF?"); 188 172 … … 211 195 float Yo = (dR < 2.0) ? source->moments->My : source->peak->yf; 212 196 197 // center of mass in subimage. Note: the calculation below uses pixel index, so we correct 198 // xCM, yCM from pixel coords to pixel index here. 199 psF32 xCM = Xo - 0.5 - source->pixels->col0; // coord of peak in subimage 200 psF32 yCM = Yo - 0.5 - source->pixels->row0; // coord of peak in subimage 201 213 202 // Calculate the Petro magnitude (make this block optional?) 214 203 // XXX set the aperture here 215 float radPetro = 2. 5*Mrf;204 float radPetro = 2.0*source->moments->Mrf; 216 205 float radPetro2 = radPetro*radPetro; 217 206 … … 222 211 // set vPix to the source pixels (it may have been set to the 223 212 // smoothed image above) 224 vPix = source->pixels->data.F32;225 vWgt = source->variance->data.F32;226 vMsk = source->mask->data.F32;213 psF32 **vPix = source->pixels->data.F32; 214 psF32 **vWgt = source->variance->data.F32; 215 psImageMaskType **vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA; 227 216 228 217 for (psS32 row = 0; row < source->pixels->numRows ; row++) { … … 253 242 254 243 // return the flux and error to parameters? 255 source->moments->PetroFlux = Sum; 256 source->moments->PetroFluxErr = sqrt(Var); 257 258 return true; 259 } 244 // source->moments->PetroFlux = Sum; 245 // source->moments->PetroFluxErr = sqrt(Var); 246 247 fprintf (stderr, "petro flux: %f +/- %f\n", Sum, sqrt(Var)); 248 249 return true; 250 }
Note:
See TracChangeset
for help on using the changeset viewer.
