IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36911


Ignore:
Timestamp:
Jun 19, 2014, 10:08:39 AM (12 years ago)
Author:
eugene
Message:

adding flux varient to the phot-like dvo db selections

Location:
branches/eam_branches/ipp-20140610/Ohana/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140610/Ohana/src/addstar/test/simple.dvo

    r35263 r36911  
    77  test.fields PS1_DEV_0 PS1_V1
    88  test.fields PS1_DEV_1 PS1_V1
    9   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
     9  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
    1313
    1414  test.fields PS1_DEV_0 PS1_V2
    1515  test.fields PS1_DEV_1 PS1_V2
    16   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
     16  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
    2020
    2121  test.fields PS1_DEV_0 PS1_V3
    2222  test.fields PS1_DEV_1 PS1_V3
    23   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
     23  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
    2727
    2828  test.fields PS1_DEV_0 PS1_V4
    2929  test.fields PS1_DEV_1 PS1_V4
    30   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
     30  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
    3434end 
    3535
     
    5050
    5151  mkinput
     52  echo mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1
    5253  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1
    5354  if ($TAP_VERBOSE)
     
    206207# this list is good for PS1_V1
    207208list 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     
    211212  X_PSF_SIG         : xccd:err #  FAIL
    212213  Y_PSF_SIG         : yccd:err # FAIL
     
    215216  POSANGLE          : SKIP # astrometry is not calibrated in the cmf
    216217  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   
    219220  AP_MAG_STANDARD   : mag:ap # FAIL
    220221  AP_MAG_RADIUS     : SKIP # no accessor
     
    222223  CAL_PSF_MAG       : SKIP # photometry is not calibrated in the cmf
    223224  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 
    228229  EXT_NSIGMA        : ext_nsigma
    229   PSF_MAJOR         : FWHM_MAJ 
    230   PSF_MINOR         : FWHM_MIN 
     230  PSF_MAJOR         : FWHM_MAJ 
     231  PSF_MINOR         : FWHM_MIN 
    231232  PSF_THETA         : THETA # FAIL
    232   PSF_QF            : PSF_QF   
     233  PSF_QF            : PSF_QF   
    233234  PSF_NDOF          : SKIP # no accessor
    234235  PSF_NPIX          : SKIP # no accessor
     
    237238  MOMENTS_YY        : SKIP # no accessor
    238239  FLAGS             : phot_flags
    239   N_FRAMES          : SKIP # no accessor       
     240  N_FRAMES          : SKIP # no accessor       
    240241end
    241242
    242243# this list is good for PS1_V2
    243244list 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     
    247248  X_PSF_SIG         : xccd:err # FAIL
    248249  Y_PSF_SIG         : yccd:err # FAIL
     
    251252  POSANGLE          : SKIP # astrometry is not calibrated in the cmf
    252253  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   
    255256  AP_MAG_STANDARD   : mag:ap # FAIL
    256257  AP_MAG_RADIUS     : SKIP # no accessor
     
    258259  CAL_PSF_MAG       : SKIP # photometry is not calibrated in the cmf
    259260  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 
    264265  EXT_NSIGMA        : ext_nsigma
    265   PSF_MAJOR         : FWHM_MAJ 
    266   PSF_MINOR         : FWHM_MIN 
     266  PSF_MAJOR         : FWHM_MAJ 
     267  PSF_MINOR         : FWHM_MIN 
    267268  PSF_THETA         : THETA # FAIL
    268   PSF_QF            : PSF_QF   
     269  PSF_QF            : PSF_QF   
    269270  PSF_NDOF          : SKIP # no accessor
    270271  PSF_NPIX          : SKIP # no accessor
     
    273274  MOMENTS_YY        : SKIP # no accessor
    274275  FLAGS             : phot_flags
    275   N_FRAMES          : SKIP # no accessor       
     276  N_FRAMES          : SKIP # no accessor       
    276277end
    277278
    278279# this list is good for PS1_V3
    279280list 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     
    283284  X_PSF_SIG         : xccd:err # FAIL
    284285  Y_PSF_SIG         : yccd:err # FAIL
    285286  POSANGLE          : SKIP # astrometry is not calibrated in the cmf
    286287  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   
    289290  PSF_INST_FLUX     : SKIP # not ingested into DVO
    290291  PSF_INST_FLUX_SIG : SKIP # not ingested into DVO
     
    297298  DEC_PSF           : SKIP # astrometry is not calibrated in the cmf
    298299  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 
    303304  EXT_NSIGMA        : ext_nsigma
    304   PSF_MAJOR         : FWHM_MAJ 
    305   PSF_MINOR         : FWHM_MIN 
     305  PSF_MAJOR         : FWHM_MAJ 
     306  PSF_MINOR         : FWHM_MIN 
    306307  PSF_THETA         : THETA # FAIL
    307   PSF_QF            : PSF_QF   
     308  PSF_QF            : PSF_QF   
    308309  PSF_QF_PERFECT    : SKIP # not ingested into DVO
    309310  PSF_NDOF          : PSF_NDOF
     
    326327end
    327328
    328 # this list is good for PS1_V4
    329 list testfields_PS1_V4
    330   IPP_IDET          : detid     
    331   X_PSF             : xccd     
    332   Y_PSF             : yccd     
    333   X_PSF_SIG         : xccd:err # FAIL
    334   Y_PSF_SIG         : yccd:err # FAIL
    335   POSANGLE          : SKIP # astrometry is not calibrated in the cmf
    336   PLTSCALE          : SKIP # astrometry is not calibrated in the cmf
    337   PSF_INST_MAG      : mag:inst 
    338   PSF_INST_MAG_SIG  : mag:err   
    339   PSF_INST_FLUX     : SKIP # not ingested into DVO
    340   PSF_INST_FLUX_SIG : SKIP # not ingested into DVO
    341   AP_MAG            : mag:aperinst # FAIL
     329# this list is good for PS1_V5
     330list 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
    342343  AP_MAG_RAW        : SKIP # not ingested into DVO
    343344  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                   
     387end                                                                   
     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  
    673673float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source);
    674674
     675float PhotInstTiny (MeasureTiny *measure, dvoMagClassType class);
     676float PhotCatTiny (MeasureTiny *measure, dvoMagClassType class);
     677float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class);
     678float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class);
     679float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code, dvoMagClassType class);
     680
     681float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source);
     682float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, dvoMagClassType class, dvoMagSourceType source);
     683
     684float PhotFluxInst (Measure *measure, dvoMagClassType class);
     685float PhotFluxCat (Measure *measure, dvoMagClassType class);
     686float PhotFluxSys (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class);
     687float PhotFluxRel (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class);
     688float PhotFluxCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code, dvoMagClassType class);
     689
     690float PhotFluxAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source);
     691float PhotFluxRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure, dvoMagClassType class, dvoMagSourceType source);
     692
    675693float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt);
    676 
    677694float 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);
    682695
    683696float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt);
     
    689702float PhotColorForCode (Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code);
    690703int 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);
    700704
    701705float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt);
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/include/dvodb.h

    r36909 r36911  
    6464  MAG_CLASS_APER,
    6565} 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 MAG
    79 
    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_AVE
    88 
    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 MAG
    96       MAG_KRON,      // in mextract -> MAG_KRON_REL, in avextract -> MAG_KRON_AVE
    97 
    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 interest
    119       MAG_PHOT_FLAGS,
    120       MAG_NCODE,
    121       MAG_NPHOT,
    122       MAG_UC_DIST,
    123       MAG_STACK_DET_ID,
    124 } ;
    125 # endif
    12666
    12767/* measure fields */
     
    163103      MEAS_OBJ_FLAGS,
    164104      MEAS_SECFILT_FLAGS,
    165       MEAS_MAG,
     105      MEAS_PHOT, // photometry class of measurements
    166106      MEAS_MINST,
    167107      MEAS_MCAT,
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/LoadPhotcodesFITS.c

    r36908 r36911  
    106106      return FALSE;
    107107    }
     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    }
    108113
    109114    if (photcode[i].type == PHOT_DEP) {
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dbExtractMeasures.c

    r36910 r36911  
    100100
    101101  switch (field->ID) {
    102     case MEAS_MAG: { /* magnitudes are already determined above */
     102    case MEAS_PHOT: { /* magnitudes are already determined above */
    103103      PhotCode *myEquiv = GetPhotcodeEquivbyCode (measure[0].photcode);
    104104
     
    170170          }
    171171          break;
     172
    172173        case MAG_OPTION_ERR:
    173174          switch (field->magLevel) {
     
    189190
    190191        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
    191219        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
    192237        case MAG_OPTION_STDEV:
    193238        case MAG_OPTION_CHISQ:
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dbFields.c

    r36908 r36911  
    6767
    6868  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);
    6971  if (!strcasecmp (string, "flux"))         return (MAG_OPTION_FLUX);
    7072  if (!strcasecmp (string, "fluxerr"))      return (MAG_OPTION_FLUX_ERR);
    71   if (!strcasecmp (string, "err"))          return (MAG_OPTION_ERR);
    7273  if (!strcasecmp (string, "stdev"))        return (MAG_OPTION_STDEV);
    7374  if (!strcasecmp (string, "chisq"))        return (MAG_OPTION_CHISQ);
     
    160161
    161162  // 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
    163172  field->magSource = MAG_SRC_CHP;
    164173  field->magLevel  = MAG_LEVEL_AVE;
     
    174183  char *firstWord = getword(fieldCopy);
    175184 
    176   // firstWord may be either mag [mextract] or photcode
     185  // firstWord may be either flux, mag or photcode
    177186  if (!strcasecmp (firstWord, "MAG")) {
    178187    // default level for 'mag' is rel
    179188    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;
    180195  }
    181196  PhotCode *code = GetPhotcodebyName (firstWord);
     
    184199  if (!code) return FALSE;
    185200
    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  }
    187208  if (code->type == PHOT_REF) {
    188209    field->magLevel = MAG_LEVEL_CAT;
    189   }
    190   if (code->type == PHOT_DEP) {
    191     field->magLevel = MAG_LEVEL_REL;
     210    // is this one required?
    192211  }
    193212 
     
    201220    dvoMagSourceType source = GetMagSource (word);
    202221    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;
    204224      ptr = skipword (ptr);
    205225      continue;
     
    208228    dvoMagLevelType level = GetMagLevel (word);
    209229    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;
    211232      ptr = skipword (ptr);
    212233      continue;
     
    215236    dvoMagClassType class = GetMagClass (word);
    216237    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;
    218240      ptr = skipword (ptr);
    219241      continue;
     
    222244    dvoMagOptionType option = GetMagOption (word);
    223245    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;
    225283      ptr = skipword (ptr);
    226284      continue;
     
    230288    free (word);
    231289  }
     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;
    232296
    233297  switch (field->magOption) {
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_photcode_ops.c

    r36910 r36911  
    1818
    1919static PhotCodeData *photcodes = NULL;
    20 static PhotCode *genericCode = NULL;
     20static PhotCode *genericCodeMag = NULL;
     21static PhotCode *genericCodeFlux = NULL;
    2122
    2223PhotCodeData *GetPhotcodeTable () {
     
    2728    photcodes[0].code = NULL;
    2829  }
    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;
    3441  }
    3542  return photcodes;
     
    6673  // "MAG" is a special word, not allowed for a photcode name
    6774  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;
    6981  }
    7082
     
    8395  if (name == NULL) return (0);
    8496
    85   // "MAG" is a special word, not allowed for a photcode name
     97  // "MAG" is a special photcode name for internal use
    8698  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;
    88104  }
    89105
     
    834850}
    835851
     852float MagToFlux (float Mag) {
     853  float Flux = pow(10.0, -0.4*(Mag));
     854  return (Flux);
     855}
     856
     857/** flux conversion *******************************************************************/
     858float 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?)
     879float 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
     907float 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
     952float 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 */
     997float 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/***/
     1031float 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 */
     1092float 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
    8361117/******** alternate photometry conversion functions using MeasureTiny and AverageTiny *********/
    8371118float PhotInstTiny (MeasureTiny *measure, dvoMagClassType class) {
Note: See TracChangeset for help on using the changeset viewer.