From 8168bddc217df31c0adab2624f2a44442c9ad8fe Mon Sep 17 00:00:00 2001 From: thopri <thopri@noc.ac.uk> Date: Wed, 22 Apr 2020 09:38:52 +0100 Subject: [PATCH] added try except to catch missing input files due to THREDDS server being down --- pynemo/nemo_bdy_gen_c.py | 6 +++++- pynemo/pynemo_exe.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pynemo/nemo_bdy_gen_c.py b/pynemo/nemo_bdy_gen_c.py index 4f1a295..01b2d39 100644 --- a/pynemo/nemo_bdy_gen_c.py +++ b/pynemo/nemo_bdy_gen_c.py @@ -11,6 +11,7 @@ Ported from Matlab code by James Harle #External Imports import numpy as np import logging +import sys #Local Imports from .utils.nemo_bdy_lib import sub2ind @@ -74,7 +75,10 @@ class Boundary: bdy_msk[grid_ind] = fval # Create padded array for overlays - msk = np.pad(bdy_msk,((1,1),(1,1)), 'constant', constant_values=(-1)) + try: + msk = np.pad(bdy_msk,((1,1),(1,1)), 'constant', constant_values=(-1)) + except ValueError: + raise Exception('the ValueError above is commonly due to PyNEMO not finding the bathymetry/mask file') # create index arrays of I and J coords igrid, jgrid = np.meshgrid(np.arange(bdy_msk.shape[1]), np.arange(bdy_msk.shape[0])) diff --git a/pynemo/pynemo_exe.py b/pynemo/pynemo_exe.py index 7069853..b3a95ee 100644 --- a/pynemo/pynemo_exe.py +++ b/pynemo/pynemo_exe.py @@ -40,7 +40,7 @@ def main(): elif opt in ("-d", "--download_cmems"): setup_file = arg t0 = time.time() - with yaspin(Spinners.earth, text='PyNEMO is running'): + with yaspin(Spinners.earth, text='Download CMEMS function is running'): profile.download_cmems(setup_file) t1 = time.time() print("CMEMS download time: %s" % (t1 - t0)) -- GitLab