From ee384a20c30272408353f14b9fe95dfd793d048a Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Thu, 23 Apr 2020 09:54:33 +0200 Subject: [PATCH 01/16] Add density --- earthdiagnostics/ocean/density.py | 173 ++++++++++++++++++++++++++++++ earthdiagnostics/work_manager.py | 2 + environment.yml | 2 +- setup.py | 3 +- test/unit/ocean/test_density.py | 42 ++++++++ 5 files changed, 220 insertions(+), 2 deletions(-) create mode 100644 earthdiagnostics/ocean/density.py create mode 100644 test/unit/ocean/test_density.py diff --git a/earthdiagnostics/ocean/density.py b/earthdiagnostics/ocean/density.py new file mode 100644 index 00000000..31302244 --- /dev/null +++ b/earthdiagnostics/ocean/density.py @@ -0,0 +1,173 @@ +# coding=utf-8 +"""Compute the total ocean heat content""" +import shutil + +import numpy as np + +import gsw.density +import iris + +from earthdiagnostics.modelingrealm import ModelingRealms +from earthdiagnostics.utils import TempFile +from earthdiagnostics.diagnostic import Diagnostic + + +class Density(Diagnostic): + """ + Compute the total ocean heat content + + :original author: Virginie Guemas + :contributor: Javier Vegas-Regidor + + :created: May 2012 + :last modified: June 2016 + + :param data_manager: data management object + :type data_manager: DataManager + :param startdate: startdate + :type startdate: str + :param member: member number + :type member: int + :param chunk: chunk's number + :type chunk: int + :param mixed_layer: If 1, restricts calculation to the mixed layer, + if -1 exclude it. If 0, no effect + :type mixed_layer: int + :param box: box to use for the average + :type box: Box + + """ + + alias = "density" + "Diagnostic alias for the configuration file" + + def __init__( + self, + data_manager, + startdate, + member, + chunk, + ): + Diagnostic.__init__(self, data_manager) + self.startdate = startdate + self.member = member + self.chunk = chunk + + def __eq__(self, other): + if self._different_type(other): + return False + return ( + self.startdate == other.startdate + and self.member == other.member + and self.chunk == other.chunk + ) + + def __str__(self): + return ( + f"Density Startdate: {self.startdate} Member: {self.member} " + f"Chunk: {self.chunk}" + ) + + def __hash__(self): + return hash(str(self)) + + @classmethod + def generate_jobs(cls, diags, options): + """ + Create a job for each chunk to compute the diagnostic + + :param diags: Diagnostics manager class + :type diags: Diags + :param options: basin, mixed layer option (1 to only compute at + the mixed layer, -1 to exclude it, 0 to ignore), + minimum depth, maximum depth + :type options: list[str] + :return: + """ + options_available = [] + options = cls.process_options(options, options_available) + + job_list = list() + for ( + startdate, + member, + chunk, + ) in diags.config.experiment.get_chunk_list(): + job_list.append( + Density( + diags.data_manager, + startdate, + member, + chunk, + ) + ) + return job_list + + def request_data(self): + """Request data required by the diagnostic""" + self.thetao = self.request_chunk( + ModelingRealms.ocean, + "thetao", + self.startdate, + self.member, + self.chunk, + ) + self.so = self.request_chunk( + ModelingRealms.ocean, + "so", + self.startdate, + self.member, + self.chunk, + ) + + def declare_data_generated(self): + """Declare data to be generated by the diagnostic""" + self.sigma0 = self.declare_chunk( + ModelingRealms.ocean, + "sigma0", + self.startdate, + self.member, + self.chunk, + ) + self.sigma2 = self.declare_chunk( + ModelingRealms.ocean, + "sigma2", + self.startdate, + self.member, + self.chunk, + ) + self.sigma4 = self.declare_chunk( + ModelingRealms.ocean, + "sigma4", + self.startdate, + self.member, + self.chunk, + ) + + def compute(self): + """Run the diagnostic""" + thetao = iris.load_cube(self.thetao.local_file) + so = iris.load_cube(self.so.local_file) + + sigma0 = gsw.density.sigma0(so.data, thetao.data) + self.sigma0.set_local_file( + self._generate_file(sigma0, 'sigma0', thetao)) + del sigma0 + + sigma2 = gsw.density.sigma2(so.data, thetao.data) + self.sigma2.set_local_file( + self._generate_file(sigma2, 'sigma2', thetao)) + del sigma2 + + sigma4 = gsw.density.sigma4(so.data, thetao.data) + self.sigma4.set_local_file( + self._generate_file(sigma4, 'sigma4', thetao)) + del sigma4 + + def _generate_file(self, sigma, name, reference): + sigma_cube = reference.copy(sigma) + sigma_cube.var_name = name + sigma_cube.units = 'kg m-3' + temp = TempFile.get() + iris.save(sigma_cube, temp, zlib=True) + return temp diff --git a/earthdiagnostics/work_manager.py b/earthdiagnostics/work_manager.py index 3666e2c7..9192b58c 100644 --- a/earthdiagnostics/work_manager.py +++ b/earthdiagnostics/work_manager.py @@ -407,6 +407,7 @@ class WorkManager(object): from .ocean.sivolume import Sivolume from .ocean.sivol2d import Sivol2d from .ocean.zonalmean import ZonalMean + from .ocean.density import Density Diagnostic.register(MixedLayerSaltContent) Diagnostic.register(Siasiesiv) @@ -433,6 +434,7 @@ class WorkManager(object): Diagnostic.register(Sivolume) Diagnostic.register(Sivol2d) Diagnostic.register(ZonalMean) + Diagnostic.register(Density) class Downloader(object): diff --git a/environment.yml b/environment.yml index 5b9fe6a6..4e90aa81 100644 --- a/environment.yml +++ b/environment.yml @@ -11,4 +11,4 @@ dependencies: - nco - eccodes - six -- iris>=2.2 +- iris>=2.4 diff --git a/setup.py b/setup.py index f4571a31..3ab9a1e7 100644 --- a/setup.py +++ b/setup.py @@ -25,13 +25,14 @@ REQUIREMENTS = { "cfgrib", "dask[array]", "diagonals", + "gsw", "netCDF4", "nco>=0.0.3", "numba", "numpy", "psutil", "openpyxl", - "scitools-iris>=2.2", + "scitools-iris>=2.4", "six", "xxhash", ], diff --git a/test/unit/ocean/test_density.py b/test/unit/ocean/test_density.py new file mode 100644 index 00000000..92b4e06d --- /dev/null +++ b/test/unit/ocean/test_density.py @@ -0,0 +1,42 @@ +# coding=utf-8 +from unittest import TestCase + +from mock import Mock + +from earthdiagnostics.ocean.density import Density + + +class TestHeatContent(TestCase): + def setUp(self): + self.data_manager = Mock() + + self.diags = Mock() + self.diags.model_version = "model_version" + self.diags.config.experiment.get_chunk_list.return_value = ( + ("20010101", 0, 0), + ("20010101", 0, 1), + ) + + def test_generate_jobs(self): + jobs = Density.generate_jobs( + self.diags, ["diagnostic"] + ) + self.assertEqual(len(jobs), 2) + self.assertEqual( + jobs[0], + Density(self.data_manager, "20010101", 0, 0) + ) + self.assertEqual( + jobs[1], + Density(self.data_manager, "20010101", 0, 1) + ) + + with self.assertRaises(Exception): + Density.generate_jobs(self.diags, ["diagnostic", "0"]) + + def test_str(self): + diag = Density(self.data_manager, "20010101", 0, 0) + self.assertEqual( + str(diag), + "Density Startdate: 20010101 Member: 0 Chunk: 0" + ) -- GitLab From b884700fdf5c2429cdcc30aee67276c5cc6280dd Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Thu, 23 Apr 2020 10:34:40 +0200 Subject: [PATCH 02/16] Add long name --- earthdiagnostics/ocean/density.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/earthdiagnostics/ocean/density.py b/earthdiagnostics/ocean/density.py index 31302244..54e41dd1 100644 --- a/earthdiagnostics/ocean/density.py +++ b/earthdiagnostics/ocean/density.py @@ -107,7 +107,7 @@ class Density(Diagnostic): """Request data required by the diagnostic""" self.thetao = self.request_chunk( ModelingRealms.ocean, - "thetao", + "bigthetao", self.startdate, self.member, self.chunk, @@ -165,8 +165,18 @@ class Density(Diagnostic): del sigma4 def _generate_file(self, sigma, name, reference): + pressure = { + 'sigma0': 0, + 'sigma2': 2000, + 'sigma4': 4000, + } sigma_cube = reference.copy(sigma) sigma_cube.var_name = name + sigma_cube.standard_name = None + sigma_cube.long_name = ( + "potential density anomaly (potential density minus 1000 Kg/m3) " + f"with reference pressure of {pressure[name]} dbar" + ) sigma_cube.units = 'kg m-3' temp = TempFile.get() iris.save(sigma_cube, temp, zlib=True) -- GitLab From 3c32479ec922d502b0a33b6321d3a42fe47791f9 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Thu, 23 Apr 2020 11:05:38 +0200 Subject: [PATCH 03/16] Update docstrings --- earthdiagnostics/ocean/density.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/earthdiagnostics/ocean/density.py b/earthdiagnostics/ocean/density.py index 54e41dd1..67172cd6 100644 --- a/earthdiagnostics/ocean/density.py +++ b/earthdiagnostics/ocean/density.py @@ -1,5 +1,5 @@ # coding=utf-8 -"""Compute the total ocean heat content""" +"""Compute the potential density anomalies""" import shutil import numpy as np @@ -14,13 +14,8 @@ from earthdiagnostics.diagnostic import Diagnostic class Density(Diagnostic): """ - Compute the total ocean heat content + Compute the total potential density anomaly - :original author: Virginie Guemas - :contributor: Javier Vegas-Regidor - - :created: May 2012 - :last modified: June 2016 :param data_manager: data management object :type data_manager: DataManager @@ -30,12 +25,6 @@ class Density(Diagnostic): :type member: int :param chunk: chunk's number :type chunk: int - :param mixed_layer: If 1, restricts calculation to the mixed layer, - if -1 exclude it. If 0, no effect - :type mixed_layer: int - :param box: box to use for the average - :type box: Box - """ alias = "density" @@ -78,9 +67,7 @@ class Density(Diagnostic): :param diags: Diagnostics manager class :type diags: Diags - :param options: basin, mixed layer option (1 to only compute at - the mixed layer, -1 to exclude it, 0 to ignore), - minimum depth, maximum depth + :param options: This diagnostic does not require extra options :type options: list[str] :return: """ -- GitLab From f0e9acbc86946d8cd409b60ce822aa522e4a167c Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Thu, 23 Apr 2020 11:36:39 +0200 Subject: [PATCH 04/16] Remove unused imports --- earthdiagnostics/ocean/density.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/earthdiagnostics/ocean/density.py b/earthdiagnostics/ocean/density.py index 67172cd6..e94d49ba 100644 --- a/earthdiagnostics/ocean/density.py +++ b/earthdiagnostics/ocean/density.py @@ -1,9 +1,5 @@ # coding=utf-8 """Compute the potential density anomalies""" -import shutil - -import numpy as np - import gsw.density import iris -- GitLab From bed71b5b698fee6470ba1cca5510d944d4e6acd3 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Tue, 28 Apr 2020 11:27:00 +0200 Subject: [PATCH 05/16] Add standard_name --- earthdiagnostics/ocean/density.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/earthdiagnostics/ocean/density.py b/earthdiagnostics/ocean/density.py index e94d49ba..3c27844c 100644 --- a/earthdiagnostics/ocean/density.py +++ b/earthdiagnostics/ocean/density.py @@ -155,7 +155,7 @@ class Density(Diagnostic): } sigma_cube = reference.copy(sigma) sigma_cube.var_name = name - sigma_cube.standard_name = None + sigma_cube.standard_name = 'sea_water_sigma_theta' sigma_cube.long_name = ( "potential density anomaly (potential density minus 1000 Kg/m3) " f"with reference pressure of {pressure[name]} dbar" -- GitLab From 4952ad28f0350756f1e260e66eb150df14b0be38 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Wed, 6 May 2020 12:28:58 +0200 Subject: [PATCH 06/16] Chunk to avoid memory issues in my workstation --- earthdiagnostics/ocean/density.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/earthdiagnostics/ocean/density.py b/earthdiagnostics/ocean/density.py index 3c27844c..c1ab44f0 100644 --- a/earthdiagnostics/ocean/density.py +++ b/earthdiagnostics/ocean/density.py @@ -1,6 +1,7 @@ # coding=utf-8 """Compute the potential density anomalies""" import gsw.density +import numpy as np import iris from earthdiagnostics.modelingrealm import ModelingRealms @@ -132,17 +133,23 @@ class Density(Diagnostic): thetao = iris.load_cube(self.thetao.local_file) so = iris.load_cube(self.so.local_file) - sigma0 = gsw.density.sigma0(so.data, thetao.data) + def apply_sigma(sigma): + return np.stack([ + sigma(so[x, ...].data, thetao[x, ...].data) + for x in range(so.shape[0]) + ]) + + sigma0 = apply_sigma(gsw.density.sigma0) self.sigma0.set_local_file( self._generate_file(sigma0, 'sigma0', thetao)) del sigma0 - sigma2 = gsw.density.sigma2(so.data, thetao.data) + sigma2 = apply_sigma(gsw.density.sigma2) self.sigma2.set_local_file( self._generate_file(sigma2, 'sigma2', thetao)) del sigma2 - sigma4 = gsw.density.sigma4(so.data, thetao.data) + sigma4 = apply_sigma(gsw.density.sigma4) self.sigma4.set_local_file( self._generate_file(sigma4, 'sigma4', thetao)) del sigma4 -- GitLab From 8f2748ba23d1a2f95ccad54b9e2e2b2b1d898236 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Mon, 18 May 2020 16:10:25 +0200 Subject: [PATCH 07/16] Use diagonals density functon --- earthdiagnostics/ocean/density.py | 63 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/earthdiagnostics/ocean/density.py b/earthdiagnostics/ocean/density.py index c1ab44f0..52e21215 100644 --- a/earthdiagnostics/ocean/density.py +++ b/earthdiagnostics/ocean/density.py @@ -1,6 +1,6 @@ # coding=utf-8 """Compute the potential density anomalies""" -import gsw.density +import diagonals.density import numpy as np import iris @@ -113,46 +113,49 @@ class Density(Diagnostic): self.member, self.chunk, ) - self.sigma2 = self.declare_chunk( - ModelingRealms.ocean, - "sigma2", - self.startdate, - self.member, - self.chunk, - ) - self.sigma4 = self.declare_chunk( - ModelingRealms.ocean, - "sigma4", - self.startdate, - self.member, - self.chunk, - ) + # self.sigma2 = self.declare_chunk( + # ModelingRealms.ocean, + # "sigma2", + # self.startdate, + # self.member, + # self.chunk, + # ) + # self.sigma4 = self.declare_chunk( + # ModelingRealms.ocean, + # "sigma4", + # self.startdate, + # self.member, + # self.chunk, + # ) def compute(self): """Run the diagnostic""" thetao = iris.load_cube(self.thetao.local_file) so = iris.load_cube(self.so.local_file) + # Convert from practical to absolute + so = so / 0.99530670233846 + + def apply_sigma(): + return diagonals.density.compute( + so.data.astype(np.float32), + thetao.data.astype(np.float32), + np.zeros(thetao.shape, dtype=np.float32) + ) - def apply_sigma(sigma): - return np.stack([ - sigma(so[x, ...].data, thetao[x, ...].data) - for x in range(so.shape[0]) - ]) - - sigma0 = apply_sigma(gsw.density.sigma0) + sigma0 = apply_sigma() self.sigma0.set_local_file( self._generate_file(sigma0, 'sigma0', thetao)) del sigma0 - sigma2 = apply_sigma(gsw.density.sigma2) - self.sigma2.set_local_file( - self._generate_file(sigma2, 'sigma2', thetao)) - del sigma2 + # sigma2 = apply_sigma() + # self.sigma2.set_local_file( + # self._generate_file(sigma2, 'sigma2', thetao)) + # del sigma2 - sigma4 = apply_sigma(gsw.density.sigma4) - self.sigma4.set_local_file( - self._generate_file(sigma4, 'sigma4', thetao)) - del sigma4 + # sigma4 = apply_sigma() + # self.sigma4.set_local_file( + # self._generate_file(sigma4, 'sigma4', thetao)) + # del sigma4 def _generate_file(self, sigma, name, reference): pressure = { -- GitLab From 02b21544ddb888150e60198dab817479c7176597 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Mon, 18 May 2020 16:10:46 +0200 Subject: [PATCH 08/16] Fix latest --- earthdiagnostics/data_convention.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/earthdiagnostics/data_convention.py b/earthdiagnostics/data_convention.py index eb137782..bcbed12c 100644 --- a/earthdiagnostics/data_convention.py +++ b/earthdiagnostics/data_convention.py @@ -884,10 +884,15 @@ class Cmor3Convention(DataConvention): self.config.cmor.version, ) if self.config.cmor.version == "latest": - versions = os.listdir(os.path.dirname(folder_path)) + base_path = os.path.dirname(folder_path) + if not os.path.isdir(base_path): + base_path = base_path.replace( + '/original_files/cmorfiles/', '/cmorfiles/') + versions = os.listdir(base_path) versions.sort(reverse=True) self.config.cmor.version = versions[0] - folder_path = folder_path.replace('/latest/', f'/{versions[0]}/') + return self.get_cmor_folder_path( + startdate, member, domain, var, frequency, grid, cmor_var) return folder_path -- GitLab From e05b96a5d1c275e616a88664e2e38d252d34d1e4 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Mon, 18 May 2020 16:16:45 +0200 Subject: [PATCH 09/16] Remove gsw dependency --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 3ab9a1e7..e45373d3 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,6 @@ REQUIREMENTS = { "cfgrib", "dask[array]", "diagonals", - "gsw", "netCDF4", "nco>=0.0.3", "numba", -- GitLab From 34c4fc5a290fe4242030ca33fdaabfed1bc3efc9 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Mon, 15 Jun 2020 13:17:13 +0200 Subject: [PATCH 10/16] Use float64 --- earthdiagnostics/ocean/density.py | 96 +++++++++++-------------------- 1 file changed, 35 insertions(+), 61 deletions(-) diff --git a/earthdiagnostics/ocean/density.py b/earthdiagnostics/ocean/density.py index 52e21215..60cc2b84 100644 --- a/earthdiagnostics/ocean/density.py +++ b/earthdiagnostics/ocean/density.py @@ -38,6 +38,7 @@ class Density(Diagnostic): self.startdate = startdate self.member = member self.chunk = chunk + self.sigmas = [0, 2] def __eq__(self, other): if self._different_type(other): @@ -89,7 +90,7 @@ class Density(Diagnostic): def request_data(self): """Request data required by the diagnostic""" - self.thetao = self.request_chunk( + self.bigthetao = self.request_chunk( ModelingRealms.ocean, "bigthetao", self.startdate, @@ -106,71 +107,44 @@ class Density(Diagnostic): def declare_data_generated(self): """Declare data to be generated by the diagnostic""" - self.sigma0 = self.declare_chunk( - ModelingRealms.ocean, - "sigma0", - self.startdate, - self.member, - self.chunk, - ) - # self.sigma2 = self.declare_chunk( - # ModelingRealms.ocean, - # "sigma2", - # self.startdate, - # self.member, - # self.chunk, - # ) - # self.sigma4 = self.declare_chunk( - # ModelingRealms.ocean, - # "sigma4", - # self.startdate, - # self.member, - # self.chunk, - # ) + self.sigma = {} + for sigma in self.sigmas: + self.sigma[sigma] = self.declare_chunk( + ModelingRealms.ocean, + f"sigma{sigma}", + self.startdate, + self.member, + self.chunk, + ) def compute(self): """Run the diagnostic""" - thetao = iris.load_cube(self.thetao.local_file) + bigthetao = iris.load_cube(self.bigthetao.local_file) so = iris.load_cube(self.so.local_file) # Convert from practical to absolute so = so / 0.99530670233846 - def apply_sigma(): - return diagonals.density.compute( - so.data.astype(np.float32), - thetao.data.astype(np.float32), - np.zeros(thetao.shape, dtype=np.float32) + for sigma in self.sigmas: + ref_pressure = sigma * 1000 + sigma_values = [] + for time in range(so.shape[0]): + sigma_values.append(diagonals.density.compute( + so[time, ...].data.astype(np.float64), + bigthetao.data[time, ...].astype(np.float64), + np.full(bigthetao.shape[1:], + ref_pressure, dtype=np.float64) + )) + sigma_values = 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' + sigma_cube.long_name = ( + "potential density anomaly (potential density minus 1000 Kg/m3) " + f"with reference pressure of {ref_pressure} dbar" ) - - sigma0 = apply_sigma() - self.sigma0.set_local_file( - self._generate_file(sigma0, 'sigma0', thetao)) - del sigma0 - - # sigma2 = apply_sigma() - # self.sigma2.set_local_file( - # self._generate_file(sigma2, 'sigma2', thetao)) - # del sigma2 - - # sigma4 = apply_sigma() - # self.sigma4.set_local_file( - # self._generate_file(sigma4, 'sigma4', thetao)) - # del sigma4 - - def _generate_file(self, sigma, name, reference): - pressure = { - 'sigma0': 0, - 'sigma2': 2000, - 'sigma4': 4000, - } - sigma_cube = reference.copy(sigma) - sigma_cube.var_name = name - sigma_cube.standard_name = 'sea_water_sigma_theta' - sigma_cube.long_name = ( - "potential density anomaly (potential density minus 1000 Kg/m3) " - f"with reference pressure of {pressure[name]} dbar" - ) - sigma_cube.units = 'kg m-3' - temp = TempFile.get() - iris.save(sigma_cube, temp, zlib=True) - return temp + sigma_cube.units = 'kg m-3' + temp = TempFile.get() + iris.save(sigma_cube, temp, zlib=True) + del sigma_cube + del sigma_values + self.sigma[sigma].set_local_file(temp) -- GitLab From 35fb06fe6e52e11e70c789ffc6ca30a6686ea112 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Mon, 15 Jun 2020 13:17:56 +0200 Subject: [PATCH 11/16] Update version --- VERSION | 2 +- doc/source/conf.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 47b322c9..1545d966 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.4.1 +3.5.0 diff --git a/doc/source/conf.py b/doc/source/conf.py index 1ab10a7a..17ef04e5 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -63,9 +63,9 @@ copyright = u"2020, BSC-CNS Earth Sciences Department" # built documents.source ~/vi # # The short X.Y version. -version = "3.4" +version = "3.5" # The full version, including alpha/beta/rc tags. -release = "3.4.1" +release = "3.5.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -- GitLab From a352977693d685cca81d397d48fbd9983fa58fef Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Mon, 15 Jun 2020 13:21:48 +0200 Subject: [PATCH 12/16] Update doc --- doc/source/codedoc/ocean.rst | 6 ++++++ doc/source/diagnostic_list.rst | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/doc/source/codedoc/ocean.rst b/doc/source/codedoc/ocean.rst index 52830bb9..acf9ad14 100644 --- a/doc/source/codedoc/ocean.rst +++ b/doc/source/codedoc/ocean.rst @@ -25,6 +25,12 @@ earthdiagnostics.ocean.cutsection :show-inheritance: :members: +earthdiagnostics.ocean.density +------------------------------ +.. automodule:: earthdiagnostics.ocean.density + :show-inheritance: + :members: + earthdiagnostics.ocean.gyres ---------------------------- .. automodule:: earthdiagnostics.ocean.gyres diff --git a/doc/source/diagnostic_list.rst b/doc/source/diagnostic_list.rst index de450a4f..f95ab6af 100644 --- a/doc/source/diagnostic_list.rst +++ b/doc/source/diagnostic_list.rst @@ -315,6 +315,16 @@ Options: 4. Domain = ocean: Variable's domain +density +~~~~~~~ + +Compute the total potential density anomaly. See :class:`~earthdiagnostics.ocean.density.Density` + +Options: +******** + +This diagnostic has no options + gyres ~~~~~ @@ -356,14 +366,14 @@ See :class:`~earthdiagnostics.ocean.heatcontentlayer.HeatContentLayer` Options: ******** -3. Min depth: +1. Min depth: Minimum depth for the calculation in meteres -4. Max depth: +2. Max depth: Maximum depth for the calculation in meters -5. Basin = 'Global': - Basin to calculate the heat content on. +3. Basins = ['Global']: + List of basins to calculate the heat content on. interpolate ~~~~~~~~~~~ @@ -381,8 +391,8 @@ Options: 1. Target grid: New grid for the data -2. Variable: - Variable to interpolate +2. VariableList: + List of variables to interpolate 3. Domain = ocean: Variable's domain -- GitLab From 49939842bbaa87488136caabfbb4c299f1a6270f Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Mon, 15 Jun 2020 13:23:16 +0200 Subject: [PATCH 13/16] Fix format --- 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 60cc2b84..d940099e 100644 --- a/earthdiagnostics/ocean/density.py +++ b/earthdiagnostics/ocean/density.py @@ -139,8 +139,8 @@ class Density(Diagnostic): sigma_cube.var_name = f'sigma{sigma}' sigma_cube.standard_name = 'sea_water_sigma_theta' sigma_cube.long_name = ( - "potential density anomaly (potential density minus 1000 Kg/m3) " - f"with reference pressure of {ref_pressure} dbar" + "potential density anomaly (potential density minus 1000 " + f"Kg/m3) with reference pressure of {ref_pressure} dbar" ) sigma_cube.units = 'kg m-3' temp = TempFile.get() -- GitLab From 4c95f67142353fbbcc4d13e7026ad831184feb3f Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Thu, 25 Jun 2020 22:06:30 +0200 Subject: [PATCH 14/16] Go back to float32 --- earthdiagnostics/ocean/density.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/earthdiagnostics/ocean/density.py b/earthdiagnostics/ocean/density.py index d940099e..d4d4aea4 100644 --- a/earthdiagnostics/ocean/density.py +++ b/earthdiagnostics/ocean/density.py @@ -129,10 +129,10 @@ class Density(Diagnostic): sigma_values = [] for time in range(so.shape[0]): sigma_values.append(diagonals.density.compute( - so[time, ...].data.astype(np.float64), - bigthetao.data[time, ...].astype(np.float64), + so[time, ...].data.astype(np.float32), + bigthetao.data[time, ...].astype(np.float32), np.full(bigthetao.shape[1:], - ref_pressure, dtype=np.float64) + ref_pressure, dtype=np.float32) )) sigma_values = np.stack(sigma_values) sigma_cube = bigthetao.copy(sigma_values) -- GitLab From f24fbe835e7938895c02f8af9c5c94cac99827db Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Thu, 25 Jun 2020 22:15:07 +0200 Subject: [PATCH 15/16] Update diagonals version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 85747d21..775abbf7 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ REQUIREMENTS = { "cdo>=1.3.4", "cfgrib", "dask[array]", - "diagonals>=0.2" + "diagonals>=0.3" "netCDF4", "nco>=0.0.3", "numba", -- GitLab From 372811bed34856323658a56bac18d0943218c4a6 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Thu, 25 Jun 2020 23:08:45 +0200 Subject: [PATCH 16/16] Fix requirements --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 775abbf7..4fab770a 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ REQUIREMENTS = { "cdo>=1.3.4", "cfgrib", "dask[array]", - "diagonals>=0.3" + "diagonals>=0.3", "netCDF4", "nco>=0.0.3", "numba", -- GitLab