Skip to content

approach='first' for TC's producing no results #289

@aaTman

Description

@aaTman

All outputs when using approach='first' for tropical cyclones produce an empty row and an init_time of 0.

Code to reproduce:

import xarray as xr
import numpy as np
from extremeweatherbench import inputs, metrics, cases, derived, calc, evaluate

# Preprocessing function for CIRA data that includes geopotential thickness calculation
# required for tropical cyclone tracks
def _preprocess_bb_cira_tc_forecast_dataset(ds: xr.Dataset) -> xr.Dataset:
    """An example preprocess function that renames the time coordinate to lead_time,
    creates a valid_time coordinate, and sets the lead time range and resolution not
    present in the original dataset.

    Args:
        ds: The forecast dataset to rename.

    Returns:
        The renamed forecast dataset.
    """
    ds = ds.rename({"time": "lead_time"})
    # The evaluation configuration is used to set the lead time range and resolution.
    ds["lead_time"] = np.array(
        [i for i in range(0, 241, 6)], dtype="timedelta64[h]"
    ).astype("timedelta64[ns]")
    ds["geopotential_thickness"] = calc.geopotential_thickness(
        ds["z"], top_level_value=300, bottom_level_value=500, geopotential=True
    )
    return ds

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

# Select single case
case_yaml.select_cases(by="case_id_number", value=151, inplace=True)

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

# Define FCNv2 forecast
fcnv2_forecast = inputs.KerchunkForecast(
    name="fcn_forecast",
    source="gs://extremeweatherbench/FOUR_v200_GFS.parq",
    variables=[derived.TropicalCycloneTrackVariables()],
    # Define metadata variable mapping for FCNv2 forecast
    variable_mapping=inputs.CIRA_metadata_variable_mapping,
    # Preprocess the FCNv2 forecast to include geopotential thickness calculation
    preprocess=_preprocess_bb_cira_tc_forecast_dataset,
    storage_options={"remote_protocol": "s3", "remote_options": {"anon": True}},
)

composite_landfall_metrics = [
    metrics.LandfallMetric(
        metrics=[
            metrics.LandfallIntensityMeanAbsoluteError,
            metrics.LandfallTimeMeanError,
            metrics.LandfallDisplacement,
        ],
        approach="first",
    )
]

tc_evaluation_object = [
    # FCNv2 forecast
    inputs.EvaluationObject(
        event_type="tropical_cyclone",
        metric_list=composite_landfall_metrics,
        target=ibtracs_target,
        forecast=fcnv2_forecast,
    ),
]

ewb = evaluate.ExtremeWeatherBench(
    case_metadata=case_yaml,
    evaluation_objects=tc_evaluation_object,
)

# Run the workflow with parallel_config backend set to dask
outputs = ewb.run(
    parallel_config={"backend": "loky", "n_jobs": 1},
)
outputs.to_csv("tc_metric_test_results.csv")

Metadata

Metadata

Assignees

Labels

unintended behavior bugbugs that result in unexpected or unintended results but are not critical to core functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions