[pencil-code] r23005 committed - Clean up of read_tracers routine ofr the case of post processing data ...

0 views
Skip to first unread message

penci...@googlecode.com

unread,
Jan 22, 2015, 9:35:58 AM1/22/15
to pencil-co...@googlegroups.com
Revision: 23005
Author: Iom...@googlemail.com
Date: Thu Jan 22 14:35:41 2015 UTC
Log: Clean up of read_tracers routine ofr the case of post processing
data read.
Fixed a bug.


https://code.google.com/p/pencil-code/source/detail?r=23005

Modified:
/trunk/python/pencil/files/tracers.py

=======================================
--- /trunk/python/pencil/files/tracers.py Thu Dec 4 19:05:35 2014 UTC
+++ /trunk/python/pencil/files/tracers.py Thu Jan 22 14:35:41 2015 UTC
@@ -21,7 +21,7 @@

call signature::

- tracers, mapping, t = read_tracers(fileName = 'tracers.dat', dataDir
= 'data/', zlim, head_size = 3)
+ tracers, mapping, t = read_tracers(fileName = 'tracers.dat', dataDir
= 'data/', zlim = [], head_size = 3)

Reads from the tracer files and computes the color map according to
A R Yeates and G Hornig 2011 J. Phys. A: Math. Theor. 44 265501
@@ -71,7 +71,8 @@
# read the cpu structure
dim = pc.read_dim(datadir = dataDir)
if (dim.nprocz > 1):
- print "error: number of cores in z-direction > 1"
+ print ": number of cores in z-direction > 1"
+ return -1

# read the parameters
params = pc.read_param(datadir = dataDir, quiet = True)
@@ -80,18 +81,17 @@
grid = pc.read_grid(datadir = dataDir, quiet = True)

# determine the file structure
- n_proc = dim.nprocx*dim.nprocy
if (post):
n_proc = 1
tracer_file = open(dataDir+fileName, 'rb')
trace_sub = struct.unpack("f", tracer_file.read(4))[0]
tracer_file.close()
+ n_times =
int(np.round(os.path.getsize(dataDir+fileName)/(4*(7*dim.nx*dim.ny*trace_sub**2))))
# sub sampling of the tracers
if (not(post)):
+ n_proc = dim.nprocx*dim.nprocy
trace_sub = params.trace_sub
n_times = os.path.getsize(dataDir+'proc0/'+fileName)/(4*(head_size
+ 7*dim.nx*dim.ny*trace_sub**2/dim.nprocx/dim.nprocy))
- else:
- n_times =
int(np.round(os.path.getsize(dataDir+fileName)/(4*(7*dim.nx*dim.ny*trace_sub**2))))

# prepare the output arrays
tracers = np.zeros((np.round(dim.nx*trace_sub),
np.round(dim.ny*trace_sub), n_times, 7))
@@ -99,8 +99,8 @@

# temporary arrays for one core
if (post):
- tracers_core = np.zeros((np.round(dim.nx*trace_sub),
np.round(dim.ny*trace_sub), n_times, 7))
- mapping_core = np.zeros((np.round(dim.nx*trace_sub),
np.round(dim.ny*trace_sub), n_times, 3))
+ tracers_core = tracers
+ mapping_core = mapping
else:
tracers_core = np.zeros((np.round(dim.nx*trace_sub/dim.nprocx),
np.round(dim.ny*trace_sub/dim.nprocy), n_times, 7))
mapping_core = np.zeros((np.round(dim.nx*trace_sub/dim.nprocx),
np.round(dim.ny*trace_sub/dim.nprocy), n_times, 3))
@@ -160,16 +160,17 @@

mapping_core[l%(int(np.round(dim_core.nx*trace_sub))),l/(int(np.round(dim_core.nx*trace_sub))),j,:]
= [1,1,1]

# copy single core data into total data arrays
-
tracers[np.round(dim_core.ipx*dim_core.nx*trace_sub):np.round((dim_core.ipx+1)*dim_core.nx*trace_sub),
\
-
np.round(dim_core.ipy*dim_core.ny*trace_sub):np.round((dim_core.ipy+1)*dim_core.ny*trace_sub),j,:]
= \
- tracers_core[:,:,j,:]
-
mapping[np.round(dim_core.ipx*dim_core.nx*trace_sub):np.round((dim_core.ipx+1)*dim_core.nx*trace_sub),
\
-
np.round(dim_core.ipy*dim_core.ny*trace_sub):np.round((dim_core.ipy+1)*dim_core.ny*trace_sub),j,:]
= \
- mapping_core[:,:,j,:]
+ if (not(post)):
+
tracers[np.round(dim_core.ipx*dim_core.nx*trace_sub):np.round((dim_core.ipx+1)*dim_core.nx*trace_sub),
\
+
np.round(dim_core.ipy*dim_core.ny*trace_sub):np.round((dim_core.ipy+1)*dim_core.ny*trace_sub),j,:]
= \
+ tracers_core[:,:,j,:]
+
mapping[np.round(dim_core.ipx*dim_core.nx*trace_sub):np.round((dim_core.ipx+1)*dim_core.nx*trace_sub),
\
+
np.round(dim_core.ipy*dim_core.ny*trace_sub):np.round((dim_core.ipy+1)*dim_core.ny*trace_sub),j,:]
= \
+ mapping_core[:,:,j,:]

- # swap axes for post evaluation
- tracers = tracers.swapaxes(0, 1)
- mapping = mapping.swapaxes(0, 1)
+ # swap axes for post evaluation
+ tracers = tracers.swapaxes(0, 1)
+ mapping = mapping.swapaxes(0, 1)

return tracers, mapping, t

Reply all
Reply to author
Forward
0 new messages