In [1]:
import csv

In [9]:
my_folder = '/home/mpre/tmp_Pinn_dose_maps/Robbie_Donald_20150327/Planned'

In [10]:
my_folder


Out[10]:
'/home/mpre/tmp_Pinn_dose_maps/Robbie_Donald_20150327/Planned'

In [11]:
import numpy as np

In [32]:
blah = np.genfromtxt(my_folder+'/1_160', delimiter=',',skiprows=11, missing_values='')

In [33]:
blah


Out[33]:
array([[             nan,  -1.24000000e+01,  -1.22000000e+01, ...,
          1.22000000e+01,   1.24000000e+01,              nan],
       [ -9.40000000e+00,   3.00000000e-03,   3.00000000e-03, ...,
          2.00000000e-03,   2.00000000e-03,              nan],
       [ -9.20000000e+00,   3.00000000e-03,   3.00000000e-03, ...,
          2.00000000e-03,   2.00000000e-03,              nan],
       ..., 
       [  9.00000000e+00,   9.00000000e-03,   9.00000000e-03, ...,
          3.00000000e-03,   2.00000000e-03,              nan],
       [  9.20000000e+00,   8.00000000e-03,   9.00000000e-03, ...,
          3.00000000e-03,   2.00000000e-03,              nan],
       [  9.40000000e+00,   7.00000000e-03,   8.00000000e-03, ...,
          3.00000000e-03,   2.00000000e-03,              nan]])

In [34]:
y_pos = blah[1:,0]

In [35]:
y_pos


Out[35]:
array([-9.4, -9.2, -9. , -8.8, -8.6, -8.4, -8.2, -8. , -7.8, -7.6, -7.4,
       -7.2, -7. , -6.8, -6.6, -6.4, -6.2, -6. , -5.8, -5.6, -5.4, -5.2,
       -5. , -4.8, -4.6, -4.4, -4.2, -4. , -3.8, -3.6, -3.4, -3.2, -3. ,
       -2.8, -2.6, -2.4, -2.2, -2. , -1.8, -1.6, -1.4, -1.2, -1. , -0.8,
       -0.6, -0.4, -0.2,  0. ,  0.2,  0.4,  0.6,  0.8,  1. ,  1.2,  1.4,
        1.6,  1.8,  2. ,  2.2,  2.4,  2.6,  2.8,  3. ,  3.2,  3.4,  3.6,
        3.8,  4. ,  4.2,  4.4,  4.6,  4.8,  5. ,  5.2,  5.4,  5.6,  5.8,
        6. ,  6.2,  6.4,  6.6,  6.8,  7. ,  7.2,  7.4,  7.6,  7.8,  8. ,
        8.2,  8.4,  8.6,  8.8,  9. ,  9.2,  9.4])

In [36]:
x_pos = blah[0, 1:-1]

In [37]:
x_pos


Out[37]:
array([-12.4, -12.2, -12. , -11.8, -11.6, -11.4, -11.2, -11. , -10.8,
       -10.6, -10.4, -10.2, -10. ,  -9.8,  -9.6,  -9.4,  -9.2,  -9. ,
        -8.8,  -8.6,  -8.4,  -8.2,  -8. ,  -7.8,  -7.6,  -7.4,  -7.2,
        -7. ,  -6.8,  -6.6,  -6.4,  -6.2,  -6. ,  -5.8,  -5.6,  -5.4,
        -5.2,  -5. ,  -4.8,  -4.6,  -4.4,  -4.2,  -4. ,  -3.8,  -3.6,
        -3.4,  -3.2,  -3. ,  -2.8,  -2.6,  -2.4,  -2.2,  -2. ,  -1.8,
        -1.6,  -1.4,  -1.2,  -1. ,  -0.8,  -0.6,  -0.4,  -0.2,   0. ,
         0.2,   0.4,   0.6,   0.8,   1. ,   1.2,   1.4,   1.6,   1.8,
         2. ,   2.2,   2.4,   2.6,   2.8,   3. ,   3.2,   3.4,   3.6,
         3.8,   4. ,   4.2,   4.4,   4.6,   4.8,   5. ,   5.2,   5.4,
         5.6,   5.8,   6. ,   6.2,   6.4,   6.6,   6.8,   7. ,   7.2,
         7.4,   7.6,   7.8,   8. ,   8.2,   8.4,   8.6,   8.8,   9. ,
         9.2,   9.4,   9.6,   9.8,  10. ,  10.2,  10.4,  10.6,  10.8,
        11. ,  11.2,  11.4,  11.6,  11.8,  12. ,  12.2,  12.4])

In [38]:
blah3 = blah[1:, 1:-1]

In [39]:
blah3.shape


Out[39]:
(95, 125)

In [40]:
%matplotlib inline

In [41]:
import matplotlib as ml
import matplotlib.pyplot as plt

In [45]:
fig = plt.figure(figsize=(6, 3.2))

ax = fig.add_subplot(111)
ax.set_title('colorMap')
plt.imshow(blah3)


Out[45]:
<matplotlib.image.AxesImage at 0x7f6726591550>

In [46]:
blah3[30, 90]


Out[46]:
0.29099999999999998

In [47]:
max(blah3)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-47-29e558208807> in <module>()
----> 1 max(blah3)

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

In [25]:
len(y_pos)


Out[25]:
105

In [26]:
blah3.shape


Out[26]:
(105, 127)

In [27]:
my_test = interpl.RectBivariateSpline(y_pos, x_pos, blah3)

In [28]:
type(my_test)


Out[28]:
scipy.interpolate.fitpack2.RectBivariateSpline

In [29]:
my_test(-0.1,-0.1)


Out[29]:
array([[ 0.20052939]])

In [30]:
my_test(-9.72,-4.112)


Out[30]:
array([[ 0.01483708]])

In [31]:
my_test([-10.0,-9.78,-9.01], [0.2,1.0, 4.0])


Out[31]:
array([[ 0.01      ,  0.009     ,  0.006     ],
       [ 0.01004644,  0.00904814,  0.00606734],
       [ 0.01394784,  0.01295004,  0.0079876 ]])

In [ ]: