Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ heatwave_evaluation_list = [
),
]
# Load in the EWB default list of event cases
case_metadata = ewb.cases.load_ewb_events_yaml_into_case_list()
case_metadata = ewb.cases.load_cases()

# Create the evaluation class, with cases and evaluation objects declared
ewb_instance = ewb.evaluation(
ewb_instance = ewb.evaluate.ExtremeWeatherBench(
case_metadata=case_metadata,
evaluation_objects=heatwave_evaluation_list,
)
Expand Down
2 changes: 1 addition & 1 deletion data_prep/ibtracs_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def update_cases_with_storm_bounds(storm_bounds, all_storms_df):
"""
logger.info("Updating cases with storm bounds...")

cases_all = ewb.cases.load_ewb_events_yaml_into_case_list()
cases_all = ewb.cases.load_cases()
cases_new = cases_all.copy()

# Update the yaml cases with storm bounds from IBTrACS data
Expand Down
16 changes: 8 additions & 8 deletions docs/examples/applied_ar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

# Load case data from the default events.yaml
# Users can also define their own cases_dict structure
case_yaml = ewb.load_cases()
case_yaml = ewb.cases.load_cases()


# ERA5 target
era5_target = ewb.targets.ERA5(
era5_target = ewb.inputs.ERA5(
variables=[
ewb.derived.AtmosphericRiverVariables(
output_variables=["atmospheric_river_land_intersection"]
Expand All @@ -22,15 +22,15 @@
)

# Forecast (HRES)
hres_forecast = ewb.forecasts.ZarrForecast(
hres_forecast = ewb.inputs.ZarrForecast(
source="gs://weatherbench2/datasets/hres/2016-2022-0012-1440x721.zarr",
name="HRES",
variables=[
ewb.derived.AtmosphericRiverVariables(
output_variables=["atmospheric_river_land_intersection"]
)
],
variable_mapping=ewb.HRES_metadata_variable_mapping,
variable_mapping=ewb.inputs.HRES_metadata_variable_mapping,
)

grap_forecast = ewb.inputs.get_cira_icechunk(
Expand All @@ -56,7 +56,7 @@
)
# Create a list of evaluation objects for atmospheric river
ar_evaluation_objects = [
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="atmospheric_river",
metric_list=[
ewb.metrics.CriticalSuccessIndex(),
Expand All @@ -66,7 +66,7 @@
target=era5_target,
forecast=hres_forecast,
),
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="atmospheric_river",
metric_list=[
ewb.metrics.CriticalSuccessIndex(),
Expand All @@ -76,7 +76,7 @@
target=era5_target,
forecast=grap_forecast,
),
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="atmospheric_river",
metric_list=[
ewb.metrics.CriticalSuccessIndex(),
Expand All @@ -91,7 +91,7 @@
if __name__ == "__main__":
# Initialize ExtremeWeatherBench; will only run on cases with event_type
# atmospheric_river
ar_ewb = ewb.evaluation(
ar_ewb = ewb.evaluate.ExtremeWeatherBench(
case_metadata=case_yaml,
evaluation_objects=ar_evaluation_objects,
)
Expand Down
14 changes: 7 additions & 7 deletions docs/examples/applied_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@

# Load case data from the default events.yaml
# Users can also define their own cases_dict structure
case_yaml = ewb.load_cases()
case_yaml = ewb.cases.load_cases()


# ERA5 target
era5_freeze_target = ewb.targets.ERA5(
era5_freeze_target = ewb.inputs.ERA5(
variables=["surface_air_temperature"],
chunks=None,
)

# GHCN target
ghcn_freeze_target = ewb.targets.GHCN(variables=["surface_air_temperature"])
ghcn_freeze_target = ewb.inputs.GHCN(variables=["surface_air_temperature"])

# Forecast (FCNv2) using helper in defaults
fcnv2_forecast = ewb.defaults.cira_fcnv2_freeze_forecast

# Load the climatology for DurationMeanError
climatology = ewb.get_climatology(quantile=0.15)
climatology = ewb.defaults.get_climatology(quantile=0.15)

# Define the metrics
metrics_list = [
Expand All @@ -36,13 +36,13 @@

# Create a list of evaluation objects for freeze
freeze_evaluation_object = [
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="freeze",
metric_list=metrics_list,
target=ghcn_freeze_target,
forecast=fcnv2_forecast,
),
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="freeze",
metric_list=metrics_list,
target=era5_freeze_target,
Expand All @@ -52,7 +52,7 @@

if __name__ == "__main__":
# Initialize ExtremeWeatherBench runner instance
freeze_ewb = ewb.evaluation(
freeze_ewb = ewb.evaluate.ExtremeWeatherBench(
case_metadata=case_yaml,
evaluation_objects=freeze_evaluation_object,
)
Expand Down
18 changes: 9 additions & 9 deletions docs/examples/applied_heatwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@

# Load case data from the default events.yaml
# Users can also define their own cases_dict structure
case_yaml = ewb.load_cases()
case_yaml = ewb.cases.load_cases()

# Define targets
# ERA5 target
era5_heatwave_target = ewb.targets.ERA5(
era5_heatwave_target = ewb.inputs.ERA5(
variables=["surface_air_temperature"],
chunks=None,
)

# GHCN target
ghcn_heatwave_target = ewb.targets.GHCN(
ghcn_heatwave_target = ewb.inputs.GHCN(
variables=["surface_air_temperature"],
)

# Define forecast (HRES)
hres_forecast = ewb.forecasts.ZarrForecast(
hres_forecast = ewb.inputs.ZarrForecast(
name="hres_forecast",
source="gs://weatherbench2/datasets/hres/2016-2022-0012-1440x721.zarr",
variables=["surface_air_temperature"],
variable_mapping=ewb.HRES_metadata_variable_mapping,
variable_mapping=ewb.inputs.HRES_metadata_variable_mapping,
preprocess=ewb.defaults.preprocess_heatwave_forecast_dataset,
)

# Load the climatology for DurationMeanError
climatology = ewb.get_climatology(quantile=0.85)
climatology = ewb.defaults.get_climatology(quantile=0.85)

# Define the metrics
metrics_list = [
Expand All @@ -45,13 +45,13 @@

# Create a list of evaluation objects for heatwave
heatwave_evaluation_object = [
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="heat_wave",
metric_list=metrics_list,
target=ghcn_heatwave_target,
forecast=hres_forecast,
),
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="heat_wave",
metric_list=metrics_list,
target=era5_heatwave_target,
Expand All @@ -60,7 +60,7 @@
]
if __name__ == "__main__":
# Initialize ExtremeWeatherBench
heatwave_ewb = ewb.evaluation(
heatwave_ewb = ewb.evaluate.ExtremeWeatherBench(
case_metadata=case_yaml,
evaluation_objects=heatwave_evaluation_object,
)
Expand Down
16 changes: 8 additions & 8 deletions docs/examples/applied_severe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@


# Load case data from the default events.yaml
case_yaml = ewb.load_cases()
case_yaml = ewb.cases.load_cases()

# Subset to one severe convection case for example
case_list = [n for n in case_yaml if n.case_id_number == 305]

# Define PPH target
pph_target = ewb.targets.PPH(
pph_target = ewb.inputs.PPH(
variables=["practically_perfect_hindcast"],
)

# Define LSR target
lsr_target = ewb.targets.LSR()
lsr_target = ewb.inputs.LSR()

# Define HRES forecast
hres_forecast = ewb.forecasts.ZarrForecast(
hres_forecast = ewb.inputs.ZarrForecast(
name="hres_forecast",
source="gs://weatherbench2/datasets/hres/2016-2022-0012-1440x721.zarr",
variables=[ewb.derived.CravenBrooksSignificantSevere(layer_depth=100)],
variable_mapping=ewb.HRES_metadata_variable_mapping,
variable_mapping=ewb.inputs.HRES_metadata_variable_mapping,
storage_options={"remote_options": {"anon": True}},
)

Expand Down Expand Up @@ -58,7 +58,7 @@
# Define evaluation objects for severe convection:
# One evaluation object for PPH
pph_evaluation_objects = [
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="severe_convection",
metric_list=pph_metrics,
target=pph_target,
Expand All @@ -68,7 +68,7 @@

# One evaluation object for LSR
lsr_evaluation_objects = [
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="severe_convection",
metric_list=lsr_metrics,
target=lsr_target,
Expand All @@ -78,7 +78,7 @@

if __name__ == "__main__":
# Initialize ExtremeWeatherBench with both evaluation objects
severe_ewb = ewb.evaluation(
severe_ewb = ewb.evaluate.ExtremeWeatherBench(
case_metadata=case_list,
evaluation_objects=lsr_evaluation_objects + pph_evaluation_objects,
)
Expand Down
16 changes: 8 additions & 8 deletions docs/examples/applied_tc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@


# Load the case collection from the YAML file
case_yaml = ewb.load_cases()
case_yaml = ewb.cases.load_cases()

# Select single case (TC Ida)
case_list = [n for n in case_yaml if n.case_id_number == 220]

# Define IBTrACS target, no arguments needed as defaults are sufficient
ibtracs_target = ewb.targets.IBTrACS()
ibtracs_target = ewb.inputs.IBTrACS()

# # Define HRES forecast
hres_forecast = ewb.forecasts.ZarrForecast(
hres_forecast = ewb.inputs.ZarrForecast(
name="hres_forecast",
source="gs://weatherbench2/datasets/hres/2016-2022-0012-1440x721.zarr",
# Define tropical cyclone track derived variable to include in the forecast
variables=[ewb.derived.TropicalCycloneTrackVariables()],
# Define metadata variable mapping for HRES forecast
variable_mapping=ewb.HRES_metadata_variable_mapping,
variable_mapping=ewb.inputs.HRES_metadata_variable_mapping,
storage_options={"remote_options": {"anon": True}},
# Preprocess the HRES forecast to include geopotential thickness calculation
preprocess=ewb.defaults.preprocess_hres_tc_forecast_dataset,
Expand Down Expand Up @@ -63,21 +63,21 @@
# the relevant cases inside the events YAML file
tc_evaluation_object = [
# HRES forecast
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="tropical_cyclone",
metric_list=composite_landfall_metrics,
target=ibtracs_target,
forecast=hres_forecast,
),
# Pangu forecast
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="tropical_cyclone",
metric_list=composite_landfall_metrics,
target=ibtracs_target,
forecast=pangu_forecast,
),
# FCNv2 forecast
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="tropical_cyclone",
metric_list=composite_landfall_metrics,
target=ibtracs_target,
Expand All @@ -87,7 +87,7 @@

if __name__ == "__main__":
# Initialize ExtremeWeatherBench
tc_ewb = ewb.evaluation(
tc_ewb = ewb.evaluate.ExtremeWeatherBench(
case_metadata=case_list,
evaluation_objects=tc_evaluation_object,
)
Expand Down
10 changes: 5 additions & 5 deletions docs/examples/example_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
import extremeweatherbench as ewb

# Define targets (observation data)
era5_heatwave_target = ewb.targets.ERA5(
era5_heatwave_target = ewb.inputs.ERA5(
variables=["surface_air_temperature"],
chunks=None,
)

# Define forecasts
fcnv2_forecast = ewb.forecasts.KerchunkForecast(
fcnv2_forecast = ewb.inputs.KerchunkForecast(
name="fcnv2_forecast",
source="gs://extremeweatherbench/FOUR_v200_GFS.parq",
variables=["surface_air_temperature"],
variable_mapping=ewb.CIRA_metadata_variable_mapping,
variable_mapping=ewb.inputs.CIRA_metadata_variable_mapping,
)

# Define evaluation objects
evaluation_objects = [
ewb.EvaluationObject(
ewb.inputs.EvaluationObject(
event_type="heat_wave",
metric_list=[
ewb.metrics.MaximumMeanAbsoluteError(),
Expand All @@ -38,7 +38,7 @@

# Load case data from the default events.yaml
# Users can also define their own cases_dict structure
cases_list = ewb.load_cases()
cases_list = ewb.cases.load_cases()

# Alternatively, users could define custom cases like this:
# cases_list = [
Expand Down
Loading
Loading