In [9]:
%pylab inline
from scipy.interpolate import interp1d


Populating the interactive namespace from numpy and matplotlib

In [2]:
R50 = 47.5
zOnR50 = concatenate((array([0.02]), arange(0.05,1.25,0.05)))
zOnR50


Out[2]:
array([ 0.02,  0.05,  0.1 ,  0.15,  0.2 ,  0.25,  0.3 ,  0.35,  0.4 ,
        0.45,  0.5 ,  0.55,  0.6 ,  0.65,  0.7 ,  0.75,  0.8 ,  0.85,
        0.9 ,  0.95,  1.  ,  1.05,  1.1 ,  1.15,  1.2 ])

In [3]:
R50of45 = array([0.997,1,1.004,1.008,1.012,1.017,1.021,1.026,1.03,
                 1.035,1.04,1.045,1.051,1.056,1.062,1.067,1.073,1.08,
                 1.086,1.092,1.099,1.106,1.113,1.120,1.128])

R50of50 = array([0.991,0.994,0.998,1.002,1.006,1.011,1.016,1.02,1.025,
                 1.03,1.035,1.041,1.046,1.052,1.058,1.064,1.07,1.076,
                 1.083,1.09,1.097,1.104,1.112,1.119,1.128])

R50of47_5 = mean([R50of45,R50of50],axis=0)
R50of47_5


Out[3]:
array([ 0.994 ,  0.997 ,  1.001 ,  1.005 ,  1.009 ,  1.014 ,  1.0185,
        1.023 ,  1.0275,  1.0325,  1.0375,  1.043 ,  1.0485,  1.054 ,
        1.06  ,  1.0655,  1.0715,  1.078 ,  1.0845,  1.091 ,  1.098 ,
        1.105 ,  1.1125,  1.1195,  1.128 ])

In [10]:
interp_funtion = interp1d(zOnR50 * 47.5,R50of47_5)

In [18]:
plot(zOnR50 * 47.5,R50of47_5,'rx')
ylabel('Stopping power ratio')
xlabel('Depth (mm)')
title('Stopping power ratios')

x0 = linspace(min(zOnR50 * 47.5),max(zOnR50 * 47.5))
plot(x0,interp_funtion(x0),'b')


Out[18]:
[<matplotlib.lines.Line2D at 0x81b8630>]

In [21]:
depth = array([25,24,23,22])
ionisation = array([])
ionisation[0] = mean([1.516,1.517,1.516])
ionisation[1] = mean([1.519,1.519])
ionisation[2] = mean([1.522])
ionisation[3] = mean([1.520])


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-21-b94da57ff4d1> in <module>()
      1 depth = array([25,24,23,22])
      2 ionisation = array([])
----> 3 ionisation[0] = mean([1.516,1.517,1.516])
      4 ionisation[1] = mean([1.519,1.519])
      5 ionisation[2] = mean([1.522])

IndexError: index 0 is out of bounds for axis 0 with size 0