In [2]:
%pylab inline
from mcmc_scripts import make_mcmc_results_figures as mfig


Populating the interactive namespace from numpy and matplotlib

In [3]:
# Toggle results directory (and photo comparison flag) between different results
#  - synthetic results (drawn from prior)
#  - stripe 82 results
#  - TODO galsim results

results_dir, compare_to_photo = "mcmc_scripts/synthetic-results", False
#results_dir, compare_to_photo = "mcmc_scripts/s82-results", True
#results_dir, compare_to_photo = "mcmc_scripts/galsim-results", False

In [15]:
mfig.make_calibration_tables(results_dir)


            within 1/2 sd      1 sd      2 sd      3 sd
parameter                                              
log r-flux       0.176842  0.313684  0.551579  0.680000
color ug         0.286316  0.524211  0.793684  0.890526
color gr         0.256842  0.463158  0.711579  0.804211
color ri         0.223158  0.427368  0.720000  0.835789
color iz         0.324211  0.583158  0.814737  0.928421
            within 1/2 sd      1 sd      2 sd      3 sd
parameter                                              
log r-flux       0.357895  0.640000  0.917895  0.989474
color ug         0.425263  0.728421  0.945263  0.995789
color gr         0.406316  0.677895  0.930526  0.991579
color ri         0.408421  0.667368  0.943158  0.987368
color iz         0.410526  0.709474  0.938947  0.989474

In [6]:
mfig.make_star_gal_roc_curves(results_dir, compare_to_photo)


======= Star vs. Galaxy AUC Scores ==========
   MC : 0.9943  [0.9900,  0.9976] 
   VB : 0.9813  [0.9685,  0.9914] 

MCMC vs VI Posterior Uncertainty Comparisons


In [8]:
# STARS
mfig.make_mcmc_vb_uncertainty_comparison_plots(results_dir, source_type="star")


/Users/acm/Dropbox (Personal)/Proj/Astro/Celeste.jl/experiments/mcmc_scripts/make_mcmc_results_figures.py:608: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  mcdf['gal_angle_deg'][mcdf['gal_angle_deg'] < 0.] += 180.
two errs:  1.0729069125971886 0.5906523254695015
-0.9999757861381785 0.1281496382713924
-1.4822303732658657 0.36390997847521867
two errs:  0.4479698915178798 0.36234586568148963
-0.5369159920020742 0.1190315830310488
-0.6225400178384644 0.19068465327447245
two errs:  0.32115379515440245 0.2993377542536762
0.04098852203238632 0.017092268810322667
0.01917248113166009 0.11941432888315262
two errs:  0.29823046623769844 0.002172007396087583
-0.9999561282059535 0.1839835149204396
-1.2960145870475643 0.3594564423512174
two errs:  0.268784854709339 0.12435863750440834
-0.9020806309422122 0.08246747754794323
-1.046506848147143 0.2829192857504318
two errs:  0.24369066782421744 0.14500301888226463
-0.9999565196968496 0.15020611013598295
-1.0986441686388024 0.23466222769625625
two errs:  0.21918422439678772 0.21475633129640728
-0.20741861589382354 0.07171262813392246
-0.2029907227934431 0.12795195067332976
two errs:  0.17472577074334594 0.18128418276470692
-0.8898772096972293 0.12404413197227647
-0.8964356217185903 0.2422052283637677
two errs:  0.14806841073620036 0.22569708834082824
-0.4323871561139653 0.10940034921508847
-0.5100158337185932 0.14506150749234267
two errs:  0.13891588972407365 0.07235164995045545
-0.3091390282421866 0.08532294595916932
-0.2425747884685684 0.15236941246006966

In [9]:
# GALAXIES
mfig.make_mcmc_vb_uncertainty_comparison_plots(results_dir, source_type="gal")


/Users/acm/Dropbox (Personal)/Proj/Astro/Celeste.jl/experiments/mcmc_scripts/make_mcmc_results_figures.py:608: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  mcdf['gal_angle_deg'][mcdf['gal_angle_deg'] < 0.] += 180.
two errs:  1.3863716704356128 0.10082906299414418
-0.080401281126595 0.18488767126293448
1.2051413263148736 0.3250974054990566
two errs:  1.3348125448912496 1.6753741212194897
-0.9898813162478917 0.2123104951341969
-1.3304428925761318 0.4693658231807386
two errs:  1.015227761693361 0.2612132099124782
0.9544203479139529 0.010006644562821744
0.20040579613307025 0.19198331318904813
two errs:  0.7691259344046273 0.18853174514332388
-0.8107736073010545 0.13314099071146746
0.1468840722468966 0.4831045961507622
two errs:  0.767478517961709 0.22479776576435362
0.6336214009716863 0.08868771418584312
1.1763021531690416 0.24938193308371104
two errs:  0.7263157848080093 0.5218971215107924
1.202807489332308 0.0496002922008852
1.4072261526295249 0.1630772362447383
two errs:  0.7258948743193926 0.4270580948146163
0.9436627367468003 0.058651837830311325
1.2424995162515766 0.16826797810803204
two errs:  0.7206696326184198 0.3969285888668216
0.029229960839908063 0.07409688271966941
0.3529710045915062 0.2788895623771616
two errs:  0.6627739393462434 0.6227646491521768
-0.12454311866958703 0.09958901240750813
-0.08453382847552032 0.2927112408230048
two errs:  0.6623819743803485 0.003448007510623352
1.3751345834138122 0.05903808731256612
2.040964565304784 0.14852403457282992

In [10]:
mfig.make_error_comparison_figs(results_dir, 
                                source_type="star", 
                                error_type="abs",
                                compare_to_photo=compare_to_photo)


/Users/acm/Dropbox (Personal)/Proj/Astro/Celeste.jl/experiments/mcmc_scripts/make_mcmc_results_figures.py:413: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  'color_ug'      : "color u-g",
/Users/acm/Dropbox (Personal)/Proj/Astro/Celeste.jl/experiments/mcmc_scripts/make_mcmc_results_figures.py:401: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  # remove nan obs
/Users/acm/Dropbox (Personal)/Proj/Astro/Celeste.jl/experiments/mcmc_scripts/make_mcmc_results_figures.py:402: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  bad_idx = (np.isnan(vbdf.flux_r_nmgy) | np.isnan(mcdf.flux_r_nmgy)).values
error     0.000252366
method           MCMC
dtype: object
error     4.63839e-05
method           MCMC
dtype: object
error     0.000117816
method           MCMC
dtype: object
error     0.000135475
method           MCMC
dtype: object
error     0.000117205
method           MCMC
dtype: object
error     0.000142062
method           MCMC
dtype: object
error     8.98815e-05
method           MCMC
dtype: object
error     6.57968e-05
method           MCMC
dtype: object
error     5.00307e-05
method           MCMC
dtype: object
error     0.00292468
method          MCMC
dtype: object
         param method     error  error stdev
0     position     VI  0.121027     0.008548
1     position   MCMC  0.110846     0.007026
2   brightness     VI  0.117664     0.008783
3   brightness   MCMC  0.093079     0.006860
4    color u-g     VI  0.332944     0.025405
5    color u-g   MCMC  0.327215     0.025055
6    color g-r     VI  0.125923     0.008603
7    color g-r   MCMC  0.127979     0.008410
8    color r-i     VI  0.110470     0.013222
9    color r-i   MCMC  0.112204     0.011790
10   color i-z     VI  0.143924     0.016923
11   color i-z   MCMC  0.154040     0.016387
12     profile     VI  0.229363     0.014621
13     profile   MCMC  0.157719     0.008376
14        axis     VI  0.105664     0.008011
15        axis   MCMC  0.073521     0.004815
16      radius     VI  0.687621     0.106170
17      radius   MCMC  0.450210     0.090326
18       angle     VI  8.943346     0.863453
19       angle   MCMC  9.641842     0.868745
Totaldf:               MCMC     VI                VI-MCMC
param                                          
position    0.111  0.121   0.0102 ($\pm$ 0.003)
brightness  0.093  0.118   0.0246 ($\pm$ 0.006)
color u-g   0.327  0.333   0.0057 ($\pm$ 0.008)
color g-r   0.128  0.126  -0.0021 ($\pm$ 0.004)
color r-i   0.112  0.110  -0.0017 ($\pm$ 0.005)
color i-z   0.154  0.144  -0.0101 ($\pm$ 0.005)
profile     0.158  0.229   0.0716 ($\pm$ 0.011)
axis        0.074  0.106   0.0321 ($\pm$ 0.006)
radius      0.450  0.688   0.2374 ($\pm$ 0.043)
angle       9.642  8.943  -0.6985 ($\pm$ 0.437)

In [11]:
mfig.make_error_comparison_figs(results_dir, 
                                source_type="gal", 
                                error_type="abs",
                                compare_to_photo=compare_to_photo)


/Users/acm/Dropbox (Personal)/Proj/Astro/Celeste.jl/experiments/mcmc_scripts/make_mcmc_results_figures.py:413: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  'color_ug'      : "color u-g",
/Users/acm/Dropbox (Personal)/Proj/Astro/Celeste.jl/experiments/mcmc_scripts/make_mcmc_results_figures.py:401: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  # remove nan obs
/Users/acm/Dropbox (Personal)/Proj/Astro/Celeste.jl/experiments/mcmc_scripts/make_mcmc_results_figures.py:402: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  bad_idx = (np.isnan(vbdf.flux_r_nmgy) | np.isnan(mcdf.flux_r_nmgy)).values
error     0.000252366
method           MCMC
dtype: object
error     4.63839e-05
method           MCMC
dtype: object
error     0.000117816
method           MCMC
dtype: object
error     0.000135475
method           MCMC
dtype: object
error     0.000117205
method           MCMC
dtype: object
error     0.000142062
method           MCMC
dtype: object
error     8.98815e-05
method           MCMC
dtype: object
error     6.57968e-05
method           MCMC
dtype: object
error     5.00307e-05
method           MCMC
dtype: object
error     0.00292468
method          MCMC
dtype: object
         param method     error  error stdev
0     position     VI  0.121027     0.008548
1     position   MCMC  0.110846     0.007026
2   brightness     VI  0.117664     0.008783
3   brightness   MCMC  0.093079     0.006860
4    color u-g     VI  0.332944     0.025405
5    color u-g   MCMC  0.327215     0.025055
6    color g-r     VI  0.125923     0.008603
7    color g-r   MCMC  0.127979     0.008410
8    color r-i     VI  0.110470     0.013222
9    color r-i   MCMC  0.112204     0.011790
10   color i-z     VI  0.143924     0.016923
11   color i-z   MCMC  0.154040     0.016387
12     profile     VI  0.229363     0.014621
13     profile   MCMC  0.157719     0.008376
14        axis     VI  0.105664     0.008011
15        axis   MCMC  0.073521     0.004815
16      radius     VI  0.687621     0.106170
17      radius   MCMC  0.450210     0.090326
18       angle     VI  8.943346     0.863453
19       angle   MCMC  9.641842     0.868745
Totaldf:               MCMC     VI                VI-MCMC
param                                          
position    0.111  0.121   0.0102 ($\pm$ 0.003)
brightness  0.093  0.118   0.0246 ($\pm$ 0.006)
color u-g   0.327  0.333   0.0057 ($\pm$ 0.008)
color g-r   0.128  0.126  -0.0021 ($\pm$ 0.004)
color r-i   0.112  0.110  -0.0017 ($\pm$ 0.005)
color i-z   0.154  0.144  -0.0101 ($\pm$ 0.005)
profile     0.158  0.229   0.0716 ($\pm$ 0.011)
axis        0.074  0.106   0.0321 ($\pm$ 0.006)
radius      0.450  0.688   0.2374 ($\pm$ 0.043)
angle       9.642  8.943  -0.6985 ($\pm$ 0.437)

In [13]:
mfig.make_est_vs_error_plots(results_dir)


.... making Error Plots --- Takes a few minutes to render
--- param log_flux_r, (source star) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
/Users/acm/Dropbox (Personal)/Proj/Astro/Celeste.jl/experiments/mcmc_scripts/make_mcmc_results_figures.py:135: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  mcdf['gal_angle_deg'][mcdf['gal_angle_deg'] < 0.] += 180.
lo, hi -2.0728826987353672 5.566224320131456
--- param color_ug, (source star) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi -4.03394862617211 5.259357670932752
--- param color_gr, (source star) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi -1.7999731097539549 3.9239747715591653
--- param color_ri, (source star) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi -0.8095658472889646 2.925815811217244
--- param color_iz, (source star) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi -0.4799852207461809 3.625172577167501
--- param log_flux_r, (source gal) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi -1.3651981445862824 4.1220923661650195
--- param color_ug, (source gal) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi -5.074418961591447 6.181480072751556
--- param color_gr, (source gal) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi -9.373380557580816 5.131610527206648
--- param color_ri, (source gal) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi -4.826746008216343 6.09097021027667
--- param color_iz, (source gal) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi -4.13852171789485 6.512583716913503
--- param gal_frac_dev, (source gal) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi 3.803956085176572e-06 0.9999921350931624
--- param gal_axis_ratio, (source gal) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi 0.0061611260319808245 0.9895115595818096
--- param gal_radius_px, (source gal) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi 0.03124634523907342 27.60860248896164
--- param gal_angle_deg, (source gal) ---- 
 true vals have 0 
 vb preds  have 0 
 mc preds  have 0 
lo, hi -78.01232362575739 254.64372090455635

In [ ]: