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.9-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d04e466a11622be0007bd80bcc0d0df0a03996215edc6bddeeb2a089df7cf813 |
|
MD5 | 3c4c5a273326358ac44269cf2a6fa9d1 |
|
BLAKE2b-256 | 2231dcc72145b5a540ed22e1fc1160a55dc8e31e514038ef48fed31ea5491974 |
Hashes for dynareadout-23.9-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e1086f0d79dd8468add1b612b8b0ffc46916b34d55516b14fa0b6a48df4c2c3 |
|
MD5 | 8de0ec281eaf4749ec2c8415dcd6d71e |
|
BLAKE2b-256 | 3024b7eca17eb1fcc13e06b8d2d2a5cf0b32c18410ffa428b9932f29fe386fc7 |
Hashes for dynareadout-23.9-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1b4fe2da1e414c8d15091e496b8302e304e2d6ded359d06a7bce7972f6a2d4c |
|
MD5 | 4dff0de379d9796aa22177b3ff48b811 |
|
BLAKE2b-256 | 553b0d515ae4d2cf2e5560bd504db1ef64a134ee3bc3a48b95121f4b5ac1b7c9 |
Hashes for dynareadout-23.9-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b9d769edb67b42d52f4a5cd898eecdef0e58d09c2503d44091828e569699da2 |
|
MD5 | eea4bb724ff7ae1ce21e2d8b8c89d11a |
|
BLAKE2b-256 | ca36f602a8f69f577b86f2cbb5953a89d97a42506c7e5610a1ccdf1ccbf3e785 |
Hashes for dynareadout-23.9-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed928f6bd8cfd6b6aac4234bda1a767d4fa4586230890a906ff44f3f5c80c66d |
|
MD5 | 1534ac7e814ab753c4a845d2bd1b1bbe |
|
BLAKE2b-256 | 1007663428ec12b8d232c00026bec4741ed4d7fcff57b3087923c4711d9a2971 |
Hashes for dynareadout-23.9-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73ba437651347d69543567667cc590161269b507a40ee92315f5c1c42b8751dc |
|
MD5 | 996b560e87cf727bfa8b602c36d5fbf0 |
|
BLAKE2b-256 | bbd4645a1b77e4bb7e9e1700c811913d790241b91056b098a8e77ddf07c25d91 |