Skip to content

Write xarray data back to xarray#12

Merged
stefsmeets merged 12 commits into
mainfrom
to_imas
Dec 11, 2023
Merged

Write xarray data back to xarray#12
stefsmeets merged 12 commits into
mainfrom
to_imas

Conversation

@stefsmeets
Copy link
Copy Markdown
Contributor

@stefsmeets stefsmeets commented Dec 6, 2023

This PR adds a way to sync the dataset back to the hdf5 file. This updates in-place.

from imas2xarray import to_imas, to_xarray

variables = ('rho_tor_norm', 'time', 't_e')
ids = 'core_profiles'

dataset = to_xarray('./data', ids=ids, variables=variables)

print(dataset['t_e'])
dataset['t_e'] += 1

to_imas('./data', dataset=dataset, ids=ids, variables=variables)

Closes #2

Todo

  • Add tests
  • Tweak scripts/modify_data.py and add example to docs
  • Wrap .open_ids in contextmanager
  • Update docstrings
  • Check that variables are in var_lookup or handle this otherwise
  • Fix tests in CI

@stefsmeets stefsmeets marked this pull request as ready for review December 11, 2023 14:18
@stefsmeets stefsmeets merged commit a785fc0 into main Dec 11, 2023
@stefsmeets stefsmeets deleted the to_imas branch December 11, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write hdf5 data

1 participant