import xarray as xr # 1. Open a GRIB file using the cfgrib engine # The file name includes the validity year (yyyy) and month (mm) of the monthly forecast file_grib = "path/to/downscaled_seasonal_yyyy_mm.grib" ds = xr.open_dataset(file_grib, engine="cfgrib") # 2. Inspect the dataset to see dimensions, variables, and metadata print(ds) # 3. Extract all available variables and convert them to NumPy arrays. # The expected array shape is (ensemble_members, days_in_month, lat, lon). data = {var: ds[var].values for var in ds.data_vars} # 4. Access individual variables mx2t24 = data["mx2t24"][:, :, :, :] mn2t24 = data["mn2t24"][:, :, :, :] tp = data["tp"][:, :, :, :]