From 5d228656a486dacb3202597b1e1579eea469c57e Mon Sep 17 00:00:00 2001 From: Max Grover Date: Thu, 27 May 2021 08:57:56 -0600 Subject: [PATCH 1/3] deal with times in cesm history file parser better --- ecgtools/parsers/cesm.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ecgtools/parsers/cesm.py b/ecgtools/parsers/cesm.py index fbed9b5..f5fa817 100644 --- a/ecgtools/parsers/cesm.py +++ b/ecgtools/parsers/cesm.py @@ -91,8 +91,14 @@ def parse_cesm_history(file): info['date'] = z[-1].strip('.') break with xr.open_dataset(file, chunks={}, decode_times=False) as ds: - time = ds.cf['time'].name - time_bounds = ds.cf.get_bounds('time').name + time = ds.cf['T'].name + + try: + time_bounds = ds.cf.get_bounds('time').name + + except KeyError: + time_bounds = '' + variables = [ v for v, da in ds.variables.items() From a4e90259d20f4660563165a05587b48e82bf32ae Mon Sep 17 00:00:00 2001 From: Max Grover Date: Thu, 27 May 2021 09:04:30 -0600 Subject: [PATCH 2/3] fix whitespace issue --- ecgtools/parsers/cesm.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ecgtools/parsers/cesm.py b/ecgtools/parsers/cesm.py index f5fa817..e2ba644 100644 --- a/ecgtools/parsers/cesm.py +++ b/ecgtools/parsers/cesm.py @@ -92,13 +92,10 @@ def parse_cesm_history(file): break with xr.open_dataset(file, chunks={}, decode_times=False) as ds: time = ds.cf['T'].name - try: - time_bounds = ds.cf.get_bounds('time').name - + time_bounds = ds.cf.get_bounds('time').name except KeyError: time_bounds = '' - variables = [ v for v, da in ds.variables.items() From 8db1ddf9eb9e23b1901bae7c6dabf00c69cdff19 Mon Sep 17 00:00:00 2001 From: Max Grover Date: Thu, 27 May 2021 09:06:29 -0600 Subject: [PATCH 3/3] fix trailing whitespace --- ecgtools/parsers/cesm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecgtools/parsers/cesm.py b/ecgtools/parsers/cesm.py index e2ba644..cc442d2 100644 --- a/ecgtools/parsers/cesm.py +++ b/ecgtools/parsers/cesm.py @@ -93,7 +93,7 @@ def parse_cesm_history(file): with xr.open_dataset(file, chunks={}, decode_times=False) as ds: time = ds.cf['T'].name try: - time_bounds = ds.cf.get_bounds('time').name + time_bounds = ds.cf.get_bounds('time').name except KeyError: time_bounds = '' variables = [