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.5-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d57c4e2af2cce6a500b6f47777bcb2f6ead0dac4912ad8f7ae16b5d188fe7542 |
|
MD5 | 2775a1c70fe028b04a2e5b96bb4a0780 |
|
BLAKE2b-256 | 7c943cb8b72a3c3e36ffccbfa8f1ba6ef744dc558a226f0845efbb468cb9468c |
Hashes for dynareadout-23.5-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfb6e37aee4461c52a6feb1b3b0be3891397427dbd9f9cbb5a8751aff69850a7 |
|
MD5 | 8bd49720993cebfba1647a111bb85c45 |
|
BLAKE2b-256 | c4c2ad886c116c1f03e092f9971abf6643b1c1537ae6811aebecbfdb8e355719 |
Hashes for dynareadout-23.5-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15091d1d55c6bc39de87390214ab7e6020d1108b5d87e1b92dddc32083b35d44 |
|
MD5 | 87e2590bb01cd40674a5842b5841baa8 |
|
BLAKE2b-256 | c1d153b29bf6910c645fc01311d5767af87e5ef1a6e1d2489ee738149eb73e60 |
Hashes for dynareadout-23.5-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 079839c95e7c3bd16ae75abc2c1e89e7d42e72da1fa6acaf718332ba79e6faac |
|
MD5 | 34f85067d2c4c13b00c5da4bc624d707 |
|
BLAKE2b-256 | 6d35a6ba67d7beea9da890b89fa0114082efadfb51001eec821c2834ca43654a |
Hashes for dynareadout-23.5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1858f8812850a1eb08636bf46f49f28bd4c04c05f4c5a66df5413796db8c2766 |
|
MD5 | b3ba83602da2764627bafbe9c3d5c5cf |
|
BLAKE2b-256 | 82ff9e5fec5a8f3c6d4e9adc0077ff1b55995d42c8410dad3e285885eb4d86a1 |
Hashes for dynareadout-23.5-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0e08e555b4f7d44604122c82e9b7f1c33036910bb7e38bc0c2dbb6bb2288cb4 |
|
MD5 | f7f729e30243fa52e0ecd9e608978ef0 |
|
BLAKE2b-256 | d03d614ab48f805ce5711f60b0949e907d2e578aea48a585272c1ef66a729e6d |