Ansi C library for parsing binary output files of LS Dyna (d3plot, binout) with bindings for python
Project description
dynareadout
An Ansi C library for parsing binary output files of LS Dyna (d3plot, binout) with bindings for python
Documentation
You can find a Wiki with API Documentation for python.
Examples
Binout
from dynareadout import Binout, BinoutType
bin_file = None
try:
# This library also supports opening multiple binout files at once by globing them
bin_file = Binout("simulation/binout*")
except RuntimeError as e:
print("Failed to open binout: {}".format(e))
exit(1)
# Print the children of the binout
children = bin_file.read("/")
for (i, child) in enumerate(children):
print("Child {}: {}".format(i, child))
# Read some data. This read method can read variables with different types, but
# there are also read methods for particular types
node_ids = bin_file.read("nodout/ids")
for (i, nid) in enumerate(node_ids):
print("Node ID {}: {}".format(i, nid))
# You can also read this variable with the read method of the particular type
# First find out what the type is
node_ids_type = bin_file.get_type_id("/nodout/metadata/ids")
# Then read the data using the special read method.
# If you already know the exact type and path of a variable
# these methods can be a bit more performant,
# since the library does not need the get the type and path first.
if node_ids_type == BinoutType.Int32:
node_ids = bin_file.read_int32("/nodout/metadata/ids")
elif node_ids_type == BinoutType.Int64:
node_ids = bin_file.read_int64("/nodout/metadata/ids")
else:
print("The node ids are not 32-Bit or 64-Bit integers")
exit(1)
for (i, nid) in enumerate(node_ids):
print("Node ID {}: {}".format(i, nid))
# If you want to read "timed" data (x_displacement, x_force, etc.) you can do so also with the read method
x_displacement = bin_file.read("nodout/x_displacement")
for (t, time_step) in enumerate(x_displacement):
for (n, x_disp) in enumerate(time_step):
print("X Displacement time_step={}, node_id={}: {}".format(t, node_ids[n], x_displacement[t][n]))
D3plot
from dynareadout import D3plot
plot_file = None
try:
# Just give it the first d3plot file and it opens all of them
plot_file = D3plot("simulation/d3plot")
except e as RuntimeError:
print("Failed to open: {}".format(e))
exit(1)
# Read the title
title = plot_file.read_title()
print("Title: {}".format(title))
# Read node ids
node_ids = plot_file.read_node_ids()
print("Nodes: {}".format(len(node_ids)))
for (i, nid) in enumerate(node_ids):
print("Node {}: {}".format(i, nid))
# Read node coordinates of time step 10
node_coords = plot_file.read_node_coordinates(10)
for i in range(len(node_coords)):
print("Node Coords {}: ({:.2f}, {:.2f}, {:.2f})".format(i, node_coords[i][0], node_coords[i][1], node_coords[i][2]))
KeyFile
from dynareadout import key_file_parse
keywords = key_file_parse("simulation/input.k")
# Parse all nodes
node_keywords = keywords["NODE"]
for i in range(len(node_keywords)):
for j in range(len(node_keywords[i])):
node = node_keywords[i][j]
node_data = node.parse_whole([8, 16, 16, 16])
nid = node_data[0]
x = node_data[1]
y = node_data[2]
z = node_data[3]
print(f"NODE {nid:d}: ({x:.3f}; {y:.3f}; {z:.3f})")
Other languages
This library is also available for C and C++ this version can be found here.
Installation
python -m pip install dynareadout
Uploading to PyPI
-
Make sure that the dynareadout submodule has the correct version
-
Update the version in
setup.py
andpyproject.toml
. Also check if new source files have been added -
Publish a new release
-
Create source distribution
python setup.py sdist
- Upload to
test.pypi.org
python -m twine upload --repository testpypi dist/*
Then insert __token__
as username and the token as password.
- Install package from
test.pypi.org
to test it
python -m pip install --upgrade --no-build-isolation --index-url https://test.pypi.org/simple/ dynareadout
-
If it works upload it to
pypi.org
-
Create windows wheel
python -m build
-
Upload windows wheel to
test.pypi.org
and test it. -
If it works upload it to
pypi.org
python -m twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for dynareadout-23.6-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69632064d38add3a823c2b4dc6028f7d8e8193ec6be8e32d8e2e02a70a82a51f |
|
MD5 | 29303d915e674fc3163e121662b8f6ee |
|
BLAKE2b-256 | c88ab83f3bbefa151efbd38e80231dda88fee9e18283bfe3ab3a14a9be4d2ae2 |
Hashes for dynareadout-23.6-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55cbd17f232c12b866e7083ee62e709e4076a2d976773b41cca511b58a9528bb |
|
MD5 | 42abf58c2c6559fb2e1b8de2d7f75e16 |
|
BLAKE2b-256 | a64f91196b41c5a5b423184449992f3885389394de324b2818d5b1b6b3b2586b |
Hashes for dynareadout-23.6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 129d638915a32e34e96782c81eb1ae7a795687a2d886010281b072ccbd2c0b06 |
|
MD5 | d59e9e3224fadd6b056000b0af7a77fa |
|
BLAKE2b-256 | 3224d1de79c70e526a75654f3483184d0fe366344a3bfd6e3df383d39eb84fe0 |
Hashes for dynareadout-23.6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9165eb0cabf86357eab0d560eaadf5298dc553e945323190086cf854709c296 |
|
MD5 | 8d7c9a568bf6f9c33f3fd2d0db3add68 |
|
BLAKE2b-256 | 063f7271c94d2a4e1fab596ce9cc0bb3a23c521f5154d003be610f0ab22adcad |
Hashes for dynareadout-23.6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddefb411d10a1236cc5f1d424fab9f6a08c4af8a2fe54668f8b6ae8d02c70f50 |
|
MD5 | de700b64751832ce6fa638018f5f113c |
|
BLAKE2b-256 | eb16a736588196d42cadc41f02cefc78c9734c2deb2ad7b29092c009cb9d50eb |
Hashes for dynareadout-23.6-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fb5053f996ecbd088f72edd6763c3d20bcd861ce9417b12bd127133466d3d20 |
|
MD5 | cab53a0967a9bfc1f21d91806dd24c8a |
|
BLAKE2b-256 | e61a06f2c6faef7e07f0510233610001499a0b864faf3ff938c5602bb3fed134 |