... | ... | @@ -25,26 +25,43 @@ def demo(): |
|
|
# Select a mesh and check which attributes it contains
|
|
|
mesh = meshes['square_5x5_tris_32']
|
|
|
# Each mesh will contain 'geometry' and 'topology'. Optionally other attributes
|
|
|
< KeysViewHDF5['HydraulicFlow', 'MaterialIDs', 'geometry', 'pressure', 'topology', 'v'] >
|
|
|
|
|
|
# < KeysViewHDF5['HydraulicFlow', 'MaterialIDs', 'geometry', 'pressure', 'topology', 'v']>
|
|
|
# Select an attribute
|
|
|
pressure = mesh['pressure']lIDs', 'geometry', 'pressure', 'topology', 'v']>
|
|
|
|
|
|
# choose any key , here in example 'pressure', it is only a reference (no copy of data into memory)
|
|
|
pressure = data['pressure']
|
|
|
pressure = mesh['pressure']
|
|
|
|
|
|
# get dimensions
|
|
|
pressure.shape
|
|
|
# example: (2, 1895)
|
|
|
# first dimension is time, here with length 2
|
|
|
# example: (8, 25)
|
|
|
# first dimension is time, here with length 8 - pressure is a variable attribute
|
|
|
|
|
|
# e.g. for MateralIDs we would get as number of time steps 1 - it is a constant attribute
|
|
|
MaterialIDs = mesh['MaterialIDs']
|
|
|
MaterialIDs.shape
|
|
|
# (1, 25)
|
|
|
|
|
|
# load data into memory (only selected data is loaded into memory)
|
|
|
# example: load all timesteps and choose all data points 100:200
|
|
|
p = pressure [:,100:200]
|
|
|
# example: load all timesteps and choose all data points 10:20
|
|
|
p = pressure [:,10:20]
|
|
|
|
|
|
# p can now be processed e.g. with numpy
|
|
|
# import numpy
|
|
|
# y = numpy.array(p)
|
|
|
|
|
|
|
|
|
# In the example of pressure attribute we have 8 time steps for the variable attributes like pressure
|
|
|
times = f['times']
|
|
|
# list all time values
|
|
|
times[:]
|
|
|
# array([0. , 0.3, 0.6, 0.9, 1.2, 1.5, 1.8, 2. ])
|
|
|
# To relate the values of pressure of timestep 2 (beginning with 0) to an actual time value we define:
|
|
|
time_step = 2
|
|
|
pressure_t2 = pressure[time_step,:]
|
|
|
t2 = times[time_step]
|
|
|
t2
|
|
|
# 0.6
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
For more details on selecting data there is
|
... | ... | |