Skip to content

Commit

Permalink
Merge pull request #33 from ThibHlln/fix-multi-div-state-dumps
Browse files Browse the repository at this point in the history
add netCDF dimension for component state divisions in dump file
  • Loading branch information
Thibault Hallouin authored Apr 14, 2021
2 parents 8698f92 + c2278f5 commit 878daa3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ v0.1.0

Released on 2021, ???.

.. rubric:: Bug fixes

* fix dump file update bug due to missing 'divisions' dimension
(`#32 <https://github.com/hydro-jules/cm4twc/issues/32>`_)

.. rubric:: Documentation

* move API reference page to doc tree root
Expand Down
12 changes: 10 additions & 2 deletions cm4twc/components/_utils/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,16 @@ def create_states_dump(filepath, states_info, solver_history,

# state variables
for var in states_info:
s = f.createVariable(var, dtype_float(),
('time', 'history', *axes))
d = states_info[var].get('divisions', 1)
if d > 1:
f.createDimension('{}_divisions'.format(var), d)
s = f.createVariable(var, dtype_float(),
('time', 'history', *axes,
'{}_divisions'.format(var)))
else:
s = f.createVariable(var, dtype_float(),
('time', 'history', *axes))

s.standard_name = var
s.units = states_info[var]['units']

Expand Down

0 comments on commit 878daa3

Please sign in to comment.