Skip to content

Commit 3f10524

Browse files
Handling Try Except Pass
1 parent 726ccf9 commit 3f10524

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

main.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,17 @@ def run_medslik_sim(self, simdir, simname, separate_slicks=False):
473473
#plotting the results
474474
if main.config["plot_options"]["plotting"]:
475475
mplot = MedslikIIPlot(main)
476-
mplot.plot_matplotlib(main.lon_min,main.lon_max,main.lat_min,main.lat_max)
477-
try:
478-
mplot.plot_mass_balance()
479-
except:
480-
pass
476+
mplot.plot_matplotlib(main.lon_min, main.lon_max, main.lat_min, main.lat_max)
477+
mplot.plot_mass_balance()
478+
479+
480+
# if main.config["plot_options"]["plotting"]:
481+
# mplot = MedslikIIPlot(main)
482+
# mplot.plot_matplotlib(main.lon_min,main.lon_max,main.lat_min,main.lat_max)
483+
# try:
484+
# mplot.plot_mass_balance()
485+
# except:
486+
# pass
481487

482488
shutil.copy("medslik_run.log", f"{main.out_directory}medslik_run.log")
483489

src/preprocessing/preprocessing_mdk3.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,13 @@ def process_bathymetry(self,gebco):
113113
grid = self.grid
114114
gebco = xr.open_dataset(gebco)
115115

116-
try:
117-
grid = grid.rename({'nav_lat':'lat','nav_lon':'lon'})
118-
except:
119-
pass
116+
if 'nav_lat' in grid and 'nav_lon' in grid:
117+
grid = grid.rename({'nav_lat': 'lat', 'nav_lon': 'lon'})
118+
119+
# try:
120+
# grid = grid.rename({'nav_lat':'lat','nav_lon':'lon'})
121+
# except:
122+
# pass
120123

121124
# interpolation on medslik grid
122125
med = gebco.interp(lon=grid.lon.values.tolist(),lat=grid.lat.values.tolist())
@@ -150,10 +153,13 @@ def process_coastline(self,gshhs):
150153

151154
grid = self.grid
152155

153-
try:
154-
grid = grid.rename({'nav_lat':'lat','nav_lon':'lon'})
155-
except:
156-
pass
156+
if 'nav_lat' in grid and 'nav_lon' in grid:
157+
grid = grid.rename({'nav_lat': 'lat', 'nav_lon': 'lon'})
158+
159+
# try:
160+
# grid = grid.rename({'nav_lat':'lat','nav_lon':'lon'})
161+
# except:
162+
# pass
157163

158164
# 1 degree buffer to collect more coastline
159165
buffer = 1

0 commit comments

Comments
 (0)