Changeset 36589
- Timestamp:
- Mar 14, 2014, 4:30:31 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140206/Ohana/src/libdvo
- Files:
-
- 6 edited
-
include/dvo.h (modified) (2 diffs)
-
include/dvodb.h (modified) (1 diff)
-
src/dbExtractAverages.c (modified) (3 diffs)
-
src/dbExtractMeasures.c (modified) (4 diffs)
-
src/dbFields.c (modified) (2 diffs)
-
src/dvo_photcode_ops.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140206/Ohana/src/libdvo/include/dvo.h
r36577 r36589 662 662 float PhotInst (Measure *measure); 663 663 float PhotCat (Measure *measure); 664 float PhotAper (Measure *measure);665 float PhotKron (Measure *measure);666 664 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt); 667 665 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt); … … 669 667 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt); 670 668 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 669 float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt); 670 671 float PhotAperInst (Measure *measure); 672 float PhotAperCat (Measure *measure); 673 float PhotAperSys (Measure *measure, Average *average, SecFilt *secfilt); 674 float PhotAperRel (Measure *measure, Average *average, SecFilt *secfilt); 675 float PhotAperCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 676 float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt); 677 float PhotAperRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 678 679 float PhotKronInst (Measure *measure); 680 float PhotKronCat (Measure *measure); 681 float PhotKronSys (Measure *measure, Average *average, SecFilt *secfilt); 682 float PhotKronRel (Measure *measure, Average *average, SecFilt *secfilt); 683 float PhotKronCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 684 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt); 685 float PhotKronRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 686 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt); 687 671 688 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt); 672 float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt);673 674 float PhotAperInst (Measure *measure);675 float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt);676 float PhotKronInst (Measure *measure);677 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt);678 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt);679 689 680 690 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt); -
branches/eam_branches/ipp-20140206/Ohana/src/libdvo/include/dvodb.h
r36490 r36589 23 23 /* magnitude types */ 24 24 enum {MAG_NONE, 25 MAG_INST, 26 MAG_CAT, 27 MAG_APER, 28 MAG_APER_INST, 29 MAG_KRON, 30 MAG_KRON_INST, 31 MAG_KRON_ERR, 32 MAG_SYS, 33 MAG_REL, 34 MAG_CAL, 25 26 // these magnitude types are from the measurement table (or derived therein) 27 // the following imply PSF magnitudes: 28 MAG_INST, // -2.5*log(DN) [ie, not DN/sec] 29 MAG_CAT, // MAG_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1) 30 MAG_SYS, // MAG_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode] 31 MAG_REL, // MAG_SYS - Mcal [specific zero point for image] 32 MAG_CAL, // MAG_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode] 33 MAG_ERR, // error on PSF MAG 34 35 // the following imply APERTURE magnitudes: 36 MAG_APER_INST, // -2.5*log(DN) [ie, not DN/sec] 37 MAG_APER_CAT, // MAG_APER_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1) 38 MAG_APER_SYS, // MAG_APER_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode] 39 MAG_APER_REL, // MAG_APER_SYS - Mcal [specific zero point for image] 40 MAG_APER_CAL, // MAG_APER_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode] 41 MAG_APER_ERR, // error on APER MAG (if known, else psf error) 42 MAG_APER, // in mextract -> MAG_APER_REL, in avextract -> MAG_APER_AVE 43 44 // the following imply KRON magnitudes: 45 MAG_KRON_INST, // -2.5*log(DN) [ie, not DN/sec] 46 MAG_KRON_CAT, // MAG_KRON_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1) 47 MAG_KRON_SYS, // MAG_KRON_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode] 48 MAG_KRON_REL, // MAG_KRON_SYS - Mcal [specific zero point for image] 49 MAG_KRON_CAL, // MAG_KRON_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode] 50 MAG_KRON_ERR, // error on KRON MAG 51 MAG_KRON, // in mextract -> MAG_KRON_REL, in avextract -> MAG_KRON_AVE 52 53 // these magnitude types are from the average (secfilt) table: 54 // the following imply PSF magnitudes (or fluxes) 35 55 MAG_AVE, 36 56 MAG_REF, 37 MAG_ERR,38 57 MAG_STDEV, 39 58 MAG_AVE_ERR, 59 MAG_CHISQ, 60 MAG_20, 61 MAG_80, 62 MAG_FLUX_PSF, 63 MAG_FLUX_PSF_ERR, 64 65 // the following imply APERTURE magnitudes: 66 MAG_APER_AVE, 67 MAG_APER_REF, 68 69 // the following imply KRON magnitudes or fluxes: 70 MAG_KRON_AVE, 71 MAG_KRON_REF, 72 MAG_FLUX_KRON, 73 MAG_FLUX_KRON_ERR, 74 75 // other secfilt fields of interest 40 76 MAG_PHOT_FLAGS, 41 MAG_CHISQ,42 77 MAG_NCODE, 43 78 MAG_NPHOT, 44 MAG_20,45 MAG_80,46 79 MAG_UC_DIST, 47 80 MAG_STACK_DET_ID, 48 MAG_FLUX_PSF,49 MAG_FLUX_PSF_ERR,50 MAG_FLUX_KRON,51 MAG_FLUX_KRON_ERR,52 81 }; 53 82 -
branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/dbExtractAverages.c
r36533 r36589 211 211 } 212 212 } else { 213 value.Flt = Phot dM(field->photcode, average, secfilt);213 value.Flt = PhotAveErr (field->photcode, average, secfilt); 214 214 } 215 215 break; … … 244 244 245 245 case MAG_APER: 246 case MAG_APER_AVE: 246 247 value.Flt = PhotAperAve (field->photcode, average, secfilt); 247 248 break; 248 249 250 case MAG_APER_REF: 251 value.Flt = PhotAperRef (field->photcode, average, secfilt, measure); 252 break; 253 249 254 case MAG_KRON: 255 case MAG_KRON_AVE: 250 256 value.Flt = PhotKronAve (field->photcode, average, secfilt); 257 break; 258 259 case MAG_KRON_REF: 260 value.Flt = PhotKronRef (field->photcode, average, secfilt, measure); 251 261 break; 252 262 … … 283 293 break; 284 294 case AVE_dMAG: 285 value.Flt = Phot dM(field->photcode, average, secfilt);295 value.Flt = PhotAveErr (field->photcode, average, secfilt); 286 296 break; 287 297 case AVE_Xm: -
branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/dbExtractMeasures.c
r35508 r36589 123 123 case MAG_REL: 124 124 case MAG_CAL: 125 case MAG_APER: 125 case MAG_ERR: 126 126 127 case MAG_APER_INST: 127 case MAG_KRON: 128 case MAG_APER_CAT: 129 case MAG_APER_SYS: 130 case MAG_APER_REL: 131 case MAG_APER_CAL: 132 case MAG_APER_ERR: 133 128 134 case MAG_KRON_INST: 135 case MAG_KRON_CAT: 136 case MAG_KRON_SYS: 137 case MAG_KRON_REL: 138 case MAG_KRON_CAL: 129 139 case MAG_KRON_ERR: 130 case MAG_ERR: 140 131 141 case MAG_PHOT_FLAGS: 132 142 equiv = myEquiv; … … 137 147 case MAG_AVE: 138 148 case MAG_REF: 149 case MAG_STDEV: 150 case MAG_AVE_ERR: 139 151 case MAG_CHISQ: 140 case MAG_AVE_ERR: 152 case MAG_FLUX_PSF: 153 case MAG_FLUX_PSF_ERR: 154 155 case MAG_APER_AVE: 156 157 case MAG_KRON_AVE: 158 case MAG_FLUX_KRON: 159 case MAG_FLUX_KRON_ERR: 160 161 case MAG_20: 162 case MAG_80: 163 case MAG_UC_DIST: 164 case MAG_STACK_DET_ID: 165 141 166 case MAG_NCODE: 142 167 case MAG_NPHOT: 143 case MAG_FLUX_PSF:144 case MAG_FLUX_PSF_ERR:145 case MAG_FLUX_KRON:146 case MAG_FLUX_KRON_ERR:147 168 equiv = field->photcode; 148 169 goto valid_photcode; … … 178 199 value.Flt = PhotRef (equiv, average, secfilt, measure); 179 200 break; 180 case MAG_APER: 181 value.Flt = PhotAper (measure); 182 break; 201 case MAG_ERR: 202 value.Flt = measure[0].dM; 203 break; 204 case MAG_AVE_ERR: 205 value.Flt = PhotAveErr (equiv, average, secfilt); 206 break; 207 183 208 case MAG_APER_INST: 184 209 value.Flt = PhotAperInst (measure); 185 210 break; 186 case MAG_KRON: 187 value.Flt = PhotKron (measure); 188 break; 211 case MAG_APER_CAT: 212 value.Flt = PhotAperCat (measure); 213 break; 214 case MAG_APER_SYS: 215 value.Flt = PhotAperSys (measure, average, secfilt); 216 break; 217 case MAG_APER: 218 case MAG_APER_REL: 219 value.Flt = PhotAperRel (measure, average, secfilt); 220 break; 221 case MAG_APER_CAL: 222 value.Flt = PhotAperCal (measure, average, secfilt, measure, equiv); 223 break; 224 case MAG_APER_AVE: 225 value.Flt = PhotAperAve (equiv, average, secfilt); 226 break; 227 case MAG_APER_REF: 228 value.Flt = PhotAperRef (equiv, average, secfilt, measure); 229 break; 230 case MAG_APER_ERR: 231 value.Flt = measure[0].dM; 232 break; 233 189 234 case MAG_KRON_INST: 190 235 value.Flt = PhotKronInst (measure); 191 236 break; 237 case MAG_KRON_CAT: 238 value.Flt = PhotKronCat (measure); 239 break; 240 case MAG_KRON_SYS: 241 value.Flt = PhotKronSys (measure, average, secfilt); 242 break; 243 case MAG_KRON: 244 case MAG_KRON_REL: 245 value.Flt = PhotKronRel (measure, average, secfilt); 246 break; 247 case MAG_KRON_CAL: 248 value.Flt = PhotKronCal (measure, average, secfilt, measure, equiv); 249 break; 250 case MAG_KRON_AVE: 251 value.Flt = PhotKronAve (equiv, average, secfilt); 252 break; 253 case MAG_KRON_REF: 254 value.Flt = PhotKronRef (equiv, average, secfilt, measure); 255 break; 192 256 case MAG_KRON_ERR: 193 value.Flt = measure[0].dMkron; 194 break; 195 case MAG_ERR: 196 value.Flt = measure[0].dM; 197 break; 198 case MAG_AVE_ERR: 199 value.Flt = PhotdM (equiv, average, secfilt); 200 break; 257 value.Flt = measure[0].dMkron; 258 break; 259 201 260 case MAG_PHOT_FLAGS: 202 261 if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) { 203 262 value.Int = measure[0].photFlags; 204 } else {205 value.Int = 0;206 263 } 207 264 break; 208 case MAG_CHISQ: 209 value.Flt = PhotXm (equiv, average, secfilt); 210 break; 265 211 266 case MAG_NCODE: 212 if (equiv == NULL) { 213 value.Int = 0; 214 break; 215 } 267 if (equiv == NULL) break; 216 268 Nsec = GetPhotcodeNsec (equiv->code); 217 269 if (Nsec == -1) break; … … 219 271 break; 220 272 case MAG_NPHOT: 221 if (equiv == NULL) { 222 value.Int = 0; 223 break; 224 } 273 if (equiv == NULL) break; 225 274 Nsec = GetPhotcodeNsec (equiv->code); 226 275 if (Nsec == -1) break; 227 276 value.Int = secfilt[Nsec].Nused; 228 277 break; 278 279 case MAG_CHISQ: 280 value.Flt = PhotXm (equiv, average, secfilt); 281 break; 282 case MAG_STDEV: 283 value.Flt = PhotMstdev (equiv, average, secfilt); 284 break; 285 case MAG_20: 286 value.Flt = PhotM20 (equiv, average, secfilt); 287 break; 288 case MAG_80: 289 value.Flt = PhotM80 (equiv, average, secfilt); 290 break; 291 case MAG_UC_DIST: 292 value.Flt = PhotUCdist (equiv, average, secfilt); 293 break; 294 229 295 case MAG_FLUX_PSF: 230 296 value.Flt = PhotAveFluxPSF (field->photcode, average, secfilt); -
branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/dbFields.c
r36084 r36589 30 30 int GetMagMode (char *string) { 31 31 32 // these all imply PSF mags: 32 33 if (!strcasecmp (string, "inst")) return (MAG_INST); 33 34 if (!strcasecmp (string, "cat")) return (MAG_CAT); … … 37 38 if (!strcasecmp (string, "ave")) return (MAG_AVE); 38 39 if (!strcasecmp (string, "ref")) return (MAG_REF); 40 if (!strcasecmp (string, "err")) return (MAG_ERR); 41 if (!strcasecmp (string, "aveerr")) return (MAG_AVE_ERR); 42 43 // these are explicit PSF mags: 44 if (!strcasecmp (string, "psf_inst")) return (MAG_INST); 45 if (!strcasecmp (string, "psf_cat")) return (MAG_CAT); 46 if (!strcasecmp (string, "psf_sys")) return (MAG_SYS); 47 if (!strcasecmp (string, "psf_rel")) return (MAG_REL); 48 if (!strcasecmp (string, "psf_cal")) return (MAG_CAL); 49 if (!strcasecmp (string, "psf_ave")) return (MAG_AVE); 50 if (!strcasecmp (string, "psf_ref")) return (MAG_REF); 51 if (!strcasecmp (string, "psf_err")) return (MAG_ERR); 52 if (!strcasecmp (string, "psf_aveerr")) return (MAG_AVE_ERR); 53 54 // these are aper mags: 39 55 if (!strcasecmp (string, "ap")) return (MAG_APER); 40 56 if (!strcasecmp (string, "aper")) return (MAG_APER); 41 57 if (!strcasecmp (string, "aperinst")) return (MAG_APER_INST); 42 58 if (!strcasecmp (string, "aper_inst")) return (MAG_APER_INST); 59 if (!strcasecmp (string, "aper_cat")) return (MAG_APER_CAT); 60 if (!strcasecmp (string, "aper_sys")) return (MAG_APER_SYS); 61 if (!strcasecmp (string, "aper_rel")) return (MAG_APER_REL); 62 if (!strcasecmp (string, "aper_cal")) return (MAG_APER_CAL); 63 if (!strcasecmp (string, "aper_ave")) return (MAG_APER_AVE); 64 if (!strcasecmp (string, "aper_ref")) return (MAG_APER_REF); 65 if (!strcasecmp (string, "aper_err")) return (MAG_APER_ERR); 66 67 // these are kron mags: 43 68 if (!strcasecmp (string, "kron")) return (MAG_KRON); 69 if (!strcasecmp (string, "kron_inst")) return (MAG_KRON_INST); 70 if (!strcasecmp (string, "kron_cat")) return (MAG_KRON_CAT); 71 if (!strcasecmp (string, "kron_sys")) return (MAG_KRON_SYS); 72 if (!strcasecmp (string, "kron_rel")) return (MAG_KRON_REL); 73 if (!strcasecmp (string, "kron_cal")) return (MAG_KRON_CAL); 74 if (!strcasecmp (string, "kron_ave")) return (MAG_KRON_AVE); 75 if (!strcasecmp (string, "kron_ref")) return (MAG_KRON_REF); 76 if (!strcasecmp (string, "kron_err")) return (MAG_KRON_ERR); 44 77 if (!strcasecmp (string, "kroninst")) return (MAG_KRON_INST); 45 if (!strcasecmp (string, "kron_inst")) return (MAG_KRON_INST);46 78 if (!strcasecmp (string, "kronerr")) return (MAG_KRON_ERR); 47 if (!strcasecmp (string, "err")) return (MAG_ERR); 48 if (!strcasecmp (string, "aveerr")) return (MAG_AVE_ERR);79 80 // other fields: 49 81 if (!strcasecmp (string, "photflags")) return (MAG_PHOT_FLAGS); 50 82 if (!strcasecmp (string, "flags")) return (MAG_PHOT_FLAGS); -
branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/dvo_photcode_ops.c
r36533 r36589 260 260 } 261 261 262 float PhotAper (Measure *measure) {263 264 int Np;265 float Mcat;266 PhotCode *code;267 268 Np = photcodes[0].hashcode[measure[0].photcode];269 if (Np == -1) return (NAN);270 271 if (photcodes[0].code[Np].type == PHOT_REF) {272 Mcat = measure[0].Map;273 return (Mcat);274 }275 code = &photcodes[0].code[Np];276 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;277 278 return (Mcat);279 }280 281 float PhotAperInst (Measure *measure) {282 283 int Np;284 float Minst;285 286 Np = photcodes[0].hashcode[measure[0].photcode];287 if (Np == -1) return (NAN);288 289 if (photcodes[0].code[Np].type == PHOT_REF) {290 Minst = measure[0].Map;291 return (Minst);292 }293 Minst = measure[0].Map - measure[0].dt - ZERO_POINT;294 295 return (Minst);296 }297 298 float PhotKron (Measure *measure) {299 300 int Np;301 float Mcat;302 PhotCode *code;303 304 Np = photcodes[0].hashcode[measure[0].photcode];305 if (Np == -1) return (NAN);306 307 if (photcodes[0].code[Np].type == PHOT_REF) {308 Mcat = measure[0].Mkron;309 return (Mcat);310 }311 code = &photcodes[0].code[Np];312 Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;313 314 return (Mcat);315 }316 317 float PhotKronInst (Measure *measure) {318 319 int Np;320 float Minst;321 322 Np = photcodes[0].hashcode[measure[0].photcode];323 if (Np == -1) return (NAN);324 325 if (photcodes[0].code[Np].type == PHOT_REF) {326 Minst = measure[0].Mkron;327 return (Minst);328 }329 Minst = measure[0].Mkron - measure[0].dt - ZERO_POINT;330 331 return (Minst);332 }333 334 262 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt) { 335 263 … … 363 291 } 364 292 365 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt) {366 367 int Np;368 float ZP;369 PhotCode *code;370 371 Np = photcodes[0].hashcode[measure[0].photcode];372 if (Np == -1) return (NAN);373 374 if (photcodes[0].code[Np].type == PHOT_REF) {375 ZP = 0.0;376 return (ZP);377 }378 code = &photcodes[0].code[Np];379 ZP = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;380 381 return (ZP);382 }383 384 293 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt) { 385 294 … … 445 354 Mcal += Mcol; 446 355 return (Mcal); 356 } 357 358 /***/ 359 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt) { 360 361 int Ns; 362 float Mave; 363 364 if (code == NULL) return NAN; 365 366 Ns = photcodes[0].hashNsec[code[0].code]; 367 Mave = (Ns == -1) ? NAN : secfilt[Ns].M; 368 return (Mave); 369 } 370 371 /* return calibrated magnitude from average/secfilt for given photcode */ 372 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) { 373 374 int i, Ns; 375 float Mave, Mref, Mcol, mc; 376 double Mc; 377 378 if (code == NULL) return NAN; 379 380 Ns = photcodes[0].hashNsec[code[0].code]; 381 Mave = (Ns == -1) ? NAN : secfilt[Ns].M; 382 Mref = Mave + SCALE*code[0].C; 383 384 mc = PhotColorForCode (average, secfilt, measure, code); 385 if (isnan(mc)) return (Mref); 386 mc = mc - SCALE*code[0].dX; 387 388 Mc = mc; 389 Mcol = 0; 390 for (i = 0; i < code[0].Nc; i++) { 391 Mcol += code[0].X[i]*Mc; 392 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 393 } 394 Mref += Mcol; 395 return (Mref); 396 } 397 398 float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt) { 399 400 int Ns; 401 float dM; 402 403 if (code == NULL) return NAN; 404 405 Ns = photcodes[0].hashNsec[code[0].code]; 406 dM = (Ns == -1) ? NAN : secfilt[Ns].dM; 407 return (dM); 408 } 409 410 /************************************** APERTURE-related Magnitudes ***********************************************/ 411 412 float PhotAperInst (Measure *measure) { 413 414 int Np; 415 float Minst; 416 417 Np = photcodes[0].hashcode[measure[0].photcode]; 418 if (Np == -1) return (NAN); 419 420 if (photcodes[0].code[Np].type == PHOT_REF) { 421 Minst = measure[0].Map; 422 return (Minst); 423 } 424 Minst = measure[0].Map - measure[0].dt - ZERO_POINT; 425 426 return (Minst); 427 } 428 429 float PhotAperCat (Measure *measure) { 430 431 int Np; 432 float Mcat; 433 PhotCode *code; 434 435 Np = photcodes[0].hashcode[measure[0].photcode]; 436 if (Np == -1) return (NAN); 437 438 if (photcodes[0].code[Np].type == PHOT_REF) { 439 Mcat = measure[0].Map; 440 return (Mcat); 441 } 442 code = &photcodes[0].code[Np]; 443 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 444 445 return (Mcat); 446 } 447 448 float PhotAperSys (Measure *measure, Average *average, SecFilt *secfilt) { 449 450 int i, Np; 451 float Mcat, Mcol, Msys, mc, Mc; 452 PhotCode *code; 453 454 Np = photcodes[0].hashcode[measure[0].photcode]; 455 if (Np == -1) return (NAN); 456 457 if (photcodes[0].code[Np].type == PHOT_REF) { 458 Mcat = measure[0].Map; 459 return (Mcat); 460 } 461 code = &photcodes[0].code[Np]; 462 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 463 464 /* for DEP, color must be made of PRI/SEC */ 465 mc = PhotColorForCode (average, secfilt, NULL, code); 466 if (isnan(mc)) return (Mcat); 467 mc = mc - SCALE*code[0].dX; 468 469 Mc = mc; 470 Mcol = 0; 471 for (i = 0; i < code[0].Nc; i++) { 472 Mcol += code[0].X[i]*Mc; 473 Mc *= mc; 474 } 475 Msys = Mcat + Mcol; 476 return (Msys); 477 } 478 479 float PhotAperRel (Measure *measure, Average *average, SecFilt *secfilt) { 480 481 int i, Np; 482 float Mcat, Mcol, Mrel, mc, Mc; 483 PhotCode *code; 484 485 Np = photcodes[0].hashcode[measure[0].photcode]; 486 if (Np == -1) return (NAN); 487 488 if (photcodes[0].code[Np].type == PHOT_REF) { 489 Mcat = measure[0].Map; 490 return (Mcat); 491 } 492 code = &photcodes[0].code[Np]; 493 Mrel = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 494 495 /* for DEP, color must be made of PRI/SEC */ 496 mc = PhotColorForCode (average, secfilt, NULL, code); 497 if (isnan(mc)) return (Mrel); 498 mc = mc - SCALE*code[0].dX; 499 500 Mc = mc; 501 Mcol = 0; 502 for (i = 0; i < code[0].Nc; i++) { 503 Mcol += code[0].X[i]*Mc; 504 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 505 } 506 Mrel += Mcol; 507 return (Mrel); 508 } 509 510 /* return calibrated magnitude from measure for given photcode */ 511 float PhotAperCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) { 512 513 int i, Np; 514 float Mcal, Mrel, Mcol, mc, Mc; 515 516 if (code == NULL) return NAN; 517 518 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 519 Np = photcodes[0].hashcode[thisone[0].photcode]; 520 if (Np == -1) return (NAN); 521 522 if (photcodes[0].code[Np].type == PHOT_REF) { 523 Mrel = thisone[0].Map; 524 return (Mrel); 525 } 526 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN); 527 528 Mcal = PhotAperRel (thisone, average, secfilt) + SCALE*code[0].C; 529 530 mc = PhotColorForCode (average, secfilt, measure, code); 531 if (isnan(mc)) return (Mcal); 532 mc = mc - SCALE*code[0].dX; 533 534 Mc = mc; 535 Mcol = 0; 536 for (i = 0; i < code[0].Nc; i++) { 537 Mcol += code[0].X[i]*Mc; 538 Mc *= mc; 539 } 540 Mcal += Mcol; 541 return (Mcal); 542 } 543 544 float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt) { 545 546 int Ns; 547 float Maper; 548 549 if (code == NULL) return NAN; 550 551 Ns = photcodes[0].hashNsec[code[0].code]; 552 Maper = (Ns == -1) ? NAN : secfilt[Ns].Map; 553 return (Maper); 554 } 555 556 /* return calibrated magnitude from average/secfilt for given photcode */ 557 float PhotAperRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) { 558 559 int i, Ns; 560 float Mave, Mref, Mcol, mc; 561 double Mc; 562 563 if (code == NULL) return NAN; 564 565 Ns = photcodes[0].hashNsec[code[0].code]; 566 Mave = (Ns == -1) ? NAN : secfilt[Ns].Map; 567 Mref = Mave + SCALE*code[0].C; 568 569 mc = PhotColorForCode (average, secfilt, measure, code); 570 if (isnan(mc)) return (Mref); 571 mc = mc - SCALE*code[0].dX; 572 573 Mc = mc; 574 Mcol = 0; 575 for (i = 0; i < code[0].Nc; i++) { 576 Mcol += code[0].X[i]*Mc; 577 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 578 } 579 Mref += Mcol; 580 return (Mref); 581 } 582 583 /************************************** KRON-related Magnitudes ***********************************************/ 584 585 float PhotKronInst (Measure *measure) { 586 587 int Np; 588 float Minst; 589 590 Np = photcodes[0].hashcode[measure[0].photcode]; 591 if (Np == -1) return (NAN); 592 593 if (photcodes[0].code[Np].type == PHOT_REF) { 594 Minst = measure[0].Mkron; 595 return (Minst); 596 } 597 Minst = measure[0].Mkron - measure[0].dt - ZERO_POINT; 598 599 return (Minst); 600 } 601 602 float PhotKronCat (Measure *measure) { 603 604 int Np; 605 float Mcat; 606 PhotCode *code; 607 608 Np = photcodes[0].hashcode[measure[0].photcode]; 609 if (Np == -1) return (NAN); 610 611 if (photcodes[0].code[Np].type == PHOT_REF) { 612 Mcat = measure[0].Mkron; 613 return (Mcat); 614 } 615 code = &photcodes[0].code[Np]; 616 Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 617 618 return (Mcat); 619 } 620 621 float PhotKronSys (Measure *measure, Average *average, SecFilt *secfilt) { 622 623 int i, Np; 624 float Mcat, Mcol, Msys, mc, Mc; 625 PhotCode *code; 626 627 Np = photcodes[0].hashcode[measure[0].photcode]; 628 if (Np == -1) return (NAN); 629 630 if (photcodes[0].code[Np].type == PHOT_REF) { 631 Msys = measure[0].Mkron; 632 return (Msys); 633 } 634 code = &photcodes[0].code[Np]; 635 Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 636 637 /* for DEP, color must be made of PRI/SEC */ 638 mc = PhotColorForCode (average, secfilt, NULL, code); 639 if (isnan(mc)) return (Mcat); 640 mc = mc - SCALE*code[0].dX; 641 642 Mc = mc; 643 Mcol = 0; 644 for (i = 0; i < code[0].Nc; i++) { 645 Mcol += code[0].X[i]*Mc; 646 Mc *= mc; 647 } 648 Msys = Mcat + Mcol; 649 return (Msys); 650 } 651 652 float PhotKronRel (Measure *measure, Average *average, SecFilt *secfilt) { 653 654 int i, Np; 655 float Mcat, Mcol, Mrel, mc, Mc; 656 PhotCode *code; 657 658 Np = photcodes[0].hashcode[measure[0].photcode]; 659 if (Np == -1) return (NAN); 660 661 if (photcodes[0].code[Np].type == PHOT_REF) { 662 Mcat = measure[0].Mkron; 663 return (Mcat); 664 } 665 code = &photcodes[0].code[Np]; 666 Mrel = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 667 668 /* for DEP, color must be made of PRI/SEC */ 669 mc = PhotColorForCode (average, secfilt, NULL, code); 670 if (isnan(mc)) return (Mrel); 671 mc = mc - SCALE*code[0].dX; 672 673 Mc = mc; 674 Mcol = 0; 675 for (i = 0; i < code[0].Nc; i++) { 676 Mcol += code[0].X[i]*Mc; 677 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 678 } 679 Mrel += Mcol; 680 return (Mrel); 681 } 682 683 /* return calibrated magnitude from measure for given photcode */ 684 float PhotKronCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) { 685 686 int i, Np; 687 float Mcal, Mrel, Mcol, mc, Mc; 688 689 if (code == NULL) return NAN; 690 691 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 692 Np = photcodes[0].hashcode[thisone[0].photcode]; 693 if (Np == -1) return (NAN); 694 695 if (photcodes[0].code[Np].type == PHOT_REF) { 696 Mrel = thisone[0].Mkron; 697 return (Mrel); 698 } 699 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN); 700 701 Mcal = PhotKronRel (thisone, average, secfilt) + SCALE*code[0].C; 702 703 mc = PhotColorForCode (average, secfilt, measure, code); 704 if (isnan(mc)) return (Mcal); 705 mc = mc - SCALE*code[0].dX; 706 707 Mc = mc; 708 Mcol = 0; 709 for (i = 0; i < code[0].Nc; i++) { 710 Mcol += code[0].X[i]*Mc; 711 Mc *= mc; 712 } 713 Mcal += Mcol; 714 return (Mcal); 715 } 716 717 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt) { 718 719 int Ns; 720 float Mkron; 721 722 if (code == NULL) return NAN; 723 724 Ns = photcodes[0].hashNsec[code[0].code]; 725 Mkron = (Ns == -1) ? NAN : secfilt[Ns].Mkron; 726 return (Mkron); 727 } 728 729 /* return calibrated magnitude from average/secfilt for given photcode */ 730 float PhotKronRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) { 731 732 int i, Ns; 733 float Mave, Mref, Mcol, mc; 734 double Mc; 735 736 if (code == NULL) return NAN; 737 738 Ns = photcodes[0].hashNsec[code[0].code]; 739 Mave = (Ns == -1) ? NAN : secfilt[Ns].Mkron; 740 Mref = Mave + SCALE*code[0].C; 741 742 mc = PhotColorForCode (average, secfilt, measure, code); 743 if (isnan(mc)) return (Mref); 744 mc = mc - SCALE*code[0].dX; 745 746 Mc = mc; 747 Mcol = 0; 748 for (i = 0; i < code[0].Nc; i++) { 749 Mcol += code[0].X[i]*Mc; 750 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 751 } 752 Mref += Mcol; 753 return (Mref); 754 } 755 756 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt) { 757 758 int Ns; 759 float dMkron; 760 761 if (code == NULL) return NAN; 762 763 Ns = photcodes[0].hashNsec[code[0].code]; 764 dMkron = (Ns == -1) ? NAN : secfilt[Ns].dMkron; 765 return (dMkron); 766 } 767 768 /********************* other support functions ********************************/ 769 770 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt) { 771 772 int Np; 773 float ZP; 774 PhotCode *code; 775 776 Np = photcodes[0].hashcode[measure[0].photcode]; 777 if (Np == -1) return (NAN); 778 779 if (photcodes[0].code[Np].type == PHOT_REF) { 780 ZP = 0.0; 781 return (ZP); 782 } 783 code = &photcodes[0].code[Np]; 784 ZP = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 785 786 return (ZP); 447 787 } 448 788 … … 497 837 } 498 838 499 /* return calibrated magnitude from average/secfilt for given photcode */500 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) {501 502 int i, Ns;503 float Mave, Mref, Mcol, mc;504 double Mc;505 506 if (code == NULL) return NAN;507 508 Ns = photcodes[0].hashNsec[code[0].code];509 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;510 Mref = Mave + SCALE*code[0].C;511 512 mc = PhotColorForCode (average, secfilt, measure, code);513 if (isnan(mc)) return (Mref);514 mc = mc - SCALE*code[0].dX;515 516 Mc = mc;517 Mcol = 0;518 for (i = 0; i < code[0].Nc; i++) {519 Mcol += code[0].X[i]*Mc;520 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */521 }522 Mref += Mcol;523 return (Mref);524 }525 526 /***/527 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt) {528 529 int Ns;530 float Mave;531 532 if (code == NULL) return NAN;533 534 Ns = photcodes[0].hashNsec[code[0].code];535 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;536 return (Mave);537 }538 539 float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt) {540 541 int Ns;542 float dM;543 544 if (code == NULL) return NAN;545 546 Ns = photcodes[0].hashNsec[code[0].code];547 dM = (Ns == -1) ? NAN : secfilt[Ns].dM;548 return (dM);549 }550 551 839 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt) { 552 840 … … 559 847 Mstdev = (Ns == -1) ? NAN : 0.001*secfilt[Ns].Mstdev; 560 848 return (Mstdev); 561 }562 563 float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt) {564 565 int Ns;566 float Maper;567 568 if (code == NULL) return NAN;569 570 Ns = photcodes[0].hashNsec[code[0].code];571 Maper = (Ns == -1) ? NAN : secfilt[Ns].Map;572 return (Maper);573 }574 575 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt) {576 577 int Ns;578 float Mkron;579 580 if (code == NULL) return NAN;581 582 Ns = photcodes[0].hashNsec[code[0].code];583 Mkron = (Ns == -1) ? NAN : secfilt[Ns].Mkron;584 return (Mkron);585 }586 587 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt) {588 589 int Ns;590 float dMkron;591 592 if (code == NULL) return NAN;593 594 Ns = photcodes[0].hashNsec[code[0].code];595 dMkron = (Ns == -1) ? NAN : secfilt[Ns].dMkron;596 return (dMkron);597 849 } 598 850
Note:
See TracChangeset
for help on using the changeset viewer.
