Changeset 9568
- Timestamp:
- Oct 13, 2006, 3:01:35 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotApResid.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotApResid.c
r9529 r9568 1 1 # include "psphot.h" 2 static char DEFAULT_OPTION[] = "SKYBIAS"; 2 3 static pmPSFApTrendOptions DEFAULT_OPTION = PM_PSF_APTREND_SKYBIAS; 3 4 4 5 // measure the aperture residual statistics … … 93 94 } 94 95 95 // APTREND options are defined by the if ... else if ... else if ... else block below 96 char *ApTrendOption = psMetadataLookupPtr (&status, recipe, "APTREND"); 97 if (!status) ApTrendOption = DEFAULT_OPTION; 96 // APTREND options : NONE SKYBIAS XY_LIN XY_QUAD SKY_XY_LIN FULL 97 // APTREND options are used in the switch block below 98 pmPSFApTrendOptions ApTrendOption = DEFAULT_OPTION; 99 char *optionName = psMetadataLookupPtr (&status, recipe, "APTREND"); 100 if (status) ApTrendOption = pmPSFApTrendOptionFromName (optionName); 101 if (ApTrendOption == PM_PSF_APTREND_ERROR) { 102 psError(PSPHOT_ERR_APERTURE, true, "invalid aperture residual trend %s", optionName); 103 return false; 104 } 98 105 99 106 // 3hi/1lo sigma clipping on the rflux vs metric fit … … 103 110 104 111 // no correction 105 if (!strcasecmp (ApTrendOption, "NONE")) { 112 switch (ApTrendOption) { 113 case PM_PSF_APTREND_NONE: 106 114 // remove ApTrend fit from pmPSFtry 107 115 psf->ApTrend->coeff[0][0][0][0] = 0; 108 } else if (!strcasecmp (ApTrendOption, "CONSTANT")) { // constant only 109 stats->clipIter = 2; 110 pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_CONSTANT);111 p sf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux);112 if (psf->ApTrend == NULL) {113 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");114 return false;115 }116 117 // apply the fit 118 stats->clipIter = 3; 119 pmPSF _MaskApTrend (psf->ApTrend, PM_PSF_CONSTANT);116 break; 117 case PM_PSF_APTREND_CONSTANT: 118 stats->clipIter = 2; 119 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 120 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 121 if (psf->ApTrend == NULL) { 122 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 123 return false; 124 } 125 // apply the fit 126 stats->clipIter = 3; 127 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 120 128 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 121 129 if (psf->ApTrend == NULL) { … … 123 131 return false; 124 132 } 125 } else if (!strcasecmp (ApTrendOption, "SKYBIAS")) { // constant and skybias only 126 // first clip out objects which are too far from the median 127 stats->clipIter = 2;128 pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_CONSTANT);129 p sf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux);130 if (psf->ApTrend == NULL) {131 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");132 return false;133 }134 135 // apply the fit 136 stats->clipIter = 3; 137 pmPSF _MaskApTrend (psf->ApTrend, PM_PSF_SKYBIAS);133 break; 134 case PM_PSF_APTREND_SKYBIAS: 135 // first clip out objects which are too far from the median 136 stats->clipIter = 2; 137 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 138 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 139 if (psf->ApTrend == NULL) { 140 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 141 return false; 142 } 143 // apply the fit 144 stats->clipIter = 3; 145 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 138 146 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 139 147 if (psf->ApTrend == NULL) { … … 141 149 return false; 142 150 } 143 } else if (!strcasecmp (ApTrendOption, "SKYSAT")) { 144 // first clip out objects which are too far from the median 145 stats->clipIter = 2;146 pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_CONSTANT);147 p sf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux);148 if (psf->ApTrend == NULL) {149 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");150 return false;151 }152 153 // apply the fit 154 stats->clipIter = 2; 155 pmPSF _MaskApTrend (psf->ApTrend, PM_PSF_SKYBIAS);151 break; 152 case PM_PSF_APTREND_SKYSAT: 153 // first clip out objects which are too far from the median 154 stats->clipIter = 2; 155 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 156 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 157 if (psf->ApTrend == NULL) { 158 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 159 return false; 160 } 161 // apply the fit 162 stats->clipIter = 2; 163 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 156 164 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 157 165 if (psf->ApTrend == NULL) { … … 159 167 return false; 160 168 } 161 162 // apply the fit 163 stats->clipIter = 3; 164 pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_SKYSAT); 169 // apply the fit 170 stats->clipIter = 3; 171 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYSAT); 165 172 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 166 173 if (psf->ApTrend == NULL) { … … 168 175 return false; 169 176 } 170 } else if (!strcasecmp (ApTrendOption, "XY_LIN")) { // constant and linear X,Y only 171 // first clip out objects which are too far from the median 172 stats->clipIter = 2;173 pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_CONSTANT);174 p sf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux);175 if (psf->ApTrend == NULL) {176 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");177 return false;178 }179 180 // apply the fit 181 stats->clipIter = 3; 182 pmPSF _MaskApTrend (psf->ApTrend, PM_PSF_XY_LIN);177 break; 178 case PM_PSF_APTREND_XY_LIN: 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 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 183 if (psf->ApTrend == NULL) { 184 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 185 return false; 186 } 187 // apply the fit 188 stats->clipIter = 3; 189 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_XY_LIN); 183 190 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 184 191 if (psf->ApTrend == NULL) { … … 186 193 return false; 187 194 } 188 } else if (!strcasecmp (ApTrendOption, "XY_QUAD")) { // constant and quadratic X,Y only 189 // first clip out objects which are too far from the median 190 stats->clipIter = 2;191 pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_CONSTANT);192 p sf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux);193 if (psf->ApTrend == NULL) {194 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");195 return false;196 }197 198 // apply the fit 199 stats->clipIter = 3; 200 pmPSF _MaskApTrend (psf->ApTrend, PM_PSF_XY_QUAD);195 break; 196 case PM_PSF_APTREND_XY_QUAD: 197 // first clip out objects which are too far from the median 198 stats->clipIter = 2; 199 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 200 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 201 if (psf->ApTrend == NULL) { 202 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 203 return false; 204 } 205 // apply the fit 206 stats->clipIter = 3; 207 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_XY_QUAD); 201 208 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 202 209 if (psf->ApTrend == NULL) { … … 204 211 return false; 205 212 } 206 } else if (!strcasecmp (ApTrendOption, "SKY_XY_LIN")) { // constant and sky, linear X,Y only 207 // first clip out objects which are too far from the median 208 stats->clipIter = 2;209 pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_CONSTANT);210 p sf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux);211 if (psf->ApTrend == NULL) {212 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");213 return false;214 }215 216 // apply the fit 217 stats->clipIter = 3; 218 pmPSF _MaskApTrend (psf->ApTrend, PM_PSF_SKY_XY_LIN);213 break; 214 case PM_PSF_APTREND_SKY_XY_LIN: 215 // first clip out objects which are too far from the median 216 stats->clipIter = 2; 217 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 218 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 219 if (psf->ApTrend == NULL) { 220 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 221 return false; 222 } 223 // apply the fit 224 stats->clipIter = 3; 225 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKY_XY_LIN); 219 226 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 220 227 if (psf->ApTrend == NULL) { … … 222 229 return false; 223 230 } 224 } else if (!strcasecmp (ApTrendOption, "SKYSAT_XY_LIN")) { // constant and sky, linear X,Y only 225 // first clip out objects which are too far from the median 226 stats->clipIter = 2;227 pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_CONSTANT);228 p sf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux);229 if (psf->ApTrend == NULL) {230 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");231 return false;232 }233 234 // apply the fit 235 stats->clipIter = 3; 236 pmPSF _MaskApTrend (psf->ApTrend, PM_PSF_SKYBIAS);231 break; 232 case PM_PSF_APTREND_SKYSAT_XY_LIN: 233 // first clip out objects which are too far from the median 234 stats->clipIter = 2; 235 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 236 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 237 if (psf->ApTrend == NULL) { 238 psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing"); 239 return false; 240 } 241 // apply the fit 242 stats->clipIter = 3; 243 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 237 244 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 238 245 if (psf->ApTrend == NULL) { … … 240 247 return false; 241 248 } 242 243 // apply the fit 244 stats->clipIter = 3; 245 pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_SKYSAT_XY_LIN); 249 // apply the fit 250 stats->clipIter = 3; 251 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYSAT_XY_LIN); 246 252 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 247 253 if (psf->ApTrend == NULL) { … … 249 255 return false; 250 256 } 251 } else if (!strcasecmp (ApTrendOption, "ALL")) { 252 // first clip out objects which are too far from the median 253 stats->clipIter = 2; 254 pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_CONSTANT); 257 break; 258 case PM_PSF_APTREND_ALL: 259 // first clip out objects which are too far from the median 260 stats->clipIter = 2; 261 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT); 255 262 psf->ApTrend = psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 256 263 if (psf->ApTrend == NULL) { … … 258 265 return false; 259 266 } 260 261 267 // fit just SkyBias and clip out objects which are too far from the median 262 268 stats->clipIter = 2; 263 pmPSF _MaskApTrend (psf->ApTrend, PM_PSF_SKYBIAS);269 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 264 270 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 265 271 if (psf->ApTrend == NULL) { … … 267 273 return false; 268 274 } 269 270 275 // finally, fit x, y, SkyBias and clip out objects which are too far from the median 271 276 stats->clipIter = 3; 272 pmPSF _MaskApTrend (psf->ApTrend, PM_PSF_ALL);277 pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_ALL); 273 278 psf->ApTrend = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux); 274 279 if (psf->ApTrend == NULL) { … … 276 281 return false; 277 282 } 278 } else { 279 psError(PSPHOT_ERR_PHOTOM, true, "Unknown APTREND value: %s", ApTrendOption); 283 break; 284 default: 285 psError(PSPHOT_ERR_PHOTOM, true, "Unknown APTREND value: %s", optionName); 280 286 return false; 281 287 }
Note:
See TracChangeset
for help on using the changeset viewer.
