Changeset 36911
- Timestamp:
- Jun 19, 2014, 10:08:39 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140610/Ohana/src
- Files:
-
- 7 edited
-
addstar/test/simple.dvo (modified) (11 diffs)
-
libdvo/include/dvo.h (modified) (2 diffs)
-
libdvo/include/dvodb.h (modified) (2 diffs)
-
libdvo/src/LoadPhotcodesFITS.c (modified) (1 diff)
-
libdvo/src/dbExtractMeasures.c (modified) (3 diffs)
-
libdvo/src/dbFields.c (modified) (9 diffs)
-
libdvo/src/dvo_photcode_ops.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140610/Ohana/src/addstar/test/simple.dvo
r35263 r36911 7 7 test.fields PS1_DEV_0 PS1_V1 8 8 test.fields PS1_DEV_1 PS1_V1 9 test.fields PS1_V1 PS1_V110 test.fields PS1_V2 PS1_V111 test.fields PS1_V3 PS1_V112 test.fields PS1_V4 PS1_V19 test.fields PS1_V1 PS1_V1 10 test.fields PS1_V2 PS1_V1 11 test.fields PS1_V3 PS1_V1 12 test.fields PS1_V4 PS1_V1 13 13 14 14 test.fields PS1_DEV_0 PS1_V2 15 15 test.fields PS1_DEV_1 PS1_V2 16 test.fields PS1_V1 PS1_V217 test.fields PS1_V2 PS1_V218 test.fields PS1_V3 PS1_V219 test.fields PS1_V4 PS1_V416 test.fields PS1_V1 PS1_V2 17 test.fields PS1_V2 PS1_V2 18 test.fields PS1_V3 PS1_V2 19 test.fields PS1_V4 PS1_V4 20 20 21 21 test.fields PS1_DEV_0 PS1_V3 22 22 test.fields PS1_DEV_1 PS1_V3 23 test.fields PS1_V1 PS1_V324 test.fields PS1_V2 PS1_V325 test.fields PS1_V3 PS1_V326 test.fields PS1_V4 PS1_V423 test.fields PS1_V1 PS1_V3 24 test.fields PS1_V2 PS1_V3 25 test.fields PS1_V3 PS1_V3 26 test.fields PS1_V4 PS1_V4 27 27 28 28 test.fields PS1_DEV_0 PS1_V4 29 29 test.fields PS1_DEV_1 PS1_V4 30 test.fields PS1_V1 PS1_V431 test.fields PS1_V2 PS1_V432 test.fields PS1_V3 PS1_V433 test.fields PS1_V4 PS1_V430 test.fields PS1_V1 PS1_V4 31 test.fields PS1_V2 PS1_V4 32 test.fields PS1_V3 PS1_V4 33 test.fields PS1_V4 PS1_V4 34 34 end 35 35 … … 50 50 51 51 mkinput 52 echo mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 52 53 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 53 54 if ($TAP_VERBOSE) … … 206 207 # this list is good for PS1_V1 207 208 list testfields_PS1_V1 208 IPP_IDET : detid 209 X_PSF : xccd 210 Y_PSF : yccd 209 IPP_IDET : detid 210 X_PSF : xccd 211 Y_PSF : yccd 211 212 X_PSF_SIG : xccd:err # FAIL 212 213 Y_PSF_SIG : yccd:err # FAIL … … 215 216 POSANGLE : SKIP # astrometry is not calibrated in the cmf 216 217 PLTSCALE : SKIP # astrometry is not calibrated in the cmf 217 PSF_INST_MAG : mag:inst 218 PSF_INST_MAG_SIG : mag:err 218 PSF_INST_MAG : mag:inst 219 PSF_INST_MAG_SIG : mag:err 219 220 AP_MAG_STANDARD : mag:ap # FAIL 220 221 AP_MAG_RADIUS : SKIP # no accessor … … 222 223 CAL_PSF_MAG : SKIP # photometry is not calibrated in the cmf 223 224 CAL_PSF_MAG_SIG : SKIP # photometry is not calibrated in the cmf 224 SKY : sky 225 SKY_SIG : sky_err 226 PSF_CHISQ : psf_chisq 227 CR_NSIGMA : cr_nsigma 225 SKY : sky 226 SKY_SIG : sky_err 227 PSF_CHISQ : psf_chisq 228 CR_NSIGMA : cr_nsigma 228 229 EXT_NSIGMA : ext_nsigma 229 PSF_MAJOR : FWHM_MAJ 230 PSF_MINOR : FWHM_MIN 230 PSF_MAJOR : FWHM_MAJ 231 PSF_MINOR : FWHM_MIN 231 232 PSF_THETA : THETA # FAIL 232 PSF_QF : PSF_QF 233 PSF_QF : PSF_QF 233 234 PSF_NDOF : SKIP # no accessor 234 235 PSF_NPIX : SKIP # no accessor … … 237 238 MOMENTS_YY : SKIP # no accessor 238 239 FLAGS : phot_flags 239 N_FRAMES : SKIP # no accessor 240 N_FRAMES : SKIP # no accessor 240 241 end 241 242 242 243 # this list is good for PS1_V2 243 244 list testfields_PS1_V2 244 IPP_IDET : detid 245 X_PSF : xccd 246 Y_PSF : yccd 245 IPP_IDET : detid 246 X_PSF : xccd 247 Y_PSF : yccd 247 248 X_PSF_SIG : xccd:err # FAIL 248 249 Y_PSF_SIG : yccd:err # FAIL … … 251 252 POSANGLE : SKIP # astrometry is not calibrated in the cmf 252 253 PLTSCALE : SKIP # astrometry is not calibrated in the cmf 253 PSF_INST_MAG : mag:inst 254 PSF_INST_MAG_SIG : mag:err 254 PSF_INST_MAG : mag:inst 255 PSF_INST_MAG_SIG : mag:err 255 256 AP_MAG_STANDARD : mag:ap # FAIL 256 257 AP_MAG_RADIUS : SKIP # no accessor … … 258 259 CAL_PSF_MAG : SKIP # photometry is not calibrated in the cmf 259 260 CAL_PSF_MAG_SIG : SKIP # photometry is not calibrated in the cmf 260 SKY : sky 261 SKY_SIG : sky_err 262 PSF_CHISQ : psf_chisq 263 CR_NSIGMA : cr_nsigma 261 SKY : sky 262 SKY_SIG : sky_err 263 PSF_CHISQ : psf_chisq 264 CR_NSIGMA : cr_nsigma 264 265 EXT_NSIGMA : ext_nsigma 265 PSF_MAJOR : FWHM_MAJ 266 PSF_MINOR : FWHM_MIN 266 PSF_MAJOR : FWHM_MAJ 267 PSF_MINOR : FWHM_MIN 267 268 PSF_THETA : THETA # FAIL 268 PSF_QF : PSF_QF 269 PSF_QF : PSF_QF 269 270 PSF_NDOF : SKIP # no accessor 270 271 PSF_NPIX : SKIP # no accessor … … 273 274 MOMENTS_YY : SKIP # no accessor 274 275 FLAGS : phot_flags 275 N_FRAMES : SKIP # no accessor 276 N_FRAMES : SKIP # no accessor 276 277 end 277 278 278 279 # this list is good for PS1_V3 279 280 list testfields_PS1_V3 280 IPP_IDET : detid 281 X_PSF : xccd 282 Y_PSF : yccd 281 IPP_IDET : detid 282 X_PSF : xccd 283 Y_PSF : yccd 283 284 X_PSF_SIG : xccd:err # FAIL 284 285 Y_PSF_SIG : yccd:err # FAIL 285 286 POSANGLE : SKIP # astrometry is not calibrated in the cmf 286 287 PLTSCALE : SKIP # astrometry is not calibrated in the cmf 287 PSF_INST_MAG : mag:inst 288 PSF_INST_MAG_SIG : mag:err 288 PSF_INST_MAG : mag:inst 289 PSF_INST_MAG_SIG : mag:err 289 290 PSF_INST_FLUX : SKIP # not ingested into DVO 290 291 PSF_INST_FLUX_SIG : SKIP # not ingested into DVO … … 297 298 DEC_PSF : SKIP # astrometry is not calibrated in the cmf 298 299 PEAK_FLUX_AS_MAG : SKIP # not ingested into DVO 299 SKY : sky 300 SKY_SIG : sky_err 301 PSF_CHISQ : psf_chisq 302 CR_NSIGMA : cr_nsigma 300 SKY : sky 301 SKY_SIG : sky_err 302 PSF_CHISQ : psf_chisq 303 CR_NSIGMA : cr_nsigma 303 304 EXT_NSIGMA : ext_nsigma 304 PSF_MAJOR : FWHM_MAJ 305 PSF_MINOR : FWHM_MIN 305 PSF_MAJOR : FWHM_MAJ 306 PSF_MINOR : FWHM_MIN 306 307 PSF_THETA : THETA # FAIL 307 PSF_QF : PSF_QF 308 PSF_QF : PSF_QF 308 309 PSF_QF_PERFECT : SKIP # not ingested into DVO 309 310 PSF_NDOF : PSF_NDOF … … 326 327 end 327 328 328 # this list is good for PS1_V 4329 list testfields_PS1_V 4330 IPP_IDET : detid 331 X_PSF : xccd 332 Y_PSF : yccd 333 X_PSF_SIG : xccd:err # FAIL334 Y_PSF_SIG : yccd:err # FAIL335 POSANGLE : SKIP # astrometry is not calibrated in the cmf336 PLTSCALE : SKIP # astrometry is not calibrated in the cmf337 PSF_INST_MAG : mag:inst 338 PSF_INST_MAG_SIG : mag:err 339 PSF_INST_FLUX : SKIP # not ingested into DVO340 PSF_INST_FLUX_SIG : SKIP # not ingested into DVO341 AP_MAG : mag:aper inst # FAIL329 # this list is good for PS1_V5 330 list testfields_PS1_V5 331 IPP_IDET : detid 332 X_PSF : xccd 333 Y_PSF : yccd 334 X_PSF_SIG : xccd:err 335 Y_PSF_SIG : yccd:err 336 POSANGLE : posangle 337 PLTSCALE : pltscale 338 PSF_INST_MAG : mag:inst 339 PSF_INST_MAG_SIG : mag:err 340 PSF_INST_FLUX : flux:inst 341 PSF_INST_FLUX_SIG : flux:inst:err 342 AP_MAG : mag:aper:inst 342 343 AP_MAG_RAW : SKIP # not ingested into DVO 343 344 AP_MAG_RADIUS : SKIP # not ingested into DVO 344 CAL_PSF_MAG : SKIP # photometry is not calibrated in the cmf 345 CAL_PSF_MAG_SIG : SKIP # photometry is not calibrated in the cmf 346 RA_PSF : SKIP # astrometry is not calibrated in the cmf 347 DEC_PSF : SKIP # astrometry is not calibrated in the cmf 348 PEAK_FLUX_AS_MAG : SKIP # not ingested into DVO 349 SKY : sky 350 SKY_SIGMA : sky_err 351 PSF_CHISQ : psf_chisq 352 CR_NSIGMA : cr_nsigma 353 EXT_NSIGMA : ext_nsigma 354 PSF_MAJOR : FWHM_MAJ 355 PSF_MINOR : FWHM_MIN 356 PSF_THETA : THETA # FAIL 357 PSF_QF : PSF_QF 358 PSF_QF_PERFECT : SKIP # not ingested into DVO 359 PSF_NDOF : PSF_NDOF 360 PSF_NPIX : PSF_NPIX 361 MOMENTS_XX : MXX 362 MOMENTS_XY : MXY 363 MOMENTS_YY : MYY 364 MOMENTS_M3C : SKIP # not ingested into DVO 365 MOMENTS_M3S : SKIP # not ingested into DVO 366 MOMENTS_M4C : SKIP # not ingested into DVO 367 MOMENTS_M4S : SKIP # not ingested into DVO 368 MOMENTS_R1 : SKIP # not ingested into DVO 369 MOMENTS_RH : SKIP # not ingested into DVO 370 KRON_FLUX : mag:kroninst 371 KRON_FLUX_ERR : mag:kronerr 372 KRON_FLUX_INNER : SKIP # not ingested into DVO 373 KRON_FLUX_OUTER : SKIP # not ingested into DVO 374 FLAGS : phot_flags 375 N_FRAMES : SKIP # not ingested into DVO 376 end 345 AP_FLUX : flux:aper:inst 346 AP_FLUX_SIG : flux:aper:inst:err 347 CAL_PSF_MAG : mag:rel 348 CAL_PSF_MAG_SIG : mag:rel:err 349 RA_PSF : ra 350 DEC_PSF : dec 351 AP_NPIX : SKIP # not ingested into DVO 352 PEAK_FLUX_AS_MAG : SKIP # not ingested into DVO 353 SKY : sky 354 SKY_SIGMA : sky_err 355 PSF_CHISQ : psf_chisq 356 CR_NSIGMA : cr_nsigma 357 EXT_NSIGMA : ext_nsigma 358 PSF_MAJOR : fwhm_maj # XXX technically, this is not FWHM but Sigma 359 PSF_MINOR : fwhm_min # XXX technically, this is not FWHM but Sigma 360 PSF_THETA : theta # FAIL 361 PSF_CORE : SKIP # not ingested into DVO 362 PSF_FWHM_MAJ : SKIP # not ingested into DVO 363 PSF_FWHM_MIN : SKIP # not ingested into DVO 364 PSF_QF : psf_qf 365 PSF_QF_PERFECT : SKIP # not ingested into DVO 366 PSF_NDOF : psf_ndof 367 PSF_NPIX : psf_npix 368 MOMENTS_XX : Mxx 369 MOMENTS_XY : Mxy 370 MOMENTS_YY : Myy 371 MOMENTS_M3C : SKIP # not ingested into DVO 372 MOMENTS_M3S : SKIP # not ingested into DVO 373 MOMENTS_M4C : SKIP # not ingested into DVO 374 MOMENTS_M4S : SKIP # not ingested into DVO 375 MOMENTS_R1 : SKIP # not ingested into DVO 376 MOMENTS_RH : SKIP # not ingested into DVO 377 KRON_FLUX : flux:kron:inst 378 KRON_FLUX_ERR : flux:kron:inst:err 379 KRON_FLUX_INNER : SKIP # not ingested into DVO 380 KRON_FLUX_OUTER : SKIP # not ingested into DVO 381 SKY_LIMIT_RAD : SKIP # not ingested into DVO 382 SKY_LIMIT_FLUX : SKIP # not ingested into DVO 383 SKY_LIMIT_SLOPE : SKIP # not ingested into DVO 384 FLAGS : phot_flags 385 FLAGS2 : SKIP # not ingested into DVO 386 N_FRAMES : SKIP # not ingested into DVO 387 end 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/include/dvo.h
r36910 r36911 673 673 float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 674 674 675 float PhotInstTiny (MeasureTiny *measure, dvoMagClassType class); 676 float PhotCatTiny (MeasureTiny *measure, dvoMagClassType class); 677 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class); 678 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class); 679 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code, dvoMagClassType class); 680 681 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 682 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, dvoMagClassType class, dvoMagSourceType source); 683 684 float PhotFluxInst (Measure *measure, dvoMagClassType class); 685 float PhotFluxCat (Measure *measure, dvoMagClassType class); 686 float PhotFluxSys (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class); 687 float PhotFluxRel (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class); 688 float PhotFluxCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code, dvoMagClassType class); 689 690 float PhotFluxAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 691 float PhotFluxRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure, dvoMagClassType class, dvoMagSourceType source); 692 675 693 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt); 676 677 694 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt); 678 float PhotAveFluxPSF (PhotCode *code, Average *average, SecFilt *secfilt);679 float PhotAvedFluxPSF (PhotCode *code, Average *average, SecFilt *secfilt);680 float PhotAveFluxKron (PhotCode *code, Average *average, SecFilt *secfilt);681 float PhotAvedFluxKron (PhotCode *code, Average *average, SecFilt *secfilt);682 695 683 696 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt); … … 689 702 float PhotColorForCode (Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 690 703 int PhotColor (Average *average, SecFilt *secfilt, Measure *measure, int c1, int c2, double *color); 691 692 float PhotInstTiny (MeasureTiny *measure, dvoMagClassType class);693 float PhotCatTiny (MeasureTiny *measure, dvoMagClassType class);694 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class);695 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class);696 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code, dvoMagClassType class);697 698 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source);699 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, dvoMagClassType class, dvoMagSourceType source);700 704 701 705 float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt); -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/include/dvodb.h
r36909 r36911 64 64 MAG_CLASS_APER, 65 65 } dvoMagClassType; 66 67 # if (0)68 enum {69 MAG_NONE,70 71 // these magnitude types are from the measurement table (or derived therein)72 // the following imply PSF magnitudes:73 MAG_INST, // -2.5*log(DN) [ie, not DN/sec]74 MAG_CAT, // MAG_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1)75 MAG_SYS, // MAG_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode]76 MAG_REL, // MAG_SYS - Mcal [specific zero point for image]77 MAG_CAL, // MAG_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode]78 MAG_ERR, // error on PSF MAG79 80 // the following imply APERTURE magnitudes:81 MAG_APER_INST, // -2.5*log(DN) [ie, not DN/sec]82 MAG_APER_CAT, // MAG_APER_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1)83 MAG_APER_SYS, // MAG_APER_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode]84 MAG_APER_REL, // MAG_APER_SYS - Mcal [specific zero point for image]85 MAG_APER_CAL, // MAG_APER_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode]86 MAG_APER_ERR, // error on APER MAG (if known, else psf error)87 MAG_APER, // in mextract -> MAG_APER_REL, in avextract -> MAG_APER_AVE88 89 // the following imply KRON magnitudes:90 MAG_KRON_INST, // -2.5*log(DN) [ie, not DN/sec]91 MAG_KRON_CAT, // MAG_KRON_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1)92 MAG_KRON_SYS, // MAG_KRON_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode]93 MAG_KRON_REL, // MAG_KRON_SYS - Mcal [specific zero point for image]94 MAG_KRON_CAL, // MAG_KRON_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode]95 MAG_KRON_ERR, // error on KRON MAG96 MAG_KRON, // in mextract -> MAG_KRON_REL, in avextract -> MAG_KRON_AVE97 98 // these magnitude types are from the average (secfilt) table:99 // the following imply PSF magnitudes (or fluxes)100 MAG_STDEV,101 MAG_AVE_ERR,102 MAG_CHISQ,103 MAG_MIN,104 MAG_MAX,105 MAG_FLUX_PSF,106 MAG_FLUX_PSF_ERR,107 108 // the following imply APERTURE magnitudes:109 MAG_APER_AVE,110 MAG_APER_REF,111 112 // the following imply KRON magnitudes or fluxes:113 MAG_KRON_AVE,114 MAG_KRON_REF,115 MAG_FLUX_KRON,116 MAG_FLUX_KRON_ERR,117 118 // other secfilt fields of interest119 MAG_PHOT_FLAGS,120 MAG_NCODE,121 MAG_NPHOT,122 MAG_UC_DIST,123 MAG_STACK_DET_ID,124 } ;125 # endif126 66 127 67 /* measure fields */ … … 163 103 MEAS_OBJ_FLAGS, 164 104 MEAS_SECFILT_FLAGS, 165 MEAS_ MAG,105 MEAS_PHOT, // photometry class of measurements 166 106 MEAS_MINST, 167 107 MEAS_MCAT, -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/LoadPhotcodesFITS.c
r36908 r36911 106 106 return FALSE; 107 107 } 108 if (!strcasecmp(photcode[i].name, "FLUX")) { 109 fprintf (stderr, "FLUX is not an allowed photcode name (reserved to DVO internals)\n"); 110 free (photcode); 111 return FALSE; 112 } 108 113 109 114 if (photcode[i].type == PHOT_DEP) { -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dbExtractMeasures.c
r36910 r36911 100 100 101 101 switch (field->ID) { 102 case MEAS_ MAG: { /* magnitudes are already determined above */102 case MEAS_PHOT: { /* magnitudes are already determined above */ 103 103 PhotCode *myEquiv = GetPhotcodeEquivbyCode (measure[0].photcode); 104 104 … … 170 170 } 171 171 break; 172 172 173 case MAG_OPTION_ERR: 173 174 switch (field->magLevel) { … … 189 190 190 191 case MAG_OPTION_FLUX: 192 switch (field->magLevel) { 193 case MAG_LEVEL_INST: 194 value.Flt = PhotFluxInst (measure, field->magClass); 195 break; 196 case MAG_LEVEL_CAT: 197 value.Flt = PhotFluxCat (measure, field->magClass); 198 break; 199 case MAG_LEVEL_SYS: 200 value.Flt = PhotFluxSys (measure, average, secfilt, field->magClass); 201 break; 202 case MAG_LEVEL_REL: 203 value.Flt = PhotFluxRel (measure, average, secfilt, field->magClass); 204 break; 205 case MAG_LEVEL_CAL: 206 value.Flt = PhotFluxCal (measure, average, secfilt, measure, equiv, field->magClass); 207 break; 208 case MAG_LEVEL_AVE: 209 value.Flt = PhotFluxAve (equiv, average, secfilt, field->magClass, field->magSource); 210 break; 211 case MAG_LEVEL_REF: 212 value.Flt = PhotFluxRef (equiv, average, secfilt, measure, field->magClass, field->magSource); 213 break; 214 case MAG_LEVEL_NONE: 215 break; 216 } 217 break; 218 191 219 case MAG_OPTION_FLUX_ERR: 220 switch (field->magLevel) { 221 case MAG_LEVEL_INST: 222 case MAG_LEVEL_CAT: 223 case MAG_LEVEL_SYS: 224 case MAG_LEVEL_REL: 225 case MAG_LEVEL_CAL: 226 // value.Flt = PhotFluxErr (measure, field->magClass); 227 break; 228 case MAG_LEVEL_AVE: 229 case MAG_LEVEL_REF: 230 // value.Flt = PhotFluxAveErr (equiv, average, secfilt, field->magClass, field->magSource); 231 break; 232 case MAG_LEVEL_NONE: 233 break; 234 } 235 break; 236 192 237 case MAG_OPTION_STDEV: 193 238 case MAG_OPTION_CHISQ: -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dbFields.c
r36908 r36911 67 67 68 68 if (!strcasecmp (string, "mag")) return (MAG_OPTION_MAG); 69 if (!strcasecmp (string, "err")) return (MAG_OPTION_ERR); 70 if (!strcasecmp (string, "magerr")) return (MAG_OPTION_ERR); 69 71 if (!strcasecmp (string, "flux")) return (MAG_OPTION_FLUX); 70 72 if (!strcasecmp (string, "fluxerr")) return (MAG_OPTION_FLUX_ERR); 71 if (!strcasecmp (string, "err")) return (MAG_OPTION_ERR);72 73 if (!strcasecmp (string, "stdev")) return (MAG_OPTION_STDEV); 73 74 if (!strcasecmp (string, "chisq")) return (MAG_OPTION_CHISQ); … … 160 161 161 162 // defaults: 162 field->ID = MEAS_MAG; // change if not true in the end? 163 field->ID = MEAS_PHOT; // change if not true in the end? 164 165 // check what options are provided. do not allow duplicate types 166 // except mag and flux may exist with err 167 dvoMagSourceType mySource = MAG_SRC_NONE; 168 dvoMagLevelType myLevel = MAG_LEVEL_NONE; 169 dvoMagClassType myClass = MAG_CLASS_NONE; 170 dvoMagOptionType myOption = MAG_OPTION_NONE; 171 163 172 field->magSource = MAG_SRC_CHP; 164 173 field->magLevel = MAG_LEVEL_AVE; … … 174 183 char *firstWord = getword(fieldCopy); 175 184 176 // firstWord may be either mag [mextract]or photcode185 // firstWord may be either flux, mag or photcode 177 186 if (!strcasecmp (firstWord, "MAG")) { 178 187 // default level for 'mag' is rel 179 188 field->magLevel = MAG_LEVEL_REL; 189 myOption = MAG_OPTION_MAG; 190 } 191 if (!strcasecmp (firstWord, "FLUX")) { 192 // default level for 'flux' is rel 193 field->magLevel = MAG_LEVEL_REL; 194 myOption = MAG_OPTION_FLUX; 180 195 } 181 196 PhotCode *code = GetPhotcodebyName (firstWord); … … 184 199 if (!code) return FALSE; 185 200 186 // enforce compatibility 201 // defaults for photcode clases 202 if (code->type == PHOT_DEP) { 203 field->magLevel = MAG_LEVEL_REL; 204 } 205 if (code->type == PHOT_SEC) { 206 field->magLevel = MAG_LEVEL_AVE; 207 } 187 208 if (code->type == PHOT_REF) { 188 209 field->magLevel = MAG_LEVEL_CAT; 189 } 190 if (code->type == PHOT_DEP) { 191 field->magLevel = MAG_LEVEL_REL; 210 // is this one required? 192 211 } 193 212 … … 201 220 dvoMagSourceType source = GetMagSource (word); 202 221 if (source != MAG_SRC_NONE) { 203 field->magSource = source; 222 if (mySource != MAG_SRC_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 223 mySource = source; 204 224 ptr = skipword (ptr); 205 225 continue; … … 208 228 dvoMagLevelType level = GetMagLevel (word); 209 229 if (level != MAG_LEVEL_NONE) { 210 field->magLevel = level; 230 if (myLevel != MAG_LEVEL_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 231 myLevel = level; 211 232 ptr = skipword (ptr); 212 233 continue; … … 215 236 dvoMagClassType class = GetMagClass (word); 216 237 if (class != MAG_CLASS_NONE) { 217 field->magClass = class; 238 if (myClass != MAG_CLASS_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 239 myClass = class; 218 240 ptr = skipword (ptr); 219 241 continue; … … 222 244 dvoMagOptionType option = GetMagOption (word); 223 245 if (option != MAG_OPTION_NONE) { 224 field->magOption = option; 246 // some combinations are OK: mag + err -> err 247 if ((myOption == MAG_OPTION_MAG) && (option == MAG_OPTION_ERR)) { 248 myOption = option; 249 ptr = skipword (ptr); 250 continue; 251 } 252 // some combinations are OK: err + mag -> err 253 if ((myOption == MAG_OPTION_ERR) && (option == MAG_OPTION_MAG)) { 254 ptr = skipword (ptr); 255 continue; 256 } 257 // some combinations are OK: flux + err -> FLUX_ERR 258 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_ERR)) { 259 myOption = MAG_OPTION_FLUX_ERR; 260 ptr = skipword (ptr); 261 continue; 262 } 263 // some combinations are OK: err + flux -> FLUX_ERR 264 if ((myOption == MAG_OPTION_ERR) && (option == MAG_OPTION_FLUX)) { 265 myOption = MAG_OPTION_FLUX_ERR; 266 ptr = skipword (ptr); 267 continue; 268 } 269 // some combinations are OK: flux + fluxerr -> FLUX_ERR 270 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_FLUX_ERR)) { 271 myOption = MAG_OPTION_FLUX_ERR; 272 ptr = skipword (ptr); 273 continue; 274 } 275 // some combinations are OK: fluxerr + flux -> FLUX_ERR 276 if ((myOption == MAG_OPTION_FLUX_ERR) && (option == MAG_OPTION_FLUX)) { 277 myOption = MAG_OPTION_FLUX_ERR; 278 ptr = skipword (ptr); 279 continue; 280 } 281 if (myOption != MAG_OPTION_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 282 myOption = option; 225 283 ptr = skipword (ptr); 226 284 continue; … … 230 288 free (word); 231 289 } 290 291 // if nothing is provided, use the defaults 292 field->magSource = (mySource == MAG_SRC_NONE) ? field->magSource : mySource; 293 field->magLevel = (myLevel == MAG_LEVEL_NONE) ? field->magLevel : myLevel; 294 field->magClass = (myClass == MAG_CLASS_NONE) ? field->magClass : myClass; 295 field->magOption = (myOption == MAG_OPTION_NONE) ? field->magOption : myOption; 232 296 233 297 switch (field->magOption) { -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_photcode_ops.c
r36910 r36911 18 18 19 19 static PhotCodeData *photcodes = NULL; 20 static PhotCode *genericCode = NULL; 20 static PhotCode *genericCodeMag = NULL; 21 static PhotCode *genericCodeFlux = NULL; 21 22 22 23 PhotCodeData *GetPhotcodeTable () { … … 27 28 photcodes[0].code = NULL; 28 29 } 29 if (genericCode == NULL) { 30 ALLOCATE (genericCode, PhotCode, 1); 31 genericCode->code = 0; 32 strcpy (genericCode->name, "MAG"); 33 genericCode->type = PHOT_MAG; 30 if (genericCodeMag == NULL) { 31 ALLOCATE (genericCodeMag, PhotCode, 1); 32 genericCodeMag->code = 0; 33 strcpy (genericCodeMag->name, "MAG"); 34 genericCodeMag->type = PHOT_MAG; 35 } 36 if (genericCodeFlux == NULL) { 37 ALLOCATE (genericCodeFlux, PhotCode, 1); 38 genericCodeFlux->code = 0; 39 strcpy (genericCodeFlux->name, "MAG"); 40 genericCodeFlux->type = PHOT_MAG; 34 41 } 35 42 return photcodes; … … 66 73 // "MAG" is a special word, not allowed for a photcode name 67 74 if (!strcasecmp (name, "MAG")) { 68 return genericCode; 75 return genericCodeMag; 76 } 77 78 // "FLUX" is a special word, not allowed for a photcode name 79 if (!strcasecmp (name, "FLUX")) { 80 return genericCodeFlux; 69 81 } 70 82 … … 83 95 if (name == NULL) return (0); 84 96 85 // "MAG" is a special word, not allowed for a photcode name97 // "MAG" is a special photcode name for internal use 86 98 if (!strcasecmp (name, "MAG")) { 87 return genericCode->code; 99 return genericCodeMag->code; 100 } 101 // "FLUX" is a special photcode name for internal use 102 if (!strcasecmp (name, "FLUX")) { 103 return genericCodeFlux->code; 88 104 } 89 105 … … 834 850 } 835 851 852 float MagToFlux (float Mag) { 853 float Flux = pow(10.0, -0.4*(Mag)); 854 return (Flux); 855 } 856 857 /** flux conversion *******************************************************************/ 858 float PhotFluxInst (Measure *measure, dvoMagClassType class) { 859 860 float Moff = - measure[0].dt - ZERO_POINT; 861 float Finst = NAN; 862 switch (class) { 863 case MAG_CLASS_PSF: 864 Finst = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF; 865 break; 866 case MAG_CLASS_KRON: 867 Finst = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron; 868 break; 869 case MAG_CLASS_APER: 870 Finst = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp; 871 break; 872 default: 873 break; 874 } 875 return (Finst); 876 } 877 878 // returns Jy fluxes assuming mag in AB? (needs an extra AP factor, right?) 879 float PhotFluxCat (Measure *measure, dvoMagClassType class) { 880 881 int Np = photcodes[0].hashcode[measure[0].photcode]; 882 if (Np == -1) return (NAN); 883 PhotCode *code = &photcodes[0].code[Np]; 884 885 // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux 886 float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 887 float Moff = Mcal - ZERO_POINT; 888 float Foff = MagToFlux(Mcal); 889 float Fcat = NAN; 890 switch (class) { 891 case MAG_CLASS_PSF: 892 Fcat = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF * Foff; 893 break; 894 case MAG_CLASS_KRON: 895 Fcat = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron * Foff; 896 break; 897 case MAG_CLASS_APER: 898 Fcat = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp * Foff; 899 break; 900 default: 901 break; 902 } 903 return (Fcat); 904 } 905 906 // corrected for color trends 907 float PhotFluxSys (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class) { 908 909 int Np = photcodes[0].hashcode[measure[0].photcode]; 910 if (Np == -1) return (NAN); 911 PhotCode *code = &photcodes[0].code[Np]; 912 913 // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux 914 float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 915 float Moff = Mcal - ZERO_POINT; 916 float Foff = MagToFlux(Mcal); 917 float Fcat = NAN; 918 switch (class) { 919 case MAG_CLASS_PSF: 920 Fcat = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF * Foff; 921 break; 922 case MAG_CLASS_KRON: 923 Fcat = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron * Foff; 924 break; 925 case MAG_CLASS_APER: 926 Fcat = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp * Foff; 927 break; 928 default: 929 break; 930 } 931 if (isnan(Fcat)) return (NAN); 932 933 // find the relevant color 934 float mc = PhotColorForCode (average, secfilt, NULL, code); 935 if (isnan(mc)) return (Fcat); 936 mc -= SCALE*code[0].dX; 937 938 // find the color correction in mags 939 int i = 0; 940 double Mc = mc; 941 float Mcol = 0; 942 for (i = 0; i < code[0].Nc; i++) { 943 Mcol += code[0].X[i]*Mc; 944 Mc *= mc; 945 } 946 float Fcol = MagToFlux (Mcol); 947 948 float Fsys = Fcat * Fcol; 949 return (Fsys); 950 } 951 952 float PhotFluxRel (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class) { 953 954 int Np = photcodes[0].hashcode[measure[0].photcode]; 955 if (Np == -1) return (NAN); 956 PhotCode *code = &photcodes[0].code[Np]; 957 958 // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux 959 float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 960 float Moff = Mcal - ZERO_POINT; 961 float Foff = MagToFlux(Mcal); 962 float Fcat = NAN; 963 switch (class) { 964 case MAG_CLASS_PSF: 965 Fcat = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF * Foff; 966 break; 967 case MAG_CLASS_KRON: 968 Fcat = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron * Foff; 969 break; 970 case MAG_CLASS_APER: 971 Fcat = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp * Foff; 972 break; 973 default: 974 break; 975 } 976 if (isnan(Fcat)) return (NAN); 977 978 /* for DEP, color must be made of PRI/SEC */ 979 float mc = PhotColorForCode (average, secfilt, NULL, code); 980 if (isnan(mc)) return (Fcat); 981 mc -= SCALE*code[0].dX; 982 983 double Mc = mc; 984 float Mcol = 0; 985 int i = 0; 986 for (i = 0; i < code[0].Nc; i++) { 987 Mcol += code[0].X[i]*Mc; 988 Mc *= mc; 989 } 990 float Fcol = MagToFlux (Mcol); 991 992 float Frel = Fcat * Fcol; 993 return (Frel); 994 } 995 996 /* return calibrated magnitude from measure for given photcode */ 997 float PhotFluxCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code, dvoMagClassType class) { 998 999 int i; 1000 1001 if (code == NULL) return NAN; 1002 1003 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 1004 int Np = photcodes[0].hashcode[thisone[0].photcode]; 1005 if (Np == -1) return (NAN); 1006 PhotCode *myCode = &photcodes[0].code[Np]; 1007 1008 if (code->code != myCode->equiv) return (NAN); 1009 1010 float Frel = PhotFluxRel (thisone, average, secfilt, class) + SCALE*code[0].C; 1011 1012 // get the relevant color term 1013 float mc = PhotColorForCode (average, secfilt, measure, code); 1014 if (isnan(mc)) return (Frel); 1015 mc -= SCALE*code[0].dX; 1016 1017 // get the corresponding color correction in mags, convert to flux 1018 double Mc = mc; 1019 float Mcol = 0; 1020 for (i = 0; i < code[0].Nc; i++) { 1021 Mcol += code[0].X[i]*Mc; 1022 Mc *= mc; 1023 } 1024 float Fcol = MagToFlux (Mcol); 1025 1026 float Fcal = Frel * Fcol; 1027 return (Fcal); 1028 } 1029 1030 /***/ 1031 float PhotFluxAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 1032 1033 if (code == NULL) return NAN; 1034 1035 int Ns = photcodes[0].hashNsec[code[0].code]; 1036 if (Ns == -1) return (NAN); 1037 1038 float Fave = NAN; 1039 switch (source) { 1040 case MAG_SRC_CHP: 1041 switch (class) { 1042 case MAG_CLASS_PSF: 1043 Fave = MagToFlux(secfilt[Ns].M); 1044 break; 1045 case MAG_CLASS_KRON: 1046 Fave = MagToFlux(secfilt[Ns].Mkron); 1047 break; 1048 case MAG_CLASS_APER: 1049 Fave = MagToFlux(secfilt[Ns].Map); 1050 break; 1051 default: 1052 break; 1053 } 1054 break; 1055 case MAG_SRC_WRP: 1056 switch (class) { 1057 case MAG_CLASS_PSF: 1058 Fave = isnan (secfilt[Ns].FpsfWrp) ? MagToFlux(secfilt[Ns].MpsfWrp) : secfilt[Ns].FpsfWrp; 1059 break; 1060 case MAG_CLASS_KRON: 1061 Fave = isnan (secfilt[Ns].FkronWrp) ? MagToFlux(secfilt[Ns].MkronWrp) : secfilt[Ns].FkronWrp; 1062 break; 1063 case MAG_CLASS_APER: 1064 Fave = isnan (secfilt[Ns].FapWrp) ? MagToFlux(secfilt[Ns].MapWrp) : secfilt[Ns].FapWrp; 1065 break; 1066 default: 1067 break; 1068 } 1069 break; 1070 case MAG_SRC_STK: 1071 switch (class) { 1072 case MAG_CLASS_PSF: 1073 Fave = isnan (secfilt[Ns].FpsfStk) ? MagToFlux(secfilt[Ns].MpsfStk) : secfilt[Ns].FpsfStk; 1074 break; 1075 case MAG_CLASS_KRON: 1076 Fave = isnan (secfilt[Ns].FkronStk) ? MagToFlux(secfilt[Ns].MkronStk) : secfilt[Ns].FkronStk; 1077 break; 1078 case MAG_CLASS_APER: 1079 Fave = isnan (secfilt[Ns].FapStk) ? MagToFlux(secfilt[Ns].MapStk) : secfilt[Ns].FapStk; 1080 break; 1081 default: 1082 break; 1083 } 1084 break; 1085 default: 1086 break; 1087 } 1088 return (Fave); 1089 } 1090 1091 /* return calibrated magnitude from average/secfilt for given photcode */ 1092 float PhotFluxRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure, dvoMagClassType class, dvoMagSourceType source) { 1093 1094 int i; 1095 1096 float Fave = PhotFluxAve (code, average, secfilt, class, source); 1097 if (isnan(Fave)) return NAN; 1098 1099 // correct for relative zero-point 1100 float Moff = SCALE*code[0].C; 1101 1102 float mc = PhotColorForCode (average, secfilt, measure, code); 1103 if (isnan(mc)) return (Fave * MagToFlux(Moff)); 1104 mc -= SCALE*code[0].dX; 1105 1106 // correct for color terms 1107 double Mc = mc; 1108 float Mcol = 0; 1109 for (i = 0; i < code[0].Nc; i++) { 1110 Mcol += code[0].X[i]*Mc; 1111 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 1112 } 1113 float Foff = MagToFlux(Mcol); 1114 return (Fave * Foff); 1115 } 1116 836 1117 /******** alternate photometry conversion functions using MeasureTiny and AverageTiny *********/ 837 1118 float PhotInstTiny (MeasureTiny *measure, dvoMagClassType class) {
Note:
See TracChangeset
for help on using the changeset viewer.
