Skip to content

Commit

Permalink
handle some cdo version issues for verts
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjwilson committed Nov 17, 2022
1 parent 271c5d9 commit 5b98e1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nctoolkit/tozlev.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ def to_zlevels(self, levels = None, thickness = None):
thick_var = ds_depths.variables[0]

ds_depths.rename({thick_var: "thickness"})
ds_depths.cdo_command("setmisstoc,1.0")
ds_depths.run()
ds_thick = ds_depths.copy()
ds_thick.divide(2)
ds_depths.vertical_cumsum()
ds_depths.rename({"thickness": "depth"})
ds_depths.subtract(ds_thick)
ds_depths.assign(depth = lambda x: x.depth * (vertical_min(x.depth) < x.depth) * (isnan(x.depth) == False))
ds_depths.assign(depth = lambda x: x.depth * (vertical_min(x.depth) < x.depth) * (isnan(x.depth) == False), drop = True)
ds_depths.subset(times = 0)
ds_depths.cdo_command("setmisstoc,-9999999")
ds_depths.run()
Expand All @@ -109,7 +110,6 @@ def to_zlevels(self, levels = None, thickness = None):

target = ds_depths.copy()
target.assign(depth = lambda x: level(x.depth) + 0 * (x.depth == x.depth), drop = True)
target.rename({"depth_2":"depth"})
target.run()

target.vertical_interp(levels = levels, fixed = True)
Expand Down
3 changes: 3 additions & 0 deletions nctoolkit/verticals.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,10 @@ def vertical_integration(self, thickness=None, depth_range=None, fixed = None):
if drop_this is not None:
self1.drop(variables = drop_this)

ds_thick.run()
self1.run()
self1.multiply(ds_thick)
self1.run()
self1.vertical_sum()
self1.run()
del ds_thick
Expand Down

0 comments on commit 5b98e1f

Please sign in to comment.