From 3f10524c881728103873ecd84c76198f7521d3da Mon Sep 17 00:00:00 2001 From: Santiago Bravo Date: Wed, 11 Dec 2024 09:24:35 -0300 Subject: [PATCH] Handling Try Except Pass --- main.py | 16 +++++++++++----- src/preprocessing/preprocessing_mdk3.py | 22 ++++++++++++++-------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index e44a0c5..cd6f4e0 100644 --- a/main.py +++ b/main.py @@ -473,11 +473,17 @@ def run_medslik_sim(self, simdir, simname, separate_slicks=False): #plotting the results if main.config["plot_options"]["plotting"]: mplot = MedslikIIPlot(main) - mplot.plot_matplotlib(main.lon_min,main.lon_max,main.lat_min,main.lat_max) - try: - mplot.plot_mass_balance() - except: - pass + mplot.plot_matplotlib(main.lon_min, main.lon_max, main.lat_min, main.lat_max) + mplot.plot_mass_balance() + + + # if main.config["plot_options"]["plotting"]: + # mplot = MedslikIIPlot(main) + # mplot.plot_matplotlib(main.lon_min,main.lon_max,main.lat_min,main.lat_max) + # try: + # mplot.plot_mass_balance() + # except: + # pass shutil.copy("medslik_run.log", f"{main.out_directory}medslik_run.log") diff --git a/src/preprocessing/preprocessing_mdk3.py b/src/preprocessing/preprocessing_mdk3.py index f9c15c2..7eb0478 100644 --- a/src/preprocessing/preprocessing_mdk3.py +++ b/src/preprocessing/preprocessing_mdk3.py @@ -113,10 +113,13 @@ def process_bathymetry(self,gebco): grid = self.grid gebco = xr.open_dataset(gebco) - try: - grid = grid.rename({'nav_lat':'lat','nav_lon':'lon'}) - except: - pass + if 'nav_lat' in grid and 'nav_lon' in grid: + grid = grid.rename({'nav_lat': 'lat', 'nav_lon': 'lon'}) + + # try: + # grid = grid.rename({'nav_lat':'lat','nav_lon':'lon'}) + # except: + # pass # interpolation on medslik grid med = gebco.interp(lon=grid.lon.values.tolist(),lat=grid.lat.values.tolist()) @@ -150,10 +153,13 @@ def process_coastline(self,gshhs): grid = self.grid - try: - grid = grid.rename({'nav_lat':'lat','nav_lon':'lon'}) - except: - pass + if 'nav_lat' in grid and 'nav_lon' in grid: + grid = grid.rename({'nav_lat': 'lat', 'nav_lon': 'lon'}) + + # try: + # grid = grid.rename({'nav_lat':'lat','nav_lon':'lon'}) + # except: + # pass # 1 degree buffer to collect more coastline buffer = 1