[cig-commits] r20139 - short/3D/PyLith/benchmarks/trunk/dynamic/scecdynrup/tpv14-2d
brad at geodynamics.org
brad at geodynamics.org
Tue May 15 15:14:33 PDT 2012
Author: brad
Date: 2012-05-15 15:14:32 -0700 (Tue, 15 May 2012)
New Revision: 20139
Modified:
short/3D/PyLith/benchmarks/trunk/dynamic/scecdynrup/tpv14-2d/tabulate_offfaultdata.py
short/3D/PyLith/benchmarks/trunk/dynamic/scecdynrup/tpv14-2d/tabulate_onfaultdata.py
Log:
Switched from tables to h5py.
Modified: short/3D/PyLith/benchmarks/trunk/dynamic/scecdynrup/tpv14-2d/tabulate_offfaultdata.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/dynamic/scecdynrup/tpv14-2d/tabulate_offfaultdata.py 2012-05-15 22:11:15 UTC (rev 20138)
+++ short/3D/PyLith/benchmarks/trunk/dynamic/scecdynrup/tpv14-2d/tabulate_offfaultdata.py 2012-05-15 22:14:32 UTC (rev 20139)
@@ -19,7 +19,7 @@
outputRoot = "scecfiles/%s_%s_%03dm_gradient" % (sim, cell,dx)
# ----------------------------------------------------------------------
-import tables
+import h5py
import numpy
import time
@@ -38,8 +38,8 @@
targets[:,1] += 2000.0
-h5 = tables.openFile("%s.h5" % (inputRoot), 'r')
-vertices = h5.root.geometry.vertices[:]
+h5 = h5py.File("%s.h5" % (inputRoot), 'r', driver="sec2")
+vertices = h5['geometry/vertices'][:]
ntargets = targets.shape[0]
indices = []
tolerance = 1.0e-6
@@ -53,21 +53,17 @@
print "Coordinates of selected points:\n",vertices[indices,:]
# Get datasets
-disp = h5.root.vertex_fields.displacement[:]
-vel = h5.root.vertex_fields.velocity[:]
+disp = h5['vertex_fields/displacement'][:]
+vel = h5['vertex_fields/velocity'][:]
+timeStamps = h5['time'][:]
-# BEGIN TEMPORARY
-#timeStamps = h5.root.vertex_fields.time (not yet available)
-ntimesteps = disp.shape[0]
-timeStamps = numpy.linspace(0, dt*ntimesteps, ntimesteps, endpoint=True)
-# END TEMPORARY
+h5.close()
+
disp = disp[:,indices,:]
vel = vel[:,indices,:]
zero = numpy.zeros( (ntimesteps, 1), dtype=numpy.float64)
-h5.close()
-
# Write data
headerA = \
"# problem = %s-2D\n" % sim.upper() + \
Modified: short/3D/PyLith/benchmarks/trunk/dynamic/scecdynrup/tpv14-2d/tabulate_onfaultdata.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/dynamic/scecdynrup/tpv14-2d/tabulate_onfaultdata.py 2012-05-15 22:11:15 UTC (rev 20138)
+++ short/3D/PyLith/benchmarks/trunk/dynamic/scecdynrup/tpv14-2d/tabulate_onfaultdata.py 2012-05-15 22:14:32 UTC (rev 20139)
@@ -19,7 +19,7 @@
outputRoot = "scecfiles/%s_%s_%03dm_gradient" % (sim, cell,dx)
# ----------------------------------------------------------------------
-import tables
+import h5py
import numpy
import time
@@ -27,8 +27,8 @@
def extract(fault, targets):
tolerance = 1.0e-6
- h5 = tables.openFile("%s-%s.h5" % (inputRoot, fault), 'r')
- vertices = h5.root.geometry.vertices[:]
+ h5 = h5py.File("%s-%s.h5" % (inputRoot, fault), 'r', driver="sec2")
+ vertices = h5['geometry/vertices'][:]
ntargets = targets.shape[0]
indices = []
for target in targets:
@@ -41,22 +41,18 @@
print "Coordinates of selected points:\n",vertices[indices,:]
# Get datasets
- slip = h5.root.vertex_fields.slip[:]
- slip_rate = h5.root.vertex_fields.slip_rate[:]
- traction = h5.root.vertex_fields.traction[:]
+ slip = h5['vertex_fields/slip'][:]
+ slip_rate = h5['vertex_fields/slip_rate'][:]
+ traction = h5['vertex_fields/traction'][:]
- # BEGIN TEMPORARY
- #timeStamps = h5.root.vertex_fields.time (not yet available)
- ntimesteps = slip.shape[0]
- timeStamps = numpy.linspace(dt, dt*ntimesteps, ntimesteps-1, endpoint=True)
- # END TEMPORARY
+ timeStamps = h5['time'][:]
+ h5.close()
+
slip = slip[1:,indices,:]
slip_rate = slip_rate[1:,indices,:]
traction = traction[1:,indices,:]
- h5.close()
-
headerA = \
"# problem = %s-2D\n" % sim.upper() + \
"# author = Brad Aagaard\n" + \
More information about the CIG-COMMITS
mailing list