ai-models


Nameai-models JSON
Version 0.5.3 PyPI version JSON
download
home_pagehttps://github.com/ecmwf-lab/ai-models
SummaryA package to run AI weather models
upload_time2024-04-19 12:46:10
maintainerNone
docs_urlNone
authorEuropean Centre for Medium-Range Weather Forecasts (ECMWF)
requires_pythonNone
licenseApache License Version 2.0
keywords tool
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ai-models

The `ai-models` command is used to run AI-based weather forecasting models. These models need to be installed independently.

## Usage

Although the source code `ai-models` and its plugins are available under open sources licences, some model weights may be available under a different licence. For example some models make their weights available under the CC-BY-NC-SA 4.0 license, which does not allow commercial use. For more informations, please check the license associated with each model on their main home page, that we link from each of the corresponding plugins.

## Prerequisites

Before using the `ai-models` command, ensure you have the following prerequisites:

- Python 3.10 (it may work with different versions, but it has been tested with 3.10 on Linux/MacOS).
- An ECMWF and/or CDS account for accessing input data (see below for more details).
- A computed with a GPU for optimal performance (strongly recommended).

## Installation

To install the `ai-models` command, run the following command:

```bash
pip install ai-models
```

## Available Models

Currently, four models can be installed:

```bash
pip install ai-models-panguweather
pip install ai-models-fourcastnet
pip install ai-models-graphcast  # Install details at https://github.com/ecmwf-lab/ai-models-graphcast
pip install ai-models-fourcastnetv2
```

See [ai-models-panguweather](https://github.com/ecmwf-lab/ai-models-panguweather), [ai-models-fourcastnet](https://github.com/ecmwf-lab/ai-models-fourcastnet),
 [ai-models-fourcastnetv2](https://github.com/ecmwf-lab/ai-models-fourcastnetv2) and [ai-models-graphcast](https://github.com/ecmwf-lab/ai-models-graphcast) for more details about these models.

## Running the models

To run model, make sure it has been installed, then simply run:

```bash
ai-models <model-name>
```

Replace `<model-name>` with the name of the specific AI model you want to run.

By default, the model will be run for a 10-day lead time (240 hours), using yesterday's 12Z analysis from ECMWF's MARS archive.

To produce a 15 days forecast, use the `--lead-time HOURS` option:

```bash
ai-models --lead-time 360 <model-name>
```

You can change the other defaults using the available command line options, as described below.

## Performances Considerations

The AI models can run on a CPU; however, they perform significantly better on a GPU. A 10-day forecast can take several hours on a CPU but only around one minute on a modern GPU.

:warning: **We strongly recommend running these models on a computer equipped with a GPU for optimal performance.**

It you see the following message when running a model, it means that the ONNX runtime was not able to find a the CUDA libraries on your system:
> [W:onnxruntime:Default, onnxruntime_pybind_state.cc:541 CreateExecutionProviderInstance] Failed to create CUDAExecutionProvider. Please reference <https://onnxruntime.ai/docs/reference/execution-providers/CUDA-ExecutionProvider.html#requirements> to ensure all dependencies are met.

To fix this issue, we suggest that you install `ai-models` in a [conda](https://docs.conda.io/en/latest/) environment and install the CUDA libraries in that environment. For example:

```bash
conda create -n ai-models python=3.10
conda activate ai-models
conda install cudatoolkit
pip install ai-models
...
```

## Assets

The AI models rely on weights and other assets created during training. The first time you run a model, you will need to download the trained weights and any additional required assets.

To download the assets before running a model, use the following command:

```bash
ai-models --download-assets <model-name>
```

The assets will be downloaded if needed and stored in the current directory. You can provide a different directory to store the assets:

```bash
ai-models --download-assets --assets <some-directory> <model-name>
```

Then, later on, simply use:

```bash
ai-models --assets <some-directory>  <model-name>
```

or

```bash
export AI_MODELS_ASSETS=<some-directory>
ai-models <model-name>
```

For better organisation of the assets directory, you can use the `--assets-sub-directory` option. This option will store the assets of each model in its own subdirectory within the specified assets directory.

## Input data

The models require input data (initial conditions) to run. You can provide the input data using different sources, as described below:

### From MARS

By default, `ai-models`  use yesterday's 12Z analysis from ECMWF, fetched from the Centre's MARS archive using the [ECMWF WebAPI](https://www.ecmwf.int/en/computing/software/ecmwf-web-api). You will need an ECMWF account to access that service.

To change the date or time, use the `--date` and `--time` options, respectively:

```bash
ai-models --date YYYYMMDD --time HHMM <model-name>
```

### From the CDS

You can start the models using ERA5 (ECMWF Reanalysis version 5) data for the [Copernicus Climate Data Store (CDS)](https://cds.climate.copernicus.eu/). You will need to create an account on the CDS. The data will be downloaded using the [CDS API](https://cds.climate.copernicus.eu/api-how-to).

To access the CDS, simply add `--input cds` on the command line. Please note that ERA5 data is added to the CDS with a delay, so you will also have to provide a date with `--date YYYYMMDD`.

```bash
ai-models --input cds --date 20230110 --time 0000 <model-name>
```

### From a GRIB file

If you have input data in the GRIB format, you can provide the file using the `--file` option:

```bash
ai-models --file <some-grib-file> <model-name>
```

The GRIB file can contain more fields than the ones required by the model. The `ai-models` command will automatically select the necessary fields from the file.

To find out the list of fields needed by a specific model as initial conditions, use the following command:

```bash
 ai-models --fields <model-name>
 ```

## Output

By default, the model output will be written in GRIB format in a file called `<model-name>.grib`. You can change the file name with the option `--path <file-name>`. If the path you specify contains placeholders between `{` and `}`, multiple files will be created based on the [eccodes](https://confluence.ecmwf.int/display/ECC) keys. For example:

```bash
 ai-models --path 'out-{step}.grib' <model-name>
 ```

This command will create a file for each forecasted time step.

If you want to disable writing the output to a file, use the `--output none` option.

## Command line options

It has the following options:

- `--help`: Displays this help message.
- `--models`: Lists all installed models.
- `--debug`: Turns on debug mode. This will print additional information to the console.

### Input

- `--input INPUT`: The input source for the model. This can be a `mars`, `cds` or `file`.
- `--file FILE`: The specific file to use as input. This option will set `--source` to `file`.

- `--date DATE`: The analysis date for the model. This defaults to yesterday.
- `--time TIME`: The analysis time for the model. This defaults to 1200.

### Output

- `--output OUTPUT`: The output destination for the model. Values are `file` or `none`.
- `--path PATH`: The path to write the output of the model.

### Run

- `--lead-time HOURS`: The number of hours to forecast. The default is 240 (10 days).

### Assets management

- `--assets ASSETS`: Specifies the path to the directory containing the model assets. The default is the current directory, but you can override it by setting the `$AI_MODELS_ASSETS` environment variable.
- `--assets-sub-directory`: Enables organising assets in `<assets-directory>/<model-name>` subdirectories.
- `--download-assets`: Downloads the assets if they do not exist.

### Misc. options

- `--fields`: Print the list of fields needed by a model as initial conditions.
- `--expver EXPVER`: The experiment version of the model output.
- `--class CLASS`: The 'class' metadata of the model output.
- `--metadata KEY=VALUE`: Additional metadata metadata in the model output

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ecmwf-lab/ai-models",
    "name": "ai-models",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "tool",
    "author": "European Centre for Medium-Range Weather Forecasts (ECMWF)",
    "author_email": "software.support@ecmwf.int",
    "download_url": "https://files.pythonhosted.org/packages/d3/92/d73a848ced08afa8ed09272b9b1cc00fb8f8a12274edd2429a1f5603f881/ai-models-0.5.3.tar.gz",
    "platform": null,
    "description": "# ai-models\n\nThe `ai-models` command is used to run AI-based weather forecasting models. These models need to be installed independently.\n\n## Usage\n\nAlthough the source code `ai-models` and its plugins are available under open sources licences, some model weights may be available under a different licence. For example some models make their weights available under the CC-BY-NC-SA 4.0 license, which does not allow commercial use. For more informations, please check the license associated with each model on their main home page, that we link from each of the corresponding plugins.\n\n## Prerequisites\n\nBefore using the `ai-models` command, ensure you have the following prerequisites:\n\n- Python 3.10 (it may work with different versions, but it has been tested with 3.10 on Linux/MacOS).\n- An ECMWF and/or CDS account for accessing input data (see below for more details).\n- A computed with a GPU for optimal performance (strongly recommended).\n\n## Installation\n\nTo install the `ai-models` command, run the following command:\n\n```bash\npip install ai-models\n```\n\n## Available Models\n\nCurrently, four models can be installed:\n\n```bash\npip install ai-models-panguweather\npip install ai-models-fourcastnet\npip install ai-models-graphcast  # Install details at https://github.com/ecmwf-lab/ai-models-graphcast\npip install ai-models-fourcastnetv2\n```\n\nSee [ai-models-panguweather](https://github.com/ecmwf-lab/ai-models-panguweather), [ai-models-fourcastnet](https://github.com/ecmwf-lab/ai-models-fourcastnet),\n [ai-models-fourcastnetv2](https://github.com/ecmwf-lab/ai-models-fourcastnetv2) and [ai-models-graphcast](https://github.com/ecmwf-lab/ai-models-graphcast) for more details about these models.\n\n## Running the models\n\nTo run model, make sure it has been installed, then simply run:\n\n```bash\nai-models <model-name>\n```\n\nReplace `<model-name>` with the name of the specific AI model you want to run.\n\nBy default, the model will be run for a 10-day lead time (240 hours), using yesterday's 12Z analysis from ECMWF's MARS archive.\n\nTo produce a 15 days forecast, use the `--lead-time HOURS` option:\n\n```bash\nai-models --lead-time 360 <model-name>\n```\n\nYou can change the other defaults using the available command line options, as described below.\n\n## Performances Considerations\n\nThe AI models can run on a CPU; however, they perform significantly better on a GPU. A 10-day forecast can take several hours on a CPU but only around one minute on a modern GPU.\n\n:warning: **We strongly recommend running these models on a computer equipped with a GPU for optimal performance.**\n\nIt you see the following message when running a model, it means that the ONNX runtime was not able to find a the CUDA libraries on your system:\n> [W:onnxruntime:Default, onnxruntime_pybind_state.cc:541 CreateExecutionProviderInstance] Failed to create CUDAExecutionProvider. Please reference <https://onnxruntime.ai/docs/reference/execution-providers/CUDA-ExecutionProvider.html#requirements> to ensure all dependencies are met.\n\nTo fix this issue, we suggest that you install `ai-models` in a [conda](https://docs.conda.io/en/latest/) environment and install the CUDA libraries in that environment. For example:\n\n```bash\nconda create -n ai-models python=3.10\nconda activate ai-models\nconda install cudatoolkit\npip install ai-models\n...\n```\n\n## Assets\n\nThe AI models rely on weights and other assets created during training. The first time you run a model, you will need to download the trained weights and any additional required assets.\n\nTo download the assets before running a model, use the following command:\n\n```bash\nai-models --download-assets <model-name>\n```\n\nThe assets will be downloaded if needed and stored in the current directory. You can provide a different directory to store the assets:\n\n```bash\nai-models --download-assets --assets <some-directory> <model-name>\n```\n\nThen, later on, simply use:\n\n```bash\nai-models --assets <some-directory>  <model-name>\n```\n\nor\n\n```bash\nexport AI_MODELS_ASSETS=<some-directory>\nai-models <model-name>\n```\n\nFor better organisation of the assets directory, you can use the `--assets-sub-directory` option. This option will store the assets of each model in its own subdirectory within the specified assets directory.\n\n## Input data\n\nThe models require input data (initial conditions) to run. You can provide the input data using different sources, as described below:\n\n### From MARS\n\nBy default, `ai-models`  use yesterday's 12Z analysis from ECMWF, fetched from the Centre's MARS archive using the [ECMWF WebAPI](https://www.ecmwf.int/en/computing/software/ecmwf-web-api). You will need an ECMWF account to access that service.\n\nTo change the date or time, use the `--date` and `--time` options, respectively:\n\n```bash\nai-models --date YYYYMMDD --time HHMM <model-name>\n```\n\n### From the CDS\n\nYou can start the models using ERA5 (ECMWF Reanalysis version 5) data for the [Copernicus Climate Data Store (CDS)](https://cds.climate.copernicus.eu/). You will need to create an account on the CDS. The data will be downloaded using the [CDS API](https://cds.climate.copernicus.eu/api-how-to).\n\nTo access the CDS, simply add `--input cds` on the command line. Please note that ERA5 data is added to the CDS with a delay, so you will also have to provide a date with `--date YYYYMMDD`.\n\n```bash\nai-models --input cds --date 20230110 --time 0000 <model-name>\n```\n\n### From a GRIB file\n\nIf you have input data in the GRIB format, you can provide the file using the `--file` option:\n\n```bash\nai-models --file <some-grib-file> <model-name>\n```\n\nThe GRIB file can contain more fields than the ones required by the model. The `ai-models` command will automatically select the necessary fields from the file.\n\nTo find out the list of fields needed by a specific model as initial conditions, use the following command:\n\n```bash\n ai-models --fields <model-name>\n ```\n\n## Output\n\nBy default, the model output will be written in GRIB format in a file called `<model-name>.grib`. You can change the file name with the option `--path <file-name>`. If the path you specify contains placeholders between `{` and `}`, multiple files will be created based on the [eccodes](https://confluence.ecmwf.int/display/ECC) keys. For example:\n\n```bash\n ai-models --path 'out-{step}.grib' <model-name>\n ```\n\nThis command will create a file for each forecasted time step.\n\nIf you want to disable writing the output to a file, use the `--output none` option.\n\n## Command line options\n\nIt has the following options:\n\n- `--help`: Displays this help message.\n- `--models`: Lists all installed models.\n- `--debug`: Turns on debug mode. This will print additional information to the console.\n\n### Input\n\n- `--input INPUT`: The input source for the model. This can be a `mars`, `cds` or `file`.\n- `--file FILE`: The specific file to use as input. This option will set `--source` to `file`.\n\n- `--date DATE`: The analysis date for the model. This defaults to yesterday.\n- `--time TIME`: The analysis time for the model. This defaults to 1200.\n\n### Output\n\n- `--output OUTPUT`: The output destination for the model. Values are `file` or `none`.\n- `--path PATH`: The path to write the output of the model.\n\n### Run\n\n- `--lead-time HOURS`: The number of hours to forecast. The default is 240 (10 days).\n\n### Assets management\n\n- `--assets ASSETS`: Specifies the path to the directory containing the model assets. The default is the current directory, but you can override it by setting the `$AI_MODELS_ASSETS` environment variable.\n- `--assets-sub-directory`: Enables organising assets in `<assets-directory>/<model-name>` subdirectories.\n- `--download-assets`: Downloads the assets if they do not exist.\n\n### Misc. options\n\n- `--fields`: Print the list of fields needed by a model as initial conditions.\n- `--expver EXPVER`: The experiment version of the model output.\n- `--class CLASS`: The 'class' metadata of the model output.\n- `--metadata KEY=VALUE`: Additional metadata metadata in the model output\n",
    "bugtrack_url": null,
    "license": "Apache License Version 2.0",
    "summary": "A package to run AI weather models",
    "version": "0.5.3",
    "project_urls": {
        "Homepage": "https://github.com/ecmwf-lab/ai-models"
    },
    "split_keywords": [
        "tool"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d392d73a848ced08afa8ed09272b9b1cc00fb8f8a12274edd2429a1f5603f881",
                "md5": "1336e1472b7aa26c90e133756694f814",
                "sha256": "d51f9b4b15923bba5e0d50568bde3a32da46b9685a3f343ce65ead7eacfdd89f"
            },
            "downloads": -1,
            "filename": "ai-models-0.5.3.tar.gz",
            "has_sig": false,
            "md5_digest": "1336e1472b7aa26c90e133756694f814",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 23174,
            "upload_time": "2024-04-19T12:46:10",
            "upload_time_iso_8601": "2024-04-19T12:46:10.827448Z",
            "url": "https://files.pythonhosted.org/packages/d3/92/d73a848ced08afa8ed09272b9b1cc00fb8f8a12274edd2429a1f5603f881/ai-models-0.5.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-19 12:46:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ecmwf-lab",
    "github_project": "ai-models",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "ai-models"
}
        
Elapsed time: 0.23821s