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.10.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20fbd4c5c99ac5f27059f954c77e74622b201179376be8898878f1967fc68a6e |
|
MD5 | 8e5d0b31a612e44957b9a0c786b1f171 |
|
BLAKE2b-256 | d05f26713fd5da278f5351da1fdbb85b6911510b2b82be36dc3ab422de5fca44 |
Hashes for dynareadout-23.10.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa6e6a9d5b74bf40c4f3e14c7161fbc81070873ecb2e14bf9bba2a3a5ae8b0c2 |
|
MD5 | 4f0a3c191ae87c58243a824fe3974b16 |
|
BLAKE2b-256 | 7d16d20aa74872ba5ad6fa0ef733dab6e24d9dda5a6d21d09c0dd74931dd396b |
Hashes for dynareadout-23.10.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c4887566c54fc61d756c5fec1a4ae50f8e816c4760ec2d203470c354273d98f |
|
MD5 | 0a58701cd5a8b0ddf19c502b91079e80 |
|
BLAKE2b-256 | 1d7db3236a840b380f24356ea7bf4e70cc4204384fbe5d80bacd4f22fd79d8e8 |
Hashes for dynareadout-23.10.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73932ad7b6ec9f7bb6094e838fa9d93a6ad6c0c6eb28b19a02bff2f04b49fe98 |
|
MD5 | ddc8eaf1861a7a65f79f2e457088e7f7 |
|
BLAKE2b-256 | 6e2a637002d10246875091b2826703246df29fc952261dd71d14bb14e9467f04 |
Hashes for dynareadout-23.10.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35c6f5eff1d8c907c5815f7ff7c6b1908b53a48ede1f824a2063611bddfacf58 |
|
MD5 | 0dae9c084707ffa47e81e5fb9488f5b1 |
|
BLAKE2b-256 | e578b977bded9a0b7b3788f4605f253d75e2c78c2497655fafe7954dfbc46874 |
Hashes for dynareadout-23.10.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b118f9e220fa73cb41d14e7ad4dbbab62eb5c256b216a9f246317749f73707b |
|
MD5 | 4bf22d495fd3b5920654c0f6cde93f81 |
|
BLAKE2b-256 | 3385306ec4364cafabc156c005befbe3de64d962385610c2cae2c18acc9900fd |