Tools to manipulate the IDSPy Dictionaries
Project description
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
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file idspy_toolkit-1.0.1.tar.gz.
File metadata
- Download URL: idspy_toolkit-1.0.1.tar.gz
- Upload date:
- Size: 38.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e65ee60319deba588c8b3d439d58b04a994e43f1c0a9f874e1f9d61fb97566d
|
|
| MD5 |
0b3d1ce795acdc830298179518866315
|
|
| BLAKE2b-256 |
16c5bbb5cda691ea3d94a96d50fbfecc0c4f3bd194123a70a5b7f4fdfa0b68b3
|
File details
Details for the file idspy_toolkit-1.0.1-py3-none-any.whl.
File metadata
- Download URL: idspy_toolkit-1.0.1-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bafe1ad5797640139dbb42b18bc8acd34600765c0a8baf18bc2d93a8a5578cf
|
|
| MD5 |
fb3a040244c406d3de92d8f6c5ffef97
|
|
| BLAKE2b-256 |
2a829adba58271ae43aed16ca3d4437620a2cb551bbce2f8f53e1182857b9e9b
|