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.8-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fa493bafdeea7411129fc9eb757ba0724979cb976bd40deb8e1e531b56278bd |
|
MD5 | 1a2717a3c7c56fc2951589de9be0447b |
|
BLAKE2b-256 | 25c84d8229dbb77272165d1c11dc964b9b04612a47e8ac5d9052dd59d239168e |
Hashes for dynareadout-23.8-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbf66886418e2a8cba0c78794b717d628ab06711fa6660df45ce10dc1870e746 |
|
MD5 | 7f6784529d069966d86e6babaa154f03 |
|
BLAKE2b-256 | c180bbf9a0271f9758c493371e8fc70063ab5c23c3562efc3aaae5df60996160 |
Hashes for dynareadout-23.8-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df2f697893e8a7677ebb62c1d446e3334a8f232adcc23f103d14ad90ace2adb8 |
|
MD5 | cf2ef580c5fc1eb435b847152a5a78b4 |
|
BLAKE2b-256 | b0e12c5f111007336afc7172916e36d4baccd566160a870ef1d0fab0289de96f |
Hashes for dynareadout-23.8-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 424ade6af5f8f7f0becc12d84f155e22046c19361736184df121b3d1d3843ca6 |
|
MD5 | f782f008e3c1502fb5242ffe02cb5646 |
|
BLAKE2b-256 | b2df33785d83ed9f6fd81c90ce4b1ec971098fc08614c6b2c0010942d286b212 |
Hashes for dynareadout-23.8-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd9526995aec314c3ec225dda4e2cdccdf605da131fb409becf2163712d0fa75 |
|
MD5 | 316d1e49cac10801e61be37e309a0a45 |
|
BLAKE2b-256 | 6218740033e2915b452bfb4183cdb36e7ee691fc3d39a34c26fba2f0c735d35b |
Hashes for dynareadout-23.8-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7e8b3ec98507d36dd21a5438d0ec8a40c84533bc059c2032706b838fd75ab33 |
|
MD5 | 7828ea58d723488403c29d907fcc3804 |
|
BLAKE2b-256 | 919a34c3b7466e725ee1240fca677a1d9bbe99f06fd96e09e01d703ee0e4671e |