Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract cubewrite() time dimension fix function #142

Closed
truth-quark opened this issue Oct 9, 2024 · 0 comments · Fixed by #144
Closed

Extract cubewrite() time dimension fix function #142

truth-quark opened this issue Oct 9, 2024 · 0 comments · Fixed by #144
Assignees

Comments

@truth-quark
Copy link
Collaborator

truth-quark commented Oct 9, 2024

This issue has several parts relating to the time coord dimension modification:

try:
# If time is a dimension but not a coordinate dimension, coord_dims('time') returns empty tuple
if tdim := cube.coord_dims('time'):
# For fields with a pseudo-level, time may not be the first dimension
if tdim != (0,):
tdim = tdim[0]
neworder = list(range(cube.ndim))
neworder.remove(tdim)
neworder.insert(0, tdim)
if verbose > 1:
print("Incorrect dimension order", cube)
print("Transpose to", neworder)
cube.transpose(neworder)
sman.write(cube,
zlib=True,
complevel=compression,
unlimited_dimensions=['time'],
fill_value=fill_value)
else:
tmp = iris.util.new_axis(cube, cube.coord('time'))
sman.write(tmp,
zlib=True,
complevel=compression,
unlimited_dimensions=['time'],
fill_value=fill_value)
except iris.exceptions.CoordinateNotFoundError:
# No time dimension (probably ancillary file)
sman.write(cube, zlib=True, complevel=compression, fill_value=fill_value)

  1. Decouple sman.write() from the time conversion logic
  2. Extract the time dimension fix to a function
  3. Merge all writes to a single function call

Unit testing is covered in #143.

@truth-quark truth-quark self-assigned this Oct 9, 2024
@truth-quark truth-quark changed the title Extract time dimension fix function Extract cubewrite() time dimension fix function Oct 9, 2024
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 a pull request may close this issue.

1 participant