In [1]:
import numpy as np
import pandas
import matplotlib.pyplot as plt
%matplotlib inline
%cd data/
flow = pandas.read_table("flow-myosin-um-per-min.txt",header=None)
In [2]:
def interpolate(data,inserted_rows):
""" Linearly Interpolate the matrix by adding rows
Args:
data (np.array): A timexSpace array
new_number_row (int): Number of rows to insert between
each source row
Returns:
(np.array): with new_number_row lines
"""
out = np.zeros((data.shape[0]*(inserted_rows),data.shape[1]))
j = 0
for i in range(out.shape[0]):
k = i%inserted_rows
if k==0:
out[i,:] = data[j,:]
if j+2 < data.shape[0]:
j += 1
else:
out[i,:] = (data[j,:]
+ float(k)/inserted_rows
* (data[j+1,:]- data[j,:]))
return out
In [8]:
flow10 = interpolate(flow.values,40)
pandas.DataFrame(flow10).to_csv("flow-myosin-um-per-minb",index=None)
print "Wrote a {} matrix.".format(flow10.shape)
plt.subplot(1,2,1)
plt.imshow(flow.values,aspect="auto",interpolation="nearest")
plt.subplot(1,2,2)
plt.imshow(flow10,aspect="auto",interpolation="nearest")
Out[8]:
In [6]:
flow10 = interpolate(flow.values,40)
flow10 = np.transpose(interpolate(np.transpose(flow10),40))
pandas.DataFrame(flow10).to_csv("flow-myosin-um-per-min_3040x2600linear-itp",index=None)
print "Wrote a {} matrix.".format(flow10.shape)
plt.subplot(1,2,1)
plt.imshow(flow.values,aspect="auto",interpolation="nearest")
plt.subplot(1,2,2)
plt.imshow(flow10,aspect="auto",interpolation="nearest")
Out[6]:
In [ ]: