This module contains a serie of function to help mange and manipulate IDSPy dataclasses
fill_missing_values
ids_to_hdf5
hdf5_to_ids
get_ids_value_from_string
set_ids_value_from_string
list_ids_members
copy_ids
Please note that this work is still under progress/heavy development and as experimental status. This means that functions arguments/signatures as long as HDF5 structure might be totally redesigned in the next updates.
## Quick example
1import pprint2import dataclasses34import idspy_toolkit5from idspy_dictionaries import ids_gyrokinetics_local as gkids67pp = pprint.PrettyPrinter(indent=2)89ids_test = gkids.GyrokineticsLocal()10# you can directly print the class to see what it looks like :11pp.pprint(ids_test)1213# if you want to see all the available classes in the current module :14ids_dict = idspy_toolkit.list_ids_members(gkids)15pp.pprint(ids_dict)1617#to fill an IDS with default values following IMAS standard18idspy_toolkit.fill_missing_values(ids_test)1920# you can use the . to access ids members :21pp.pprint(ids_test.ids_properties)2223# and to set a value :24ids_test.ids_properties.comment="a comment"2526# if in a script you want to reach a "deeper" value, you can use the function *get_ids_value_from_string*27idspy_toolkit.get_ids_value_from_string(ids_test, "ids_properties/comment")28# and for list element, put the element index after an #29idspy_toolkit.get_ids_value_from_string(ids_test, "tag#0/name")3031# same kind of function exist to set a value :32idspy_toolkit.set_ids_value_from_string(ids_test, "tag#0/name", "a new tag name")3334# to print the ids as a dictionary ( better with a vertical screen ;)):35ids_dict = dataclasses.asdict(ids_test)36pp.pprint(ids_dict)3738# HDF5 Operations Example39# Save IDS to HDF5 file (will raise IOError if file exists)40idspy_toolkit.ids_to_hdf5(ids_test, "my_ids.h5")4142# Save with overwrite option and array size constraints43idspy_toolkit.ids_to_hdf5(ids_test, "my_ids.h5",44overwrite=True, # Overwrite existing file45max_array_dim=2, # Maximum array dimensions46max_array_size=100, # Maximum size in MB47max_array_elements=1000) # Maximum number of elements4849# Load IDS from HDF5 file with constraints50loaded_ids = idspy_toolkit.hdf5_to_ids("my_ids.h5",51ids_gyrokinetics.Gyrokinetics,52fill=True, # Fill missing values with defaults53todict=True, # Convert XML strings to dictionaries54max_array_dim=2, # Maximum array dimensions to load55max_array_size=100, # Maximum array size in MB56max_array_elements=1000) # Maximum number of elements
Metadata
Release files for idspy-toolkit 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| idspy_toolkit-1.0.1.tar.gz | 38.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| idspy_toolkit-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 63.6 kB
Release files / idspy_toolkit-1.0.1.tar.gz
| Download URL | idspy_toolkit-1.0.1.tar.gz |
|---|---|
| Size | 38.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e65ee60319deba588c8b3d439d58b04a994e43f1c0a9f874e1f9d61fb97566d
|
|
BLAKE2b-256 checksum How to use checksums |
16c5bbb5cda691ea3d94a96d50fbfecc0c4f3bd194123a70a5b7f4fdfa0b68b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.10
|
Release files / idspy_toolkit-1.0.1-py3-none-any.whl
| Download URL | idspy_toolkit-1.0.1-py3-none-any.whl |
|---|---|
| Size | 24.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2bafe1ad5797640139dbb42b18bc8acd34600765c0a8baf18bc2d93a8a5578cf
|
|
BLAKE2b-256 checksum How to use checksums |
2a829adba58271ae43aed16ca3d4437620a2cb551bbce2f8f53e1182857b9e9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.10
|