High-Performance and Thread-Safe library for parsing binary output files and key files of LS Dyna (d3plot, binout, input deck)
Project description
dynareadout
High-Performance and Thread-Safe C/C++ library for parsing binary output files and key files of LS Dyna (d3plot, binout, input deck) with bindings for python.
Documentation
You can find a Wiki with API Documentation for python.
Examples
Binout
from dynareadout import Binout
bin_file = None
try:
# This library also supports opening multiple binout files at once by globing them
bin_file = Binout("path/to/your/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 in range(len(node_ids)):
print("Node ID {}: {}".format(i, node_ids[i]))
# You can also find out if a variable exists
node_ids_exist = bin_file.variable_exists("/nodout/metadata/ids")
# Get the number of time steps in the binout
nodout_timesteps = bin_file.get_num_timesteps("/nodout")
# The time steps can vary inside the binout
rcforc_timesteps = bin_file.get_num_timesteps("/rcforc")
# 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("path/to/your/d3plot")
except RuntimeError as e:
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("path/to/your/input.k")
# Parse all nodes
node_keywords = keywords["NODE"]
# Loop over all *NODE keywords
for i in range(len(node_keywords)):
# Loop over all cards of each *NODE keyword
for j in range(len(node_keywords[i])):
node = node_keywords[i][j]
# Then you can parse the variables of each card as integers and floats
# The list of integers holds all the widths of each variable in the card in characters
nid, x, y, z = node.parse_whole([8, 16, 16, 16])
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.7-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eded697e258689699cb0fd402252ce107ba42b0023bf0505f9b0190c1c38381e |
|
MD5 | 183dbd36dfffbb42e6585e7f501b4659 |
|
BLAKE2b-256 | ebd059f60e53daadf4c2525607fafcfb2d5ee4c1859f4b0b016d68b81243aa82 |
Hashes for dynareadout-23.7-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2402569da2159776b5b6fbcdb061ee4cc9f9d815011789e31af2cafbcdee1ef |
|
MD5 | 39f9794afd24ac3ae9eae4629fca831a |
|
BLAKE2b-256 | f49ba0e280a9425fd4e6751e919c76f50f4b57529786213427e31ef3619315ed |
Hashes for dynareadout-23.7-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe457f7790e21332ebf1e3daf299c2c84448bdad32c423c70faa5c83968b952d |
|
MD5 | 77173ca41b1cf875740fd9b7627a8703 |
|
BLAKE2b-256 | 446f8ea637078f70691a72e69e3b31af95a80850872db0b7587bd28c0a160cee |
Hashes for dynareadout-23.7-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77f9ab68234442bf79404678f8d7a158cd74bc97dfa67811d84979e64f74d01d |
|
MD5 | 2f498df9502647584f1e2aff26e42558 |
|
BLAKE2b-256 | 02828f596b9769072ed0c7d1d58e2d42fd0f3900d90518900a606a3c45df0cf6 |
Hashes for dynareadout-23.7-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22864bc00655744230a361c9bc3f514cd9ba4174f658124d12003aab2c7cd214 |
|
MD5 | d23e6ab6cb516aff76fa626165937602 |
|
BLAKE2b-256 | 990e840a8581c104688199a330cb68cb8f7d7c95637b82a0c86a458febafd712 |
Hashes for dynareadout-23.7-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1081e3ce2858b452cb86b37e2d21c2930d495466a0d29574916ff66e721e504 |
|
MD5 | cc5432ad958850cb38e28413dfde7d01 |
|
BLAKE2b-256 | f2e588d66d3dc67c89b2440eaaf3dc5bc215e33168f3ae2c4b2973e6ecca9522 |