Skip to content

Commit

Permalink
Simplify some func argument processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielabdi-noaa committed Mar 14, 2022
1 parent 4c66e68 commit d80b1ca
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 27 deletions.
11 changes: 5 additions & 6 deletions ush/check_ruc_lsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import os
import unittest

from python_utils import process_args, import_vars, print_input_args, \
from python_utils import process_args, set_env_var, import_vars, print_input_args, \
load_xml_file, has_tag_with_value

def check_ruc_lsm(**kwargs):
def check_ruc_lsm(ccpp_phys_suite_fp):
""" This file defines a function that checks whether the RUC land surface
model (LSM) parameterization is being called by the selected physics suite.
Expand All @@ -16,10 +16,7 @@ def check_ruc_lsm(**kwargs):
Boolean
"""

valid_args = ['ccpp_phys_suite_fp']
dictionary = process_args(valid_args, **kwargs)
print_input_args(dictionary)
import_vars(dictionary=dictionary)
print_input_args(locals())

tree = load_xml_file(ccpp_phys_suite_fp)
has_ruc = has_tag_with_value(tree, "scheme", "lsm_ruc")
Expand All @@ -28,4 +25,6 @@ def check_ruc_lsm(**kwargs):
class Testing(unittest.TestCase):
def test_check_ruc_lsm(self):
self.assertTrue( check_ruc_lsm(ccpp_phys_suite_fp="test_data/suite_FV3_GSD_SAR.xml") )
def setUp(self):
set_env_var('DEBUG',True)

8 changes: 2 additions & 6 deletions ush/create_diag_table_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from fill_jinja_template import fill_jinja_template

def create_diag_table_file(**kwargs):
def create_diag_table_file(run_dir):
""" Creates a diagnostic table file for each cycle to be run
Args:
Expand All @@ -18,11 +18,7 @@ def create_diag_table_file(**kwargs):
Boolean
"""

#process input arguments
valid_args = [ "run_dir" ]
dictionary = process_args(valid_args, **kwargs)
print_input_args(dictionary)
import_vars(dictionary=dictionary)
print_input_args(locals())

#import all environment variables
import_vars()
Expand Down
7 changes: 2 additions & 5 deletions ush/get_crontab_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
run_command, define_macos_utilities, check_var_valid_value
from constants import valid_vals_BOOLEAN

def get_crontab_contents(**kwargs):
def get_crontab_contents(called_from_cron):
"""
#-----------------------------------------------------------------------
#
Expand All @@ -35,10 +35,7 @@ def get_crontab_contents(**kwargs):
#-----------------------------------------------------------------------
"""

valid_args=["called_from_cron"]
dictionary = process_args(valid_args, **kwargs)
print_input_args(dictionary)
import_vars(dictionary=dictionary)
print_input_args(locals())

#import all env vars
IMPORTS = ["MACHINE"]
Expand Down
7 changes: 2 additions & 5 deletions ush/set_ozone_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
print_input_args, print_info_msg, print_err_msg_exit,\
define_macos_utilities,load_xml_file,has_tag_with_value,find_pattern_in_str

def set_ozone_param(**kwargs):
def set_ozone_param(ccpp_phys_suite_fp):
""" Function that does the following:
(1) Determines the ozone parameterization being used by checking in the
CCPP physics suite XML.
Expand Down Expand Up @@ -36,10 +36,7 @@ def set_ozone_param(**kwargs):
ozone_param: a string
"""

valid_args = ['ccpp_phys_suite_fp']
dictionary = process_args(valid_args, **kwargs)
print_input_args(dictionary)
import_vars(dictionary=dictionary)
print_input_args(locals())

# import all environment variables
import_vars()
Expand Down
7 changes: 2 additions & 5 deletions ush/set_thompson_mp_fix_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
print_input_args,print_info_msg, print_err_msg_exit,\
define_macos_utilities,load_xml_file,has_tag_with_value

def set_thompson_mp_fix_files(**kwargs):
def set_thompson_mp_fix_files(ccpp_phys_suite_fp, thompson_mp_climo_fn):
""" Function that first checks whether the Thompson
microphysics parameterization is being called by the selected physics
suite. If not, it sets the output variable whose name is specified by
Expand All @@ -26,10 +26,7 @@ def set_thompson_mp_fix_files(**kwargs):
boolean: sdf_uses_thompson_mp
"""

valid_args = ['ccpp_phys_suite_fp', 'thompson_mp_climo_fn']
dictionary = process_args(valid_args, **kwargs)
print_input_args(dictionary)
import_vars(dictionary=dictionary)
print_input_args(locals())

# import all environment variables
import_vars()
Expand Down

0 comments on commit d80b1ca

Please sign in to comment.