Changeset 9771
- Timestamp:
- Oct 28, 2006, 10:32:57 AM (20 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 2 added
- 8 edited
-
Makefile.am (modified) (2 diffs)
-
models/pmModel_TEST1.c (added)
-
psphot.h (modified) (1 diff)
-
psphotApResid.c (modified) (3 diffs)
-
psphotChoosePSF.c (modified) (3 diffs)
-
psphotEnsemblePSF.c (modified) (1 diff)
-
psphotEvalPSF.c (modified) (3 diffs)
-
psphotModelGroupInit.c (modified) (1 diff)
-
psphotReadout.c (modified) (1 diff)
-
psphotTestPSF.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/Makefile.am
r8512 r9771 3 3 libpsphot_la_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) 4 4 5 bin_PROGRAMS = psphot 5 bin_PROGRAMS = psphot polyfitTest 6 6 7 psphot_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) 7 8 psphot_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) 8 9 psphot_LDADD = libpsphot.la 10 psphot_SOURCES = psphot.c 9 11 10 psphot_SOURCES = \ 11 psphot.c 12 polyfitTest_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) 13 polyfitTest_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) 14 polyfitTest_SOURCES = polyfitTest.c 12 15 13 16 libpsphot_la_SOURCES = \ … … 44 47 psphotWeightBias.c \ 45 48 psphotSourceFreePixels.c \ 49 psphotTestPSF.c \ 46 50 psphotCleanup.c 47 51 -
trunk/psphot/src/psphot.h
r9270 r9771 15 15 // top-level psphot functions 16 16 const char *psphotCVSName(void); 17 18 // XXX test functions 19 bool psphotTestPSF (pmReadout *readout, psArray *sources, psMetadata *recipe); 20 bool pmPSFtestModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask); 17 21 18 22 pmConfig *psphotArguments (int argc, char **argv); -
trunk/psphot/src/psphotApResid.c
r9734 r9771 1 1 # include "psphot.h" 2 // XXXX this code fails if there are too few sources to measure the aperture residual 3 // the larger problem is that the rules for accepting more polynomial terms are weak. 2 4 3 5 static pmPSFApTrendOptions DEFAULT_OPTION = PM_PSF_APTREND_SKYBIAS; … … 12 14 pmModel *model; 13 15 pmSource *source; 16 17 PS_ASSERT_PTR_NON_NULL(psf, false); 18 PS_ASSERT_PTR_NON_NULL(psf->ApTrend, false); 19 PS_ASSERT_PTR_NON_NULL(readout, false); 20 PS_ASSERT_PTR_NON_NULL(sources, false); 21 PS_ASSERT_PTR_NON_NULL(recipe, false); 14 22 15 23 psTimerStart ("psphot"); … … 115 123 break; 116 124 case PM_PSF_APTREND_CONSTANT: 117 stats->clipIter = 2; 118 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 119 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 120 if (psf->ApTrend == NULL) { 121 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 122 return false; 123 } 124 // apply the fit 125 stats->clipIter = 3; 126 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 127 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 128 if (psf->ApTrend == NULL) { 129 psError(PSPHOT_ERR_PHOTOM, false, "Fitting aperture correction"); 130 return false; 131 } 132 break; 125 stats->clipIter = 2; 126 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 127 if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 128 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 129 return false; 130 } 131 // apply the fit 132 stats->clipIter = 3; 133 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 134 if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 135 psError(PSPHOT_ERR_PHOTOM, false, "Fitting aperture correction"); 136 return false; 137 } 138 break; 133 139 case PM_PSF_APTREND_SKYBIAS: 134 // first clip out objects which are too far from the median 135 stats->clipIter = 2; 136 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 137 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 138 if (psf->ApTrend == NULL) { 139 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 140 return false; 141 } 142 // apply the fit 143 stats->clipIter = 3; 144 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 145 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 146 if (psf->ApTrend == NULL) { 147 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias"); 148 return false; 149 } 150 break; 140 // first clip out objects which are too far from the median 141 stats->clipIter = 2; 142 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 143 if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 144 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 145 return false; 146 } 147 // apply the fit 148 stats->clipIter = 3; 149 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 150 if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 151 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias"); 152 return false; 153 } 154 break; 151 155 case PM_PSF_APTREND_SKYSAT: 152 // first clip out objects which are too far from the median 153 stats->clipIter = 2; 154 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 155 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 156 if (psf->ApTrend == NULL) { 157 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 158 return false; 159 } 160 // apply the fit 161 stats->clipIter = 2; 162 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 163 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 164 if (psf->ApTrend == NULL) { 165 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias"); 166 return false; 167 } 168 // apply the fit 169 stats->clipIter = 3; 170 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYSAT); 171 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 172 if (psf->ApTrend == NULL) { 173 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting skysat"); 174 return false; 175 } 176 break; 156 // first clip out objects which are too far from the median 157 stats->clipIter = 2; 158 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 159 if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 160 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 161 return false; 162 } 163 // apply the fit 164 stats->clipIter = 2; 165 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 166 if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 167 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias"); 168 return false; 169 } 170 // apply the fit 171 stats->clipIter = 3; 172 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYSAT); 173 if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 174 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting skysat"); 175 return false; 176 } 177 break; 177 178 case PM_PSF_APTREND_XY_LIN: 178 // first clip out objects which are too far from the median 179 stats->clipIter = 2; 180 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 181 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 182 if (psf->ApTrend == NULL) { 183 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 184 return false; 185 } 186 // apply the fit 187 stats->clipIter = 3; 188 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_XY_LIN); 189 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 190 if (psf->ApTrend == NULL) { 191 psError(PSPHOT_ERR_PHOTOM, false, "fitting, XY_LIN"); 192 return false; 193 } 194 break; 179 // first clip out objects which are too far from the median 180 stats->clipIter = 2; 181 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 182 if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 183 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 184 return false; 185 } 186 // apply the fit 187 stats->clipIter = 3; 188 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_XY_LIN); 189 if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 190 psError(PSPHOT_ERR_PHOTOM, false, "fitting, XY_LIN"); 191 return false; 192 } 193 break; 195 194 case PM_PSF_APTREND_XY_QUAD: 196 // first clip out objects which are too far from the median 197 stats->clipIter = 2; 198 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 199 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 200 if (psf->ApTrend == NULL) { 201 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 202 return false; 203 } 204 // apply the fit 205 stats->clipIter = 3; 206 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_XY_QUAD); 207 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 208 if (psf->ApTrend == NULL) { 209 psError(PSPHOT_ERR_PHOTOM, false, "Fitting XY_QUAD"); 210 return false; 211 } 212 break; 195 // first clip out objects which are too far from the median 196 stats->clipIter = 2; 197 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 198 if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 199 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 200 return false; 201 } 202 // apply the fit 203 stats->clipIter = 3; 204 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_XY_QUAD); 205 if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 206 psError(PSPHOT_ERR_PHOTOM, false, "Fitting XY_QUAD"); 207 return false; 208 } 209 break; 213 210 case PM_PSF_APTREND_SKY_XY_LIN: 214 // first clip out objects which are too far from the median 215 stats->clipIter = 2; 216 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 217 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 218 if (psf->ApTrend == NULL) { 219 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 220 return false; 221 } 222 // apply the fit 223 stats->clipIter = 3; 224 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKY_XY_LIN); 225 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 226 if (psf->ApTrend == NULL) { 227 psError(PSPHOT_ERR_PHOTOM, false, "Fitting sky xy_lin"); 228 return false; 229 } 230 break; 211 // first clip out objects which are too far from the median 212 stats->clipIter = 2; 213 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 214 if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 215 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 216 return false; 217 } 218 // apply the fit 219 stats->clipIter = 3; 220 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKY_XY_LIN); 221 if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 222 psError(PSPHOT_ERR_PHOTOM, false, "Fitting sky xy_lin"); 223 return false; 224 } 225 break; 231 226 case PM_PSF_APTREND_SKYSAT_XY_LIN: 232 // first clip out objects which are too far from the median 233 stats->clipIter = 2; 234 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 235 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 236 if (psf->ApTrend == NULL) { 237 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 238 return false; 239 } 240 // apply the fit 241 stats->clipIter = 3; 242 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 243 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 244 if (psf->ApTrend == NULL) { 245 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias"); 246 return false; 247 } 248 // apply the fit 249 stats->clipIter = 3; 250 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYSAT_XY_LIN); 251 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 252 if (psf->ApTrend == NULL) { 253 psError(PSPHOT_ERR_PHOTOM, false, "Fitting skyset xy_lin"); 254 return false; 255 } 256 break; 227 // first clip out objects which are too far from the median 228 stats->clipIter = 2; 229 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 230 if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 231 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 232 return false; 233 } 234 // apply the fit 235 stats->clipIter = 3; 236 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 237 if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 238 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias"); 239 return false; 240 } 241 // apply the fit 242 stats->clipIter = 3; 243 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYSAT_XY_LIN); 244 if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 245 psError(PSPHOT_ERR_PHOTOM, false, "Fitting skyset xy_lin"); 246 return false; 247 } 248 break; 257 249 case PM_PSF_APTREND_ALL: 258 // first clip out objects which are too far from the median 259 stats->clipIter = 2; 260 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 261 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 262 if (psf->ApTrend == NULL) { 263 psError(PSPHOT_ERR_PHOTOM, false, "Failed to measure apTrend"); 264 return false; 265 } 266 // fit just SkyBias and clip out objects which are too far from the median 267 stats->clipIter = 2; 268 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 269 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 270 if (psf->ApTrend == NULL) { 271 psError(PSPHOT_ERR_PHOTOM, false, "fitting skyBias"); 272 return false; 273 } 274 // finally, fit x, y, SkyBias and clip out objects which are too far from the median 275 stats->clipIter = 3; 276 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_ALL); 277 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 278 if (psf->ApTrend == NULL) { 279 psError(PSPHOT_ERR_PHOTOM, false, "fitting all"); 280 return false; 281 } 282 break; 250 // first clip out objects which are too far from the median 251 stats->clipIter = 2; 252 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 253 if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 254 psError(PSPHOT_ERR_PHOTOM, false, "Failed to measure apTrend"); 255 return false; 256 } 257 // fit just SkyBias and clip out objects which are too far from the median 258 stats->clipIter = 2; 259 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 260 if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 261 psError(PSPHOT_ERR_PHOTOM, false, "fitting skyBias"); 262 return false; 263 } 264 // finally, fit x, y, SkyBias and clip out objects which are too far from the median 265 stats->clipIter = 3; 266 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_ALL); 267 if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) { 268 psError(PSPHOT_ERR_PHOTOM, false, "fitting all"); 269 return false; 270 } 271 break; 283 272 default: 284 273 psError(PSPHOT_ERR_PHOTOM, true, "Unknown APTREND value: %s", optionName); -
trunk/psphot/src/psphotChoosePSF.c
r9734 r9771 163 163 164 164 // make a model with unit central intensity at the image center 165 modelEXT->params->data.F32[ 0] = 0;166 modelEXT->params->data.F32[ 1] = 1;167 modelEXT->params->data.F32[ 2] = 0.5*image->numCols;168 modelEXT->params->data.F32[ 3] = 0.5*image->numRows;165 modelEXT->params->data.F32[PM_PAR_SKY] = 0; 166 modelEXT->params->data.F32[PM_PAR_I0] = 1; 167 modelEXT->params->data.F32[PM_PAR_XPOS] = 0.5*image->numCols; 168 modelEXT->params->data.F32[PM_PAR_YPOS] = 0.5*image->numRows; 169 169 170 170 // construct a PSF model at this coordinate … … 178 178 psF64 FWHM_X = 2*modelRadiusFunc (modelPSF->params, 0.5); 179 179 180 shape.sx = modelPSF->params->data.F32[4]; 181 shape.sy = modelPSF->params->data.F32[5]; 182 shape.sxy = modelPSF->params->data.F32[6]; 180 // XXX make sure this is consistent with the re-definition of PM_PAR_SXX 181 shape.sx = modelPSF->params->data.F32[PM_PAR_SXX]; 182 shape.sy = modelPSF->params->data.F32[PM_PAR_SYY]; 183 shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY]; 183 184 axes = psEllipseShapeToAxes (shape); 184 185 … … 195 196 } 196 197 198 // XXX fix this wrt re-definition of PM_PAR_SXX 197 199 bool psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources) { 198 200 -
trunk/psphot/src/psphotEnsemblePSF.c
r9734 r9771 126 126 pmModelAdd (flux, mask, model, false, false); 127 127 128 // XXX test output line 129 if ((fabs(x - 298) < 2) && (fabs(y - 583) < 2)) { 130 psphotSaveImage (NULL, inSource->pixels, "weird.obj.fits"); 131 psphotSaveImage (NULL, flux, "weird.mod.fits"); 132 } 133 128 134 // calculate nDOF (nPix - 1) 129 135 // int Nmaskpix = psImageCountPixelMask (mask, allArray, PM_MASK_SAT); -
trunk/psphot/src/psphotEvalPSF.c
r9270 r9771 6 6 7 7 // identify objects consistent with PSF shape/magnitude distribution 8 // we expect dparams[4],dparams[5] to have a scatter of: 9 // sigma_x / (S/N) * sqrt(2) 10 // 1 / (params[4],params[5])*(S/N) 11 12 // sigma_x : 1 / SX 13 // dsx : 1 / (SX * SN) 14 // dsx_o = hypot (1/(SX*SN), MIN_DSX) 8 // we expect dparams[PM_PAR_SXX],dparams[PM_PAR_SXX] to have a scatter of: 9 // sigma_x / (S/N) 15 10 16 11 // any objects which is consistent with the PSF should have 17 // abs(dparams[ 5]) < N * dsxLine(mag) & abs(dparams[6]) < N * dsyLine(mag)12 // abs(dparams[PM_PAR_SXX]) < N * dsxLine(mag) & abs(dparams[PM_PAR_SYY]) < N * dsyLine(mag) 18 13 // this includes a minimum buffer (DS) for the brighter objects 14 15 // EAM : 2006.10.20 : I have re-defined params[PM_PAR_SXX] : it is now sqrt(2)*sigma_x, not 1/sigma_x 19 16 20 17 // saturated stars should fall outside (larger), but have peaks above SATURATION … … 51 48 float dSX, dSY, SX, SY, SN; 52 49 float nSx, nSy, Chi; 50 51 // do we actually have a valid PSF model? 52 if (model == NULL) { 53 source->mode &= ~PM_SOURCE_MODE_FITTED; 54 return false; 55 } 56 57 // did the model fit fail for one or another reason? 58 switch (model->status) { 59 case PM_MODEL_SUCCESS: 60 break; 61 case PM_MODEL_UNTRIED: 62 source->mode &= ~PM_SOURCE_MODE_FITTED; 63 return false; 64 case PM_MODEL_BADARGS: 65 case PM_MODEL_NONCONVERGE: 66 case PM_MODEL_OFFIMAGE: 67 default: 68 source->mode |= PM_SOURCE_MODE_FAIL; 69 return false; 70 } 71 72 // unless we prove otherwise, this object is a star. 73 source->type = PM_SOURCE_TYPE_STAR; 74 75 // the following source->mode information pertains to modelPSF: 76 source->mode |= PM_SOURCE_MODE_PSFMODEL; 77 78 // if the object has fitted peak above saturation, label as SATSTAR 79 // this is a valid PSF object, but ignore the other quality tests 80 // remember: fit does not use saturated pixels (masked) 81 // XXX no extended object can saturate and stay extended... 82 if (model->params->data.F32[PM_PAR_I0] >= SATURATION) { 83 if (source->mode & PM_SOURCE_MODE_PSFSTAR) { 84 psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n"); 85 } 86 source->mode |= PM_SOURCE_MODE_SATSTAR; 87 return true; 88 } 89 90 // if the object has a fitted peak below 0, the fit did not converge cleanly 91 if (model->params->data.F32[PM_PAR_I0] <= 0) { 92 source->mode |= PM_SOURCE_MODE_FAIL; 93 return false; 94 } 95 96 // if the source was predicted to be a SATSTAR, but it fitted below saturation, 97 // make a note to the user 98 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 99 psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n"); 100 source->mode &= ~PM_SOURCE_MODE_SATSTAR; 101 } 102 103 SN = model->params->data.F32[PM_PAR_I0]/model->dparams->data.F32[1]; 104 SX = model->params->data.F32[PM_PAR_SXX]/M_SQRT2; 105 SY = model->params->data.F32[PM_PAR_SYY]/M_SQRT2; 106 dSX = model->dparams->data.F32[PM_PAR_SXX]; 107 dSY = model->dparams->data.F32[PM_PAR_SYY]; 108 Chi = model->chisqNorm / model->nDOF; 109 110 // swing of sigma_x,y in sigmas 111 nSx = dSX / hypot (MIN_DS, (SX / SN)); 112 nSy = dSY / hypot (MIN_DS, (SY / SN)); 113 114 // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[] 115 keep = TRUE; 116 keep &= (fabs(nSx) < PSF_SHAPE_NSIGMA); 117 keep &= (fabs(nSy) < PSF_SHAPE_NSIGMA); 118 keep &= (SN > PSF_MIN_SN); 119 keep &= (Chi < PSF_MAX_CHI); 120 if (keep) return true; 121 122 // this source is not a star, warn if it was a PSFSTAR 123 if (source->mode & PM_SOURCE_MODE_PSFSTAR) { 124 psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality (%f, %f : %f %f %f %f)\n", 125 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], nSx, nSy, SN, Chi); 126 } else { 127 psLogMsg ("psphot", 5, "fails PSF fit (%f, %f : %f %f %f %f)\n", 128 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], nSx, nSy, SN, Chi); 129 } 130 131 // object appears to be small, suspected defect 132 if ((nSx <= -PSF_SHAPE_NSIGMA) || (nSy <= -PSF_SHAPE_NSIGMA)) { 133 source->type = PM_SOURCE_TYPE_DEFECT; 134 return false; 135 } 136 137 // object appears to be large, suspected extended source 138 if ((nSx >= PSF_SHAPE_NSIGMA) || (nSy >= PSF_SHAPE_NSIGMA)) { 139 source->type = PM_SOURCE_TYPE_EXTENDED; 140 return false; 141 } 142 143 // poor-quality fit; only keep if nothing else works... 144 source->mode |= PM_SOURCE_MODE_POOR; 145 return false; 146 } 147 148 // examine the model->status, fit parameters, etc and decide if the model succeeded 149 // set the source->type and source->mode appropriately 150 bool psphotEvalDBL (pmSource *source, pmModel *model) { 53 151 54 152 // do we actually have a valid PSF model? … … 103 201 source->mode &= ~PM_SOURCE_MODE_SATSTAR; 104 202 } 105 106 SN = model->params->data.F32[1]/model->dparams->data.F32[1];107 SX = model->params->data.F32[4];108 SY = model->params->data.F32[5];109 dSX = model->dparams->data.F32[4];110 dSY = model->dparams->data.F32[5];111 Chi = model->chisqNorm / model->nDOF;112 113 // swing of sigma_x,y in sigmas114 nSx = dSX / hypot (MIN_DS, 1 / (SX * SN));115 nSy = dSY / hypot (MIN_DS, 1 / (SY * SN));116 117 // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[]118 keep = TRUE;119 keep &= (fabs(nSx) < PSF_SHAPE_NSIGMA);120 keep &= (fabs(nSy) < PSF_SHAPE_NSIGMA);121 keep &= (SN > PSF_MIN_SN);122 keep &= (Chi < PSF_MAX_CHI);123 if (keep) return true;124 125 // this source is not a star, warn if it was a PSFSTAR126 if (source->mode & PM_SOURCE_MODE_PSFSTAR) {127 psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality (%f, %f : %f %f %f %f)\n",128 model->params->data.F32[2], model->params->data.F32[3], nSx, nSy, SN, Chi);129 } else {130 psLogMsg ("psphot", 5, "fails PSF fit (%f, %f : %f %f %f %f)\n",131 model->params->data.F32[2], model->params->data.F32[3], nSx, nSy, SN, Chi);132 }133 134 // object appears to be small, suspected defect135 if ((nSx <= -PSF_SHAPE_NSIGMA) || (nSy <= -PSF_SHAPE_NSIGMA)) {136 source->type = PM_SOURCE_TYPE_DEFECT;137 return false;138 }139 140 // object appears to be large, suspected extended source141 if ((nSx >= PSF_SHAPE_NSIGMA) || (nSy >= PSF_SHAPE_NSIGMA)) {142 source->type = PM_SOURCE_TYPE_EXTENDED;143 return false;144 }145 146 // poor-quality fit; only keep if nothing else works...147 source->mode |= PM_SOURCE_MODE_POOR;148 return false;149 }150 151 // examine the model->status, fit parameters, etc and decide if the model succeeded152 // set the source->type and source->mode appropriately153 bool psphotEvalDBL (pmSource *source, pmModel *model) {154 155 // do we actually have a valid PSF model?156 if (model == NULL) {157 source->mode &= ~PM_SOURCE_MODE_FITTED;158 return false;159 }160 161 // did the model fit fail for one or another reason?162 switch (model->status) {163 case PM_MODEL_SUCCESS:164 break;165 case PM_MODEL_UNTRIED:166 source->mode &= ~PM_SOURCE_MODE_FITTED;167 return false;168 case PM_MODEL_BADARGS:169 case PM_MODEL_NONCONVERGE:170 case PM_MODEL_OFFIMAGE:171 default:172 source->mode |= PM_SOURCE_MODE_FAIL;173 return false;174 }175 176 // unless we prove otherwise, this object is a star.177 source->type = PM_SOURCE_TYPE_STAR;178 179 // the following source->mode information pertains to modelPSF:180 source->mode |= PM_SOURCE_MODE_PSFMODEL;181 182 // if the object has fitted peak above saturation, label as SATSTAR183 // this is a valid PSF object, but ignore the other quality tests184 // remember: fit does not use saturated pixels (masked)185 // XXX no extended object can saturate and stay extended...186 if (model->params->data.F32[1] >= SATURATION) {187 if (source->mode & PM_SOURCE_MODE_PSFSTAR) {188 psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");189 }190 source->mode |= PM_SOURCE_MODE_SATSTAR;191 return true;192 }193 194 // if the object has a fitted peak below 0, the fit did not converge cleanly195 if (model->params->data.F32[1] <= 0) {196 source->mode |= PM_SOURCE_MODE_FAIL;197 return false;198 }199 200 // if the source was predicted to be a SATSTAR, but it fitted below saturation,201 // make a note to the user202 if (source->mode & PM_SOURCE_MODE_SATSTAR) {203 psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");204 source->mode &= ~PM_SOURCE_MODE_SATSTAR;205 }206 203 return true; 207 204 } -
trunk/psphot/src/psphotModelGroupInit.c
r9270 r9771 4 4 // psModule/src/objects/models 5 5 6 # include "models/pmModel_TAUSS.c" 6 // # include "models/pmModel_TAUSS.c" 7 # include "models/pmModel_TEST1.c" 7 8 8 9 static pmModelGroup userModels[] = { 9 {"PS_MODEL_TAUSS", 9, pmModelFunc_TAUSS, pmModelFlux_TAUSS, pmModelRadius_TAUSS, pmModelLimits_TAUSS, pmModelGuess_TAUSS, pmModelFromPSF_TAUSS, pmModelFitStatus_TAUSS}, 10 {"PS_MODEL_TEST1", 7, pmModelFunc_TEST1, pmModelFlux_TEST1, pmModelRadius_TEST1, pmModelLimits_TEST1, pmModelGuess_TEST1, pmModelFromPSF_TEST1, pmModelFitStatus_TEST1}, 11 // {"PS_MODEL_TAUSS", 9, pmModelFunc_TAUSS, pmModelFlux_TAUSS, pmModelRadius_TAUSS, pmModelLimits_TAUSS, pmModelGuess_TAUSS, pmModelFromPSF_TAUSS, pmModelFitStatus_TAUSS}, 10 12 }; 11 13 -
trunk/psphot/src/psphotReadout.c
r9576 r9771 62 62 return true; 63 63 } 64 65 // psphotTestPSF (readout, sources, recipe); 66 // exit (1); 64 67 65 68 // use bright stellar objects to measure PSF
Note:
See TracChangeset
for help on using the changeset viewer.
