In [1]:
import matplotlib
import pylab
In [18]:
singledata = pylab.loadtxt('./rhodata.txt')
In [19]:
pylab.plot(singledata)
pylab.title("rho from rhodata.txt")
pylab.xlabel("cell number i")
pylab.ylabel("rho (kg/m^3)")
Out[19]:
In [13]:
%matplotlib inline
%config InlineBackend.figure_formats = {'svg','png'}
In [14]:
pylab.show()
In [18]:
from math import exp, floor, sqrt
def gaussian( xvar, A, k, x_0):
return A*exp(-k*(xvar-x_0)*(xvar-x_0))
def gaussian2d( xvar, yvar, A, k, x_0,y_0 ):
return A*exp(-k*( (xvar-x_0)*(xvar-x_0)+(yvar-y_0)*(yvar-y_0)))
In [9]:
NCELLS = 800
DIMY = 800
RHO0 = 0.656
L_0 = 1.0
DELTAx = L_0/(float(NCELLS))
In [9]:
testvalues = [gaussian(xvar*DELTAx,RHO0,1./sqrt(0.00001),0.25) for xvar in range(0,NCELLS)]
testivalues = [ int((value*DIMY)) for value in testvalues]
In [13]:
pylab.plot(testivalues)
Out[13]:
In [10]:
NCELLSX = 800
NCELLSY = 800
L_0X = 1.0
L_0Y = 1.0
DELTAx = L_0X/(float(NCELLSX))
DELTAy = L_0Y/(float(NCELLSY))
In [3]:
import numpy as np
In [11]:
testvalues2 = np.array( [[gaussian2d(xvar*DELTAx,yvar*DELTAy,RHO0,1./sqrt(0.00001),0.25,0.25) for xvar in range(0,NCELLSX)] for yvar in range(0,NCELLSY)])
In [14]:
import matplotlib.pyplot as plt
In [17]:
plt.imshow(testvalues2) # , interpolation="nearest", origin="upper")
plt.colorbar()
plt.show()
In [24]:
value = gaussian2d(210*DELTAx,210*DELTAy,RHO0,1./sqrt(0.00001),0.25,0.25)
value = value/0.2
valueint = floor(value)
In [25]:
floor(255*(value - valueint))
Out[25]:
In [ ]: