Changeset 36154
- Timestamp:
- Sep 27, 2013, 3:47:04 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130904
- Files:
-
- 4 edited
-
psModules/src/objects/pmSourceIO_CFF.c (modified) (6 diffs)
-
psphot/src/psphotGalaxyShape.c (modified) (3 diffs)
-
psphot/src/psphotMergeSources.c (modified) (2 diffs)
-
psphot/src/psphotPetroFlux.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO_CFF.c
r36152 r36154 72 72 assert (modelType > -1); 73 73 74 // how to deal with this? 75 int galaxyModelType = pmModelClassGetType ("PS_MODEL_EXP"); 76 74 77 // We get the size of the table, and allocate the array of sources first because the table 75 78 // is large and ephemeral --- when the table gets blown away, whatever is allocated after … … 87 90 } 88 91 89 // here are the things we read from the FITS table 90 91 unsigned int ID = psMetadataLookupU32 (&status, row, "IPP_IDET");92 float X = psMetadataLookupF32 (&status, row, "X_PSF");93 float Y = psMetadataLookupF32 (&status, row, "Y_PSF");92 // here are the things we read from the FITS table (XXX modify names if needed) 93 94 unsigned int ID = psMetadataLookupU32 (&status, row, "IPP_IDET"); 95 float X = psMetadataLookupF32 (&status, row, "X_PSF"); 96 float Y = psMetadataLookupF32 (&status, row, "Y_PSF"); 94 97 95 98 float apRadius = psMetadataLookupS32 (&status, row, "AP_RADIUS"); … … 97 100 float petRadius = psMetadataLookupU32 (&status, row, "PETRO_RADIUS"); 98 101 bool fitGalaxy = psMetadataLookupU32 (&status, row, "FIT_GALAXY"); 102 bool psfStar = psMetadataLookupU32 (&status, row, "PSF_STAR"); 99 103 100 104 float Rmajor = psMetadataLookupU32 (&status, row, "R_MAJOR"); … … 108 112 source->type = PM_SOURCE_TYPE_STAR; // XXX this should be added to the flags 109 113 114 // XXX we can set this in general, but for a specific image, we need to weed out SATSTARS 115 if (psfStar) { 116 source->tmpFlags |= PM_SOURCE_TMPF_CANDIDATE_PSFSTAR; 117 } 118 110 119 // NOTE: A SEGV here because "model" is NULL is probably caused by not initialising the models. 111 120 psF32 *PAR = model->params->data.F32; 112 121 psF32 *dPAR = model->dparams->data.F32; 113 122 114 source->seq = ID;115 PAR[PM_PAR_XPOS] = X;116 PAR[PM_PAR_YPOS] = Y;123 source->seq = ID; 124 PAR[PM_PAR_XPOS] = X; 125 PAR[PM_PAR_YPOS] = Y; 117 126 118 127 dPAR[PM_PAR_XPOS] = 0.0; … … 129 138 130 139 source->psfMag = 0.0; 131 source->psfMagErr = 0.0;140 source->psfMagErr = 0.0; 132 141 source->apMag = 0.0; 133 142 source->apRadius = apRadius; 143 144 // we generate a somewhat fake PSF model here -- 145 // in most (all?) contexts, we will replace this with a measured psf model 146 // elsewhere 134 147 axes.major = 1.0; 135 148 axes.minor = 1.0; … … 138 151 139 152 float peakFlux = 1.0; 140 141 source->peak = pmPeakAlloc(PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], peakFlux, PM_PEAK_LONE); 153 source->peak = pmPeakAlloc(X, Y, peakFlux, PM_PEAK_LONE); 154 source->peak->xf = X; // more accurate position 155 source->peak->yf = Y; // more accurate position 156 source->peak->dx = 0.0; 157 source->peak->dy = 0.0; 142 158 source->peak->rawFlux = peakFlux; 143 159 source->peak->smoothFlux = peakFlux; 144 source->peak->xf = PAR[PM_PAR_XPOS]; // more accurate position 145 source->peak->yf = PAR[PM_PAR_YPOS]; // more accurate position 146 source->peak->dx = dPAR[PM_PAR_XPOS]; 147 source->peak->dy = dPAR[PM_PAR_YPOS]; 148 149 assert (status); 160 161 source->moments = pmMomentsAlloc (); 162 source->moments->Mx = X; 163 source->moments->My = Y; 164 source->moments->Mrf = kronRadius; 165 source->tmpFlags |= PM_SOURCE_TMPF_MOMENTS_MEASURED; 166 // XXX does the above cause a problem with pmSourceMoments (do we run it?) 167 168 if (isfinite(petRadius)) { 169 source->extpars = pmSourceExtendedParsAlloc (); 170 source->extpars->petrosianRadius = petRadius; 171 } 172 173 if (fitGalaxy) { 174 source->modelFits = psArrayAllocEmpty (models->list->n); 175 pmModel *model = pmModelAlloc(modelType); 176 psF32 *xPAR = model->params->data.F32; 177 178 xPAR[PM_PAR_SKY] = 0.0; 179 xPAR[PM_PAR_I0] = 1.0; 180 xPAR[PM_PAR_XPOS] = X; 181 xPAR[PM_PAR_YPOS] = Y; 182 183 psEllipseAxes galAxes; 184 galAxes.major = Rmajor; 185 galAxes.minor = Rminor; 186 galAxes.theta = theta; // XXX degrees or radians? 187 188 pmPSF_AxesToModel (PAR, guessAxes, galModelType); 189 xPAR[PM_PAR_7] = Sindex; 190 191 psArrayAdd (source->modelFits, 1, model); 192 psFree (model); 193 194 } 150 195 151 196 sources->data[i] = source; -
branches/eam_branches/ipp-20130904/psphot/src/psphotGalaxyShape.c
r36148 r36154 210 210 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue; 211 211 212 // XXX where are we storing the supplied kron radius?212 // psphotSetRadiusMomentsExact sets the radius based on Mrf 213 213 if (!isfinite(source->moments->Mrf)) continue; 214 214 215 // modelFits is allocated if a galaxy fit is requested 216 if (!source->modelFits) continue; 217 218 psphotSetRadiusMomentsExact(&fitRadius, &windowRadius, readout, source, markVal); // NOTE : 6 allocs 219 215 220 // skip saturated stars modeled with a radial profile 221 // XXX worry about this at some point.. 216 222 if (source->mode2 & PM_SOURCE_MODE2_SATSTAR_PROFILE) continue; 217 223 … … 221 227 } 222 228 223 // XXX this is not right (use same concept as general source fit)224 float windowRadius = 6.0*source->moments->Mrf ;225 226 // re-allocate image, weight, mask arrays for each peak with box big enough to fit BIG_RADIUS227 pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2);228 psAssert (source->pixels, "WTF?");229 230 229 // this function populates moments->Mrf,GalaxyShape,GalaxyShapeErr 231 230 // do the following for a set of shapes (Ex,Ey) … … 245 244 pmModelType modelType = pmModelClassGetType ("PS_MODEL_EXP"); 246 245 247 pmModel *model = pmModelAlloc(modelType); 248 if (!model) { 249 return NULL; 250 } 251 246 pmModel *model = source->modelFits->data[0]; 247 if (!model) return false; 248 249 // we are using fitOptions->mode : be sure this makes sense 252 250 pmPCMdata *pcm = pmPCMinit (source, fitOptions, model, maskVal, psfSize); 253 251 252 // we are fitting only PM_PAR_I0; the shape elements are generated from a grid 254 253 psF32 *PAR = pcm->modelConv->params->data.F32; 255 254 255 // double check that the guess is carried along... 256 256 257 // I have some source guess (e0, e1, e2) 257 psEllipsePol guessPol; 258 psEllipseAxes guessAxes = pmPSF_ModelToAxes (PAR, modelType); 259 psEllipsePol guessPol = psEllipseAxesToPol (guessAxes); 258 260 259 261 // I am going to retain the value of e0, and grid search around e1,e2 -
branches/eam_branches/ipp-20130904/psphot/src/psphotMergeSources.c
r36146 r36154 105 105 { 106 106 pmReadout *readoutCMF = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT.CMF"); 107 if (!readoutCMF) goto load TXT;107 if (!readoutCMF) goto loadCFF; 108 108 109 109 extCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.DETECTIONS"); … … 111 111 for (int i = 0; i < extCMF->allSources->n; i++) { 112 112 pmSource *source = extCMF->allSources->data[i]; 113 source->mode |= PM_SOURCE_MODE_EXTERNAL; 114 115 // the supplied peak flux needs to be re-normalized 116 source->peak->rawFlux = 1.0; 117 source->peak->smoothFlux = 1.0; 118 source->peak->detValue = 1.0; 119 120 // drop the loaded source modelPSF 121 psFree (source->modelPSF); 122 source->modelPSF = NULL; 123 source->imageID = index; 124 125 psArrayAdd (detections->newSources, 100, source); 126 } 127 } 128 } 129 130 loadCFF: 131 // load data from input CFF file: 132 { 133 pmReadout *readoutCFF = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT.CFF"); 134 if (!readoutCFF) goto loadTXT; 135 136 extCFF = psMetadataLookupPtr (NULL, readoutCFF->analysis, "PSPHOT.DETECTIONS"); 137 if (extCFF) { 138 for (int i = 0; i < extCFF->allSources->n; i++) { 139 pmSource *source = extCFF->allSources->data[i]; 113 140 source->mode |= PM_SOURCE_MODE_EXTERNAL; 114 141 -
branches/eam_branches/ipp-20130904/psphot/src/psphotPetroFlux.c
r36148 r36154 187 187 PS_ASSERT_PTR_NON_NULL(source->peak, false); 188 188 PS_ASSERT_PTR_NON_NULL(source->pixels, false); 189 PS_ASSERT_PTR_NON_NULL(source->variance, false); 190 PS_ASSERT_PTR_NON_NULL(source->moments, false); 191 PS_ASSERT_PTR_NON_NULL(source->extpars, false); 189 192 190 193 // the peak position is less accurate but less subject to extreme deviations … … 202 205 // Calculate the Petro magnitude (make this block optional?) 203 206 // XXX set the aperture here 204 float radPetro = 2.0*source->moments->Mrf;207 float radPetro = PETROSIAN_RADII*source->extpars->petrosianRadius; 205 208 float radPetro2 = radPetro*radPetro; 206 209 … … 242 245 243 246 // return the flux and error to parameters? 244 // source->moments->PetroFlux = Sum; 245 // source->moments->PetroFluxErr = sqrt(Var); 247 source->extpars->petrosianFlux = Sum; 248 source->extpars->petrosianFluxErr = sqrt(Var); 249 source->extpars->petrosianFill = nPetroPix / (M_PI * radPetro2); 246 250 247 251 fprintf (stderr, "petro flux: %f +/- %f\n", Sum, sqrt(Var));
Note:
See TracChangeset
for help on using the changeset viewer.
