Skip to content

Commit

Permalink
use geodatasets and make spatial plot of probabilities at obs. points
Browse files Browse the repository at this point in the history
  • Loading branch information
Fariborz Daneshvar committed Sep 4, 2024
1 parent 9ae8e04 commit 3111110
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions stormworkflow/post/storm_roc_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from pathlib import Path
from cartopy.feature import NaturalEarthFeature

import geodatasets

os.environ['USE_PYGEOS'] = '0'
import geopandas as gpd

Expand Down Expand Up @@ -164,6 +166,8 @@ def main(args):
# Load probabilities.nc file
ds_prob = xr.open_dataset(prob_nc_path)

gdf_countries = gpd.read_file(geodatasets.get_path('naturalearth land'))

# gdf_countries = gpd.GeoSeries(
# NaturalEarthFeature(category='physical', scale='10m', name='land',).geometries(),
# crs=4326,
Expand All @@ -186,17 +190,17 @@ def main(args):
)
df_obs_storm[f'{source}_prob'] = prediction_prob

# # Plot probabilities at obs. points
# plot_probabilities(
# df_obs_storm,
# f'{source}_prob',
# gdf_countries,
# f'Probability of {source} exceeding {thresholds_ft[threshold_count]} ft \n {storm}, {year}, {leadtime}-hr leadtime',
# os.path.join(
# output_directory,
# f'prob_{source}_above_{thresholds_ft[threshold_count]}ft_{storm}_{year}_{leadtime}-hr.png',
# ),
# )
# Plot probabilities at obs. points
plot_probabilities(
df_obs_storm,
f'{source}_prob',
gdf_countries,
f'Probability of {source} exceeding {thresholds_ft[threshold_count]} ft \n {storm}, {year}, {leadtime}-hr leadtime',
os.path.join(
output_directory,
f'prob_{source}_above_{thresholds_ft[threshold_count]}ft_{storm}_{year}_{leadtime}-hr.png',
),
)

# Loop through probabilities: calculate hit/miss/... & POD/FAR
prob_count = -1
Expand Down

0 comments on commit 3111110

Please sign in to comment.