From fdbe225c1bf7e5c714ecd310181f6201de31d918 Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Thu, 27 Jun 2024 13:37:26 -0700 Subject: [PATCH 01/25] consolidate cmor setups and e2c logging --- e3sm_to_cmip/__main__.py | 107 +++++++++------ e3sm_to_cmip/_logger.py | 122 +++++++++--------- e3sm_to_cmip/cmor_handlers/handler.py | 37 +++--- .../cmor_handlers/mpas_vars/areacello.py | 12 +- .../cmor_handlers/mpas_vars/fsitherm.py | 10 +- e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py | 9 +- .../cmor_handlers/mpas_vars/hfsifrazil.py | 9 +- .../cmor_handlers/mpas_vars/masscello.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py | 9 +- .../cmor_handlers/mpas_vars/mlotst.py | 9 +- .../cmor_handlers/mpas_vars/msftmz.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py | 9 +- .../cmor_handlers/mpas_vars/siconc.py | 9 +- .../cmor_handlers/mpas_vars/simass.py | 9 +- .../cmor_handlers/mpas_vars/sisnmass.py | 9 +- .../cmor_handlers/mpas_vars/sisnthick.py | 9 +- .../cmor_handlers/mpas_vars/sitemptop.py | 10 +- .../cmor_handlers/mpas_vars/sithick.py | 9 +- .../cmor_handlers/mpas_vars/sitimefrac.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py | 11 +- e3sm_to_cmip/cmor_handlers/mpas_vars/so.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py | 9 +- .../cmor_handlers/mpas_vars/thetao.py | 11 +- .../cmor_handlers/mpas_vars/thetaoga.py | 9 +- .../cmor_handlers/mpas_vars/thkcello.py | 20 ++- e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py | 9 +- .../cmor_handlers/mpas_vars/volcello.py | 12 +- e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py | 9 +- e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py | 9 +- .../cmor_handlers/mpas_vars/zhalfo.py | 12 +- e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py | 9 +- e3sm_to_cmip/cmor_handlers/utils.py | 38 ++---- e3sm_to_cmip/cmor_handlers/vars/areacella.py | 51 +++----- e3sm_to_cmip/cmor_handlers/vars/clisccp.py | 38 ++---- e3sm_to_cmip/cmor_handlers/vars/orog.py | 47 ++----- e3sm_to_cmip/cmor_handlers/vars/sftlf.py | 47 ++----- e3sm_to_cmip/mpas.py | 59 ++++----- e3sm_to_cmip/util.py | 27 ++-- 51 files changed, 479 insertions(+), 489 deletions(-) diff --git a/e3sm_to_cmip/__main__.py b/e3sm_to_cmip/__main__.py index c939abb9..973de7b0 100755 --- a/e3sm_to_cmip/__main__.py +++ b/e3sm_to_cmip/__main__.py @@ -21,8 +21,12 @@ from tqdm import tqdm from e3sm_to_cmip import ROOT_HANDLERS_DIR, __version__, resources -from e3sm_to_cmip._logger import _setup_logger, _setup_root_logger +from datetime import datetime, timezone + +from e3sm_to_cmip._logger import e2c_logger + from e3sm_to_cmip.cmor_handlers.utils import ( + instantiate_h_utils_logger, MPAS_REALMS, REALMS, Frequency, @@ -32,7 +36,10 @@ derive_handlers, load_all_handlers, ) +from e3sm_to_cmip.cmor_handlers.handler import instantiate_handler_logger + from e3sm_to_cmip.util import ( + instantiate_util_logger, FREQUENCIES, _get_table_info, get_handler_info_msg, @@ -50,11 +57,6 @@ warnings.filterwarnings("ignore") -# Setup the root logger and this module's logger. -log_filename = _setup_root_logger() -logger = _setup_logger(__name__, propagate=True) - - @dataclass class CLIArguments: """A data class storing the command line arguments for e3sm_to_cmip. @@ -97,9 +99,14 @@ class CLIArguments: class E3SMtoCMIP: def __init__(self, args: Optional[List[str]] = None): + global logger # A dictionary of command line arguments. parsed_args = self._parse_args(args) + # Setup this module's logger AFTER args parsed in E3SMtoCMIP init, so that + # default log file is NOT created for mere "--help" or "--version" calls. + logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True) + # NOTE: The order of these attributes align with class CLIArguments. # ====================================================================== # Run Mode settings. @@ -115,8 +122,6 @@ def __init__(self, args: Optional[List[str]] = None): self.debug: bool = parsed_args.debug self.timeout: int = parsed_args.timeout - # ====================================================================== - # CMOR settings. # ====================================================================== self.var_list: List[str] = self._get_var_list(parsed_args.var_list) self.realm: Union[Realm, MPASRealm] = parsed_args.realm @@ -140,6 +145,9 @@ def __init__(self, args: Optional[List[str]] = None): if self.precheck_path is not None: self._run_precheck() + self.handlers = self._get_handlers() + + def echo_settings(self): logger.info("--------------------------------------") logger.info("| E3SM to CMIP Configuration") logger.info("--------------------------------------") @@ -149,9 +157,7 @@ def __init__(self, args: Optional[List[str]] = None): logger.info(f" * precheck_path='{self.precheck_path}'") logger.info(f" * freq='{self.freq}'") logger.info(f" * realm='{self.realm}'") - logger.info(f" * Writing log output file to: {log_filename}") - - self.handlers = self._get_handlers() + # logger.info(f" * Writing log output file to: {log_filename}") def run(self): # Setup logger information and print out e3sm_to_cmip CLI arguments. @@ -161,17 +167,16 @@ def run(self): self.output_path, "user_metadata.json" ) - # Setup directories using the CLI argument paths (e.g., output dir). - # ====================================================================== - if not self.info_mode: - self._setup_dirs_with_paths() - # Run e3sm_to_cmip with info mode. # ====================================================================== if self.info_mode: self._run_info_mode() sys.exit(0) + # Setup directories using the CLI argument paths (e.g., output dir). + # ====================================================================== + self._setup_dirs_with_paths() + # Run e3sm_to_cmip to CMORize serially or in parallel. # ====================================================================== timer = None @@ -306,7 +311,8 @@ def _parse_args(self, args: Optional[List[str]]) -> CLIArguments: sys.exit(1) # Parse the arguments and perform validation. - parsed_args = argparser.parse_args(args_to_parse) + parsed_args = argparser.parse_args(args_to_parse) # (exits here if args == "-h" or "--help" or "--version") + self._validate_parsed_args(parsed_args) # Convert to this data class for type checking to work. @@ -531,7 +537,7 @@ def _setup_argparser(self) -> argparse.ArgumentParser: "-h", "--help", action="help", - default=argparse.SUPPRESS, + # default=argparse.SUPPRESS, help="show this help message and exit", ) @@ -635,13 +641,13 @@ def _setup_dirs_with_paths(self): copy_user_metadata(self.user_metadata, self.output_path) # Setup temp storage directory - temp_path = os.environ.get("TMPDIR") - if temp_path is None: - temp_path = f"{self.output_path}/tmp" - if not os.path.exists(temp_path): - os.makedirs(temp_path) + # temp_path = os.environ.get("TMPDIR") + # if temp_path is None: + # temp_path = f"{self.output_path}/tmp" + # if not os.path.exists(temp_path): + # os.makedirs(temp_path) - tempfile.tempdir = temp_path + # tempfile.tempdir = temp_path def _run_info_mode(self): # noqa: C901 logger.info("--------------------------------------") @@ -778,12 +784,15 @@ def _run_serial(self) -> int: # noqa: C901 int 1 if an error occurs, else 0 """ + + do_pbar = False try: num_handlers = len(self.handlers) num_success = 0 + num_failure = 0 name = None - if self.realm != "atm": + if self.realm != "atm" and do_pbar: pbar = tqdm(total=len(self.handlers)) for _, handler in enumerate(self.handlers): @@ -816,7 +825,7 @@ def _run_serial(self) -> int: # noqa: C901 } msg = f"Trying to CMORize with handler: {handler}" - logger.info(msg) + logger.critical(msg) # NOTE: We need a try and except statement here for TypeError because # the VarHandler.cmorize method does not use **kwargs, while the handle @@ -838,17 +847,18 @@ def _run_serial(self) -> int: # noqa: C901 except Exception as e: print_debug(e) - if name is not None: + if name is not None and name is not "": num_success += 1 - msg = f"Finished {name}, {num_success}/{num_handlers} jobs complete" + msg = f"Finished {name}, {num_success}/{num_handlers} jobs complete (via run_serial)" logger.info(msg) else: + num_failure += 1 msg = f"Error running handler {handler['name']}" logger.info(msg) - if self.realm != "atm": + if self.realm != "atm" and do_pbar: pbar.update(1) - if self.realm != "atm": + if self.realm != "atm" and do_pbar: pbar.close() except Exception as error: @@ -858,6 +868,8 @@ def _run_serial(self) -> int: # noqa: C901 msg = f"{num_success} of {num_handlers} handlers complete" logger.info(msg) + if num_failure > 0: + return 1 return 0 def _run_parallel(self) -> int: # noqa: C901 @@ -872,6 +884,8 @@ def _run_parallel(self) -> int: # noqa: C901 pool_res = list() will_run = [] + do_pbar = False + for idx, handler in enumerate(self.handlers): handler_method = handler["method"] handler_variables = handler["raw_variables"] @@ -926,8 +940,10 @@ def _run_parallel(self) -> int: # noqa: C901 pool_res.append(res) # wait for each result to complete - pbar = tqdm(total=len(pool_res)) + if do_pbar: + pbar = tqdm(total=len(pool_res)) num_success = 0 + num_failure = 0 num_handlers = len(self.handlers) finished_success = [] for idx, res in enumerate(pool_res): @@ -936,26 +952,30 @@ def _run_parallel(self) -> int: # noqa: C901 finished_success.append(out) if out: num_success += 1 - msg = f"Finished {out}, {idx + 1}/{num_handlers} jobs complete" + msg = f"Finished {out}, {idx + 1}/{num_handlers} jobs complete (via run_parallel)" else: + num_failure += 1 msg = f'Error running handler {self.handlers[idx]["name"]}' logger.error(msg) logger.info(msg) except Exception as e: print_debug(e) - pbar.update(1) + if do_pbar: + pbar.update(1) - pbar.close() + if do_pbar: + pbar.close() pool.shutdown() msg = f"{num_success} of {num_handlers} handlers complete" logger.info(msg) failed = set(will_run) - set(finished_success) - if failed: + if failed or num_failure > 0: logger.error(f"{', '.join(list(failed))} failed to complete") logger.error(msg) + return 1 return 0 @@ -963,11 +983,26 @@ def _timeout_exit(self): print_message("Hit timeout limit, exiting") os.kill(os.getpid(), signal.SIGINT) +logger=None def main(args: Optional[List[str]] = None): + global logger +def main(args: Optional[List[str]] = None): + global logger + app = E3SMtoCMIP(args) - app.run() + + # These calls allow loggers that create default logfiles to avoid being + # instantiated by arguments "--help" or "--version". + instantiate_util_logger() + instantiate_h_utils_logger() + instantiate_handler_logger() + + app.echo_settings() + return app.run() if __name__ == "__main__": + + main() diff --git a/e3sm_to_cmip/_logger.py b/e3sm_to_cmip/_logger.py index 2e14df7c..bcf08ecf 100644 --- a/e3sm_to_cmip/_logger.py +++ b/e3sm_to_cmip/_logger.py @@ -1,68 +1,66 @@ +import inspect import logging import os -import time -from datetime import datetime - -from pytz import UTC - - -def _setup_root_logger() -> str: # pragma: no cover - """Sets up the root logger. - - The logger module will write to a log file and stream the console - simultaneously. - - The log files are saved in a `/logs` directory relative to where - `e3sm_to_cmip` is executed. - - Returns - ------- - str - The name of the logfile. - """ - os.makedirs("logs", exist_ok=True) - filename = f'logs/{UTC.localize(datetime.utcnow()).strftime("%Y%m%d_%H%M%S_%f")}' - log_format = "%(asctime)s_%(msecs)03d:%(levelname)s:%(funcName)s:%(message)s" - - # Setup the logging module. - logging.basicConfig( - filename=filename, - format=log_format, - datefmt="%Y%m%d_%H%M%S", - level=logging.DEBUG, - ) - logging.captureWarnings(True) - logging.Formatter.converter = time.gmtime - - # Configure and add a console stream handler. - console_handler = logging.StreamHandler() - console_handler.setLevel(logging.INFO) - log_formatter = logging.Formatter(log_format) - console_handler.setFormatter(log_formatter) - logging.getLogger().addHandler(console_handler) - - return filename - - -def _setup_logger(name, propagate=True) -> logging.Logger: - """Sets up a logger object. - - This function is intended to be used at the top-level of a module. - - Parameters - ---------- - name : str - Name of the file where this function is called. - propagate : bool, optional - Propogate this logger module's messages to the root logger or not, by - default True. - - Returns - ------- - logging.Logger - The logger. - """ +from datetime import datetime, timezone + +''' + ACCEPTS: + name= + logfilename= [default = e2c_logs/dflt_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log] + log_level= [default = DEBUG] + to_console=[True|False] [default = False] + to_logfile=[True|False] [default = False] + propagate=[True|False] [default = False] +''' + +default_log_dir = "e2c_logs" +default_log = f"{default_log_dir}/e2c_root_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log" + +def e2c_logger(name=None, logfilename=default_log, set_log_level=None, to_console=False, to_logfile=False, propagate=False): + + # print(f"DEBUG: _logger: entered e2c_logger at {datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')} called by {name}", flush=True) + + default_log_lvl = logging.DEBUG + + # create logging directory as required + + if to_logfile: + dn = os.path.dirname(logfilename) + if len(dn) and not os.path.exists(dn): + os.makedirs(dn) + logger = logging.getLogger(name) + if name == None or name == "__main__": + logger = logger.root + logger.propagate = propagate + if set_log_level == "None" or set_log_level == "DEBUG": + log_level = default_log_lvl + elif set_log_level == "INFO": + log_level = logging.INFO + elif set_log_level == "WARNING": + log_level = logging.WARNING + elif set_log_level == "ERROR": + log_level = logging.ERROR + elif set_log_level == "CRITICAL": + log_level = logging.CRITICAL + else: log_level = default_log_lvl + + logger.setLevel(log_level) + + logger.handlers = [] + + if to_console: + logStreamHandler = logging.StreamHandler() + logStreamHandler.setFormatter(logging.Formatter("%(asctime)s_%(msecs)03d:%(levelname)s:%(name)s:%(funcName)s:%(message)s",datefmt="%Y%m%d_%H%M%S")) + logger.addHandler(logStreamHandler) + + if to_logfile: + logFileHandler = logging.FileHandler(logfilename) + logFileHandler.setFormatter(logging.Formatter("%(asctime)s_%(msecs)03d:%(levelname)s:%(name)s:%(funcName)s:%(message)s",datefmt="%Y%m%d_%H%M%S")) + logger.addHandler(logFileHandler) + return logger + + diff --git a/e3sm_to_cmip/cmor_handlers/handler.py b/e3sm_to_cmip/cmor_handlers/handler.py index 7766504e..655df5c1 100644 --- a/e3sm_to_cmip/cmor_handlers/handler.py +++ b/e3sm_to_cmip/cmor_handlers/handler.py @@ -2,7 +2,6 @@ import abc import json -import logging import os from typing import Any, Dict, KeysView, List, Literal, Optional, Tuple, TypedDict @@ -12,11 +11,17 @@ import xcdat as xc import yaml -from e3sm_to_cmip._logger import _setup_logger from e3sm_to_cmip.cmor_handlers import FILL_VALUE, _formulas from e3sm_to_cmip.util import _get_table_for_non_monthly_freq +from e3sm_to_cmip._logger import e2c_logger + +logger=None + +def instantiate_handler_logger(): + global logger + + logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=True) -logger = _setup_logger(__name__) # The names for valid hybrid sigma levels. HYBRID_SIGMA_LEVEL_NAMES = [ @@ -267,7 +272,7 @@ def cmorize( # the variables. Otherwise, the IDs of cmor objects gets wiped after # every loop. cmor.close() - logger.debug( + logger.info( f"{self.name}: CMORized and file write complete, closing CMOR I/O." ) @@ -290,7 +295,7 @@ def _all_vars_have_filepaths( """ for var, filepaths in vars_to_filespaths.items(): if len(filepaths) == 0: - logging.error(f"{var}: Unable to find input files for {var}") + logger.error(f"{var}: Unable to find input files for {var}") return False return True @@ -317,22 +322,22 @@ def _setup_cmor_module( logdir : str | None The optional log directory. """ - if log_dir is not None: - logpath = log_dir - else: - cwd = os.getcwd() - logpath = os.path.join(cwd, "cmor_logs") + # if log_dir is not None: + # logpath = log_dir + # else: + # cwd = os.getcwd() + # logpath = os.path.join(cwd, "cmor_logs") - os.makedirs(logpath, exist_ok=True) - logfile = os.path.join(logpath, var_name + ".log") + # os.makedirs(logpath, exist_ok=True) + # logfile = os.path.join(logpath, var_name + ".log") - cmor.setup( - inpath=tables_path, netcdf_file_action=cmor.CMOR_REPLACE, logfile=logfile - ) + print("DEBUG: EMPLOYED HANDLER.PY _setup_cmor_module()", flush=True) + + cmor.setup(inpath=tables_path, netcdf_file_action=cmor.CMOR_REPLACE,logfile="/dev/null") cmor.dataset_json(metadata_path) cmor.load_table(self.table) - logging.info(f"{var_name}: CMOR setup complete") + logger.info(f"{var_name}: CMOR setup complete") def _get_var_time_dim(self, table_path: str) -> str | None: """Get the CMIP variable's time dimension, if it exists. diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py index 867c8d95..b8d2b867 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py @@ -2,10 +2,11 @@ compute Grid-Cell Area for Ocean Variables areacello """ import xarray -import logging -from e3sm_to_cmip import mpas -from e3sm_to_cmip.util import print_message, setup_cmor +from e3sm_to_cmip import mpas, util +from e3sm_to_cmip.util import print_message +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPAS_mesh', 'MPAS_map'] @@ -41,7 +42,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -65,8 +66,7 @@ def handle(infiles, tables, user_input_path, **kwargs): # area_b is in square radians, so need to multiply by the earth_radius**2 ds[VAR_NAME] = earth_radius**2*area_b*ds[VAR_NAME] - setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, - user_input_path=user_input_path) + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'latitude', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py index 351efc6a..b6d097ba 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py @@ -5,9 +5,11 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas + +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -43,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): print_message(f'Simple CMOR output not supported for {VAR_NAME}', 'error') return None - logging.info(f'Starting {VAR_NAME}') + logger.info(f'Starting {VAR_NAME}') mappingFileName = infiles['MPAS_map'] timeSeriesFiles = infiles['MPASO'] @@ -60,7 +62,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py index a7c0d281..6d4fdf25 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -46,7 +47,7 @@ def handle(infiles, tables, user_input_path, **kwargs): print_message(f'Simple CMOR output not supported for {VAR_NAME}', 'error') return None - logging.info(f'Starting {VAR_NAME}') + logger.info(f'Starting {VAR_NAME}') mappingFileName = infiles['MPAS_map'] timeSeriesFiles = infiles['MPASO'] @@ -73,7 +74,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py index baf5c2e1..83cd202f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): print_message(f'Simple CMOR output not supported for {VAR_NAME}', 'error') return None - logging.info(f'Starting {VAR_NAME}') + logger.info(f'Starting {VAR_NAME}') timeSeriesFiles = infiles['MPASO'] mappingFileName = infiles['MPAS_map'] @@ -76,7 +77,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py index 6030ccd1..4a7dc32c 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py @@ -5,10 +5,11 @@ from __future__ import absolute_import, division, print_function import xarray -import logging import netCDF4 +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPASO_namelist', 'MPAS_mesh', 'MPAS_map'] @@ -45,7 +46,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) namelistFileName = infiles['MPASO_namelist'] meshFileName = infiles['MPAS_mesh'] @@ -77,7 +78,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds[VAR_NAME] = ds[VAR_NAME].where( ds[VAR_NAME] != netCDF4.default_fillvals['f4'], 0.) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py index 8155fcea..085fbfd5 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py @@ -6,9 +6,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPASO_namelist', 'MPAS_mesh'] @@ -45,7 +46,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) namelistFileName = infiles['MPASO_namelist'] meshFileName = infiles['MPAS_mesh'] @@ -69,7 +70,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.add_time(ds, dsIn) ds.compute() - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py index 43309b1e..079eeadb 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -66,7 +67,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.add_mask(ds, cellMask2D) ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py index 1e255108..70d28ec1 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPASO_MOC_regions', 'MPASO_namelist'] @@ -47,7 +48,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] timeSeriesFiles = infiles['MPASO'] @@ -76,7 +77,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = ds.rename({'moc': VAR_NAME}) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) region = ['global_ocean', 'atlantic_arctic_ocean'] diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py index 792fa1b8..0c233744 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPASO_namelist', 'MPAS_mesh', 'MPAS_map', 'PSL'] @@ -46,7 +47,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) namelistFileName = infiles['MPASO_namelist'] meshFileName = infiles['MPAS_mesh'] @@ -84,7 +85,7 @@ def handle(infiles, tables, user_input_path, **kwargs): with xarray.open_mfdataset(pslFileNames, concat_dim='time') as dsIn: ds[VAR_NAME] = ds[VAR_NAME] + dsIn.PSL.values - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py index 304ac8c8..ed694d01 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPASO_namelist', 'MPAS_mesh', 'MPAS_map', 'PSL'] @@ -45,7 +46,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) namelistFileName = infiles['MPASO_namelist'] meshFileName = infiles['MPAS_mesh'] @@ -80,7 +81,7 @@ def handle(infiles, tables, user_input_path, **kwargs): with xarray.open_mfdataset(pslFileNames, concat_dim='time') as dsIn: ds[VAR_NAME] = ds[VAR_NAME] + dsIn.PSL.values - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py index af9e28fa..f4e368e0 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_map'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) mappingFileName = infiles['MPAS_map'] timeSeriesFiles = infiles['MPASO'] @@ -61,7 +62,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py index f9a38943..6c7ad22d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py @@ -6,9 +6,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASSI', 'MPAS_mesh', 'MPAS_map'] @@ -45,7 +46,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -63,7 +64,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='seaice') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py index ec514576..158d8df9 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py @@ -6,9 +6,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASSI', 'MPAS_mesh', 'MPAS_map'] @@ -41,7 +42,7 @@ def handle(infiles, tables, user_input_path, **kwargs): the name of the processed variable after processing is complete """ msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -62,7 +63,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='seaice') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py index 1542d421..e1d31269 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py @@ -6,9 +6,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASSI', 'MPAS_mesh', 'MPAS_map'] @@ -46,7 +47,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -67,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='seaice') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py index 13de8a81..57ebadb4 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py @@ -6,9 +6,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASSI', 'MPAS_mesh', 'MPAS_map'] @@ -46,7 +47,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -67,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='seaice') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py index 706ea8e1..7868a573 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py @@ -5,11 +5,11 @@ from __future__ import absolute_import, division, print_function -import logging - import xarray +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -48,7 +48,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -67,7 +67,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='seaice') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py index e9b66c89..70cf0ae5 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py @@ -6,9 +6,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASSI', 'MPAS_mesh', 'MPAS_map'] @@ -46,7 +47,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -66,7 +67,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='seaice') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py index 591ff362..4645555b 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py @@ -6,9 +6,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASSI', 'MPAS_mesh', 'MPAS_map'] @@ -45,7 +46,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -65,7 +66,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='seaice') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py index b3105fbf..a3bc3c1a 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py @@ -6,9 +6,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASSI', 'MPAS_mesh', 'MPAS_map'] @@ -45,7 +46,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -69,7 +70,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='seaice') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py index 4fd8b4f4..0306ffa4 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py @@ -6,10 +6,11 @@ from __future__ import absolute_import, division, print_function import xarray -import logging - -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_console=True, propagate=False) + # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASSI', 'MPAS_mesh', 'MPAS_map'] @@ -45,7 +46,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -70,7 +71,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='seaice') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py index d622383e..5c5f3a20 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -67,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py index 81626534..ed411d77 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -67,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py index 7f3f0d5c..16dd324d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py @@ -6,9 +6,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh'] @@ -46,7 +47,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] timeSeriesFiles = infiles['MPASO'] @@ -70,7 +71,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.add_time(ds, dsIn) ds.compute() - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py index 0d4b731e..0367f837 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -67,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py index be153e90..932bcc9e 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] timeSeriesFiles = infiles['MPASO'] @@ -66,7 +67,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds.compute() ds.compute() - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py index dea84253..1e78aa7c 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_map'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) mappingFileName = infiles['MPAS_map'] timeSeriesFiles = infiles['MPASO'] @@ -61,7 +62,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py index 032a2436..703d753d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_map'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) mappingFileName = infiles['MPAS_map'] timeSeriesFiles = infiles['MPASO'] @@ -61,7 +62,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py index f35af82c..2d2649c3 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -43,8 +44,8 @@ def handle(infiles, tables, user_input_path, **kwargs): print_message(msg) return - msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + msg = f'Starting {__name__}' + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -67,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py index 632c0a21..3826740a 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py @@ -6,9 +6,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh'] @@ -46,7 +47,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] timeSeriesFiles = infiles['MPASO'] @@ -70,7 +71,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.add_time(ds, dsIn) ds.compute() - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py index 01e6420e..a1500075 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py @@ -3,11 +3,12 @@ """ import xarray -import logging import netCDF4 +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas -from e3sm_to_cmip.util import print_message, setup_cmor +from e3sm_to_cmip import mpas, util +from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -42,19 +43,25 @@ def handle(infiles, tables, user_input_path, **kwargs): print_message(msg) return - msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + msg = f'Starting {__name__}' + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] timeSeriesFiles = infiles['MPASO'] + msg = f' Calling xarray.open_dataset()' + logger.info(msg) + dsMesh = xarray.open_dataset(meshFileName, mask_and_scale=False) _, cellMask3D = mpas.get_mpaso_cell_masks(dsMesh) variableList = ['timeMonthly_avg_layerThickness', 'xtime_startMonthly', 'xtime_endMonthly'] + msg = f' Calling mpas.open_mfdataset()' + logger.info(msg) + ds = xarray.Dataset() with mpas.open_mfdataset(timeSeriesFiles, variableList) as dsIn: ds[VAR_NAME] = \ @@ -71,8 +78,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds[VAR_NAME] = ds[VAR_NAME].where( ds[VAR_NAME] != netCDF4.default_fillvals['f4'], 0.) - setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, - user_input_path=user_input_path) + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py index 8c08df06..ac5ce720 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -67,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py index 4bc4d36d..a1e6b9ae 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -67,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py index 34bb9e96..7d390051 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] timeSeriesFiles = infiles['MPASO'] @@ -66,7 +67,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds.compute() ds.compute() - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py index da0562e4..b6a5bb1d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -67,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py index 0085a97a..0317ebc7 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -44,7 +45,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -67,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py index 9a228bea..3e087dfb 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py @@ -3,11 +3,12 @@ """ import xarray -import logging import netCDF4 +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas -from e3sm_to_cmip.util import print_message, setup_cmor +from e3sm_to_cmip import mpas, util +from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -43,7 +44,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -85,8 +86,7 @@ def handle(infiles, tables, user_input_path, **kwargs): # multiply variables in this order so they don't get transposed ds[VAR_NAME] = ds[VAR_NAME]*earth_radius**2*area_b - setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, - user_input_path=user_input_path) + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py index b2e838a7..01c406fa 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py @@ -6,9 +6,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh'] @@ -45,7 +46,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] timeSeriesFiles = infiles['MPASO'] @@ -67,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds.compute() - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py index 2a4ab15d..a7b87ffd 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_map'] @@ -46,7 +47,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) mappingFileName = infiles['MPAS_map'] timeSeriesFiles = infiles['MPASO'] @@ -71,7 +72,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py index 59995dca..1b2f98f2 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py @@ -5,10 +5,11 @@ from __future__ import absolute_import, division, print_function import xarray -import logging import numpy +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -45,7 +46,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -70,7 +71,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py index 42fe931c..54dea42d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py @@ -5,10 +5,11 @@ from __future__ import absolute_import, division, print_function import xarray -import logging import numpy +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASO', 'MPAS_mesh', 'MPAS_map'] @@ -45,7 +46,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -76,7 +77,7 @@ def handle(infiles, tables, user_input_path, **kwargs): zLayerBot = (zLayerBot - layerThickness.isel(nVertLevels=zIndex)).where(mask) zLayerBot.compute() - # print('done zLayerBot {}/{}'.format(zIndex+1, nVertLevels)) + logger.info(f"done zLayerBot {zIndex+1}/{nVertLevels}") slices.append(zLayerBot) maskSlices.append(mask) ds[VAR_NAME] = xarray.concat(slices, dim='olevhalf') @@ -85,12 +86,13 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = ds.transpose('Time', 'olevhalf', 'nCells') ds = mpas.add_time(ds, dsIn) ds.compute() + logger.info(f"returned from ds.compute()") ds = mpas.remap(ds, 'mpasocean', mappingFileName) depth_coord_half = numpy.zeros(nVertLevels+1) depth_coord_half[1:] = dsMesh.refBottomDepth.values - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py index 7903d818..b2686bbc 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py @@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function import xarray -import logging +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) -from e3sm_to_cmip import mpas +from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -45,7 +46,7 @@ def handle(infiles, tables, user_input_path, **kwargs): return msg = 'Starting {name}'.format(name=__name__) - logging.info(msg) + logger.info(msg) meshFileName = infiles['MPAS_mesh'] mappingFileName = infiles['MPAS_map'] @@ -69,7 +70,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean') + util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/utils.py b/e3sm_to_cmip/cmor_handlers/utils.py index 8f946e8e..f67232a7 100644 --- a/e3sm_to_cmip/cmor_handlers/utils.py +++ b/e3sm_to_cmip/cmor_handlers/utils.py @@ -11,11 +11,16 @@ LEGACY_HANDLER_DIR_PATH, MPAS_HANDLER_DIR_PATH, ) -from e3sm_to_cmip._logger import _setup_logger from e3sm_to_cmip.cmor_handlers.handler import VarHandler from e3sm_to_cmip.util import _get_table_for_non_monthly_freq -logger = _setup_logger(__name__) +from e3sm_to_cmip._logger import e2c_logger + +def instantiate_h_utils_logger(): + global logger + + logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) + # Type aliases Frequency = Literal["mon", "day", "6hrLev", "6hrPlev", "6hrPlevPt", "3hr", "1hr"] @@ -55,6 +60,7 @@ def load_all_handlers( KeyError If no handlers are defined for a CMIP6 variable in `handlers.yaml`. """ + handlers_by_var: Dict[str, List[Dict[str, Any]]] = _get_handlers_by_var() missing_handlers: List[str] = [] @@ -172,6 +178,7 @@ def derive_handlers( If a handler could not be derived for a CMIP6 variable using the existing E3SM variables. """ + # TODO: Refactor the function parameters. handlers_by_var: Dict[str, List[Dict[str, Any]]] = _get_handlers_by_var() derived_handlers: List[Dict[str, Any]] = [] @@ -360,15 +367,15 @@ def _get_handlers_from_modules(path: str) -> Dict[str, List[Dict[str, Any]]]: "handler.py", "utils.py", ]: - var = file.split(".")[0] - filepath = os.path.join(root, file) - module = _get_handler_module(var, filepath) + module_name = file.split(".")[0] + module_path = os.path.join(root, file) + module = SourceFileLoader(module_name, module_path).load_module() # NOTE: The value is set to a list with a single dict entry # so that it is compatible with the data structure for storing # all var handlers (which can have multiple handlers per # variable). - handlers[var] = [ + handlers[module_name] = [ { "name": module.VAR_NAME, "units": module.VAR_UNITS, @@ -385,22 +392,3 @@ def _get_handlers_from_modules(path: str) -> Dict[str, List[Dict[str, Any]]]: return handlers -def _get_handler_module(module_name: str, module_path: str): - """Get the variable handler Python module. - - Parameters - ---------- - module_name : str - The name of the module, which should be the key of the variable (e.g., - "orog"). - module_path : str - The absolute path to the variable handler Python module. - - Returns - ------- - module - The module. - """ - module = SourceFileLoader(module_name, module_path).load_module() - - return module diff --git a/e3sm_to_cmip/cmor_handlers/vars/areacella.py b/e3sm_to_cmip/cmor_handlers/vars/areacella.py index dcd4d0e7..f23d8b8b 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/areacella.py +++ b/e3sm_to_cmip/cmor_handlers/vars/areacella.py @@ -4,7 +4,6 @@ from __future__ import absolute_import, division, print_function, unicode_literals import json -import logging import os import numpy as np @@ -12,11 +11,11 @@ import cmor from e3sm_to_cmip import resources -from e3sm_to_cmip._logger import _setup_logger from e3sm_to_cmip.mpas import write_netcdf -from e3sm_to_cmip.util import print_message +from e3sm_to_cmip.util import setup_cmor, print_message -logger = _setup_logger(__name__) +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) # list of raw variable names needed RAW_VARIABLES = [str("area")] @@ -56,46 +55,30 @@ def handle_simple(infiles): def handle(infiles, tables, user_input_path, table, logdir): - msg = "{}: Starting".format(VAR_NAME) - logger.info(msg) + logger.info(f"{VAR_NAME}: Starting") # check that we have some input files for every variable zerofiles = False for variable in RAW_VARIABLES: if len(infiles[variable]) == 0: - msg = "{}: Unable to find input files for {}".format(VAR_NAME, variable) + msg = f"{VAR_NAME}: Unable to find input files for {variable}" print_message(msg) - logging.error(msg) + logger.error(msg) zerofiles = True if zerofiles: return None - # Create the logging directory and setup cmor - if logdir: - logpath = logdir - else: - outpath, _ = os.path.split(logger.__dict__["handlers"][0].baseFilename) - logpath = os.path.join(outpath, "cmor_logs") - os.makedirs(logpath, exist_ok=True) + setup_cmor(VAR_NAME, tables, TABLE, user_input_path) - logfile = os.path.join(logpath, VAR_NAME + ".log") - - cmor.setup(inpath=tables, netcdf_file_action=cmor.CMOR_REPLACE, logfile=logfile) - - cmor.dataset_json(str(user_input_path)) - cmor.load_table(str(TABLE)) - - msg = "{}: CMOR setup complete".format(VAR_NAME) - logging.info(msg) + logger.info(f"{VAR_NAME}: CMOR setup complete") # extract data from the input file - msg = "areacella: loading area" - logger.info(msg) + logger.info("areacella: loading area") filename = infiles["area"][0] if not os.path.exists(filename): - raise IOError("File not found: {}".format(filename)) + raise IOError(f"File not found: {filename}") ds = xr.open_dataset(filename, decode_times=False) @@ -108,8 +91,7 @@ def handle(infiles, tables, user_input_path, table, logdir): "area": ds["area"], } - msg = "{name}: loading axes".format(name=VAR_NAME) - logger.info(msg) + logger.info(f"{VAR_NAME}: loading axes") axes = [ { @@ -126,8 +108,7 @@ def handle(infiles, tables, user_input_path, table, logdir): }, ] - msg = "areacella: running CMOR" - logging.info(msg) + logger.info(f"{VAR_NAME}: running CMOR") axis_ids = list() for axis in axes: @@ -139,12 +120,10 @@ def handle(infiles, tables, user_input_path, table, logdir): outdata = data["area"].values * pow(RADIUS, 2) cmor.write(varid, outdata) - msg = "{}: write complete, closing".format(VAR_NAME) - logger.debug(msg) + logger.debug(f"{VAR_NAME}: write complete, closing") cmor.close() - msg = "{}: file close complete".format(VAR_NAME) - logger.debug(msg) + logger.debug(f"{VAR_NAME}: file close complete") - return "areacella" + return VAR_NAME diff --git a/e3sm_to_cmip/cmor_handlers/vars/clisccp.py b/e3sm_to_cmip/cmor_handlers/vars/clisccp.py index 05368eb8..f07b4ddb 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/clisccp.py +++ b/e3sm_to_cmip/cmor_handlers/vars/clisccp.py @@ -5,7 +5,6 @@ """ from __future__ import absolute_import, annotations, division, unicode_literals -import logging import os from typing import Dict, List, Union @@ -13,10 +12,10 @@ import xarray as xr import cmor -from e3sm_to_cmip._logger import _setup_logger -from e3sm_to_cmip.util import print_message +from e3sm_to_cmip.util import setup_cmor, print_message -logger = _setup_logger(__name__) +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) # list of raw variable names needed RAW_VARIABLES = [str("FISCCP1_COSP")] @@ -59,35 +58,23 @@ def handle( # noqa: C901 If CMORizing was successful, return the output CMIP variable name to indicate success. If failed, return None .""" - logging.info(f"Starting {VAR_NAME}") + logger.info(f"Starting {VAR_NAME}") nonzero = False for variable in RAW_VARIABLES: if len(vars_to_filepaths[variable]) == 0: msg = f"{variable}: Unable to find input files for {RAW_VARIABLES}" print_message(msg) - logging.error(msg) + logger.error(msg) nonzero = True if nonzero: return None - msg = f"{VAR_NAME}: running with input files: {vars_to_filepaths}" - logger.debug(msg) + logger.debug(f"{VAR_NAME}: running with input files: {vars_to_filepaths}") - if logdir is not None: - logfile = logfile = os.path.join(logdir, VAR_NAME + ".log") - else: - logfile = os.path.join(os.getcwd(), "logs") - if not os.path.exists(logfile): - os.makedirs(logfile) - logfile = os.path.join(logfile, VAR_NAME + ".log") + setup_cmor(VAR_NAME, tables, TABLE, metadata_path) - cmor.setup(inpath=tables, netcdf_file_action=cmor.CMOR_REPLACE, logfile=logfile) - cmor.dataset_json(metadata_path) - cmor.load_table(TABLE) - - msg = f"{VAR_NAME}: CMOR setup complete" - logger.info(msg) + logger.info(f"{VAR_NAME}: CMOR setup complete") data: Dict[str, Union[np.ndarray, xr.DataArray]] = {} @@ -164,8 +151,7 @@ def handle( # noqa: C901 varid = cmor.variable(VAR_NAME, VAR_UNITS, axis_ids) # write out the data - msg = f"{VAR_NAME}: time {data['time_bnds'][0][0]:1.1f} - {data['time_bnds'][-1][-1]:1.1f}" - logger.info(msg) + logger.info(f"{VAR_NAME}: time {data['time_bnds'][0][0]:1.1f} - {data['time_bnds'][-1][-1]:1.1f}") cmor.write( varid, @@ -174,11 +160,9 @@ def handle( # noqa: C901 time_bnds=data["time_bnds"], ) - msg = f"{VAR_NAME}: write complete, closing" - logger.info(msg) + logger.info(f"{VAR_NAME}: write complete, closing") cmor.close() - msg = f"{VAR_NAME}: file close complete" - logger.info(msg) + logger.info(f"{VAR_NAME}: file close complete") return VAR_NAME diff --git a/e3sm_to_cmip/cmor_handlers/vars/orog.py b/e3sm_to_cmip/cmor_handlers/vars/orog.py index 6767e71b..c17aa02e 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/orog.py +++ b/e3sm_to_cmip/cmor_handlers/vars/orog.py @@ -4,7 +4,6 @@ from __future__ import absolute_import, division, print_function, unicode_literals import json -import logging import os import numpy as np @@ -12,11 +11,11 @@ import cmor from e3sm_to_cmip import resources -from e3sm_to_cmip._logger import _setup_logger from e3sm_to_cmip.mpas import write_netcdf -from e3sm_to_cmip.util import print_message +from e3sm_to_cmip.util import setup_cmor, print_message -logger = _setup_logger(__name__) +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) # list of raw variable names needed RAW_VARIABLES = [str("PHIS")] @@ -56,8 +55,7 @@ def handle_simple(infiles): def handle(infiles, tables, user_input_path, table, logdir): - msg = f"{VAR_NAME}: Starting" - logger.info(msg) + logger.info(f"{VAR_NAME}: Starting") # check that we have some input files for every variable zerofiles = False @@ -65,32 +63,17 @@ def handle(infiles, tables, user_input_path, table, logdir): if len(infiles[variable]) == 0: msg = f"{VAR_NAME}: Unable to find input files for {variable}" print_message(msg) - logging.error(msg) + logger.error(msg) zerofiles = True if zerofiles: return None - # Create the logging directory and setup cmor - if logdir: - logpath = logdir - else: - outpath, _ = os.path.split(logger.__dict__["handlers"][0].baseFilename) - logpath = os.path.join(outpath, "cmor_logs") - os.makedirs(logpath, exist_ok=True) + setup_cmor(VAR_NAME, tables, TABLE, user_input_path) - logfile = os.path.join(logpath, VAR_NAME + ".log") - - cmor.setup(inpath=tables, netcdf_file_action=cmor.CMOR_REPLACE, logfile=logfile) - - cmor.dataset_json(str(user_input_path)) - cmor.load_table(str(TABLE)) - - msg = "{}: CMOR setup complete".format(VAR_NAME) - logging.info(msg) + logger.info(f"{VAR_NAME}: CMOR setup complete") # extract data from the input file - msg = "orog: loading PHIS" - logger.info(msg) + logger.info("orog: loading PHIS") filename = infiles["PHIS"][0] @@ -108,8 +91,7 @@ def handle(infiles, tables, user_input_path, table, logdir): "PHIS": ds["PHIS"], } - msg = f"{VAR_NAME}: loading axes" - logger.info(msg) + logger.info(f"{VAR_NAME}: loading axes") axes = [ { @@ -126,8 +108,7 @@ def handle(infiles, tables, user_input_path, table, logdir): }, ] - msg = "orog: running CMOR" - logging.info(msg) + logger.info("orog: running CMOR") axis_ids = list() for axis in axes: @@ -139,12 +120,10 @@ def handle(infiles, tables, user_input_path, table, logdir): outdata = data["PHIS"].values / GRAV cmor.write(varid, outdata) - msg = "{}: write complete, closing".format(VAR_NAME) - logger.debug(msg) + logger.debug(f"{VAR_NAME}: write complete, closing") cmor.close() - msg = "{}: file close complete".format(VAR_NAME) - logger.debug(msg) + logger.debug(f"{VAR_NAME}: file close complete") - return "orog" + return VARNAME diff --git a/e3sm_to_cmip/cmor_handlers/vars/sftlf.py b/e3sm_to_cmip/cmor_handlers/vars/sftlf.py index 0a5f4da2..0401458e 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/sftlf.py +++ b/e3sm_to_cmip/cmor_handlers/vars/sftlf.py @@ -4,7 +4,6 @@ from __future__ import absolute_import, division, print_function, unicode_literals import json -import logging import os import numpy as np @@ -12,11 +11,11 @@ import cmor from e3sm_to_cmip import resources -from e3sm_to_cmip._logger import _setup_logger from e3sm_to_cmip.mpas import write_netcdf -from e3sm_to_cmip.util import print_message +from e3sm_to_cmip.util import setup_cmor, print_message -logger = _setup_logger(__name__) +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) # list of raw variable names needed RAW_VARIABLES = [str("LANDFRAC")] @@ -55,8 +54,7 @@ def handle_simple(infiles): def handle(infiles, tables, user_input_path, table, logdir): - msg = f"{VAR_NAME}: Starting" - logger.info(msg) + logger.info(f"{VAR_NAME}: Starting") # check that we have some input files for every variable zerofiles = False @@ -64,32 +62,17 @@ def handle(infiles, tables, user_input_path, table, logdir): if len(infiles[variable]) == 0: msg = f"{VAR_NAME}: Unable to find input files for {variable}" print_message(msg) - logging.error(msg) + logger.error(msg) zerofiles = True if zerofiles: return None - # Create the logging directory and setup cmor - if logdir: - logpath = logdir - else: - outpath, _ = os.path.split(logger.__dict__["handlers"][0].baseFilename) - logpath = os.path.join(outpath, "cmor_logs") - os.makedirs(logpath, exist_ok=True) + setup_cmor(VAR_NAME, tables, TABLE, user_input_path) - logfile = os.path.join(logpath, VAR_NAME + ".log") - - cmor.setup(inpath=tables, netcdf_file_action=cmor.CMOR_REPLACE, logfile=logfile) - - cmor.dataset_json(str(user_input_path)) - cmor.load_table(str(TABLE)) - - msg = "{}: CMOR setup complete".format(VAR_NAME) - logging.info(msg) + logger.info(f"{VAR_NAME}: CMOR setup complete") # extract data from the input file - msg = "sftlf: loading LANDFRAC" - logger.info(msg) + logger.info("sftlf: loading LANDFRAC") filename = infiles["LANDFRAC"][0] @@ -107,8 +90,7 @@ def handle(infiles, tables, user_input_path, table, logdir): "LANDFRAC": ds["LANDFRAC"], } - msg = f"{VAR_NAME}: loading axes" - logger.info(msg) + logger.info(f"{VAR_NAME}: loading axes") axes = [ { @@ -125,8 +107,7 @@ def handle(infiles, tables, user_input_path, table, logdir): }, ] - msg = "sftlf: running CMOR" - logging.info(msg) + logger.info(f"{VAR_NAME}: running CMOR") axis_ids = list() for axis in axes: @@ -138,12 +119,10 @@ def handle(infiles, tables, user_input_path, table, logdir): outdata = data["LANDFRAC"].values * 100.0 cmor.write(varid, outdata) - msg = "{}: write complete, closing".format(VAR_NAME) - logger.debug(msg) + logger.debug(f"{VAR_NAME}: write complete, closing") cmor.close() - msg = "{}: file close complete".format(VAR_NAME) - logger.debug(msg) + logger.debug(f"{VAR_NAME}: file close complete") - return "sftlf" + return VAR_NAME diff --git a/e3sm_to_cmip/mpas.py b/e3sm_to_cmip/mpas.py index 755db9e1..0e56c98e 100644 --- a/e3sm_to_cmip/mpas.py +++ b/e3sm_to_cmip/mpas.py @@ -5,7 +5,6 @@ from __future__ import absolute_import, division, print_function import argparse -import logging import multiprocessing import os import re @@ -23,21 +22,22 @@ import xarray from dask.diagnostics import ProgressBar +from e3sm_to_cmip._logger import e2c_logger +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def run_ncremap_cmd(args, env): - logtext = f"mpas.py: remap: ncremap args = {args}" - logging.info(logtext) proc = subprocess.Popen( args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env ) (out, err) = proc.communicate() - logging.info(out) + if proc.returncode: - print("Error running ncremap command: {}".format(" ".join(args))) + arglist = " ".join(args) + logger.error(f"Error running ncremap command: {arglist}") print(err.decode("utf-8")) raise subprocess.CalledProcessError( # type: ignore - "ncremap returned {}".format(proc.returncode) # type: ignore + f"ncremap returned {proc.returncode}" # type: ignore ) @@ -46,6 +46,9 @@ def remap_seaice_sgs(inFileName, outFileName, mappingFileName, renorm_threshold= ds_in = xarray.open_dataset(inFileName, decode_times=False) outFilePath = f"{outFileName}sub" os.makedirs(outFilePath) + + logger.info(f"Calling run_ncremap_cmd for each ds_slice in {range(ds_in.sizes['time'])}") + for t_index in range(ds_in.sizes["time"]): ds_slice = ds_in.isel(time=slice(t_index, t_index + 1)) ds_slice.to_netcdf(f"{outFilePath}/temp_in{t_index}.nc") @@ -77,13 +80,17 @@ def remap_seaice_sgs(inFileName, outFileName, mappingFileName, renorm_threshold= def remap(ds, pcode, mappingFileName, threshold=0.0): """Use ncreamp to remap the xarray Dataset to a new target grid""" + delete_tempfiles = True + # write the dataset to a temp file inFileName = _get_temp_path() outFileName = _get_temp_path() if "depth" in ds.dims: + logger.info(f"Calling ds.transpose") ds = ds.transpose("time", "depth", "nCells", "nbnd") + logger.info(f"Calling write_netcdf() (inFileName={inFileName})") write_netcdf(ds, inFileName, unlimited="time") # set an environment variable to make sure we're not using czender's @@ -111,6 +118,7 @@ def remap(ds, pcode, mappingFileName, threshold=0.0): inFileName, outFileName, ] + logger.info(f"Calling run_ncremap_cmd with args {args}") run_ncremap_cmd(args, env) elif pcode == "mpasseaice": # MPAS-Seaice is a special case because the of the time-varying SGS field @@ -127,9 +135,10 @@ def remap(ds, pcode, mappingFileName, threshold=0.0): ds.load() - # remove the temporary files - os.remove(inFileName) - os.remove(outFileName) + if delete_tempfiles: + # remove the temporary files + os.remove(inFileName) + os.remove(outFileName) return ds @@ -321,7 +330,6 @@ def open_mfdataset( concat_dim="Time", mask_and_scale=False, chunks=chunks, - lock=False, ) if variableList is not None: @@ -351,6 +359,9 @@ def write_netcdf(ds, fileName, fillValues=netCDF4.default_fillvals, unlimited=No encodingDict = {} variableNames = list(ds.data_vars.keys()) + list(ds.coords.keys()) for variableName in variableNames: + if "_FillValue" in ds[variableName].attrs: + # There's already a fill value attribute so don't add a new one + continue isNumeric = np.issubdtype(ds[variableName].dtype, np.number) if isNumeric: dtype = ds[variableName].dtype @@ -395,29 +406,9 @@ def convert_namelist_to_dict(fileName): return nml -def setup_cmor(varname, tables, user_input_path, component="ocean", table=None): - """Set up CMOR for MPAS-Ocean or MPAS-Seaice""" - logfile = os.path.join(os.getcwd(), "cmor_logs") - if not os.path.exists(logfile): - os.makedirs(logfile) - logfile = os.path.join(logfile, varname + ".log") - cmor.setup(inpath=tables, netcdf_file_action=cmor.CMOR_REPLACE, logfile=logfile) - cmor.dataset_json(str(user_input_path)) - if table is None: - if component == "ocean": - table = "CMIP6_Omon.json" - elif component == "seaice": - table = "CMIP6_SImon.json" - else: - raise ValueError("Unexpected component {}".format(component)) - try: - cmor.load_table(table) - except Exception: - raise ValueError("Unable to load table from {}".format(varname)) - - def write_cmor(axes, ds, varname, varunits, d2f=True, **kwargs): """Write a time series of a variable in the format expected by CMOR""" + axis_ids = list() for axis in axes: axis_id = cmor.axis(**axis) @@ -437,6 +428,10 @@ def write_cmor(axes, ds, varname, varunits, d2f=True, **kwargs): str(varname), str(varunits), axis_ids, missing_value=fillValue, **kwargs ) + # adding "shuffle" reduced size on disk by 14%, need to test for performance impact. + # if varname not in [ "lat", "lev", "lon" ]: + # cmor.set_deflate(varid, True, True, 1) + # write out the data try: if "time" not in ds.dims: @@ -449,7 +444,7 @@ def write_cmor(axes, ds, varname, varunits, d2f=True, **kwargs): time_bnds=ds.time_bnds.values, ) except Exception as error: - logging.exception(f"Error in cmor.write for {varname}") + logger.exception(f"Error in cmor.write for {varname}") raise Exception(error) finally: cmor.close(varid) diff --git a/e3sm_to_cmip/util.py b/e3sm_to_cmip/util.py index 8c57c995..723b76ca 100644 --- a/e3sm_to_cmip/util.py +++ b/e3sm_to_cmip/util.py @@ -14,10 +14,12 @@ import yaml from tqdm import tqdm -from e3sm_to_cmip._logger import _setup_logger +from e3sm_to_cmip._logger import e2c_logger -logger = _setup_logger(__name__) +def instantiate_util_logger(): + global logger + logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) ATMOS_TABLES = [ "CMIP6_Amon.json", @@ -103,24 +105,25 @@ def print_message(message, status="error"): # ------------------------------------------------------------------ -def setup_cmor(var_name, table_path, table_name, user_input_path): +def setup_cmor(varname, table_path, table_name, user_input_path): """ Sets up cmor and logging for a single handler """ - var_name = str(var_name) - table_path = str(table_path) - table_name = str(table_name) - user_input_path = str(user_input_path) - logfile = os.path.join(os.getcwd(), "logs") + logfile = os.path.join(os.getcwd(), "cmor_logs") if not os.path.exists(logfile): os.makedirs(logfile) + logfile = os.path.join(logfile, varname + ".log") - logfile = os.path.join(logfile, var_name + ".log") cmor.setup(inpath=table_path, netcdf_file_action=cmor.CMOR_REPLACE, logfile=logfile) - cmor.dataset_json(user_input_path) - cmor.load_table(table_name) + cmor.dataset_json(str(user_input_path)) + + try: + cmor.load_table(table_name) + except Exception: + raise ValueError(f"Unable to load table {table_name} for {varname}") + # ------------------------------------------------------------------ @@ -561,7 +564,7 @@ def find_mpas_files(component, path, map_path=None): # noqa: C901 pattern_v2 = "mocBasinsAndTransects" for infile in contents: if pattern_v1 in infile or pattern_v2 in infile: - logger.info(f"component mpas0_moc_regions found: {infile}") + logger.info(f"component mpaso_moc_regions found: {infile}") return os.path.abspath(os.path.join(path, infile)) raise IOError("Unable to find mpaso_moc_regions in the input directory") From 580a1a4f65f325f428edc89360cef6976538c5df Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Thu, 27 Jun 2024 15:03:35 -0700 Subject: [PATCH 02/25] revert handler cmor setup to logfile --- e3sm_to_cmip/cmor_handlers/handler.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/e3sm_to_cmip/cmor_handlers/handler.py b/e3sm_to_cmip/cmor_handlers/handler.py index 655df5c1..4212745f 100644 --- a/e3sm_to_cmip/cmor_handlers/handler.py +++ b/e3sm_to_cmip/cmor_handlers/handler.py @@ -322,18 +322,18 @@ def _setup_cmor_module( logdir : str | None The optional log directory. """ - # if log_dir is not None: - # logpath = log_dir - # else: - # cwd = os.getcwd() - # logpath = os.path.join(cwd, "cmor_logs") + if log_dir is not None: + logpath = log_dir + else: + cwd = os.getcwd() + logpath = os.path.join(cwd, "cmor_logs") - # os.makedirs(logpath, exist_ok=True) - # logfile = os.path.join(logpath, var_name + ".log") + os.makedirs(logpath, exist_ok=True) + logfile = os.path.join(logpath, var_name + ".log") print("DEBUG: EMPLOYED HANDLER.PY _setup_cmor_module()", flush=True) - cmor.setup(inpath=tables_path, netcdf_file_action=cmor.CMOR_REPLACE,logfile="/dev/null") + cmor.setup(inpath=tables_path, netcdf_file_action=cmor.CMOR_REPLACE,logfile=logfile) cmor.dataset_json(metadata_path) cmor.load_table(self.table) From 0a380d4d64c54bff57052f3c107edc75f0d8f51d Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Thu, 27 Jun 2024 15:27:29 -0700 Subject: [PATCH 03/25] add commentary on do_shuffle and delete_tempfiles as future flags --- e3sm_to_cmip/mpas.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/e3sm_to_cmip/mpas.py b/e3sm_to_cmip/mpas.py index 0e56c98e..615197ce 100644 --- a/e3sm_to_cmip/mpas.py +++ b/e3sm_to_cmip/mpas.py @@ -80,6 +80,7 @@ def remap_seaice_sgs(inFileName, outFileName, mappingFileName, renorm_threshold= def remap(ds, pcode, mappingFileName, threshold=0.0): """Use ncreamp to remap the xarray Dataset to a new target grid""" + # TODO: Make this a global commandline switch delete_tempfiles = True # write the dataset to a temp file @@ -429,7 +430,8 @@ def write_cmor(axes, ds, varname, varunits, d2f=True, **kwargs): ) # adding "shuffle" reduced size on disk by 14%, need to test for performance impact. - # if varname not in [ "lat", "lev", "lon" ]: + # TODO: Pass a commandline arg "--shuffle" down to this point. + # if do_shuffle and varname not in [ "lat", "lev", "lon" ]: # cmor.set_deflate(varid, True, True, 1) # write out the data From 20feb790b9f7eee1aff32ad78d9d8c71f607a626 Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Thu, 27 Jun 2024 15:49:46 -0700 Subject: [PATCH 04/25] minor cleanup --- e3sm_to_cmip/__main__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/e3sm_to_cmip/__main__.py b/e3sm_to_cmip/__main__.py index 973de7b0..314a2bae 100755 --- a/e3sm_to_cmip/__main__.py +++ b/e3sm_to_cmip/__main__.py @@ -311,7 +311,8 @@ def _parse_args(self, args: Optional[List[str]]) -> CLIArguments: sys.exit(1) # Parse the arguments and perform validation. - parsed_args = argparser.parse_args(args_to_parse) # (exits here if args == "-h" or "--help" or "--version") + # NOTE: exits here if args == "-h" or "--help" or "--version", else validate + parsed_args = argparser.parse_args(args_to_parse) self._validate_parsed_args(parsed_args) @@ -785,7 +786,9 @@ def _run_serial(self) -> int: # noqa: C901 1 if an error occurs, else 0 """ + # TODO: Make this a command-line flag. do_pbar = False + try: num_handlers = len(self.handlers) num_success = 0 @@ -884,6 +887,7 @@ def _run_parallel(self) -> int: # noqa: C901 pool_res = list() will_run = [] + # NOTE: Make this a command-line flag. do_pbar = False for idx, handler in enumerate(self.handlers): @@ -992,8 +996,8 @@ def main(args: Optional[List[str]] = None): app = E3SMtoCMIP(args) - # These calls allow loggers that create default logfiles to avoid being - # instantiated by arguments "--help" or "--version". + # These calls allow module loggers that create default logfiles to avoid being + # instantiated by arguments "--help" or "--version" upon import. instantiate_util_logger() instantiate_h_utils_logger() instantiate_handler_logger() From 1aea912a918ecc5df16612de58c1de7871ff3852 Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Thu, 27 Jun 2024 15:56:35 -0700 Subject: [PATCH 05/25] minor cleanup --- e3sm_to_cmip/cmor_handlers/handler.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/e3sm_to_cmip/cmor_handlers/handler.py b/e3sm_to_cmip/cmor_handlers/handler.py index 4212745f..87ade4e0 100644 --- a/e3sm_to_cmip/cmor_handlers/handler.py +++ b/e3sm_to_cmip/cmor_handlers/handler.py @@ -331,9 +331,7 @@ def _setup_cmor_module( os.makedirs(logpath, exist_ok=True) logfile = os.path.join(logpath, var_name + ".log") - print("DEBUG: EMPLOYED HANDLER.PY _setup_cmor_module()", flush=True) - - cmor.setup(inpath=tables_path, netcdf_file_action=cmor.CMOR_REPLACE,logfile=logfile) + cmor.setup(inpath=tables_path, netcdf_file_action=cmor.CMOR_REPLACE, logfile=logfile) cmor.dataset_json(metadata_path) cmor.load_table(self.table) From 811d208af3b45ca91bfb485f4b614a0a36ef72fb Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Wed, 10 Jul 2024 13:34:12 -0700 Subject: [PATCH 06/25] convert mpas handlers setup_cmor calls to employ named parameters --- e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/so.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py | 2 +- 41 files changed, 41 insertions(+), 41 deletions(-) diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py index b8d2b867..e85af48c 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py @@ -66,7 +66,7 @@ def handle(infiles, tables, user_input_path, **kwargs): # area_b is in square radians, so need to multiply by the earth_radius**2 ds[VAR_NAME] = earth_radius**2*area_b*ds[VAR_NAME] - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'latitude', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py index b6d097ba..1cc9baf1 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py @@ -62,7 +62,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py index 6d4fdf25..8d629665 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py @@ -74,7 +74,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py index 83cd202f..28236818 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py @@ -77,7 +77,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py index 4a7dc32c..3962cab2 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py @@ -78,7 +78,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds[VAR_NAME] = ds[VAR_NAME].where( ds[VAR_NAME] != netCDF4.default_fillvals['f4'], 0.) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py index 085fbfd5..2f16bcc0 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py @@ -70,7 +70,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.add_time(ds, dsIn) ds.compute() - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py index 079eeadb..6ae36f42 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py @@ -67,7 +67,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.add_mask(ds, cellMask2D) ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py index 70d28ec1..8170aa77 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py @@ -77,7 +77,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = ds.rename({'moc': VAR_NAME}) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) region = ['global_ocean', 'atlantic_arctic_ocean'] diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py index 0c233744..3c63538a 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py @@ -85,7 +85,7 @@ def handle(infiles, tables, user_input_path, **kwargs): with xarray.open_mfdataset(pslFileNames, concat_dim='time') as dsIn: ds[VAR_NAME] = ds[VAR_NAME] + dsIn.PSL.values - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py index ed694d01..d6454aba 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py @@ -81,7 +81,7 @@ def handle(infiles, tables, user_input_path, **kwargs): with xarray.open_mfdataset(pslFileNames, concat_dim='time') as dsIn: ds[VAR_NAME] = ds[VAR_NAME] + dsIn.PSL.values - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py index f4e368e0..5fa6d8d2 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py @@ -62,7 +62,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py index 6c7ad22d..aea2798f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py @@ -64,7 +64,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py index 158d8df9..1cda7ec1 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py @@ -63,7 +63,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py index e1d31269..5269447f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py index 57ebadb4..c59f6e3d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py index 7868a573..3ea12bbc 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py @@ -67,7 +67,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py index 70cf0ae5..3008f06f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py @@ -67,7 +67,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py index 4645555b..886a01a8 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py @@ -66,7 +66,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py index a3bc3c1a..ca6e233d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py @@ -70,7 +70,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py index 0306ffa4..74a160b6 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py @@ -71,7 +71,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasseaice', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py index 5c5f3a20..0e684291 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py index ed411d77..38e6951c 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py index 16dd324d..e992ec42 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py @@ -71,7 +71,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.add_time(ds, dsIn) ds.compute() - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py index 0367f837..9c928df5 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py index 932bcc9e..6eb80383 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py @@ -67,7 +67,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds.compute() ds.compute() - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py index 1e78aa7c..a5a64b50 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py @@ -62,7 +62,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py index 703d753d..72e17edf 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py @@ -62,7 +62,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py index 2d2649c3..c5feeaf3 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py index 3826740a..dc8bf9bf 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py @@ -71,7 +71,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.add_time(ds, dsIn) ds.compute() - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py index a1500075..b3906fdb 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py @@ -78,7 +78,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds[VAR_NAME] = ds[VAR_NAME].where( ds[VAR_NAME] != netCDF4.default_fillvals['f4'], 0.) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py index ac5ce720..1e00f230 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py index a1e6b9ae..8968156d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py index 7d390051..f73573e7 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py @@ -67,7 +67,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds.compute() ds.compute() - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py index b6a5bb1d..a6e1849f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py index 0317ebc7..e43e77ca 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py index 3e087dfb..937363c4 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py @@ -86,7 +86,7 @@ def handle(infiles, tables, user_input_path, **kwargs): # multiply variables in this order so they don't get transposed ds[VAR_NAME] = ds[VAR_NAME]*earth_radius**2*area_b - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py index 01c406fa..dcb2d5a0 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds.compute() - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py index a7b87ffd..c590c025 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py @@ -72,7 +72,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py index 1b2f98f2..c1b47ecd 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py @@ -71,7 +71,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py index 54dea42d..0a8c3d20 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py @@ -92,7 +92,7 @@ def handle(infiles, tables, user_input_path, **kwargs): depth_coord_half = numpy.zeros(nVertLevels+1) depth_coord_half[1:] = dsMesh.refBottomDepth.values - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py index b2686bbc..f4ed201d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py @@ -70,7 +70,7 @@ def handle(infiles, tables, user_input_path, **kwargs): ds = mpas.remap(ds, 'mpasocean', mappingFileName) - util.setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + util.setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) # create axes axes = [{'table_entry': 'time', From 14c50efae528d5932b8104f69ac9f88e22a5b139 Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Wed, 10 Jul 2024 13:53:59 -0700 Subject: [PATCH 07/25] converted residual var handlers to call setup_cmor with named parameters --- e3sm_to_cmip/cmor_handlers/vars/areacella.py | 2 +- e3sm_to_cmip/cmor_handlers/vars/clisccp.py | 2 +- e3sm_to_cmip/cmor_handlers/vars/orog.py | 2 +- e3sm_to_cmip/cmor_handlers/vars/sftlf.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/e3sm_to_cmip/cmor_handlers/vars/areacella.py b/e3sm_to_cmip/cmor_handlers/vars/areacella.py index f23d8b8b..7f2cae3c 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/areacella.py +++ b/e3sm_to_cmip/cmor_handlers/vars/areacella.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, table, logdir): if zerofiles: return None - setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) logger.info(f"{VAR_NAME}: CMOR setup complete") diff --git a/e3sm_to_cmip/cmor_handlers/vars/clisccp.py b/e3sm_to_cmip/cmor_handlers/vars/clisccp.py index f07b4ddb..37ecaa0d 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/clisccp.py +++ b/e3sm_to_cmip/cmor_handlers/vars/clisccp.py @@ -72,7 +72,7 @@ def handle( # noqa: C901 logger.debug(f"{VAR_NAME}: running with input files: {vars_to_filepaths}") - setup_cmor(VAR_NAME, tables, TABLE, metadata_path) + setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=metadata_path) logger.info(f"{VAR_NAME}: CMOR setup complete") diff --git a/e3sm_to_cmip/cmor_handlers/vars/orog.py b/e3sm_to_cmip/cmor_handlers/vars/orog.py index c17aa02e..dded14ce 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/orog.py +++ b/e3sm_to_cmip/cmor_handlers/vars/orog.py @@ -68,7 +68,7 @@ def handle(infiles, tables, user_input_path, table, logdir): if zerofiles: return None - setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) logger.info(f"{VAR_NAME}: CMOR setup complete") diff --git a/e3sm_to_cmip/cmor_handlers/vars/sftlf.py b/e3sm_to_cmip/cmor_handlers/vars/sftlf.py index 0401458e..243da904 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/sftlf.py +++ b/e3sm_to_cmip/cmor_handlers/vars/sftlf.py @@ -67,7 +67,7 @@ def handle(infiles, tables, user_input_path, table, logdir): if zerofiles: return None - setup_cmor(VAR_NAME, tables, TABLE, user_input_path) + setup_cmor(var_name=VAR_NAME, table_path=tables, table_name=TABLE, user_input_path=user_input_path) logger.info(f"{VAR_NAME}: CMOR setup complete") From c2bf7396e53f99b80c5c72f162497faa4cd497a5 Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Wed, 10 Jul 2024 13:57:04 -0700 Subject: [PATCH 08/25] changed varname to var_name in util setup_cmor to match named params in handler calls. --- e3sm_to_cmip/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e3sm_to_cmip/util.py b/e3sm_to_cmip/util.py index 723b76ca..076d1e0d 100644 --- a/e3sm_to_cmip/util.py +++ b/e3sm_to_cmip/util.py @@ -105,7 +105,7 @@ def print_message(message, status="error"): # ------------------------------------------------------------------ -def setup_cmor(varname, table_path, table_name, user_input_path): +def setup_cmor(var_name, table_path, table_name, user_input_path): """ Sets up cmor and logging for a single handler """ @@ -113,7 +113,7 @@ def setup_cmor(varname, table_path, table_name, user_input_path): logfile = os.path.join(os.getcwd(), "cmor_logs") if not os.path.exists(logfile): os.makedirs(logfile) - logfile = os.path.join(logfile, varname + ".log") + logfile = os.path.join(logfile, var_name + ".log") cmor.setup(inpath=table_path, netcdf_file_action=cmor.CMOR_REPLACE, logfile=logfile) @@ -122,7 +122,7 @@ def setup_cmor(varname, table_path, table_name, user_input_path): try: cmor.load_table(table_name) except Exception: - raise ValueError(f"Unable to load table {table_name} for {varname}") + raise ValueError(f"Unable to load table {table_name} for {var_name}") From fe151b37793e38349465f718860c4140c59bbb03 Mon Sep 17 00:00:00 2001 From: TonyB9000 <57807130+TonyB9000@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:41:50 -0700 Subject: [PATCH 09/25] Update e3sm_to_cmip/_logger.py Co-authored-by: Tom Vo --- e3sm_to_cmip/_logger.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/e3sm_to_cmip/_logger.py b/e3sm_to_cmip/_logger.py index bcf08ecf..8c16067e 100644 --- a/e3sm_to_cmip/_logger.py +++ b/e3sm_to_cmip/_logger.py @@ -17,9 +17,6 @@ default_log = f"{default_log_dir}/e2c_root_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log" def e2c_logger(name=None, logfilename=default_log, set_log_level=None, to_console=False, to_logfile=False, propagate=False): - - # print(f"DEBUG: _logger: entered e2c_logger at {datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')} called by {name}", flush=True) - default_log_lvl = logging.DEBUG # create logging directory as required From cd381e8017ac8a6c05719b97279be5d730f6bfd9 Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Tue, 16 Jul 2024 16:11:39 -0700 Subject: [PATCH 10/25] applied suggested changes to PR --- e3sm_to_cmip/_logger.py | 16 ++++++---------- e3sm_to_cmip/mpas.py | 2 -- e3sm_to_cmip/util.py | 1 - 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/e3sm_to_cmip/_logger.py b/e3sm_to_cmip/_logger.py index bcf08ecf..ee296843 100644 --- a/e3sm_to_cmip/_logger.py +++ b/e3sm_to_cmip/_logger.py @@ -13,16 +13,12 @@ propagate=[True|False] [default = False] ''' -default_log_dir = "e2c_logs" -default_log = f"{default_log_dir}/e2c_root_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log" +DEFAULT_LOG_LEVEL = logging.DEBUG -def e2c_logger(name=None, logfilename=default_log, set_log_level=None, to_console=False, to_logfile=False, propagate=False): +DEFAULT_LOG_DIR = "e2c_logs" +DEFAULT_LOG = f"{default_log_dir}/e2c_root_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log" - # print(f"DEBUG: _logger: entered e2c_logger at {datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')} called by {name}", flush=True) - - default_log_lvl = logging.DEBUG - - # create logging directory as required +def e2c_logger(name=None, logfilename=DEFAULT_LOG, set_log_level=None, to_console=False, to_logfile=False, propagate=False): if to_logfile: dn = os.path.dirname(logfilename) @@ -36,7 +32,7 @@ def e2c_logger(name=None, logfilename=default_log, set_log_level=None, to_consol logger.propagate = propagate if set_log_level == "None" or set_log_level == "DEBUG": - log_level = default_log_lvl + log_level = DEFAULT_LOG_LEVEL elif set_log_level == "INFO": log_level = logging.INFO elif set_log_level == "WARNING": @@ -45,7 +41,7 @@ def e2c_logger(name=None, logfilename=default_log, set_log_level=None, to_consol log_level = logging.ERROR elif set_log_level == "CRITICAL": log_level = logging.CRITICAL - else: log_level = default_log_lvl + else: log_level = DEFAULT_LOG_LEVEL logger.setLevel(log_level) diff --git a/e3sm_to_cmip/mpas.py b/e3sm_to_cmip/mpas.py index 615197ce..e672d9a3 100644 --- a/e3sm_to_cmip/mpas.py +++ b/e3sm_to_cmip/mpas.py @@ -137,7 +137,6 @@ def remap(ds, pcode, mappingFileName, threshold=0.0): ds.load() if delete_tempfiles: - # remove the temporary files os.remove(inFileName) os.remove(outFileName) @@ -409,7 +408,6 @@ def convert_namelist_to_dict(fileName): def write_cmor(axes, ds, varname, varunits, d2f=True, **kwargs): """Write a time series of a variable in the format expected by CMOR""" - axis_ids = list() for axis in axes: axis_id = cmor.axis(**axis) diff --git a/e3sm_to_cmip/util.py b/e3sm_to_cmip/util.py index 076d1e0d..97006da7 100644 --- a/e3sm_to_cmip/util.py +++ b/e3sm_to_cmip/util.py @@ -109,7 +109,6 @@ def setup_cmor(var_name, table_path, table_name, user_input_path): """ Sets up cmor and logging for a single handler """ - logfile = os.path.join(os.getcwd(), "cmor_logs") if not os.path.exists(logfile): os.makedirs(logfile) From f8aeaddfbf309f23ae6d940a3f21b7505ad5034a Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Tue, 16 Jul 2024 17:55:03 -0700 Subject: [PATCH 11/25] cleaned up import listings in handlers --- e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py | 2 +- e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py | 4 +--- e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/so.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py | 3 +-- e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py | 3 +-- e3sm_to_cmip/cmor_handlers/vars/areacella.py | 4 +--- e3sm_to_cmip/cmor_handlers/vars/clisccp.py | 3 +-- e3sm_to_cmip/cmor_handlers/vars/orog.py | 3 +-- e3sm_to_cmip/cmor_handlers/vars/sftlf.py | 3 +-- 45 files changed, 45 insertions(+), 91 deletions(-) diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py index e85af48c..0d745cee 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py @@ -6,7 +6,6 @@ from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPAS_mesh', 'MPAS_map'] @@ -16,6 +15,7 @@ VAR_UNITS = 'm2' TABLE = 'CMIP6_Ofx.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py index 1cc9baf1..3b6851e0 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py @@ -6,9 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -20,6 +17,7 @@ VAR_UNITS = 'kg m-2 s-1' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py index 8d629665..f6ea7a51 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -19,6 +17,7 @@ VAR_UNITS = 'W m-2' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py index 28236818..7dd8701f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -19,6 +17,7 @@ VAR_UNITS = 'W m-2' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py index 3962cab2..a49dea15 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py @@ -7,8 +7,6 @@ import xarray import netCDF4 from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = 'kg m-2' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py index 2f16bcc0..61af9378 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = 'kg' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py index 6ae36f42..caa0517f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py index 8170aa77..7a222e17 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'kg s-1' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py index 3c63538a..031cf9cc 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'Pa' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py index d6454aba..8ae2327c 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'Pa' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py index 5fa6d8d2..4f7792d3 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'kg m-2 s-1' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py index aea2798f..26b07d27 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = '%' TABLE = 'CMIP6_SImon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py index 1cda7ec1..9e69d0ed 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = 'kg m-2' TABLE = 'CMIP6_SImon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py index 5269447f..366252b5 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = 'kg m-2' TABLE = 'CMIP6_SImon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py index c59f6e3d..a151193d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_SImon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py index 3ea12bbc..81516870 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -20,6 +18,7 @@ VAR_UNITS = 'K' TABLE = 'CMIP6_SImon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py index 3008f06f..12517295 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_SImon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py index 886a01a8..e8ca6058 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = '1' TABLE = 'CMIP6_SImon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py index ca6e233d..a3912ebf 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_SImon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py index 74a160b6..cfd45168 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py @@ -9,8 +9,6 @@ from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_console=True, propagate=False) - # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASSI', 'MPAS_mesh', 'MPAS_map'] @@ -19,6 +17,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_SImon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_console=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py index 0e684291..4f22c74b 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py index 38e6951c..68bc9573 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py index e992ec42..96e8c0b9 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py index 9c928df5..29551c97 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py index 6eb80383..6baa9da8 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py index a5a64b50..ef8ab635 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'N m-2' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py index 72e17edf..83a472ab 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'N m-2' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py index c5feeaf3..8e734df4 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py index dc8bf9bf..6e49486f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py index b3906fdb..f4b96eb0 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py @@ -5,8 +5,6 @@ import xarray import netCDF4 from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,6 +15,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py index 1e00f230..5363b0b1 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py index 8968156d..09217fcb 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py index f73573e7..9f8da753 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py index a6e1849f..5ebf9861 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py index e43e77ca..dde854d9 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py index 937363c4..1a929d08 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py @@ -5,8 +5,6 @@ import xarray import netCDF4 from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,6 +15,7 @@ VAR_UNITS = 'm3' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py index dcb2d5a0..46f46b80 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py @@ -7,8 +7,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = 'm3' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py index c590c025..6dc42596 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -18,6 +16,7 @@ VAR_UNITS = 'kg m-2 s-1' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py index c1b47ecd..cc82e40b 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py @@ -7,8 +7,6 @@ import xarray import numpy from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py index 0a8c3d20..5a01b57d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py @@ -7,8 +7,6 @@ import xarray import numpy from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -19,6 +17,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py index f4ed201d..23a350fb 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py @@ -6,8 +6,6 @@ import xarray from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -19,6 +17,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/vars/areacella.py b/e3sm_to_cmip/cmor_handlers/vars/areacella.py index 7f2cae3c..1217524a 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/areacella.py +++ b/e3sm_to_cmip/cmor_handlers/vars/areacella.py @@ -13,10 +13,7 @@ from e3sm_to_cmip import resources from e3sm_to_cmip.mpas import write_netcdf from e3sm_to_cmip.util import setup_cmor, print_message - from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) - # list of raw variable names needed RAW_VARIABLES = [str("area")] VAR_NAME = str("areacella") @@ -24,6 +21,7 @@ TABLE = str("CMIP6_fx.json") RADIUS = 6.37122e6 +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle_simple(infiles): resource_path, _ = os.path.split(os.path.abspath(resources.__file__)) diff --git a/e3sm_to_cmip/cmor_handlers/vars/clisccp.py b/e3sm_to_cmip/cmor_handlers/vars/clisccp.py index 37ecaa0d..a934b084 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/clisccp.py +++ b/e3sm_to_cmip/cmor_handlers/vars/clisccp.py @@ -13,9 +13,7 @@ import cmor from e3sm_to_cmip.util import setup_cmor, print_message - from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) # list of raw variable names needed RAW_VARIABLES = [str("FISCCP1_COSP")] @@ -23,6 +21,7 @@ VAR_UNITS = str("%") TABLE = str("CMIP6_CFmon.json") +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle( # noqa: C901 vars_to_filepaths: Dict[str, List[str]], diff --git a/e3sm_to_cmip/cmor_handlers/vars/orog.py b/e3sm_to_cmip/cmor_handlers/vars/orog.py index dded14ce..cb33c646 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/orog.py +++ b/e3sm_to_cmip/cmor_handlers/vars/orog.py @@ -13,9 +13,7 @@ from e3sm_to_cmip import resources from e3sm_to_cmip.mpas import write_netcdf from e3sm_to_cmip.util import setup_cmor, print_message - from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) # list of raw variable names needed RAW_VARIABLES = [str("PHIS")] @@ -24,6 +22,7 @@ TABLE = str("CMIP6_fx.json") GRAV = 9.80616 +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle_simple(infiles): resource_path, _ = os.path.split(os.path.abspath(resources.__file__)) diff --git a/e3sm_to_cmip/cmor_handlers/vars/sftlf.py b/e3sm_to_cmip/cmor_handlers/vars/sftlf.py index 243da904..b646d437 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/sftlf.py +++ b/e3sm_to_cmip/cmor_handlers/vars/sftlf.py @@ -13,9 +13,7 @@ from e3sm_to_cmip import resources from e3sm_to_cmip.mpas import write_netcdf from e3sm_to_cmip.util import setup_cmor, print_message - from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) # list of raw variable names needed RAW_VARIABLES = [str("LANDFRAC")] @@ -23,6 +21,7 @@ VAR_UNITS = str("%") TABLE = str("CMIP6_fx.json") +logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle_simple(infiles): resource_path, _ = os.path.split(os.path.abspath(resources.__file__)) From 1094638b45fda79b05f0aed2bf0d90dd43757c2f Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Wed, 17 Jul 2024 08:45:30 -0700 Subject: [PATCH 12/25] Employed docstring --- e3sm_to_cmip/_logger.py | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/e3sm_to_cmip/_logger.py b/e3sm_to_cmip/_logger.py index ee296843..a7104f9f 100644 --- a/e3sm_to_cmip/_logger.py +++ b/e3sm_to_cmip/_logger.py @@ -3,15 +3,6 @@ import os from datetime import datetime, timezone -''' - ACCEPTS: - name= - logfilename= [default = e2c_logs/dflt_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log] - log_level= [default = DEBUG] - to_console=[True|False] [default = False] - to_logfile=[True|False] [default = False] - propagate=[True|False] [default = False] -''' DEFAULT_LOG_LEVEL = logging.DEBUG @@ -19,15 +10,35 @@ DEFAULT_LOG = f"{default_log_dir}/e2c_root_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log" def e2c_logger(name=None, logfilename=DEFAULT_LOG, set_log_level=None, to_console=False, to_logfile=False, propagate=False): + """ Return a root or named logger with variable configuration. + Parameters + ---------- + name : str + The name displayed for the logger in messages. + If name == None or name == "__main__", the root logger is returned + logfilename : str + If logfile handling is requested, any logfile may be specified, or else + the default (e2c_logs/dflt_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log) is used. + set_log_level : str + One of { "DEBUG" (default), "INFO", "WARNING", "ERROR", "CRITICAL" } + to_console : boolean + If True, a logging.StreamHandler is supplied. Default = False + to_logfile : boolean + If True, a logging.FileHandler is supplied. Default = False. + propagate : boolean + If True, messages logged are propagated to the root logger. Default = False. + """ + if to_logfile: dn = os.path.dirname(logfilename) if len(dn) and not os.path.exists(dn): os.makedirs(dn) - logger = logging.getLogger(name) if name == None or name == "__main__": logger = logger.root + else: + logger = logging.getLogger(name) logger.propagate = propagate @@ -47,14 +58,17 @@ def e2c_logger(name=None, logfilename=DEFAULT_LOG, set_log_level=None, to_consol logger.handlers = [] + msgfmt = "%(asctime)s_%(msecs)03d:%(levelname)s:%(name)s:%(funcName)s:%(message)s" + datefmt = "%Y%m%d_%H%M%S" + if to_console: logStreamHandler = logging.StreamHandler() - logStreamHandler.setFormatter(logging.Formatter("%(asctime)s_%(msecs)03d:%(levelname)s:%(name)s:%(funcName)s:%(message)s",datefmt="%Y%m%d_%H%M%S")) + logStreamHandler.setFormatter(logging.Formatter(msgfmt, datefmt=datefmt)) logger.addHandler(logStreamHandler) if to_logfile: logFileHandler = logging.FileHandler(logfilename) - logFileHandler.setFormatter(logging.Formatter("%(asctime)s_%(msecs)03d:%(levelname)s:%(name)s:%(funcName)s:%(message)s",datefmt="%Y%m%d_%H%M%S")) + logFileHandler.setFormatter(logging.Formatter(msgfmt, datefmt=datefmt)) logger.addHandler(logFileHandler) return logger From 76490c21f08c3a86ffb230528f95eb8b12261ab2 Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Wed, 17 Jul 2024 10:31:57 -0700 Subject: [PATCH 13/25] addressed Tom Vo's comments and suggestions - phase one. --- e3sm_to_cmip/__main__.py | 24 +++++++++---------- e3sm_to_cmip/_logger.py | 2 +- e3sm_to_cmip/cmor_handlers/handler.py | 4 ++-- .../cmor_handlers/mpas_vars/areacello.py | 4 ++-- .../cmor_handlers/mpas_vars/fsitherm.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py | 4 ++-- .../cmor_handlers/mpas_vars/hfsifrazil.py | 4 ++-- .../cmor_handlers/mpas_vars/masscello.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py | 4 ++-- .../cmor_handlers/mpas_vars/mlotst.py | 4 ++-- .../cmor_handlers/mpas_vars/msftmz.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py | 4 ++-- .../cmor_handlers/mpas_vars/siconc.py | 4 ++-- .../cmor_handlers/mpas_vars/simass.py | 4 ++-- .../cmor_handlers/mpas_vars/sisnmass.py | 4 ++-- .../cmor_handlers/mpas_vars/sisnthick.py | 4 ++-- .../cmor_handlers/mpas_vars/sitemptop.py | 4 ++-- .../cmor_handlers/mpas_vars/sithick.py | 4 ++-- .../cmor_handlers/mpas_vars/sitimefrac.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/so.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py | 4 ++-- .../cmor_handlers/mpas_vars/thetao.py | 4 ++-- .../cmor_handlers/mpas_vars/thetaoga.py | 4 ++-- .../cmor_handlers/mpas_vars/thkcello.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py | 4 ++-- .../cmor_handlers/mpas_vars/volcello.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py | 4 ++-- .../cmor_handlers/mpas_vars/zhalfo.py | 4 ++-- e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py | 4 ++-- e3sm_to_cmip/cmor_handlers/utils.py | 4 ++-- e3sm_to_cmip/cmor_handlers/vars/areacella.py | 4 ++-- e3sm_to_cmip/cmor_handlers/vars/clisccp.py | 4 ++-- e3sm_to_cmip/cmor_handlers/vars/orog.py | 4 ++-- e3sm_to_cmip/cmor_handlers/vars/sftlf.py | 4 ++-- e3sm_to_cmip/mpas.py | 4 ++-- e3sm_to_cmip/util.py | 4 ++-- 51 files changed, 110 insertions(+), 112 deletions(-) diff --git a/e3sm_to_cmip/__main__.py b/e3sm_to_cmip/__main__.py index 314a2bae..43335cbe 100755 --- a/e3sm_to_cmip/__main__.py +++ b/e3sm_to_cmip/__main__.py @@ -23,7 +23,7 @@ from e3sm_to_cmip import ROOT_HANDLERS_DIR, __version__, resources from datetime import datetime, timezone -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip.cmor_handlers.utils import ( instantiate_h_utils_logger, @@ -105,7 +105,7 @@ def __init__(self, args: Optional[List[str]] = None): # Setup this module's logger AFTER args parsed in E3SMtoCMIP init, so that # default log file is NOT created for mere "--help" or "--version" calls. - logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True) + logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True) # NOTE: The order of these attributes align with class CLIArguments. # ====================================================================== @@ -641,14 +641,14 @@ def _setup_dirs_with_paths(self): if not self.simple_mode: copy_user_metadata(self.user_metadata, self.output_path) - # Setup temp storage directory - # temp_path = os.environ.get("TMPDIR") - # if temp_path is None: - # temp_path = f"{self.output_path}/tmp" - # if not os.path.exists(temp_path): - # os.makedirs(temp_path) + Setup temp storage directory + temp_path = os.environ.get("TMPDIR") + if temp_path is None: + temp_path = f"{self.output_path}/tmp" + if not os.path.exists(temp_path): + os.makedirs(temp_path) - # tempfile.tempdir = temp_path + tempfile.tempdir = temp_path def _run_info_mode(self): # noqa: C901 logger.info("--------------------------------------") @@ -828,7 +828,7 @@ def _run_serial(self) -> int: # noqa: C901 } msg = f"Trying to CMORize with handler: {handler}" - logger.critical(msg) + logger.info(msg) # NOTE: We need a try and except statement here for TypeError because # the VarHandler.cmorize method does not use **kwargs, while the handle @@ -887,7 +887,7 @@ def _run_parallel(self) -> int: # noqa: C901 pool_res = list() will_run = [] - # NOTE: Make this a command-line flag. + # TODO: Make this a command-line flag. do_pbar = False for idx, handler in enumerate(self.handlers): @@ -989,8 +989,6 @@ def _timeout_exit(self): logger=None -def main(args: Optional[List[str]] = None): - global logger def main(args: Optional[List[str]] = None): global logger diff --git a/e3sm_to_cmip/_logger.py b/e3sm_to_cmip/_logger.py index a7104f9f..b88ff042 100644 --- a/e3sm_to_cmip/_logger.py +++ b/e3sm_to_cmip/_logger.py @@ -9,7 +9,7 @@ DEFAULT_LOG_DIR = "e2c_logs" DEFAULT_LOG = f"{default_log_dir}/e2c_root_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log" -def e2c_logger(name=None, logfilename=DEFAULT_LOG, set_log_level=None, to_console=False, to_logfile=False, propagate=False): +def _logger(name=None, logfilename=DEFAULT_LOG, set_log_level=None, to_console=False, to_logfile=False, propagate=False): """ Return a root or named logger with variable configuration. Parameters diff --git a/e3sm_to_cmip/cmor_handlers/handler.py b/e3sm_to_cmip/cmor_handlers/handler.py index 87ade4e0..63244eab 100644 --- a/e3sm_to_cmip/cmor_handlers/handler.py +++ b/e3sm_to_cmip/cmor_handlers/handler.py @@ -13,14 +13,14 @@ from e3sm_to_cmip.cmor_handlers import FILL_VALUE, _formulas from e3sm_to_cmip.util import _get_table_for_non_monthly_freq -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger logger=None def instantiate_handler_logger(): global logger - logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=True) + logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=True) # The names for valid hybrid sigma levels. diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py index 0d745cee..7c6fdf05 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py @@ -5,7 +5,7 @@ from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPAS_mesh', 'MPAS_map'] @@ -15,7 +15,7 @@ VAR_UNITS = 'm2' TABLE = 'CMIP6_Ofx.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py index 3b6851e0..2fffa459 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +17,7 @@ VAR_UNITS = 'kg m-2 s-1' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py index f6ea7a51..91c9b338 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +17,7 @@ VAR_UNITS = 'W m-2' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py index 7dd8701f..158e54ff 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +17,7 @@ VAR_UNITS = 'W m-2' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py index a49dea15..608159bf 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py @@ -6,7 +6,7 @@ import xarray import netCDF4 -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = 'kg m-2' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py index 61af9378..f91870b9 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = 'kg' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py index caa0517f..87664547 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py index 7a222e17..37805003 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'kg s-1' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py index 031cf9cc..396edcc2 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'Pa' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py index 8ae2327c..e0df47bf 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'Pa' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py index 4f7792d3..cc9240dc 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'kg m-2 s-1' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py index 26b07d27..e0bf5a5c 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = '%' TABLE = 'CMIP6_SImon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py index 9e69d0ed..47a7d97a 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = 'kg m-2' TABLE = 'CMIP6_SImon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py index 366252b5..6242138f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = 'kg m-2' TABLE = 'CMIP6_SImon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py index a151193d..cf5bbb70 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_SImon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py index 81516870..e11cfe43 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -18,7 +18,7 @@ VAR_UNITS = 'K' TABLE = 'CMIP6_SImon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py index 12517295..47777fb2 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_SImon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py index e8ca6058..b3a8c6b8 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = '1' TABLE = 'CMIP6_SImon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py index a3912ebf..b071e2ad 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_SImon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py index cfd45168..ab940d2b 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py @@ -8,7 +8,7 @@ import xarray from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger # 'MPAS' as a placeholder for raw variables needed RAW_VARIABLES = ['MPASSI', 'MPAS_mesh', 'MPAS_map'] @@ -17,7 +17,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_SImon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_console=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_console=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py index 4f22c74b..dba627a5 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py index 68bc9573..9c4c6ccf 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py index 96e8c0b9..b308686a 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py index 29551c97..d713b983 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py index 6baa9da8..5401fafc 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py index ef8ab635..0bc680cb 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'N m-2' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py index 83a472ab..064fe15f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'N m-2' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py index 8e734df4..7e210086 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py index 6e49486f..a5d02431 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py index f4b96eb0..1a538583 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py @@ -4,7 +4,7 @@ import xarray import netCDF4 -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -15,7 +15,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py index 5363b0b1..86a3e29f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py index 09217fcb..5f164831 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py index 9f8da753..633aa419 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py index 5ebf9861..4db9607e 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py index dde854d9..8a00a44f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py index 1a929d08..81644a85 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py @@ -4,7 +4,7 @@ import xarray import netCDF4 -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -15,7 +15,7 @@ VAR_UNITS = 'm3' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py index 46f46b80..04482a0f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = 'm3' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py index 6dc42596..0ceb2b15 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -16,7 +16,7 @@ VAR_UNITS = 'kg m-2 s-1' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py index cc82e40b..b221ee02 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py @@ -6,7 +6,7 @@ import xarray import numpy -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py index 5a01b57d..b8eaa441 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py @@ -6,7 +6,7 @@ import xarray import numpy -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message # 'MPAS' as a placeholder for raw variables needed @@ -17,7 +17,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py index 23a350fb..3fb571b1 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +17,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/utils.py b/e3sm_to_cmip/cmor_handlers/utils.py index f67232a7..f74ee9bf 100644 --- a/e3sm_to_cmip/cmor_handlers/utils.py +++ b/e3sm_to_cmip/cmor_handlers/utils.py @@ -14,12 +14,12 @@ from e3sm_to_cmip.cmor_handlers.handler import VarHandler from e3sm_to_cmip.util import _get_table_for_non_monthly_freq -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger def instantiate_h_utils_logger(): global logger - logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) + logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) # Type aliases diff --git a/e3sm_to_cmip/cmor_handlers/vars/areacella.py b/e3sm_to_cmip/cmor_handlers/vars/areacella.py index 1217524a..b57c42bf 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/areacella.py +++ b/e3sm_to_cmip/cmor_handlers/vars/areacella.py @@ -13,7 +13,7 @@ from e3sm_to_cmip import resources from e3sm_to_cmip.mpas import write_netcdf from e3sm_to_cmip.util import setup_cmor, print_message -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger # list of raw variable names needed RAW_VARIABLES = [str("area")] VAR_NAME = str("areacella") @@ -21,7 +21,7 @@ TABLE = str("CMIP6_fx.json") RADIUS = 6.37122e6 -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle_simple(infiles): resource_path, _ = os.path.split(os.path.abspath(resources.__file__)) diff --git a/e3sm_to_cmip/cmor_handlers/vars/clisccp.py b/e3sm_to_cmip/cmor_handlers/vars/clisccp.py index a934b084..784579ea 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/clisccp.py +++ b/e3sm_to_cmip/cmor_handlers/vars/clisccp.py @@ -13,7 +13,7 @@ import cmor from e3sm_to_cmip.util import setup_cmor, print_message -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger # list of raw variable names needed RAW_VARIABLES = [str("FISCCP1_COSP")] @@ -21,7 +21,7 @@ VAR_UNITS = str("%") TABLE = str("CMIP6_CFmon.json") -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle( # noqa: C901 vars_to_filepaths: Dict[str, List[str]], diff --git a/e3sm_to_cmip/cmor_handlers/vars/orog.py b/e3sm_to_cmip/cmor_handlers/vars/orog.py index cb33c646..b12c3436 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/orog.py +++ b/e3sm_to_cmip/cmor_handlers/vars/orog.py @@ -13,7 +13,7 @@ from e3sm_to_cmip import resources from e3sm_to_cmip.mpas import write_netcdf from e3sm_to_cmip.util import setup_cmor, print_message -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger # list of raw variable names needed RAW_VARIABLES = [str("PHIS")] @@ -22,7 +22,7 @@ TABLE = str("CMIP6_fx.json") GRAV = 9.80616 -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle_simple(infiles): resource_path, _ = os.path.split(os.path.abspath(resources.__file__)) diff --git a/e3sm_to_cmip/cmor_handlers/vars/sftlf.py b/e3sm_to_cmip/cmor_handlers/vars/sftlf.py index b646d437..17c6947b 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/sftlf.py +++ b/e3sm_to_cmip/cmor_handlers/vars/sftlf.py @@ -13,7 +13,7 @@ from e3sm_to_cmip import resources from e3sm_to_cmip.mpas import write_netcdf from e3sm_to_cmip.util import setup_cmor, print_message -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger # list of raw variable names needed RAW_VARIABLES = [str("LANDFRAC")] @@ -21,7 +21,7 @@ VAR_UNITS = str("%") TABLE = str("CMIP6_fx.json") -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def handle_simple(infiles): resource_path, _ = os.path.split(os.path.abspath(resources.__file__)) diff --git a/e3sm_to_cmip/mpas.py b/e3sm_to_cmip/mpas.py index e672d9a3..4287df24 100644 --- a/e3sm_to_cmip/mpas.py +++ b/e3sm_to_cmip/mpas.py @@ -22,8 +22,8 @@ import xarray from dask.diagnostics import ProgressBar -from e3sm_to_cmip._logger import e2c_logger -logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +from e3sm_to_cmip._logger import _logger +logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) def run_ncremap_cmd(args, env): diff --git a/e3sm_to_cmip/util.py b/e3sm_to_cmip/util.py index 97006da7..8529a94f 100644 --- a/e3sm_to_cmip/util.py +++ b/e3sm_to_cmip/util.py @@ -14,12 +14,12 @@ import yaml from tqdm import tqdm -from e3sm_to_cmip._logger import e2c_logger +from e3sm_to_cmip._logger import _logger def instantiate_util_logger(): global logger - logger = e2c_logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) + logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) ATMOS_TABLES = [ "CMIP6_Amon.json", From 93238fdcec852e360d62d41cfaabb9892056ab1a Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Thu, 18 Jul 2024 08:49:46 -0700 Subject: [PATCH 14/25] fixed typo comment missing initial # --- e3sm_to_cmip/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e3sm_to_cmip/__main__.py b/e3sm_to_cmip/__main__.py index 43335cbe..f91cd037 100755 --- a/e3sm_to_cmip/__main__.py +++ b/e3sm_to_cmip/__main__.py @@ -641,7 +641,7 @@ def _setup_dirs_with_paths(self): if not self.simple_mode: copy_user_metadata(self.user_metadata, self.output_path) - Setup temp storage directory + # Setup temp storage directory temp_path = os.environ.get("TMPDIR") if temp_path is None: temp_path = f"{self.output_path}/tmp" From d670c1f0169fcfcf554dbe3e93e86e827e81f072 Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Thu, 18 Jul 2024 09:08:49 -0700 Subject: [PATCH 15/25] corrected case error --- e3sm_to_cmip/_logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e3sm_to_cmip/_logger.py b/e3sm_to_cmip/_logger.py index debce0f0..2bfde8e0 100644 --- a/e3sm_to_cmip/_logger.py +++ b/e3sm_to_cmip/_logger.py @@ -6,7 +6,7 @@ DEFAULT_LOG_LEVEL = logging.DEBUG DEFAULT_LOG_DIR = "e2c_logs" -DEFAULT_LOG = f"{default_log_dir}/e2c_root_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log" +DEFAULT_LOG = f"{DEFAULT_LOG_DIR}/e2c_root_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log" def _logger(name=None, logfilename=DEFAULT_LOG, set_log_level=None, to_console=False, to_logfile=False, propagate=False): """ Return a root or named logger with variable configuration. From 3019e3718f4b3d28f4de4d268316e3230242437c Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Fri, 19 Jul 2024 12:03:40 -0700 Subject: [PATCH 16/25] added global logger explanation --- e3sm_to_cmip/__main__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/e3sm_to_cmip/__main__.py b/e3sm_to_cmip/__main__.py index f91cd037..83db2927 100755 --- a/e3sm_to_cmip/__main__.py +++ b/e3sm_to_cmip/__main__.py @@ -99,12 +99,17 @@ class CLIArguments: class E3SMtoCMIP: def __init__(self, args: Optional[List[str]] = None): + # logger assignment is moved into __init__ AFTER the call to _parse_args + # to prevent the default logfile directory being created whenever a call + # to "--help" or "--version" is invoked. Doing so, however, makes the + # logger unavailable to the functions in this class unless made global. global logger + # A dictionary of command line arguments. parsed_args = self._parse_args(args) - # Setup this module's logger AFTER args parsed in E3SMtoCMIP init, so that - # default log file is NOT created for mere "--help" or "--version" calls. + # Setup this module's logger AFTER args are parsed in __init__, so that + # default log file is NOT created for "--help" or "--version" calls. logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True) # NOTE: The order of these attributes align with class CLIArguments. @@ -987,10 +992,7 @@ def _timeout_exit(self): print_message("Hit timeout limit, exiting") os.kill(os.getpid(), signal.SIGINT) -logger=None - def main(args: Optional[List[str]] = None): - global logger app = E3SMtoCMIP(args) From d268ca512691f609e05e677078ddc17ef443bf73 Mon Sep 17 00:00:00 2001 From: TonyB9000 <57807130+TonyB9000@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:39:33 -0700 Subject: [PATCH 17/25] Update e3sm_to_cmip/__main__.py Co-authored-by: Tom Vo --- e3sm_to_cmip/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/e3sm_to_cmip/__main__.py b/e3sm_to_cmip/__main__.py index 83db2927..3420e55b 100755 --- a/e3sm_to_cmip/__main__.py +++ b/e3sm_to_cmip/__main__.py @@ -162,7 +162,6 @@ def echo_settings(self): logger.info(f" * precheck_path='{self.precheck_path}'") logger.info(f" * freq='{self.freq}'") logger.info(f" * realm='{self.realm}'") - # logger.info(f" * Writing log output file to: {log_filename}") def run(self): # Setup logger information and print out e3sm_to_cmip CLI arguments. From db96ce2b582ef21ffd457d441c498b9adab1da48 Mon Sep 17 00:00:00 2001 From: TonyB9000 <57807130+TonyB9000@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:40:02 -0700 Subject: [PATCH 18/25] Update e3sm_to_cmip/__main__.py Co-authored-by: Tom Vo --- e3sm_to_cmip/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/e3sm_to_cmip/__main__.py b/e3sm_to_cmip/__main__.py index 3420e55b..147b33a7 100755 --- a/e3sm_to_cmip/__main__.py +++ b/e3sm_to_cmip/__main__.py @@ -969,6 +969,7 @@ def _run_parallel(self) -> int: # noqa: C901 logger.info(msg) except Exception as e: print_debug(e) + if do_pbar: pbar.update(1) From 7e83c4fa1beab8dedab3faf36f944a3f5ad01f37 Mon Sep 17 00:00:00 2001 From: TonyB9000 <57807130+TonyB9000@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:40:20 -0700 Subject: [PATCH 19/25] Update e3sm_to_cmip/__main__.py Co-authored-by: Tom Vo --- e3sm_to_cmip/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/e3sm_to_cmip/__main__.py b/e3sm_to_cmip/__main__.py index 147b33a7..ad9f06ce 100755 --- a/e3sm_to_cmip/__main__.py +++ b/e3sm_to_cmip/__main__.py @@ -975,6 +975,7 @@ def _run_parallel(self) -> int: # noqa: C901 if do_pbar: pbar.close() + pool.shutdown() msg = f"{num_success} of {num_handlers} handlers complete" From 7a1c302edb08afe8655c7a2d3e7f78332bbf66de Mon Sep 17 00:00:00 2001 From: TonyB9000 <57807130+TonyB9000@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:41:12 -0700 Subject: [PATCH 20/25] Update e3sm_to_cmip/_logger.py Co-authored-by: Tom Vo --- e3sm_to_cmip/_logger.py | 1 - 1 file changed, 1 deletion(-) diff --git a/e3sm_to_cmip/_logger.py b/e3sm_to_cmip/_logger.py index 2bfde8e0..c1df34e3 100644 --- a/e3sm_to_cmip/_logger.py +++ b/e3sm_to_cmip/_logger.py @@ -28,7 +28,6 @@ def _logger(name=None, logfilename=DEFAULT_LOG, set_log_level=None, to_console=F propagate : boolean If True, messages logged are propagated to the root logger. Default = False. """ - if to_logfile: dn = os.path.dirname(logfilename) if len(dn) and not os.path.exists(dn): From 2b12405c0e342b4982f8135a22ca69fe5a4ab0ed Mon Sep 17 00:00:00 2001 From: TonyB9000 <57807130+TonyB9000@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:42:30 -0700 Subject: [PATCH 21/25] Update e3sm_to_cmip/cmor_handlers/handler.py Co-authored-by: Tom Vo --- e3sm_to_cmip/cmor_handlers/handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e3sm_to_cmip/cmor_handlers/handler.py b/e3sm_to_cmip/cmor_handlers/handler.py index 63244eab..aa4cfdb4 100644 --- a/e3sm_to_cmip/cmor_handlers/handler.py +++ b/e3sm_to_cmip/cmor_handlers/handler.py @@ -15,7 +15,7 @@ from e3sm_to_cmip.util import _get_table_for_non_monthly_freq from e3sm_to_cmip._logger import _logger -logger=None +logger = None def instantiate_handler_logger(): global logger From 94b4e70ccab17aff62bd74d68e9b3bc754dc3afc Mon Sep 17 00:00:00 2001 From: TonyB9000 <57807130+TonyB9000@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:45:36 -0700 Subject: [PATCH 22/25] Update e3sm_to_cmip/__main__.py Co-authored-by: Tom Vo --- e3sm_to_cmip/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/e3sm_to_cmip/__main__.py b/e3sm_to_cmip/__main__.py index ad9f06ce..8bc27ba8 100755 --- a/e3sm_to_cmip/__main__.py +++ b/e3sm_to_cmip/__main__.py @@ -542,7 +542,6 @@ def _setup_argparser(self) -> argparse.ArgumentParser: "-h", "--help", action="help", - # default=argparse.SUPPRESS, help="show this help message and exit", ) From 6fd16702ea0ad86419295016af7a15d7869e5bad Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Fri, 2 Aug 2024 16:52:57 -0700 Subject: [PATCH 23/25] convert _logger calls to employ logging log_levels directly, updated 40+ modules to include logging module to accommodate, and addressed issues such as spurious newlines, or lack thereof. --- e3sm_to_cmip/__main__.py | 3 +- e3sm_to_cmip/_logger.py | 30 +++++++++---------- e3sm_to_cmip/cmor_handlers/handler.py | 3 +- .../cmor_handlers/mpas_vars/areacello.py | 3 +- .../cmor_handlers/mpas_vars/fsitherm.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py | 3 +- .../cmor_handlers/mpas_vars/hfsifrazil.py | 3 +- .../cmor_handlers/mpas_vars/masscello.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py | 3 +- .../cmor_handlers/mpas_vars/mlotst.py | 3 +- .../cmor_handlers/mpas_vars/msftmz.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py | 3 +- .../cmor_handlers/mpas_vars/siconc.py | 3 +- .../cmor_handlers/mpas_vars/simass.py | 3 +- .../cmor_handlers/mpas_vars/sisnmass.py | 3 +- .../cmor_handlers/mpas_vars/sisnthick.py | 3 +- .../cmor_handlers/mpas_vars/sitemptop.py | 3 +- .../cmor_handlers/mpas_vars/sithick.py | 3 +- .../cmor_handlers/mpas_vars/sitimefrac.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/so.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py | 3 +- .../cmor_handlers/mpas_vars/thetao.py | 3 +- .../cmor_handlers/mpas_vars/thetaoga.py | 3 +- .../cmor_handlers/mpas_vars/thkcello.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py | 3 +- .../cmor_handlers/mpas_vars/volcello.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py | 3 +- .../cmor_handlers/mpas_vars/zhalfo.py | 3 +- e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py | 3 +- e3sm_to_cmip/cmor_handlers/vars/areacella.py | 3 +- e3sm_to_cmip/cmor_handlers/vars/clisccp.py | 3 +- e3sm_to_cmip/cmor_handlers/vars/orog.py | 3 +- e3sm_to_cmip/cmor_handlers/vars/sftlf.py | 3 +- e3sm_to_cmip/mpas.py | 3 +- e3sm_to_cmip/util.py | 3 +- 50 files changed, 112 insertions(+), 65 deletions(-) diff --git a/e3sm_to_cmip/__main__.py b/e3sm_to_cmip/__main__.py index ad9f06ce..39a84266 100755 --- a/e3sm_to_cmip/__main__.py +++ b/e3sm_to_cmip/__main__.py @@ -23,6 +23,7 @@ from e3sm_to_cmip import ROOT_HANDLERS_DIR, __version__, resources from datetime import datetime, timezone +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip.cmor_handlers.utils import ( @@ -110,7 +111,7 @@ def __init__(self, args: Optional[List[str]] = None): # Setup this module's logger AFTER args are parsed in __init__, so that # default log file is NOT created for "--help" or "--version" calls. - logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True) + logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True) # NOTE: The order of these attributes align with class CLIArguments. # ====================================================================== diff --git a/e3sm_to_cmip/_logger.py b/e3sm_to_cmip/_logger.py index c1df34e3..ffcdace5 100644 --- a/e3sm_to_cmip/_logger.py +++ b/e3sm_to_cmip/_logger.py @@ -8,8 +8,16 @@ DEFAULT_LOG_DIR = "e2c_logs" DEFAULT_LOG = f"{DEFAULT_LOG_DIR}/e2c_root_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log" -def _logger(name=None, logfilename=DEFAULT_LOG, set_log_level=None, to_console=False, to_logfile=False, propagate=False): - """ Return a root or named logger with variable configuration. + +def _logger( + name=None, + logfilename=DEFAULT_LOG, + log_level=None, + to_console=False, + to_logfile=False, + propagate=False, +): + """Return a root or named logger with variable configuration. Parameters ---------- @@ -19,8 +27,9 @@ def _logger(name=None, logfilename=DEFAULT_LOG, set_log_level=None, to_console=F logfilename : str If logfile handling is requested, any logfile may be specified, or else the default (e2c_logs/dflt_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log) is used. - set_log_level : str - One of { "DEBUG" (default), "INFO", "WARNING", "ERROR", "CRITICAL" } + log_level : int + One of { logging.DEBUG (default), logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL } + as defined in the module "logging". to_console : boolean If True, a logging.StreamHandler is supplied. Default = False to_logfile : boolean @@ -40,17 +49,8 @@ def _logger(name=None, logfilename=DEFAULT_LOG, set_log_level=None, to_console=F logger.propagate = propagate - if set_log_level == "None" or set_log_level == "DEBUG": + if log_level == None: log_level = DEFAULT_LOG_LEVEL - elif set_log_level == "INFO": - log_level = logging.INFO - elif set_log_level == "WARNING": - log_level = logging.WARNING - elif set_log_level == "ERROR": - log_level = logging.ERROR - elif set_log_level == "CRITICAL": - log_level = logging.CRITICAL - else: log_level = DEFAULT_LOG_LEVEL logger.setLevel(log_level) @@ -70,5 +70,3 @@ def _logger(name=None, logfilename=DEFAULT_LOG, set_log_level=None, to_console=F logger.addHandler(logFileHandler) return logger - - diff --git a/e3sm_to_cmip/cmor_handlers/handler.py b/e3sm_to_cmip/cmor_handlers/handler.py index aa4cfdb4..c722e3db 100644 --- a/e3sm_to_cmip/cmor_handlers/handler.py +++ b/e3sm_to_cmip/cmor_handlers/handler.py @@ -13,6 +13,7 @@ from e3sm_to_cmip.cmor_handlers import FILL_VALUE, _formulas from e3sm_to_cmip.util import _get_table_for_non_monthly_freq +import logging from e3sm_to_cmip._logger import _logger logger = None @@ -20,7 +21,7 @@ def instantiate_handler_logger(): global logger - logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=True) + logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=True) # The names for valid hybrid sigma levels. diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py index 7c6fdf05..07200c44 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/areacello.py @@ -2,6 +2,7 @@ compute Grid-Cell Area for Ocean Variables areacello """ import xarray +import logging from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -15,7 +16,7 @@ VAR_UNITS = 'm2' TABLE = 'CMIP6_Ofx.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py index 2fffa459..eb930a98 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/fsitherm.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = 'kg m-2 s-1' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py index 91c9b338..d0cae9fe 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfds.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = 'W m-2' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py index 158e54ff..bea6a040 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/hfsifrazil.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = 'W m-2' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py index 608159bf..74795aa9 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/masscello.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging import netCDF4 from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util @@ -17,7 +18,7 @@ VAR_UNITS = 'kg m-2' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py index f91870b9..dc810d5e 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/masso.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = 'kg' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py index 87664547..9a774b9f 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/mlotst.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py index 37805003..770b26e3 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/msftmz.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'kg s-1' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py index 396edcc2..2827082a 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/pbo.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'Pa' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py index e0df47bf..def4bdce 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/pso.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'Pa' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py index cc9240dc..56126110 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sfdsi.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'kg m-2 s-1' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py index e0bf5a5c..914e617b 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siconc.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = '%' TABLE = 'CMIP6_SImon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py index 47a7d97a..030b937c 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/simass.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util @@ -17,7 +18,7 @@ VAR_UNITS = 'kg m-2' TABLE = 'CMIP6_SImon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py index 6242138f..6706c7a6 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnmass.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = 'kg m-2' TABLE = 'CMIP6_SImon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py index cf5bbb70..498617ad 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sisnthick.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_SImon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py index e11cfe43..b912e553 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitemptop.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -18,7 +19,7 @@ VAR_UNITS = 'K' TABLE = 'CMIP6_SImon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py index 47777fb2..704e5ca2 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sithick.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_SImon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py index b3a8c6b8..4689a0bd 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sitimefrac.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = '1' TABLE = 'CMIP6_SImon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py index b071e2ad..623e6792 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siu.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_SImon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py index ab940d2b..159d6ba1 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/siv.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message from e3sm_to_cmip._logger import _logger @@ -17,7 +18,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_SImon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_console=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_console=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py index dba627a5..18090935 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/so.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py index 9c4c6ccf..15b501be 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sob.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util @@ -16,7 +17,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py index b308686a..1674635d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/soga.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py index d713b983..dfb70769 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sos.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py index 5401fafc..a89aaa67 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/sosga.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = '0.001' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py index 0bc680cb..5926de7d 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauuo.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'N m-2' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py index 064fe15f..db08ad7a 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tauvo.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'N m-2' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py index 7e210086..fd19d7aa 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetao.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py index a5d02431..6bbff77c 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thetaoga.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py index 1a538583..969fd314 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/thkcello.py @@ -3,6 +3,7 @@ """ import xarray +import logging import netCDF4 from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util @@ -15,7 +16,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py index 86a3e29f..027aefba 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tob.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py index 5f164831..e0607021 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tos.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py index 633aa419..91898ca9 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/tosga.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'degC' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py index 4db9607e..b7498054 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/uo.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py index 8a00a44f..976c9722 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/vo.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py index 81644a85..96f2c534 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/volcello.py @@ -3,6 +3,7 @@ """ import xarray +import logging import netCDF4 from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util @@ -15,7 +16,7 @@ VAR_UNITS = 'm3' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py index 04482a0f..0249dc44 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/volo.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = 'm3' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py index 0ceb2b15..8f3bb5ce 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/wfo.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -16,7 +17,7 @@ VAR_UNITS = 'kg m-2 s-1' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py index b221ee02..59d50de0 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/wo.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging import numpy from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util @@ -17,7 +18,7 @@ VAR_UNITS = 'm s-1' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py index b8eaa441..28189541 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/zhalfo.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging import numpy from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util @@ -17,7 +18,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py b/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py index 3fb571b1..e79f429a 100644 --- a/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py +++ b/e3sm_to_cmip/cmor_handlers/mpas_vars/zos.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import xarray +import logging from e3sm_to_cmip._logger import _logger from e3sm_to_cmip import mpas, util from e3sm_to_cmip.util import print_message @@ -17,7 +18,7 @@ VAR_UNITS = 'm' TABLE = 'CMIP6_Omon.json' -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle(infiles, tables, user_input_path, **kwargs): """ diff --git a/e3sm_to_cmip/cmor_handlers/vars/areacella.py b/e3sm_to_cmip/cmor_handlers/vars/areacella.py index b57c42bf..57fcdd1e 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/areacella.py +++ b/e3sm_to_cmip/cmor_handlers/vars/areacella.py @@ -13,6 +13,7 @@ from e3sm_to_cmip import resources from e3sm_to_cmip.mpas import write_netcdf from e3sm_to_cmip.util import setup_cmor, print_message +import logging from e3sm_to_cmip._logger import _logger # list of raw variable names needed RAW_VARIABLES = [str("area")] @@ -21,7 +22,7 @@ TABLE = str("CMIP6_fx.json") RADIUS = 6.37122e6 -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle_simple(infiles): resource_path, _ = os.path.split(os.path.abspath(resources.__file__)) diff --git a/e3sm_to_cmip/cmor_handlers/vars/clisccp.py b/e3sm_to_cmip/cmor_handlers/vars/clisccp.py index 784579ea..8ace54c6 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/clisccp.py +++ b/e3sm_to_cmip/cmor_handlers/vars/clisccp.py @@ -13,6 +13,7 @@ import cmor from e3sm_to_cmip.util import setup_cmor, print_message +import logging from e3sm_to_cmip._logger import _logger # list of raw variable names needed @@ -21,7 +22,7 @@ VAR_UNITS = str("%") TABLE = str("CMIP6_CFmon.json") -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle( # noqa: C901 vars_to_filepaths: Dict[str, List[str]], diff --git a/e3sm_to_cmip/cmor_handlers/vars/orog.py b/e3sm_to_cmip/cmor_handlers/vars/orog.py index b12c3436..f86b3084 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/orog.py +++ b/e3sm_to_cmip/cmor_handlers/vars/orog.py @@ -13,6 +13,7 @@ from e3sm_to_cmip import resources from e3sm_to_cmip.mpas import write_netcdf from e3sm_to_cmip.util import setup_cmor, print_message +import logging from e3sm_to_cmip._logger import _logger # list of raw variable names needed @@ -22,7 +23,7 @@ TABLE = str("CMIP6_fx.json") GRAV = 9.80616 -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle_simple(infiles): resource_path, _ = os.path.split(os.path.abspath(resources.__file__)) diff --git a/e3sm_to_cmip/cmor_handlers/vars/sftlf.py b/e3sm_to_cmip/cmor_handlers/vars/sftlf.py index 17c6947b..835b7b6e 100644 --- a/e3sm_to_cmip/cmor_handlers/vars/sftlf.py +++ b/e3sm_to_cmip/cmor_handlers/vars/sftlf.py @@ -13,6 +13,7 @@ from e3sm_to_cmip import resources from e3sm_to_cmip.mpas import write_netcdf from e3sm_to_cmip.util import setup_cmor, print_message +import logging from e3sm_to_cmip._logger import _logger # list of raw variable names needed @@ -21,7 +22,7 @@ VAR_UNITS = str("%") TABLE = str("CMIP6_fx.json") -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def handle_simple(infiles): resource_path, _ = os.path.split(os.path.abspath(resources.__file__)) diff --git a/e3sm_to_cmip/mpas.py b/e3sm_to_cmip/mpas.py index 4287df24..25156116 100644 --- a/e3sm_to_cmip/mpas.py +++ b/e3sm_to_cmip/mpas.py @@ -22,8 +22,9 @@ import xarray from dask.diagnostics import ProgressBar +import logging from e3sm_to_cmip._logger import _logger -logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) +logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) def run_ncremap_cmd(args, env): diff --git a/e3sm_to_cmip/util.py b/e3sm_to_cmip/util.py index 8529a94f..56ac3842 100644 --- a/e3sm_to_cmip/util.py +++ b/e3sm_to_cmip/util.py @@ -14,12 +14,13 @@ import yaml from tqdm import tqdm +import logging from e3sm_to_cmip._logger import _logger def instantiate_util_logger(): global logger - logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) + logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) ATMOS_TABLES = [ "CMIP6_Amon.json", From 28f82c512caf809c6e2fd2019087329624bf0df4 Mon Sep 17 00:00:00 2001 From: Tony Bartoletti Date: Mon, 26 Aug 2024 15:07:49 -0700 Subject: [PATCH 24/25] forgot one instance of import logging for defined constant --- e3sm_to_cmip/cmor_handlers/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e3sm_to_cmip/cmor_handlers/utils.py b/e3sm_to_cmip/cmor_handlers/utils.py index f74ee9bf..2bd3a530 100644 --- a/e3sm_to_cmip/cmor_handlers/utils.py +++ b/e3sm_to_cmip/cmor_handlers/utils.py @@ -14,12 +14,13 @@ from e3sm_to_cmip.cmor_handlers.handler import VarHandler from e3sm_to_cmip.util import _get_table_for_non_monthly_freq +import logging from e3sm_to_cmip._logger import _logger def instantiate_h_utils_logger(): global logger - logger = _logger(name=__name__, set_log_level="INFO", to_logfile=True, propagate=False) + logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) # Type aliases From 5e602212c13160efa8f3987766cbdc3942f33b7d Mon Sep 17 00:00:00 2001 From: tomvothecoder Date: Mon, 26 Aug 2024 15:16:36 -0700 Subject: [PATCH 25/25] Code review changes - Add type annotations to `_logger._logger` - Fix import order across modules using `isort` --- e3sm_to_cmip/__main__.py | 65 ++++++++++++++------------- e3sm_to_cmip/_logger.py | 37 +++++++-------- e3sm_to_cmip/cmor_handlers/handler.py | 19 ++++---- e3sm_to_cmip/cmor_handlers/utils.py | 11 +++-- e3sm_to_cmip/mpas.py | 21 +++++---- e3sm_to_cmip/util.py | 12 +++-- 6 files changed, 86 insertions(+), 79 deletions(-) diff --git a/e3sm_to_cmip/__main__.py b/e3sm_to_cmip/__main__.py index 7ba32e4c..17e1a4ee 100755 --- a/e3sm_to_cmip/__main__.py +++ b/e3sm_to_cmip/__main__.py @@ -4,6 +4,7 @@ from __future__ import absolute_import, division, print_function, unicode_literals import argparse +import logging import os import signal import sys @@ -21,33 +22,28 @@ from tqdm import tqdm from e3sm_to_cmip import ROOT_HANDLERS_DIR, __version__, resources -from datetime import datetime, timezone - -import logging from e3sm_to_cmip._logger import _logger - +from e3sm_to_cmip.cmor_handlers.handler import _instantiate_handler_logger from e3sm_to_cmip.cmor_handlers.utils import ( - instantiate_h_utils_logger, MPAS_REALMS, REALMS, Frequency, MPASRealm, Realm, _get_mpas_handlers, + _instantiate_h_utils_logger, derive_handlers, load_all_handlers, ) -from e3sm_to_cmip.cmor_handlers.handler import instantiate_handler_logger - from e3sm_to_cmip.util import ( - instantiate_util_logger, FREQUENCIES, _get_table_info, - get_handler_info_msg, + _instantiate_util_logger, add_metadata, copy_user_metadata, find_atm_files, find_mpas_files, + get_handler_info_msg, precheck, print_debug, print_message, @@ -153,7 +149,7 @@ def __init__(self, args: Optional[List[str]] = None): self.handlers = self._get_handlers() - def echo_settings(self): + def print_config(self): logger.info("--------------------------------------") logger.info("| E3SM to CMIP Configuration") logger.info("--------------------------------------") @@ -422,7 +418,9 @@ def _setup_argparser(self) -> argparse.ArgumentParser: nargs="+", required=True, metavar="", - help=("Space separated list of CMIP variables to convert from E3SM to CMIP."), + help=( + "Space separated list of CMIP variables to convert from E3SM to CMIP." + ), ) optional_run.add_argument( "--realm", @@ -669,7 +667,7 @@ def _run_info_mode(self): # noqa: C901 # if the user asked if the variable is included in the table # but didnt ask about the files in the inpath - elif self.freq and self.tables_path and not self.input_path: # info mode 2 + elif self.freq and self.tables_path and not self.input_path: # info mode 2 for handler in self.handlers: table_info = _get_table_info(self.tables_path, handler["table"]) if handler["name"] not in table_info["variable_entry"]: @@ -677,15 +675,16 @@ def _run_info_mode(self): # noqa: C901 print_message(msg, status="error") continue else: - if self.freq == "mon" and handler['table'] == "CMIP6_day.json": + if self.freq == "mon" and handler["table"] == "CMIP6_day.json": continue - if ( self.freq == "day" or self.freq == "3hr" ) and handler['table'] == "CMIP6_Amon.json": + if (self.freq == "day" or self.freq == "3hr") and handler[ + "table" + ] == "CMIP6_Amon.json": continue hand_msg = get_handler_info_msg(handler) messages.append(hand_msg) - elif self.freq and self.tables_path and self.input_path: # info mode 3 - + elif self.freq and self.tables_path and self.input_path: # info mode 3 file_path = next(Path(self.input_path).glob("*.nc")) with xr.open_dataset(file_path) as ds: @@ -725,9 +724,11 @@ def _run_info_mode(self): # noqa: C901 # but we only want the latter in the "hand_msg" output. # The vars "hass" and "rlut" have multiple freqs. - if self.freq == "mon" and handler['table'] == "CMIP6_day.json": + if self.freq == "mon" and handler["table"] == "CMIP6_day.json": continue - if ( self.freq == "day" or self.freq == "3hr" ) and handler['table'] == "CMIP6_Amon.json": + if (self.freq == "day" or self.freq == "3hr") and handler[ + "table" + ] == "CMIP6_Amon.json": continue hand_msg = None @@ -791,7 +792,7 @@ def _run_serial(self) -> int: # noqa: C901 """ # TODO: Make this a command-line flag. - do_pbar = False + use_pbar = False try: num_handlers = len(self.handlers) @@ -799,7 +800,7 @@ def _run_serial(self) -> int: # noqa: C901 num_failure = 0 name = None - if self.realm != "atm" and do_pbar: + if self.realm != "atm" and use_pbar: pbar = tqdm(total=len(self.handlers)) for _, handler in enumerate(self.handlers): @@ -854,7 +855,7 @@ def _run_serial(self) -> int: # noqa: C901 except Exception as e: print_debug(e) - if name is not None and name is not "": + if name is not None and name != "": num_success += 1 msg = f"Finished {name}, {num_success}/{num_handlers} jobs complete (via run_serial)" logger.info(msg) @@ -863,13 +864,14 @@ def _run_serial(self) -> int: # noqa: C901 msg = f"Error running handler {handler['name']}" logger.info(msg) - if self.realm != "atm" and do_pbar: + if self.realm != "atm" and use_pbar: pbar.update(1) - if self.realm != "atm" and do_pbar: - pbar.close() + if self.realm != "atm" and use_pbar: + pbar.close() except Exception as error: print_debug(error) + return 1 else: msg = f"{num_success} of {num_handlers} handlers complete" @@ -877,6 +879,7 @@ def _run_serial(self) -> int: # noqa: C901 if num_failure > 0: return 1 + return 0 def _run_parallel(self) -> int: # noqa: C901 @@ -993,21 +996,19 @@ def _timeout_exit(self): print_message("Hit timeout limit, exiting") os.kill(os.getpid(), signal.SIGINT) -def main(args: Optional[List[str]] = None): +def main(args: Optional[List[str]] = None): app = E3SMtoCMIP(args) - # These calls allow module loggers that create default logfiles to avoid being + # These calls allow module loggers that create default logfiles to avoid being # instantiated by arguments "--help" or "--version" upon import. - instantiate_util_logger() - instantiate_h_utils_logger() - instantiate_handler_logger() + _instantiate_util_logger() + _instantiate_h_utils_logger() + _instantiate_handler_logger() - app.echo_settings() + app.print_config() return app.run() if __name__ == "__main__": - - main() diff --git a/e3sm_to_cmip/_logger.py b/e3sm_to_cmip/_logger.py index ffcdace5..06d5d43d 100644 --- a/e3sm_to_cmip/_logger.py +++ b/e3sm_to_cmip/_logger.py @@ -1,21 +1,19 @@ -import inspect import logging import os from datetime import datetime, timezone - DEFAULT_LOG_LEVEL = logging.DEBUG DEFAULT_LOG_DIR = "e2c_logs" DEFAULT_LOG = f"{DEFAULT_LOG_DIR}/e2c_root_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log" def _logger( - name=None, - logfilename=DEFAULT_LOG, - log_level=None, - to_console=False, - to_logfile=False, - propagate=False, + name: str | None = None, + logfilename: str = DEFAULT_LOG, + log_level: int = DEFAULT_LOG_LEVEL, + to_console: bool = False, + to_logfile: bool = False, + propagate: bool = False, ): """Return a root or named logger with variable configuration. @@ -28,30 +26,27 @@ def _logger( If logfile handling is requested, any logfile may be specified, or else the default (e2c_logs/dflt_log-{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S_%f')}.log) is used. log_level : int - One of { logging.DEBUG (default), logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL } - as defined in the module "logging". - to_console : boolean - If True, a logging.StreamHandler is supplied. Default = False - to_logfile : boolean - If True, a logging.FileHandler is supplied. Default = False. + Logging.DEBUG (default), logging.INFO, logging.WARNING, logging.ERROR, + or logging.CRITICAL, by default logging.DEBUG. + to_console : bool + If True, a logging.StreamHandler is supplied, by default False. + to_logfile : bool + If True, a logging.FileHandler is supplied, by default False. propagate : boolean - If True, messages logged are propagated to the root logger. Default = False. + If True, messages logged are propagated to the root logger, by default + False. """ if to_logfile: dn = os.path.dirname(logfilename) if len(dn) and not os.path.exists(dn): os.makedirs(dn) - if name == None or name == "__main__": - logger = logger.root + if name is None or name == "__main__": + logger = logger.root # noqa: F821 else: logger = logging.getLogger(name) logger.propagate = propagate - - if log_level == None: - log_level = DEFAULT_LOG_LEVEL - logger.setLevel(log_level) logger.handlers = [] diff --git a/e3sm_to_cmip/cmor_handlers/handler.py b/e3sm_to_cmip/cmor_handlers/handler.py index c722e3db..ab965826 100644 --- a/e3sm_to_cmip/cmor_handlers/handler.py +++ b/e3sm_to_cmip/cmor_handlers/handler.py @@ -2,6 +2,7 @@ import abc import json +import logging import os from typing import Any, Dict, KeysView, List, Literal, Optional, Tuple, TypedDict @@ -11,17 +12,19 @@ import xcdat as xc import yaml +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip.cmor_handlers import FILL_VALUE, _formulas from e3sm_to_cmip.util import _get_table_for_non_monthly_freq -import logging -from e3sm_to_cmip._logger import _logger logger = None -def instantiate_handler_logger(): + +def _instantiate_handler_logger(): global logger - logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=True) + logger = _logger( + name=__name__, log_level=logging.INFO, to_logfile=True, propagate=True + ) # The names for valid hybrid sigma levels. @@ -273,9 +276,7 @@ def cmorize( # the variables. Otherwise, the IDs of cmor objects gets wiped after # every loop. cmor.close() - logger.info( - f"{self.name}: CMORized and file write complete, closing CMOR I/O." - ) + logger.info(f"{self.name}: CMORized and file write complete, closing CMOR I/O.") return self.name @@ -332,7 +333,9 @@ def _setup_cmor_module( os.makedirs(logpath, exist_ok=True) logfile = os.path.join(logpath, var_name + ".log") - cmor.setup(inpath=tables_path, netcdf_file_action=cmor.CMOR_REPLACE, logfile=logfile) + cmor.setup( + inpath=tables_path, netcdf_file_action=cmor.CMOR_REPLACE, logfile=logfile + ) cmor.dataset_json(metadata_path) cmor.load_table(self.table) diff --git a/e3sm_to_cmip/cmor_handlers/utils.py b/e3sm_to_cmip/cmor_handlers/utils.py index 2bd3a530..993fad2c 100644 --- a/e3sm_to_cmip/cmor_handlers/utils.py +++ b/e3sm_to_cmip/cmor_handlers/utils.py @@ -11,16 +11,17 @@ LEGACY_HANDLER_DIR_PATH, MPAS_HANDLER_DIR_PATH, ) +from e3sm_to_cmip._logger import _logger from e3sm_to_cmip.cmor_handlers.handler import VarHandler from e3sm_to_cmip.util import _get_table_for_non_monthly_freq -import logging -from e3sm_to_cmip._logger import _logger -def instantiate_h_utils_logger(): +def _instantiate_h_utils_logger(): global logger - logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) + logger = _logger( + name=__name__, set_log_level="INFO", to_logfile=True, propagate=False + ) # Type aliases @@ -391,5 +392,3 @@ def _get_handlers_from_modules(path: str) -> Dict[str, List[Dict[str, Any]]]: ] return handlers - - diff --git a/e3sm_to_cmip/mpas.py b/e3sm_to_cmip/mpas.py index 25156116..c682cb02 100644 --- a/e3sm_to_cmip/mpas.py +++ b/e3sm_to_cmip/mpas.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function import argparse +import logging import multiprocessing import os import re @@ -22,16 +23,18 @@ import xarray from dask.diagnostics import ProgressBar -import logging from e3sm_to_cmip._logger import _logger -logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) -def run_ncremap_cmd(args, env): +logger = _logger( + name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False +) + +def run_ncremap_cmd(args, env): proc = subprocess.Popen( args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env ) - (out, err) = proc.communicate() + (_, err) = proc.communicate() if proc.returncode: arglist = " ".join(args) @@ -48,7 +51,9 @@ def remap_seaice_sgs(inFileName, outFileName, mappingFileName, renorm_threshold= outFilePath = f"{outFileName}sub" os.makedirs(outFilePath) - logger.info(f"Calling run_ncremap_cmd for each ds_slice in {range(ds_in.sizes['time'])}") + logger.info( + f"Calling run_ncremap_cmd for each ds_slice in {range(ds_in.sizes['time'])}" + ) for t_index in range(ds_in.sizes["time"]): ds_slice = ds_in.isel(time=slice(t_index, t_index + 1)) @@ -89,10 +94,10 @@ def remap(ds, pcode, mappingFileName, threshold=0.0): outFileName = _get_temp_path() if "depth" in ds.dims: - logger.info(f"Calling ds.transpose") + logger.info("Calling ds.transpose") ds = ds.transpose("time", "depth", "nCells", "nbnd") - logger.info(f"Calling write_netcdf() (inFileName={inFileName})") + logger.info(f"Calling write_netcdf() (inFileName={inFileName})") write_netcdf(ds, inFileName, unlimited="time") # set an environment variable to make sure we're not using czender's @@ -120,7 +125,7 @@ def remap(ds, pcode, mappingFileName, threshold=0.0): inFileName, outFileName, ] - logger.info(f"Calling run_ncremap_cmd with args {args}") + logger.info(f"Calling run_ncremap_cmd with args {args}") run_ncremap_cmd(args, env) elif pcode == "mpasseaice": # MPAS-Seaice is a special case because the of the time-varying SGS field diff --git a/e3sm_to_cmip/util.py b/e3sm_to_cmip/util.py index 56ac3842..e97d6659 100644 --- a/e3sm_to_cmip/util.py +++ b/e3sm_to_cmip/util.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, division, print_function, unicode_literals import json +import logging import os import re import sys @@ -14,13 +15,16 @@ import yaml from tqdm import tqdm -import logging from e3sm_to_cmip._logger import _logger -def instantiate_util_logger(): + +def _instantiate_util_logger(): global logger - logger = _logger(name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False) + logger = _logger( + name=__name__, log_level=logging.INFO, to_logfile=True, propagate=False + ) + ATMOS_TABLES = [ "CMIP6_Amon.json", @@ -125,7 +129,6 @@ def setup_cmor(var_name, table_path, table_name, user_input_path): raise ValueError(f"Unable to load table {table_name} for {var_name}") - # ------------------------------------------------------------------ @@ -318,6 +321,7 @@ def _get_table_info(tables, table): with open(table, "r") as instream: return json.load(instream) + def get_handler_info_msg(handler): msg = { "CMIP6 Name": handler["name"],