Skip to content

Commit

Permalink
Replace general exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ekatef committed Oct 12, 2023
1 parent dfe0867 commit 139ae5d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/build_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,10 @@ def load_EEZ(countries_codes, geo_crs, EEZ_gpkg="./data/eez/eez_v11.gpkg"):
guide) or together with pypsa-earth package.
"""
if not os.path.exists(EEZ_gpkg):
raise Exception(
logger.error(
f"File EEZ {EEZ_gpkg} not found, please download it from https://www.marineregions.org/download_file.php?name=World_EEZ_v11_20191118_gpkg.zip and copy it in {os.path.dirname(EEZ_gpkg)}"
)
sys.exit(1)

geodf_EEZ = gpd.read_file(EEZ_gpkg).to_crs(geo_crs)
geodf_EEZ.dropna(axis=0, how="any", subset=["ISO_TER1"], inplace=True)
Expand Down Expand Up @@ -588,9 +589,10 @@ def convert_GDP(name_file_nc, year=2015, out_logging=False):

# Check if file exists, otherwise throw exception
if not os.path.exists(GDP_nc):
raise Exception(
logger.error(
f"File {name_file_nc} not found, please download it from https://datadryad.org/stash/dataset/doi:10.5061/dryad.dk1j0 and copy it in {os.path.dirname(GDP_nc)}"
)
sys.exit(1)

# open nc dataset
GDP_dataset = xr.open_dataset(GDP_nc)
Expand Down

0 comments on commit 139ae5d

Please sign in to comment.