diff --git a/VERSION b/VERSION index bf50b583b787819260fdbc7e8ca8c239702f950b..3b8d36d048a75e8c8029a5d1e1862b68c705cc91 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -3.0.0b47 +3.0.0b48 diff --git a/diags.conf b/diags.conf index 38fc56a033b358f423e998b9165224335ae184cc..7e2588c97ef559000a1066e8f0e7ce46c4611e9f 100644 --- a/diags.conf +++ b/diags.conf @@ -15,7 +15,7 @@ CON_FILES = /esnas/autosubmit/con_files/ # Diagnostics to run, space separated. You must provide for each one the name and the parameters (comma separated) or # an alias defined in the ALIAS section (see more below). If you are using the diagnostics just to CMORize, leave it # empty -DIAGS = +DIAGS = mxl # DIAGS = OHC # Frequency of the data you want to use by default. Some diagnostics do not use this value: i.e. monmean always stores # its results at monthly frequency (obvious) and has a parameter to specify input's frequency. diff --git a/doc/source/codedoc/ocean.rst b/doc/source/codedoc/ocean.rst index 5ca11d71e4e36774561732b93ade7f2b714069a7..e8fcbe6e2bddf7e4909681c9df5d12053187cebf 100644 --- a/doc/source/codedoc/ocean.rst +++ b/doc/source/codedoc/ocean.rst @@ -79,6 +79,12 @@ earthdiagnostics.ocean.moc :show-inheritance: :members: +earthdiagnostics.ocean.mxl +-------------------------- +.. automodule:: earthdiagnostics.ocean.mxl + :show-inheritance: + :members: + earthdiagnostics.ocean.psi -------------------------- .. automodule:: earthdiagnostics.ocean.psi diff --git a/doc/source/conf.py b/doc/source/conf.py index 5be47d4f251acce395b89b90c2438a26db510b34..11b03e3fc37db004bd0dc0a67acfee087fb68c1f 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -64,7 +64,7 @@ copyright = u'2016, BSC-CNS Earth Sciences Department' # The short X.Y version. version = '3.0b' # The full version, including alpha/beta/rc tags. -release = '3.0.0b47' +release = '3.0.0b48' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/source/diagnostic_list.rst b/doc/source/diagnostic_list.rst index 5c393d890190d9cc17930b09769f16f5957def9b..2376a8ec6d13234f2f1146d105fab15b21fa2299 100644 --- a/doc/source/diagnostic_list.rst +++ b/doc/source/diagnostic_list.rst @@ -474,6 +474,16 @@ Options: This diagnostic has no options +mxl +~~~~ + +Compute the mixed layer depth. See :class:`~earthdiagnostics.ocean.mxl.Mxl` + +Options: +******** + +This diagnostic has no options + psi ~~~~ diff --git a/earthdiagnostics/EarthDiagnostics.pdf b/earthdiagnostics/EarthDiagnostics.pdf index 6b099383f507b51964aa8a4dfb002e228a10964c..84ba83795edf9d553ff19d365793f917ce4f7169 100644 Binary files a/earthdiagnostics/EarthDiagnostics.pdf and b/earthdiagnostics/EarthDiagnostics.pdf differ diff --git a/earthdiagnostics/earthdiags.py b/earthdiagnostics/earthdiags.py index af81f2590a1a72e9b3913136538d38147bd384a3..625421a086507c3fff8709b4eea5aef1be2faf2f 100755 --- a/earthdiagnostics/earthdiags.py +++ b/earthdiagnostics/earthdiags.py @@ -275,6 +275,7 @@ class EarthDiags(object): Diagnostic.register(HeatContent) Diagnostic.register(RegionMean) Diagnostic.register(Rotation) + Diagnostic.register(Mxl) def clean(self): Log.info('Removing scratch folder...') diff --git a/earthdiagnostics/ocean/__init__.py b/earthdiagnostics/ocean/__init__.py index 14f2bd65898c5f46465845ec408688e9f1d7bacd..30db8957001262e3aa3c5ae0a7779eb9b0d70984 100644 --- a/earthdiagnostics/ocean/__init__.py +++ b/earthdiagnostics/ocean/__init__.py @@ -21,3 +21,4 @@ from earthdiagnostics.ocean.heatcontentlayer import HeatContentLayer from earthdiagnostics.ocean.mixedlayerheatcontent import MixedLayerHeatContent from earthdiagnostics.ocean.regionmean import RegionMean from earthdiagnostics.ocean.rotation import Rotation +from earthdiagnostics.ocean.mxl import Mxl diff --git a/earthdiagnostics/ocean/mxl.py b/earthdiagnostics/ocean/mxl.py new file mode 100644 index 0000000000000000000000000000000000000000..b3ac1eb6336e4bcff3fcba30993c8a118a070664 --- /dev/null +++ b/earthdiagnostics/ocean/mxl.py @@ -0,0 +1,77 @@ +# coding=utf-8 +import os + +from earthdiagnostics import cdftools +from earthdiagnostics.diagnostic import Diagnostic +from earthdiagnostics.utils import Utils, TempFile +from earthdiagnostics.modelingrealm import ModelingRealms + + +class Mxl(Diagnostic): + """ + Compute the mixed layer depth + + :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 + """ + + alias = 'mxl' + "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): + return self.startdate == other.startdate and self.member == other.member and self.chunk == other.chunk + + def __str__(self): + return 'Mixed layer Startdate: {0} Member: {1} Chunk: {2}'.format(self.startdate, self.member, self.chunk) + + @classmethod + def generate_jobs(cls, diags, options): + """ + Creates a job for each chunk to compute the diagnostic + + :param diags: Diagnostics manager class + :type diags: Diags + :param options: None + :type options: list[str] + :return: + """ + if len(options) > 1: + raise Exception('The mxl diagnostic has no options') + job_list = list() + for startdate, member, chunk in diags.config.experiment.get_chunk_list(): + job_list.append(Mxl(diags.data_manager, startdate, member, chunk)) + return job_list + + def compute(self): + """ + Runs the diagnostic + """ + temp = TempFile.get() + thetao = self.data_manager.get_file(ModelingRealms.ocean, 'thetao', self.startdate, self.member, self.chunk) + so = self.data_manager.get_file(ModelingRealms.ocean, 'so', self.startdate, self.member, self.chunk) + cdftools.run('cdfmxl', input=[thetao, so], output=temp, options='-nc4') + os.remove(thetao) + os.remove(so) + temp2 = TempFile.get() + source = Utils.openCdf(temp) + destiny = Utils.openCdf(temp2, 'w') + Utils.copy_variable(source, destiny, 'somxl010', must_exist=True, add_dimensions=True) + Utils.copy_variable(source, destiny, 'lat') + Utils.copy_variable(source, destiny, 'lon') + source.close() + destiny.close() + self.send_file(temp2, ModelingRealms.ocean, 'mlotst', self.startdate, self.member, self.chunk, + rename_var='somxl010') + os.remove(temp)