From bf1ee8ee03c623d5151330b7264e3dd031a65aaa Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Wed, 9 Dec 2020 09:49:51 +0100 Subject: [PATCH 1/3] Fix latest version and cdo interpolation --- earthdiagnostics/data_convention.py | 3 +++ earthdiagnostics/ocean/interpolatecdo.py | 25 +++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/earthdiagnostics/data_convention.py b/earthdiagnostics/data_convention.py index 5e4dd4b5..c6bb6aab 100644 --- a/earthdiagnostics/data_convention.py +++ b/earthdiagnostics/data_convention.py @@ -896,6 +896,9 @@ class Cmor3Convention(DataConvention): if not os.path.isdir(base_path): base_path = base_path.replace( '/original_files/cmorfiles/', '/cmorfiles/') + if not os.path.isdir(base_path): + base_path = base_path.replace( + '/cmorfiles/', '/diags/') versions = os.listdir(base_path) versions.sort(reverse=True) self.config.cmor.version = versions[0] diff --git a/earthdiagnostics/ocean/interpolatecdo.py b/earthdiagnostics/ocean/interpolatecdo.py index 3de0f28a..42dd17a9 100644 --- a/earthdiagnostics/ocean/interpolatecdo.py +++ b/earthdiagnostics/ocean/interpolatecdo.py @@ -1,6 +1,7 @@ # coding=utf-8 """CDO-based interpolation""" import os +from cdo import CDOException import numpy as np @@ -399,11 +400,25 @@ class InterpolateCDO(Diagnostic): handler.close() temp = TempFile.get() - Utils.cdo().remap( - ",".join((self.grid.split("_")[0], self.weights)), - input=variable_file, - output=temp, - ) + try: + Utils.cdo().remap( + ",".join((self.grid.split("_")[0], self.weights)), + input=variable_file, + output=temp, + ) + except CDOException as ex: + msg = ( + '(cdf_put_vara_double): NetCDF: Numeric ' + 'conversion not representable' + ) + if msg not in ex.msg: + raise + Utils.cdo().remap( + ",".join((self.grid.split("_")[0], self.weights)), + input=variable_file, + output=temp, + options='-b F64' + ) handler = Utils.open_cdf(temp) if units: -- GitLab From 012685ce27fdf6211bf1a1f3e7ceb91bb45e3a66 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Thu, 10 Dec 2020 11:52:36 +0100 Subject: [PATCH 2/3] Fix invalid values in density --- earthdiagnostics/ocean/density.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/earthdiagnostics/ocean/density.py b/earthdiagnostics/ocean/density.py index d4d4aea4..69b070c4 100644 --- a/earthdiagnostics/ocean/density.py +++ b/earthdiagnostics/ocean/density.py @@ -134,7 +134,7 @@ class Density(Diagnostic): np.full(bigthetao.shape[1:], ref_pressure, dtype=np.float32) )) - sigma_values = np.stack(sigma_values) + sigma_values = np.ma.masked_invalid(np.stack(sigma_values)) sigma_cube = bigthetao.copy(sigma_values) sigma_cube.var_name = f'sigma{sigma}' sigma_cube.standard_name = 'sea_water_sigma_theta' @@ -144,7 +144,7 @@ class Density(Diagnostic): ) sigma_cube.units = 'kg m-3' temp = TempFile.get() - iris.save(sigma_cube, temp, zlib=True) + iris.save(sigma_cube, temp, zlib=True, fill_value=1e20) del sigma_cube del sigma_values self.sigma[sigma].set_local_file(temp) -- GitLab From f9549907daad181668b3b3c1e1588d326f2e1aa2 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Thu, 10 Dec 2020 15:35:47 +0100 Subject: [PATCH 3/3] Bump version --- VERSION | 2 +- doc/source/conf.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 87ce4929..444877d4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.5.2 +3.5.3 diff --git a/doc/source/conf.py b/doc/source/conf.py index e939abc0..9e05183a 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -65,7 +65,7 @@ copyright = u"2020, BSC-CNS Earth Sciences Department" # The short X.Y version. version = "3.5" # The full version, including alpha/beta/rc tags. -release = "3.5.1" +release = "3.5.3" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -- GitLab