From b751433c0e8d8c619a359dac83072e2e741cee03 Mon Sep 17 00:00:00 2001 From: Fabien Maussion Date: Fri, 30 Nov 2018 10:51:54 +0100 Subject: [PATCH] Doc: example run_with_spinup --- docs/run_examples/_code/run_with_spinup.py | 10 +++++----- oggm/core/gcm_climate.py | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/run_examples/_code/run_with_spinup.py b/docs/run_examples/_code/run_with_spinup.py index 065810155..31442904f 100644 --- a/docs/run_examples/_code/run_with_spinup.py +++ b/docs/run_examples/_code/run_with_spinup.py @@ -77,12 +77,12 @@ execute_entity_task(task, gdirs) # Additional climate file (CESM) -cfg.PATHS['gcm_temp_file'] = get_demo_file('cesm.TREFHT.160001-200512' - '.selection.nc') -cfg.PATHS['gcm_precc_file'] = get_demo_file('cesm.PRECC.160001-200512' - '.selection.nc') -cfg.PATHS['gcm_precl_file'] = get_demo_file('cesm.PRECL.160001-200512' +cfg.PATHS['cesm_temp_file'] = get_demo_file('cesm.TREFHT.160001-200512' '.selection.nc') +cfg.PATHS['cesm_precc_file'] = get_demo_file('cesm.PRECC.160001-200512' + '.selection.nc') +cfg.PATHS['cesm_precl_file'] = get_demo_file('cesm.PRECL.160001-200512' + '.selection.nc') execute_entity_task(tasks.process_cesm_data, gdirs) # Inversion tasks diff --git a/oggm/core/gcm_climate.py b/oggm/core/gcm_climate.py index 2de0a134c..dfdc8552f 100644 --- a/oggm/core/gcm_climate.py +++ b/oggm/core/gcm_climate.py @@ -164,8 +164,13 @@ def process_cesm_data(gdir, filesuffix='', fpath_temp=None, fpath_precc=None, time_units = nc.variables['time'].units calendar = nc.variables['time'].calendar - time = netCDF4.num2date(tempds.time_bnds[:, 0], time_units, - calendar=calendar) + try: + # xarray v0.11 + time = netCDF4.num2date(tempds.time_bnds[:, 0], time_units, + calendar=calendar) + except TypeError: + # xarray > v0.11 + time = tempds.time_bnds[:, 0].values # select for location lon = gdir.cenlon