### Install WeatherBench 2 and Dependencies Source: https://weatherbench2.readthedocs.io/en/latest/_sources/evaluation Installs the WeatherBench 2 package and essential dependencies using pip. Ensure you have Python and pip installed before running this command. ```bash pip install weatherbench2 ``` -------------------------------- ### Example of Running Evaluation with Apache Beam in Python Source: https://weatherbench2.readthedocs.io/en/latest/evaluation Provides a commented-out example of how to run the evaluation using Apache Beam, which is recommended for larger datasets. It shows how to specify the Beam runner and input chunk sizes for distributed processing. ```python # evaluation.evaluate_with_beam( # data_config, # eval_configs, # runner='DirectRunner', # input_chunks={'time': 20}, # ) ``` -------------------------------- ### Install WeatherBench 2 using pip Source: https://weatherbench2.readthedocs.io/en/latest/evaluation Installs the WeatherBench 2 framework from its GitHub repository using pip. This command may sometimes trigger warnings regarding the Pandas version, but the installation should proceed correctly. ```shell # Pip might complain about the Pandas version. The notebook should still work as expected. !pip install git+https://github.com/google-research/weatherbench2.git ``` -------------------------------- ### Basic Data Loading Example Source: https://weatherbench2.readthedocs.io/en/latest/_sources/evaluation Demonstrates how to load weather data using WeatherBench 2. This involves specifying the dataset and time range for data retrieval. ```python import weatherbench2 as wb2 data = wb2.load_data( dataset="era5", times=('2000-01-01', '2000-12-31') ) ``` -------------------------------- ### Setup WeatherBench Configuration in Python Source: https://weatherbench2.readthedocs.io/en/latest/evaluation Imports the necessary configuration module from the WeatherBench2 library to begin setting up evaluation parameters. This is the initial step before defining data or evaluation specifics. ```python from weatherbench2 import config ``` -------------------------------- ### Clone WeatherBench 2 Repository Source: https://weatherbench2.readthedocs.io/en/latest/index This command clones the WeatherBench 2 GitHub repository to your local machine. It's the first step to get started with the project. ```bash git clone git@github.com:google-research/weatherbench2.git ``` -------------------------------- ### Simple Linear Regression Forecasting Model Source: https://weatherbench2.readthedocs.io/en/latest/_sources/evaluation A basic example of a forecasting model using linear regression. This function takes historical data and predicts future values. ```python import weatherbench2 as wb2 import numpy as np def simple_linear_regression(data): # Placeholder for actual linear regression implementation # This function should take historical data and return predictions print("Running simple linear regression...") # Example: return a copy of the input data as a prediction return data.copy() ``` -------------------------------- ### Running a Forecasting Experiment Source: https://weatherbench2.readthedocs.io/en/latest/_sources/evaluation Shows how to set up and run a forecasting experiment using a specified model and configuration. This involves defining parameters and executing the forecast. ```python import weatherbench2 as wb2 # Load data (assuming data is already loaded as shown in previous examples) data = wb2.load_data(dataset="era5", times=('2000-01-01', '2000-12-31')) # Define the forecasting model (e.g., using a predefined model or a custom one) model = wb2.models.LinearRegression( resolution=wb2.Resolution.T63, time_range=(0, 360) # Example time range in days ) # Run the forecasting experiment predictions = wb2.run_experiment( model=model, data=data, output_dir="./forecast_output" ) ``` -------------------------------- ### WeatherBench 2 Evaluation Script Example Source: https://weatherbench2.readthedocs.io/en/latest/command-line-scripts This example demonstrates how to execute the `evaluate.py` script with specific command-line arguments. It showcases a practical application of the script for running evaluations, likely involving setting paths to forecast and observation data, and potentially other configuration options. ```bash python evaluate.py \ ``` -------------------------------- ### Install WeatherBench 2 with GCP Requirements Source: https://weatherbench2.readthedocs.io/en/latest/index This command installs WeatherBench 2 along with optional requirements for launching jobs on Google Cloud Platform (GCP). ```bash pip install .[gcp] ``` -------------------------------- ### Data Handling and Preprocessing Source: https://weatherbench2.readthedocs.io/en/latest/_sources/evaluation Details on loading and preprocessing weather data for use with forecasting models. This includes selecting datasets and specifying time periods. ```python import weatherbench2 as wb2 # Load data from a specific dataset (e.g., 'era5') for a given time range data = wb2.load_data( dataset="era5", times=("1980-01-01", "2014-12-31") ) # Data preprocessing steps would typically follow here, such as: # - Normalization # - Feature selection # - Splitting into training and validation sets ``` -------------------------------- ### Install WeatherBench 2 Source: https://weatherbench2.readthedocs.io/en/latest/index These commands install the WeatherBench 2 package using pip. The first command changes the directory to the cloned repository, and the second installs the package. An editable install is available for development. ```bash cd weatherbench2 pip install . ``` ```bash pip install -e . ``` -------------------------------- ### Configuration for a Forecasting Model Source: https://weatherbench2.readthedocs.io/en/latest/_sources/evaluation Illustrates how to configure a forecasting model, specifying resolution, time range, and other relevant parameters. This configuration is used when initializing a model object. ```python from weatherbench2.models import Resolution # Example configuration for a model resolution = Resolution.T63 time_range = (0, 360) # Forecast for 360 days # This configuration would be passed to a model constructor, e.g.: # model = SomeModel(resolution=resolution, time_range=time_range) ``` -------------------------------- ### Open Zarr Dataset with xarray Source: https://weatherbench2.readthedocs.io/en/latest/_sources/data-guide Opens a Zarr dataset from a Google Cloud Storage (GCS) path using the xarray library. This function requires the xarray library to be installed and assumes access to the specified GCS bucket. ```python import xarray as xr xr.open_zarr('gs://weatherbench2/datasets/neuralgcm_deterministic/2020-240x121_equiangular_with_poles_conservative.zarr') ``` -------------------------------- ### Load Keisler Dataset with xarray Source: https://weatherbench2.readthedocs.io/en/latest/_sources/data-guide This snippet demonstrates how to open and load the Keisler dataset from a Zarr store located in Google Cloud Storage using the xarray library. It assumes xarray and dask are installed. The output will be a dask-backed xarray DataArray representing weather data. ```python xr.open_zarr('gs://weatherbench2/datasets/keisler/2020-360x181.zarr') ``` -------------------------------- ### Open Zarr Dataset with Xarray Source: https://weatherbench2.readthedocs.io/en/latest/data-guide This snippet demonstrates how to open a Zarr dataset from a Google Cloud Storage (GCS) path using the xarray library in Python. It assumes the necessary libraries are installed and credentials are configured. ```python import xarray as xr xr.open_zarr('gs://weatherbench2/datasets/ifs_ens/2018-2022-1440x721.zarr') ``` -------------------------------- ### Open Zarr Dataset with Xarray Source: https://weatherbench2.readthedocs.io/en/latest/data-guide Opens a dataset stored in Zarr format from a Google Cloud Storage path using the xarray library. This is a common method for accessing large, chunked datasets. It requires the xarray library to be installed. ```python import xarray as xr xr.open_zarr('gs://weatherbench2/datasets/hres/2016-2022-0012-1440x721.zarr') ``` -------------------------------- ### Evaluate ERA5 Forecasts vs ERA5 using Bash Source: https://weatherbench2.readthedocs.io/en/latest/_sources/official-evaluation This script demonstrates the setup for evaluating ERA5 forecasts against ERA5 observational data. It specifies the necessary paths for forecast data, observations, and climatology, along with output configurations. This example is incomplete as it lacks the full set of arguments. ```bash python evaluate.py -- \ --forecast_path=gs://weatherbench2/datasets/era5-forecasts/2020-64x32_equiangular_conservative.zarr \ --obs_path=gs://weatherbench2/datasets/era5/1959-2022-6h-64x32_equiangular_conservative.zarr \ --climatology_path=gs://weatherbench2/datasets/era5-hourly-climatology/1990-2019_6h_64x32_equiangular_conservative.zarr \ ``` -------------------------------- ### Open ERA5 Zarr Dataset with xarray Source: https://weatherbench2.readthedocs.io/en/latest/_sources/data-guide Opens the ERA5 dataset stored in Zarr format from a Google Cloud Storage bucket using the xarray library. This is a common starting point for accessing and analyzing the WeatherBench 2 data. ```python xr.open_zarr('gs://weatherbench2/datasets/era5/1959-2023_01_10-wb13-6h-1440x721_with_derived_variables.zarr') ``` -------------------------------- ### Open ERA5 Forecasts with Xarray Source: https://weatherbench2.readthedocs.io/en/latest/data-guide Opens a specific ERA5 forecast dataset (2020-1440x721.zarr) from Google Cloud Storage using the xarray library. This function is used to load the forecast data for analysis. It requires the xarray library to be installed. ```python xr.open_zarr('gs://weatherbench2/datasets/era5-forecasts/2020-1440x721.zarr') ``` -------------------------------- ### Evaluate FUXI Forecasts (Python) Source: https://weatherbench2.readthedocs.io/en/latest/official-evaluation This Python script evaluates the FUXI forecast model. It configures paths for forecast, observation, and climatology data, along with output settings, input chunking, and evaluation criteria. This example also demonstrates specifying specific pressure levels for evaluation and including derived variables. ```python python evaluate.py -- \ --forecast_path=gs://weatherbench2/datasets/fuxi/2020-64x32_equiangular_conservative.zarr \ --obs_path=gs://weatherbench2/datasets/era5/1959-2022-6h-64x32_equiangular_conservative.zarr \ --climatology_path=gs://weatherbench2/datasets/era5-hourly-climatology/1990-2019_6h_64x32_equiangular_conservative.zarr \ --output_dir=$OUTDIR/64x32/deterministic/ \ --output_file_prefix=fuxi_vs_era_2020_ \ --input_chunks=init_time=1 \ --fanout=27 \ --regions=all \ --eval_configs=deterministic,deterministic_temporal \ --evaluate_climatology=False \ --evaluate_persistence=False \ --time_start=2020-01-01 \ --time_stop=2020-12-31 \ --levels=500,850 \ --variables=geopotential,temperature,u_component_of_wind,v_component_of_wind,2m_temperature,10m_u_component_of_wind,10m_v_component_of_wind,mean_sea_level_pressure,10m_wind_speed,wind_speed \ --add_land_region=False \ --use_beam=True ``` -------------------------------- ### Open Zarr Dataset with Xarray in Python Source: https://weatherbench2.readthedocs.io/en/latest/data-guide Opens a Zarr dataset from a Google Cloud Storage (GCS) path using the xarray library. This is useful for loading large, chunked datasets for analysis. Ensure you have xarray and the necessary GCS connectors installed. ```python import xarray as xr dataset = xr.open_zarr('gs://weatherbench2/datasets/hres_t0/2016-2022-6h-1440x721.zarr') ``` -------------------------------- ### Displaying Coordinate Data Source: https://weatherbench2.readthedocs.io/en/latest/_sources/evaluation This snippet shows how to display the data associated with coordinates like 'latitude', 'level', and 'longitude'. It extracts preview data and associated metadata. ```html
array([ 50, 100, 150, 200, 250, 300, 400, 500, 600, 700, 850, 925,
1000])array([ 0. , 5.625, 11.25 , 16.875, 22.5 , 28.125, 33.75 , 39.375,
45. , 50.625, 56.25 , 61.875, 67.5 , 73.125, 78.75 , 84.375,
90. , 95.625, 101.25 , 106.875, 112.5 , 118.125, 123.75 , 129.375,
135. , 140.625, 146.25 , 151.875, 157.5 , 163.125, 168.75 , 174.375,
180. , 185.625, 191.25 , 196.875, 202.5 , 208.125, 213.75 , 219.375,
225. , 230.625, 236.25 , 241.875, 247.5 , 253.125, 258.75 , 264.375,
270. , 275.625, 281.25 , 286.875, 292.5 , 298.125, 303.75 , 309.375,
315. , 320.625, 326.25 , 331.875, 337.5 , 343.125, 348.75 , 354.375])