From a7b1f4b4226f302a3e82392239516fb41bbfba5c Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Thu, 9 Jul 2020 09:26:30 -0600 Subject: [PATCH 1/4] Use correct Python syntax to test if a variable is a list or a dictionary --- scripts/ccpp_prebuild.py | 2 +- scripts/mkcap.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ccpp_prebuild.py b/scripts/ccpp_prebuild.py index 68353ed3..29e6e069 100755 --- a/scripts/ccpp_prebuild.py +++ b/scripts/ccpp_prebuild.py @@ -378,7 +378,7 @@ def check_optional_arguments(metadata, arguments, optional_arguments): # *DH 2020-05-26 for subroutine_name in optional_arguments[module_name].keys(): # If optional arguments are listed individually, check each of them - if type(optional_arguments[module_name][subroutine_name]) is list: + if isinstance(optional_arguments[module_name][subroutine_name], list): for var_name in optional_arguments[module_name][subroutine_name]: if not var_name in arguments[module_name][scheme_name][subroutine_name]: raise Exception("Explicitly requested optional argument '{}' not known to {}/{}".format( diff --git a/scripts/mkcap.py b/scripts/mkcap.py index 9170424c..06e59d37 100755 --- a/scripts/mkcap.py +++ b/scripts/mkcap.py @@ -91,7 +91,7 @@ def dimensions(self): @dimensions.setter def dimensions(self, value): - if not type(value) is list: + if not isinstance(value, list): raise TypeError('Invalid type for variable property dimensions, must be a list') self._dimensions = value @@ -170,7 +170,7 @@ def actions(self): @actions.setter def actions(self, values): - if type(values)==dict: + if isinstance(values, dict): for key in values.keys(): if key in ['in', 'out'] and isstring(values[key]): self._actions[key] = values[key] From f375880668a03e45d58bbb16fef35541d6184381 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Thu, 9 Jul 2020 09:22:47 -0600 Subject: [PATCH 2/4] scripts/conversion_tools/unit_conversion.py: add conversion from degrees to radians and vice versa --- scripts/conversion_tools/unit_conversion.py | 30 ++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/scripts/conversion_tools/unit_conversion.py b/scripts/conversion_tools/unit_conversion.py index b61d670a..3b192b3c 100755 --- a/scripts/conversion_tools/unit_conversion.py +++ b/scripts/conversion_tools/unit_conversion.py @@ -113,7 +113,35 @@ def kg_kg_minus_1__to__g_kg_minus_1(): def g_kg_minus_1__to__kg_kg_minus_1(): """Convert gram per kilogram to kilogram per kilogram""" - return '{var}/1.0E+3{kind}' + return '1.0E-3{kind}*{var}' + +################## +# Plane angle # +################## + +def radian__to__degrees(): + """Convert radian to degrees""" + return '57.295779513{kind}*{var}' + +def degrees__to__radian(): + """Convert degrees to radian""" + return '{var}/57.295779513{kind}' + +def radian__to__degrees_north(): + """Convert radian to degrees north""" + return radian__to__degrees() + +def degrees_north__to__radian(): + """Convert degrees north to radian""" + return degrees__to__radian() + +def radian__to__degrees_east(): + """Convert radian to degrees east""" + return radian__to__degrees() + +def degrees_east__to__radian(): + """Convert degrees east to radian""" + return degrees__to__radian() ################## # Composed units # From db66a81f7a54b7145900e747fffd2f428664925b Mon Sep 17 00:00:00 2001 From: Man Zhang Date: Mon, 13 Jul 2020 10:40:09 -0600 Subject: [PATCH 3/4] fix a bug to avoid reading keys in metadata2html.py --- scripts/metadata2html.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/metadata2html.py b/scripts/metadata2html.py index 148a081e..2e27ea3a 100755 --- a/scripts/metadata2html.py +++ b/scripts/metadata2html.py @@ -74,7 +74,7 @@ def import_config(configfile, logger): def get_metadata_files_from_config(config, logger): """Create a list of metadata filenames for a CCPP prebuild configuration""" filenames = [] - for sourcefile in config['variable_definition_files'] + config['scheme_files'].keys(): + for sourcefile in config['variable_definition_files'] + config['scheme_files']: metafile = os.path.splitext(sourcefile)[0]+'.meta' if os.path.isfile(metafile): filenames.append(metafile) From d71e0d5a454dcf0b6ce3e08517cac15bf9b5f1fe Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Mon, 13 Jul 2020 11:32:12 -0600 Subject: [PATCH 4/4] scripts/conversion_tools/unit_conversion.py: make unit 'degree' singular --- scripts/conversion_tools/unit_conversion.py | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/conversion_tools/unit_conversion.py b/scripts/conversion_tools/unit_conversion.py index 3b192b3c..b8d50707 100755 --- a/scripts/conversion_tools/unit_conversion.py +++ b/scripts/conversion_tools/unit_conversion.py @@ -119,29 +119,29 @@ def g_kg_minus_1__to__kg_kg_minus_1(): # Plane angle # ################## -def radian__to__degrees(): - """Convert radian to degrees""" +def radian__to__degree(): + """Convert radian to degree""" return '57.295779513{kind}*{var}' -def degrees__to__radian(): - """Convert degrees to radian""" +def degree__to__radian(): + """Convert degree to radian""" return '{var}/57.295779513{kind}' -def radian__to__degrees_north(): - """Convert radian to degrees north""" - return radian__to__degrees() +def radian__to__degree_north(): + """Convert radian to degree north""" + return radian__to__degree() -def degrees_north__to__radian(): - """Convert degrees north to radian""" - return degrees__to__radian() +def degree_north__to__radian(): + """Convert degree north to radian""" + return degree__to__radian() -def radian__to__degrees_east(): - """Convert radian to degrees east""" - return radian__to__degrees() +def radian__to__degree_east(): + """Convert radian to degree east""" + return radian__to__degree() -def degrees_east__to__radian(): - """Convert degrees east to radian""" - return degrees__to__radian() +def degree_east__to__radian(): + """Convert degree east to radian""" + return degree__to__radian() ################## # Composed units #