In [1]:
%load_ext watermark
%watermark -u -d -v -p numpy,matplotlib,scipy,pandas,sklearn,mlxtend


last updated: 2017-12-05 

CPython 2.7.13
IPython 5.3.0

numpy 1.12.1
matplotlib 2.0.2
scipy 0.19.0
pandas 0.20.1
sklearn 0.19.0
mlxtend 0.7.0

In [2]:
%matplotlib inline
from __future__ import division, print_function
import numpy as np
from scipy import optimize
import pandas as pd
import matplotlib.pyplot as plt
import seaborn.apionly as sns

import comptools as comp
import comptools.analysis.plotting as plotting

In [3]:
# config = 'IC86.2012'
config = 'IC79.2010'
num_groups = 4
comp_list = comp.get_comp_list(num_groups=num_groups)

In [4]:
df_sim_train, df_sim_test = comp.load_sim(config=config,
                                          energy_key='MC_log_energy', 
                                          log_energy_min=log_energy_min,
                                          log_energy_max=log_energy_max,
                                          verbose=True)


sim quality cut event flow:
             IceTopQualityCuts:    1.0    1.0
         lap_InIce_containment:  0.793  0.793
              InIceQualityCuts:  0.795   0.76
                 num_hits_1_60:  0.997  0.759
             reco_energy_range:  0.874  0.662
                 IceTop_charge:  0.962  0.635


/home/jbourbeau/cr-composition/comptools/dataframe_functions.py:148: RuntimeWarning: divide by zero encountered in log10
  df['log_IceTop_charge_175m'] = np.log10(df['IceTop_charge_175m'])

In [8]:
sim_train.lap_log_energy.max()


Out[8]:
8.0409516507997338

In [42]:
def fit_beta(charges, distances, log_s125, lap_beta):

    charges = np.asarray(charges)
    distances = np.asarray(distances)
    print('charges = {}'.format(charges))
    print('distances = {}'.format(distances))
    print('log_s125 = {}'.format(log_s125))
    print('lap_beta = {}'.format(lap_beta))

    def LDF(dists, beta):
        return 10**log_s125 * (dists/125)**(-beta-0.303*np.log10(dists/125))
#         return log_s125 - beta*np.log10(dists/125) - 0.303*np.log10(np.log10(dists/125))

    popt, pcov = optimize.curve_fit(LDF, distances, np.log10(charges))
#     popt, pcov = optimize.curve_fit(LDF, distances, np.log10(charges), p0=lap_beta-1)
    print(popt)

In [43]:
df_sim['tank_dists'][3]


Out[43]:
array([ 563.19205409,  728.49952746,  597.57259199,  502.87094917,
        360.81235537,  341.88334214,  486.27225865,  488.75861346,
        345.31191548,  272.50841185,  278.50628564,  381.40689465,
        397.40017885,  217.60213822,  134.96804375,  126.1607868 ,
        184.98520993,  175.21405068,  306.44667554,  200.66732924,
        210.26010017,   99.47640616,  104.17753637,   68.28022341,
         58.88122516,  195.86382601,  189.26460486,  397.49789313,
        251.46569843,  259.43667521,  137.74640939,  146.61478985,
         74.31949249,   82.34447256,  135.79599198,  127.29198893,
        249.79335454,  240.31324681,  244.0123336 ,  250.63420275,
        172.22679976,  168.84823934,  166.75610549,  174.90084695,
        238.9441929 ,  359.87787381])

In [44]:
np.log10(df_sim['tank_dists'][3]/125)


Out[44]:
array([ 0.65374651,  0.76551926,  0.67948066,  0.60454653,  0.46037139,
        0.43696793,  0.58996948,  0.59218441,  0.44130155,  0.3384699 ,
        0.34792499,  0.48447853,  0.50231805,  0.24075315,  0.03332094,
        0.00401438,  0.17022699,  0.14665892,  0.3894449 ,  0.20556666,
        0.22584685, -0.09918993, -0.07913593, -0.26261508, -0.32693318,
        0.19504422,  0.18015939,  0.50242482,  0.30356874,  0.31712136,
        0.04217027,  0.06926777, -0.22580728, -0.18127556,  0.03597694,
        0.00789106,  0.30067087,  0.2838677 ,  0.29050177,  0.30213032,
        0.13919072,  0.13058652,  0.12517173,  0.1458819 ,  0.28138647,
        0.45924513])

In [45]:
fit_beta(df_sim['tank_charges'][3], df_sim['tank_dists'][3], df_sim['log_s125'][3], df_sim['lap_beta'][3])


charges = [  1.1489253    0.14102778   0.74507076   0.25572646   0.18200278
   0.45130467   0.54038841   0.26852089   0.22046663   1.03550625
   1.51601493   0.31989381   0.15767671   1.04164982   2.05677414
   7.54050732   1.68407524   1.83120334   0.81869787   0.21163651
   1.94171214   6.6918025   14.103755    53.04872513  81.28752899
   2.57384896   1.91906309   0.13023351   1.65206754   2.56118107
   1.74762833   2.67273593  21.19219398  21.02318764   4.47604799
   5.14276934   1.68159831   0.95564413   4.39349222   0.69666201
   2.64331651   3.85827303   1.49899232   2.27820587   1.17120278
   0.227301  ]
distances = [ 563.19205409  728.49952746  597.57259199  502.87094917  360.81235537
  341.88334214  486.27225865  488.75861346  345.31191548  272.50841185
  278.50628564  381.40689465  397.40017885  217.60213822  134.96804375
  126.1607868   184.98520993  175.21405068  306.44667554  200.66732924
  210.26010017   99.47640616  104.17753637   68.28022341   58.88122516
  195.86382601  189.26460486  397.49789313  251.46569843  259.43667521
  137.74640939  146.61478985   74.31949249   82.34447256  135.79599198
  127.29198893  249.79335454  240.31324681  244.0123336   250.63420275
  172.22679976  168.84823934  166.75610549  174.90084695  238.9441929
  359.87787381]
log_s125 = 0.843307351744
lap_beta = 3.45811535972
[ 0.86563224]

In [11]:
dist_bins = np.logspace(-2, 4, 50)
charge_bins = np.logspace(-2, 1, 50)
def make_charge_dist_hist(charges, dists):
    # Create charge vs distance histogram
    hist, _ , _ = np.histogram2d(dists, charges, bins=(dist_bins, charge_bins))
    return hist

In [ ]:
y, x = np.meshgrid(charge_bins, dist_bins)

In [ ]:


In [ ]:
np.logspace(-2, 1, 50)

In [8]:
hist = make_charge_dist_hist(df_sim['tank_charges'].values[0], df_sim['tank_dists'][0])

In [32]:
n_side = 2
fig, axarr = plt.subplots(n_side, n_side, sharex=True, sharey=True)
for i, ax in zip(range(n_side**2), axarr.flat):
#     plotting.histogram_2D(df_sim['tank_dists'].values[i], df_sim['tank_charges'].values[i],
#                           bins=(np.logspace(-2, 4, 50), np.logspace(0, 3, 50)), ax=ax,
#                           log_counts=False, logx=False, logy=False, colorbar=False)
    hist = make_charge_dist_hist(df_sim['tank_charges'].values[i], df_sim['tank_dists'].values[i])
    print(hist.sum())
    hist = np.ma.masked_where(hist == 0, hist)
    im = ax.pcolormesh(dist_bins, charge_bins, hist)
    cb = plt.colorbar(im)
#     ax = sns.heatmap(hist, ax=ax, xticklabels=dist_bins[:-1].astype(str))
#     ax.imshow(hist)
#     ax.scatter(np.log10(df_sim['tank_dists'].values[i]),
#                np.log10(df_sim['tank_charges'].values[i]))
ax.set_yscale("log", nonposy='clip')
ax.set_xscale("log")
# plt.tight_layout()
plt.show()


14.0
23.0
14.0
17.0

In [6]:
num_samples = 50
with sns.color_palette("Blues_d", num_samples):
    fig, ax = plt.subplots()
    for i in range(num_samples):
        ax.scatter(df_sim['tank_dists'].values[i],
                   df_sim['tank_charges'].values[i], alpha=0.2)
    ax.set_xlim([1e0, 1e4])        
    ax.set_ylim([1e-3, 1e4])        
    ax.set_yscale("log", nonposy='clip')
    ax.set_xscale("log")
    # plt.tight_layout()
    plt.show()


/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/figure.py:1742: UserWarning: This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect.
  warnings.warn("This figure includes Axes that are not "

In [7]:
def LDF(beta, log_s125, r):
    return 10**log_s125 * (r/125)**(-beta-0.303*np.log10(r/125))

In [13]:
n_side = 2
distances = np.logspace(0, 4, 100)
# print(distances)
# with sns.color_palette("Blues_d", num_samples):
fig, axarr = plt.subplots(n_side, n_side, sharex=True, sharey=True)
random_subset_df = df_sim.sample(n_side**2, random_state=2)
for row_tuple, ax in zip(random_subset_df.iterrows(), axarr.flatten()):
    row_idx, row = row_tuple
    
    ax.scatter(row['tank_dists'], row['tank_charges'], alpha=0.3, marker='.', color='gray')
    
    print(row['lap_beta'], row['log_s125'])
    laputop_ldf = LDF(row['lap_beta'], row['log_s125'], distances)
    l1 = ax.plot(distances, laputop_ldf, marker='None', ls='-', label='Laputop')[0]
    
    print(row['refit_beta'], row['log_s125'])
    refit_ldf = LDF(row['refit_beta'], row['log_s125'], distances)
    l2 = ax.plot(distances, refit_ldf, marker='None', ls='-', label='Re-fit')[0]
    
    ax.set_yscale("log", nonposy='clip')
    ax.set_xscale("log")
    ax.set_xlim([1e0, 1e4])        
    ax.set_ylim([1e-3, 1e4])
    ax.grid()
fig.legend([l1, l2], ['Laputop LDF', 'Refit LDF'], loc='upper center', bbox_to_anchor=(0.55, 1.125),
           frameon=False, ncol=2)
fig.text(0.5, -0.025, 'Lateral distance [m]', ha='center', fontsize=14)
fig.text(-0.025, 0.5, 'Tank charge [VEM]', va='center', rotation='vertical', fontsize=14)
plt.tight_layout()
plt.savefig('/home/jbourbeau/public_html/figures/charge-vs-dist-example.png')
plt.show()


2.88650088879 0.300849604363
1.43955518677 0.300849604363
2.95602467801 0.887908461397
2.40548344906 0.887908461397
3.31569026441 0.458840155992
2.14098650078 0.458840155992
2.97201777135 1.44564143712
2.65965477183 1.44564143712

In [38]:
dists = df_sim.tank_dists.values
print(dists)


[ array([ 661.82345535,  494.45487814,  416.95505193,  353.27120235,
        302.03857324,  264.50866298,  264.75784349,  330.81415675,
        322.95446681,  378.57681536,  230.1123634 ,  235.80761465,
        192.38540618,  201.26092021,  208.35621233,  199.97889665,
        256.17613896,  343.70666475,  226.07460175,  231.82515483,
        119.76596282,  128.15030981,   94.78458174,   88.44607897,
        167.1674268 ,  159.48611645,  366.37529722,  643.59947075,
        277.29383872,  273.96139546,  152.71443034,  156.56067963,
         67.83753327,   75.6959883 ,   81.33586296,   72.67109222,
        197.55734667,  188.22677043,  289.3976885 ,  570.63000738,
        276.61098781,  174.59325452,  183.71578459,  126.25800315,
        134.61844127,  182.70362432,  174.82687281,  285.77809334,
        293.89797653,  245.58024923,  255.28326265,  236.69048142])
 array([ 367.79042974,  355.25767674,  380.79149599,  384.12348354,
        533.13885791,  249.2142156 ,  259.03803986,  260.90869779,
        330.06161639,  410.86126994,  506.82453359,  257.1701323 ,
        265.43920162,  179.77231431,  171.76349457,  142.54171124,
        148.90267947,  195.41541278,  200.89969244,  307.2348412 ,
        316.82390158,  413.7003678 ,  300.04147681,  143.32750343,
        144.11909481,   46.42647165,   54.78031324,  107.72789773,
        116.36242888,  216.00163765,  225.13190929,  317.31133524,
        448.57940033,  340.04971889,  206.37040465,  201.39334105,
         97.62994114,   89.28766498,   79.32499447,   83.08703651,
        140.59236422,  135.04674654,  253.9011017 ,  251.66907554,
        410.69090864,  218.10909265,  208.53453629,  151.87320281,
        144.13362057,  159.05085144,  162.22049641,  241.36446314,
        351.21394135,  405.90459849,  320.11858431,  271.77463133,
        289.73148122,  452.028963  ,  366.9844331 ,  367.91540508,
        482.14416945])
 array([ 563.19205409,  728.49952746,  597.57259199,  502.87094917,
        360.81235537,  341.88334214,  486.27225865,  488.75861346,
        345.31191548,  272.50841185,  278.50628564,  381.40689465,
        397.40017885,  217.60213822,  134.96804375,  126.1607868 ,
        184.98520993,  175.21405068,  306.44667554,  200.66732924,
        210.26010017,   99.47640616,  104.17753637,   68.28022341,
         58.88122516,  195.86382601,  189.26460486,  397.49789313,
        251.46569843,  259.43667521,  137.74640939,  146.61478985,
         74.31949249,   82.34447256,  135.79599198,  127.29198893,
        249.79335454,  240.31324681,  244.0123336 ,  250.63420275,
        172.22679976,  168.84823934,  166.75610549,  174.90084695,
        238.9441929 ,  359.87787381])
 ...,
 array([ 149.47661801,  141.47817864,   79.87082876,   74.34210435,
        131.91357334,  139.71472265,  230.85108445,  233.83306195,
        362.48439761,  371.90994689,  213.89171982,  207.30471669,
         75.24340147,   65.77207646,   48.08938641,   56.438548  ,
        144.79533572,  144.66240414,  288.50349316,  297.48897566,
        391.74822032,  399.59847119,  262.60887014,  260.73075446,
        203.60155488,  198.32416906,  132.58787273,  127.4769122 ,
        156.16549501,  162.89270382,  272.31288121,  278.93332573,
        335.80004347,  332.82895613,  452.27577814,  419.70080923,
        415.75842732,  293.74895131,  284.94143118,  233.95663142,
        224.3828057 ,  233.35047895,  227.97473656,  279.60391729,
        281.48451523,  341.09106773,  349.68890845,  426.08726656,
        422.01608137,  519.74324607,  417.32013049,  408.33327113,
        354.37986564,  344.11396041,  340.65888458,  339.44352   ,
        302.13124113,  305.85764323,  351.90587801,  356.92007671,
        458.09556314,  449.09959439,  544.51130575,  535.98281415,
        613.26586558,  531.6352494 ,  477.0076452 ,  466.82493712,
        417.2128617 ,  410.54513995,  397.10708421,  403.7883523 ,
        419.7557638 ,  427.1668509 ,  740.14759411,  644.46788829,
        584.45513313,  529.94222351,  503.44723973,  499.95329694,
        498.38977522,  527.73335397,  528.36925122,  580.42305554,
        666.80202811,  658.91997408,  647.74390458,  618.84712955,
        598.09671978,  734.67735186,  702.75600441,  733.61448011])
 array([ 273.03446424,  264.23642493,  176.11317586,  167.738742  ,
         94.00627263,   92.40939703,  135.92637973,  134.914533  ,
        245.85970413,  255.0951336 ,  339.19441056,  332.05319523,
        196.20109705,  187.53971802,   88.76889242,   79.67101873,
         24.59589835,   18.82606776,  160.21441858,  169.31681336,
        263.99491599,  271.6530608 ,  376.71052171,  376.46311462,
        304.35058106,  296.78063769,  183.40861838,  173.6965667 ,
        118.15085112,  117.07775439,  163.784423  ,  167.88083097,
        209.03592556,  206.8903559 ,  330.45988413,  324.04716719,
        522.30135074,  517.06630755,  377.92501174,  370.41343091,
        284.32610913,  275.52513656,  227.0688921 ,  218.0325599 ,
        217.08765961,  214.61416742,  244.82871998,  252.57227818,
        303.61315818,  456.21079855,  447.65630737,  620.57406759,
        494.43742244,  486.37744642,  406.6167987 ,  396.90695631,
        362.92474543,  358.35654631,  280.51776539,  287.55131364,
        287.58621491,  295.19145852,  347.65685946,  430.12254635,
        421.23905234,  502.85242528,  613.615333  ,  530.22034747,
        520.52430634,  443.68655985,  438.89807802,  399.1256388 ,
        407.75140087,  385.96961739,  394.74476187,  424.16898218,
        503.47058459,  504.57729475,  557.61017456,  551.92811613,
        721.53638375,  564.01636872,  479.56701935,  507.13371341,
        511.40287458,  574.27300994,  566.95425978,  649.68259881,
        775.04756579,  690.78554673,  686.3930039 ,  579.02550103,
        579.36615167,  631.61099304,  625.96625379,  683.01827323,
        703.86030945,  737.96549703])
 array([ 269.18789107,  272.0079669 ,  318.85621395,  319.90342405,
        405.41313589,  412.59248096,  498.03162758,  499.46264373,
        617.85332295,  627.086739  ,  166.82678496,  161.42485193,
        206.14241103,  214.67726239,  288.45165401,  295.80602106,
        394.19074301,  389.51777674,  518.28004769,  527.94120451,
        621.58407231,  627.8406177 ,   92.24358727,  101.20159722,
         74.80221793,   78.78504753,  194.23113178,  203.99781504,
        297.38753319,  306.38171695,  438.86460715,  448.58365699,
        540.58313559,  533.90322112,  156.60659873,  149.9999637 ,
         33.46058655,   26.71290442,  136.43822637,  137.84935256,
        252.03986385,  258.07311607,  364.199799  ,  372.68427204,
        465.37110677,  473.5483735 ,  593.96886747,  586.08623488,
        251.76383536,  242.98450719,  146.26867426,  136.92975204,
        149.13883571,  142.4284139 ,  217.62082546,  225.04940863,
        298.25678392,  293.09546407,  408.79961567,  406.84090112,
        683.88805715,  677.1940576 ,  778.62685733,  771.49277169,
        343.1820349 ,  334.43097057,  267.62414211,  258.31452976,
        236.74258014,  227.23208554,  249.81830083,  241.0504557 ,
        294.2881848 ,  293.85687509,  388.91113682,  390.92220995,
        493.37248313,  496.80821659,  670.66722917,  665.86898216,
        779.58544465,  873.10317856,  375.73777631,  368.88159887,
        330.61135969,  322.8833651 ,  327.42374613,  318.88776352,
        338.34666883,  341.59695675,  416.2962568 ,  409.34166814,
        500.19398927,  495.62888316,  597.13579515,  594.83252966,
        732.07784595,  723.3155891 ,  460.31667198,  450.8841871 ,
        421.7660332 ,  414.341191  ,  422.90322058,  464.1788977 ,
        458.68346987,  528.98813573,  601.78814057,  822.06546168,
        525.72003908,  530.74067344,  571.68567274,  622.45058125,
        630.38283263,  645.92759517])]

In [39]:
dists = pd.Series(np.concatenate(dists).ravel())
dists


Out[39]:
0           661.823455
1           494.454878
2           416.955052
3           353.271202
4           302.038573
5           264.508663
6           264.757843
7           330.814157
8           322.954467
9           378.576815
10          230.112363
11          235.807615
12          192.385406
13          201.260920
14          208.356212
15          199.978897
16          256.176139
17          343.706665
18          226.074602
19          231.825155
20          119.765963
21          128.150310
22           94.784582
23           88.446079
24          167.167427
25          159.486116
26          366.375297
27          643.599471
28          277.293839
29          273.961395
               ...    
14975938    330.611360
14975939    322.883365
14975940    327.423746
14975941    318.887764
14975942    338.346669
14975943    341.596957
14975944    416.296257
14975945    409.341668
14975946    500.193989
14975947    495.628883
14975948    597.135795
14975949    594.832530
14975950    732.077846
14975951    723.315589
14975952    460.316672
14975953    450.884187
14975954    421.766033
14975955    414.341191
14975956    422.903221
14975957    464.178898
14975958    458.683470
14975959    528.988136
14975960    601.788141
14975961    822.065462
14975962    525.720039
14975963    530.740673
14975964    571.685673
14975965    622.450581
14975966    630.382833
14975967    645.927595
dtype: float64

In [47]:
dists.min()


Out[47]:
0.16207671883457211

In [50]:
distance_bins = np.logspace(-2, 6, 100)
distance_counts = np.histogram(dists.values, bins=distance_bins)[0]
fig, ax = plt.subplots()
plotting.plot_steps(distance_bins, distance_counts, yerr=np.sqrt(distance_counts), ax=ax)
ax.set_xscale("log", nonposx='clip')
ax.set_yscale("log", nonposx='clip')
ax.set_ylabel('Counts')
ax.set_xlabel('Tank distance [m]')
ax.set_ylim(0)
ax.grid()
plt.savefig('/home/jbourbeau/public_html/figures/tank-distance-hist.png')
plt.show()



In [37]:
fig, ax = plt.subplots()
dists.plot(kind='hist', bins=100, ax=ax)
ax.set_ylabel('Counts')
ax.set_xlabel('Tank distance')
plt.show()



KeyboardInterruptTraceback (most recent call last)
<ipython-input-37-472375aed122> in <module>()
      1 fig, ax = plt.subplots()
----> 2 dists.plot(kind='hist', bins=100, ax=ax)
      3 ax.set_ylabel('Counts')
      4 ax.set_xlabel('Tank distance')
      5 plt.show()

/home/jbourbeau/.local/lib/python2.7/site-packages/pandas/tools/plotting.pyc in __call__(self, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds)
   3598                            colormap=colormap, table=table, yerr=yerr,
   3599                            xerr=xerr, label=label, secondary_y=secondary_y,
-> 3600                            **kwds)
   3601     __call__.__doc__ = plot_series.__doc__
   3602 

/home/jbourbeau/.local/lib/python2.7/site-packages/pandas/tools/plotting.pyc in plot_series(data, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds)
   2672                  yerr=yerr, xerr=xerr,
   2673                  label=label, secondary_y=secondary_y,
-> 2674                  **kwds)
   2675 
   2676 

/home/jbourbeau/.local/lib/python2.7/site-packages/pandas/tools/plotting.pyc in _plot(data, x, y, subplots, ax, kind, **kwds)
   2468         plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
   2469 
-> 2470     plot_obj.generate()
   2471     plot_obj.draw()
   2472     return plot_obj.result

/home/jbourbeau/.local/lib/python2.7/site-packages/pandas/tools/plotting.pyc in generate(self)
   1047 
   1048         for ax in self.axes:
-> 1049             self._post_plot_logic_common(ax, self.data)
   1050             self._post_plot_logic(ax, self.data)
   1051 

/home/jbourbeau/.local/lib/python2.7/site-packages/pandas/tools/plotting.pyc in _post_plot_logic_common(self, ax, data)
   1167     def _post_plot_logic_common(self, ax, data):
   1168         """Common post process for each axes"""
-> 1169         labels = [pprint_thing(key) for key in data.index]
   1170         labels = dict(zip(range(len(data.index)), labels))
   1171 

/home/jbourbeau/.local/lib/python2.7/site-packages/pandas/formats/printing.pyc in pprint_thing(thing, _nest_lvl, escape_chars, default_escapes, quote_strings, max_seq_items)
    226         result = fmt % as_escaped_unicode(thing)
    227     else:
--> 228         result = as_escaped_unicode(thing)
    229 
    230     return compat.text_type(result)  # always unicode

/home/jbourbeau/.local/lib/python2.7/site-packages/pandas/formats/printing.pyc in as_escaped_unicode(thing, escape_chars)
    189 
    190         try:
--> 191             result = compat.text_type(thing)  # we should try this first
    192         except UnicodeDecodeError:
    193             # either utf-8 or we replace errors

KeyboardInterrupt: 

RuntimeErrorTraceback (most recent call last)
/home/jbourbeau/.local/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
    305                 pass
    306             else:
--> 307                 return printer(obj)
    308             # Finally look for special method names
    309             method = get_real_method(obj, self.print_method)

/home/jbourbeau/.local/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in <lambda>(fig)
    238 
    239     if 'png' in formats:
--> 240         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
    241     if 'retina' in formats or 'png2x' in formats:
    242         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

/home/jbourbeau/.local/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in print_figure(fig, fmt, bbox_inches, **kwargs)
    122 
    123     bytes_io = BytesIO()
--> 124     fig.canvas.print_figure(bytes_io, **kw)
    125     data = bytes_io.getvalue()
    126     if fmt == 'svg':

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2190                     orientation=orientation,
   2191                     dryrun=True,
-> 2192                     **kwargs)
   2193                 renderer = self.figure._cachedRenderer
   2194                 bbox_inches = self.figure.get_tightbbox(renderer)

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
    543 
    544     def print_png(self, filename_or_obj, *args, **kwargs):
--> 545         FigureCanvasAgg.draw(self)
    546         renderer = self.get_renderer()
    547         original_dpi = renderer.dpi

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in draw(self)
    462 
    463         try:
--> 464             self.figure.draw(self.renderer)
    465         finally:
    466             RendererAgg.lock.release()

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     61     def draw_wrapper(artist, renderer, *args, **kwargs):
     62         before(artist, renderer)
---> 63         draw(artist, renderer, *args, **kwargs)
     64         after(artist, renderer)
     65 

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/figure.pyc in draw(self, renderer)
   1141 
   1142             mimage._draw_list_compositing_images(
-> 1143                 renderer, self, dsu, self.suppressComposite)
   1144 
   1145             renderer.close_group('figure')

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/image.pyc in _draw_list_compositing_images(renderer, parent, dsu, suppress_composite)
    137     if not_composite or not has_images:
    138         for zorder, a in dsu:
--> 139             a.draw(renderer)
    140     else:
    141         # Composite any adjacent images together

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     61     def draw_wrapper(artist, renderer, *args, **kwargs):
     62         before(artist, renderer)
---> 63         draw(artist, renderer, *args, **kwargs)
     64         after(artist, renderer)
     65 

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)
   2407             renderer.stop_rasterizing()
   2408 
-> 2409         mimage._draw_list_compositing_images(renderer, self, dsu)
   2410 
   2411         renderer.close_group('axes')

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/image.pyc in _draw_list_compositing_images(renderer, parent, dsu, suppress_composite)
    137     if not_composite or not has_images:
    138         for zorder, a in dsu:
--> 139             a.draw(renderer)
    140     else:
    141         # Composite any adjacent images together

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     61     def draw_wrapper(artist, renderer, *args, **kwargs):
     62         before(artist, renderer)
---> 63         draw(artist, renderer, *args, **kwargs)
     64         after(artist, renderer)
     65 

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/axis.pyc in draw(self, renderer, *args, **kwargs)
   1139 
   1140         for tick in ticks_to_draw:
-> 1141             tick.draw(renderer)
   1142 
   1143         # scale up the axis label box to also find the neighbors, not

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     61     def draw_wrapper(artist, renderer, *args, **kwargs):
     62         before(artist, renderer)
---> 63         draw(artist, renderer, *args, **kwargs)
     64         after(artist, renderer)
     65 

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/axis.pyc in draw(self, renderer)
    262 
    263         if self.label1On:
--> 264             self.label1.draw(renderer)
    265         if self.label2On:
    266             self.label2.draw(renderer)

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     61     def draw_wrapper(artist, renderer, *args, **kwargs):
     62         before(artist, renderer)
---> 63         draw(artist, renderer, *args, **kwargs)
     64         after(artist, renderer)
     65 

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/text.pyc in draw(self, renderer)
    796                     textrenderer.draw_tex(gc, x, y, clean_line,
    797                                           textobj._fontproperties, angle,
--> 798                                           mtext=mtext)
    799                 else:
    800                     textrenderer.draw_text(gc, x, y, clean_line,

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in draw_tex(self, gc, x, y, s, prop, angle, ismath, mtext)
    252         texmanager = self.get_texmanager()
    253 
--> 254         Z = texmanager.get_grey(s, size, self.dpi)
    255         Z = np.array(Z * 255.0, np.uint8)
    256 

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/texmanager.pyc in get_grey(self, tex, fontsize, dpi)
    582 
    583         if alpha is None:
--> 584             pngfile = self.make_png(tex, fontsize, dpi)
    585             X = read_png(os.path.join(self.texcache, pngfile))
    586 

/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/texmanager.pyc in make_png(self, tex, fontsize, dpi)
    523                     'dvipng was not able to process the following '
    524                     'file:\n%s\nHere is the full report generated by '
--> 525                     'dvipng: \n\n' % dvifile + report)
    526             else:
    527                 mpl.verbose.report(report, 'debug')

RuntimeError: dvipng was not able to process the following file:
/home/jbourbeau/.cache/matplotlib/tex.cache/d4507a6187ef2a336b573fe2f8391709.dvi
Here is the full report generated by dvipng: 

No dvipng error report available.
<matplotlib.figure.Figure at 0x7f5aee13b0d0>

In [ ]: