2 hist3d.py - GPUE: Split Operator based GPU solver for Nonlinear 3 Schrodinger Equation, Copyright (C) 2011-2015, Lee J. O'Riordan 4 <loriordan@gmail.com>, Tadhg Morgan, Neil Crowley. All rights reserved. 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are 10 1. Redistributions of source code must retain the above copyright 11 notice, this list of conditions and the following disclaimer. 13 2. Redistributions in binary form must reproduce the above copyright 14 notice, this list of conditions and the following disclaimer in the 15 documentation and/or other materials provided with the distribution. 17 3. Neither the name of the copyright holder nor the names of its 18 contributors may be used to endorse or promote products derived from 19 this software without specific prior written permission. 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 24 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 27 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 from mpl_toolkits.mplot3d
import Axes3D
35 import matplotlib.pyplot
as plt
37 from numpy
import genfromtxt
41 c = ConfigParser.ConfigParser()
42 c.readfp(open(
r'Params.dat'))
44 xDim = int(c.getfloat(
'Params',
'xDim'))
45 yDim = int(c.getfloat(
'Params',
'yDim'))
46 gndMaxVal = int(c.getfloat(
'Params',
'gsteps'))
47 evMaxVal = int(c.getfloat(
'Params',
'esteps'))
48 incr = int(c.getfloat(
'Params',
'print_out'))
49 sep = (c.getfloat(
'Params',
'dx'))
50 dx = (c.getfloat(
'Params',
'dx'))
51 dt = (c.getfloat(
'Params',
'dt'))
52 xMax = (c.getfloat(
'Params',
'xMax'))
53 yMax = (c.getfloat(
'Params',
'yMax'))
61 for i
in range(start, fin, incr):
62 v_arr=genfromtxt(
'vort_lsq_' + str(i) +
'.csv',delimiter=
',' )
66 for i1
in range(0,v_arr.size/2):
67 for i2
in range(i1,v_arr.size/2):
68 datatmp.append(m.sqrt( abs(v_arr[i1][0]*sep - v_arr[i2][0]*sep)**2 + abs(v_arr[i1][1]*sep - v_arr[i2][1]*sep)**2 ))
70 hist=np.histogram(datatmp,bins=np.arange(1.0,m.sqrt(xDim**2 + yDim**2),1.0))
71 data.append(hist[:][0])
72 """ Takes in a matrix (see structure above) and generate a pseudo-3D histogram by overlaying close, semitransparent bars. """ 73 for time, occurrence
in zip(range(len(data)), data):
74 dist = range(len(occurrence))
75 barband = range(-45, 45, 5)
77 ax.bar(dist, occurrence, zs=time, zdir=
'y', color=np.random.rand(3,1), alpha=0.8)
82 ax.set_zlabel(
'Occurrances')
84 plt.savefig(
"HIST_N.pdf")
91 for i
in range(start, fin, incr):
92 v_arr=genfromtxt(
'vort_lsq_' + str(i) +
'.csv',delimiter=
',' )
96 for i1
in range(0,v_arr.size/2):
97 for i2
in range(i1,v_arr.size/2):
98 m_tmp = m.sqrt(abs(v_arr[i1][0]*sep - v_arr[i2][0]*sep)**2 + abs(v_arr[i1][1]*sep - v_arr[i2][1]*sep)**2 )
99 datatmp.append( m_tmp )
101 hist=np.histogram(datatmp,bins=np.arange(0.0,240.0,0.1))
102 data.append(hist[:][0])
105 ax = fig.add_subplot(111)
107 plt.gca().invert_yaxis()
108 ax.set_aspect(
'auto')
110 fig.savefig(
"HIST_PCOLOR.pdf")
def plot_xyz_histogram(start, fin, incr, barcolor)
def plot_hist_pcolor(start, fin, incr, barcolor)