Skip to content

Commit

Permalink
Merge pull request #9 from CMCC-Foundation/no-shell
Browse files Browse the repository at this point in the history
Handling Try Except Pass
  • Loading branch information
atakeigor authored Dec 11, 2024
2 parents b9204fd + 3f10524 commit 9caa119
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
16 changes: 11 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
22 changes: 14 additions & 8 deletions src/preprocessing/preprocessing_mdk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9caa119

Please sign in to comment.