Skip to content

Commit

Permalink
Doc: example run_with_spinup
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion committed Nov 30, 2018
1 parent 586ae0f commit a974d8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 5 additions & 5 deletions docs/run_examples/_code/run_with_spinup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions oggm/core/gcm_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a974d8c

Please sign in to comment.