Skip to content

Commit

Permalink
parametric Z write
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhassell committed Jun 14, 2024
1 parent 8135fcc commit 94b9156
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Version NEXTRELEASE

* Upgrades to allow cfdm to work with Python 3.12
(https://github.com/NCAS-CMS/cfdm/issues/302)
* Fix bug that caused `cfdm.write` to fail when a parametric Z
dimension coordinate did not have a ``computed_standard_name``
attribute (https://github.com/NCAS-CMS/cfdm/issues/303)

----

Expand Down
2 changes: 1 addition & 1 deletion cfdm/read_write/netcdf/netcdfwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -3323,7 +3323,7 @@ def _write_field_or_domain(
coord, "computed_standard_name", None
)
if x is None:
self.implementation.set_property(
self.implementation.set_properties(
field_coordinates[key],
{"computed_standard_name": csn},
copy=False,
Expand Down
10 changes: 10 additions & 0 deletions cfdm/test/test_read_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,16 @@ def test_read_url(self):
f = cfdm.read(remote)
self.assertEqual(len(f), 1)

def test_write_parametric_Z_coordinate(self):
"""Test write of parametric Z coordinate."""
# Thes write when a parametric Z dimension coordinate does not
# have a compute_standard_name attribute
f = cfdm.example_field(1)
f.coordinate("atmosphere_hybrid_height_coordinate").del_property(
"computed_standard_name", None
)
cfdm.write(f, tmpfile)


if __name__ == "__main__":
print("Run date:", datetime.datetime.now())
Expand Down

0 comments on commit 94b9156

Please sign in to comment.