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.11-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9c065bfbde412620956a74948035bc0e2f920abeec77614629d52a478f6129d |
|
MD5 | 83d225211a15088ca54ba6f7d024bf57 |
|
BLAKE2b-256 | ab09d6959edbee00f709305c26ce7f92a6bcd67494d2f00e60e8d5d9560b5014 |
Hashes for dynareadout-23.11-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6057204776346868fc418012792a072c5aa80ae390831c5227d793242f7863cd |
|
MD5 | e5d027caabf1daa5dd28e08ccb1cbab4 |
|
BLAKE2b-256 | 06f71a332caf0e25244d3315686dd02d091fb8b98577d743f64a2a9760154236 |
Hashes for dynareadout-23.11-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59d62d8dfc56dd9e99e848c01faaaa38c4bb0d0f4844227720b452e2d19bb7f7 |
|
MD5 | dfe12ada6038769470de922102321f1a |
|
BLAKE2b-256 | 0ebf3f0827d2610aa918463753bd24233d70cd34cd3b30b94b75a500c255896e |
Hashes for dynareadout-23.11-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3fba97575a5a6f47ee910940b8d51d99d4262130e5889ff22ed33e3001d6df4 |
|
MD5 | 458af059086d934aede60d7396e9ed7c |
|
BLAKE2b-256 | 0f93ac76e27c45759ec95472b4b00861365699953db7cf6d0725160aabda9043 |
Hashes for dynareadout-23.11-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89743bb95d63e10e6065f670b5763cbd8d94002d7b7694c128394811385fd1ee |
|
MD5 | 6902fce75ba18e20aa815b3e66c7eeee |
|
BLAKE2b-256 | 66150798572e3f9ca62e5755b38e7834982fc5aec6bacef026fa99871abc8c95 |
Hashes for dynareadout-23.11-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90fc583e9e2d40aa11e245fae8d38fc86d4e2366c52e8ab0802268e0e8ffed6c |
|
MD5 | 425fa65070ec4966478c2c3df3e7227c |
|
BLAKE2b-256 | 766e8f1a7bfcd2dcd42378d63ff52f599f45c1e89124359d3e8299a7c3497595 |