ecmwf-opendata


Nameecmwf-opendata JSON
Version 0.3.10 PyPI version JSON
download
home_pagehttps://github.com/ecmwf/ecmwf-opendata
SummaryA package to download ECMWF open data
upload_time2024-09-15 16:24:59
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.
            # ecmwf-opendata

`ecmwf-opendata` is a package to simplify the download of ECMWF [open data](https://www.ecmwf.int/en/forecasts/datasets/open-data). It implements a request-based interface to the dataset using ECMWF's MARS language to select meteorological fields, similar to the existing  [ecmwf-api-client](https://github.com/ecmwf/ecmwf-api-client) Python package.

A collection of Jupyter Notebooks that make use of that package is available [here](https://github.com/ecmwf/notebook-examples/tree/master/opencharts).

## Installation

The `ecmwf-opendata` Python package can be installed from PyPI with:

```$ pip install ecmwf-opendata```

## Usage
The example below will download the latest available 10-day forecast for the *mean sea level pressure* (`msl`) into a local file called `data.grib2`:

```python
from ecmwf.opendata import Client

client = Client()

client.retrieve(
    step=240,
    type="fc",
    param="msl",
    target="data.grib2",
)
```

> ❗ **NOTE:** This package is designed for users that want to download a subset of the whole dataset. If you plan to download a large percentage of each data file, it may be more efficient to download whole files and filter out the data you want locally. See the documentation on the [file naming convention](https://confluence.ecmwf.int/display/DAC/ECMWF+open+data:+real-time+forecasts) for more information. Alternatively, you can use this tool to download whole files by only specifying `date`, `time`, `step`, `stream` and `type`. Please be aware that all data for a full day is in the order of 726 GiB.


## Options

The constructor of the client object takes the following options:

```python
client = Client(
    source="ecmwf",
    model="ifs",
    resol="0p25",
    preserve_request_order=False,
    infer_stream_keyword=True,
)
```

where:

- `source` is either the name of server to contact or a fully qualified URL. Possible values are `ecmwf` to access ECMWF's servers, or `azure` to access data hosted on Microsoft's Azure. Default is `ecmwf`.

- `model` is the name of the model that produced the data. Use `ifs` for the physics-driven model and `aifs` for the data-driven model. Please note that `aifs` is currently experimental and only produces a small subset of fields. Default is `ifs`.

- `resol` specifies the resolution of the data. Default is `0p25` for 0.25 degree resolution, and is the only resolution that is currently available.

- `preserve_request_order`. If this flag is set to `True`, the library will attempt to write the retrieved data into the target file in the order specified by the request. For example, if the request specifies `param=[2t,msl]` the library will ensure that the field `2t` is first in the target file, while with `param=[msl,2t]`, the field `msl` will be first. This also works across different keywords: `...,levelist=[500,100],param=[z,t],...` will produce different output to `...,param=[z,t],levelist=[500,100],...`
If the flag is set to `False`, the library will sort the request to minimise the number of HTTP requests made to the server, leading to faster download speeds. Default is `False`.

- `infer_stream_keyword`. The `stream` keyword represents the ECMWF forecasting system that creates the data. Setting it properly requires knowledge of how ECMWF runs its operations. If this boolean is set to `True`, the library will try to infer the correct value for the `stream` keyword based on the rest of the request. Default is `True` if model is `ifs`.

 > ⚠️ **NOTE:** It is recommended **not** to set the `preserve_request_order` flag to `True` when downloading a large number of fields as this will add extra load on the servers.

## Methods

> `Client.retrieve()`

The `Client.retrieve()` method takes request as input and will retrieve the corresponding data from the server and write them in the user's target file.

A request is a list of keyword/value pairs used to select the desired data. It is possible to specify a list of values for a given keyword.

The request can either be specified as a dictionary:

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

request = {
    "time": 0,
    "type": "fc",
    "step": 24,
    "param": ["2t", "msl"],
}

client.retrieve(request, "data.grib2")

# or:

client.retrieve(
    request=request,
    target="data.grib2",
)
```

or directly as arguments to the `retrieve()` method:

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

client.retrieve(
    time=0,
    type="fc",
    step=24,
    param=["2t", "msl"],
    target="data.grib2",
)
```

The `date` and `time` keyword are used to select the date and time of the forecast run (see [Date and time](#date-and-time) below). If `date` or both `date` and `time` are not specified, the library will query the server for the most recent matching data. The `date` and `time` of the downloaded forecast is returned by the `retrieve()` method.

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

result = client.retrieve(
    type="fc",
    step=24,
    param=["2t", "msl"],
    target="data.grib2",
)

print(result.datetime)
```

may print `2022-01-23 00:00:00`.

> `Client.download()`

The `Client.download()` method takes the same parameters as the `Client.retrieve()` method, but will download the whole data files from the server, ignoring keywords like `param`, `levelist` or `number`.

The example below will download all field from the latest time step 24, ignoring the keyword `param`:

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

client.download(
    param="msl",
    type="fc",
    step=24,
    target="data.grib2",
)

```

> `Client.latest()`

The `Client.latest()` method takes the same parameters as the `Client.retrieve()` method, and returns the date of the most recent matching forecast without downloading the data:

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

print(client.latest(
    type="fc",
    step=24,
    param=["2t", "msl"],
    target="data.grib2",
))
```

may print `2022-01-23 00:00:00`.

> ⏰ **NOTE**: The data is available between 7 and 9 hours after the forecast starting date and time, depending on the forecasting system and the time step specified.

## Request keywords

The supported keywords are:

- `type`: the type of data (compulsory, defaults to `fc`).
- `stream`: the forecast system (optional if unambiguous, compulsory otherwise). See the `infer_stream_keyword` [above](#options).
- `date`: the date at which the forecast starts.
- `time`: the time at which the forecast starts.
- `step`: the forecast time step in hours, or `fcmonth`, the time step in months for the seasonal forecast (compulsory, default to `0` and `1`, respectively).

and (all optional, with no defaults):

- `param`: the meteorological parameters, such as wind, pressure or humidity.
- `levtype`: select between single level parameters and parameters on pressure levels.
- `levelist`: the list of pressure levels when relevant.
- `number`: the list of ensemble member numbers when relevant.

The keywords in the first list are used to identify which file to access, while the second list is used to identify which parts of the files need to be actually downloaded. Some HTTP servers are able to return multiple parts of a file, while other can only return a single part from a file. In the latter case, the library may perform many HTTP requests to the server. If you wish to download whole files, only provide keywords from the first list.

### Date and time

The date and time parameters refer to the starting time of the forecast. All date and time are expressed in UTC.

There are several ways to specify the date and time in a request.

Date can be specified using strings, numbers and Python `datetime.datetime` or `datetime.date` objects:

```python
...
    date='20220125',
    time=12,
...
    date='2022-01-25',
    time=12,
...
    date='2022-01-25 12:00:00',
...
    date=20220125,
    time=12,
...
    date=datetime.datetime(2022, 1, 25, 12, 0, 0),
...
    date=datetime.date(2022, 1, 25),
    time=12,
...
```

Dates can also be given as a number less than or equal to zero. In this case, it is equivalent to the current UTC date minus the given number of days:

```python
...
    date=0, # today
    date=-1, # yesterday
    date=-2, # the day before yesterday
...
```

The keyword `time` can be given as a string or an integer, or a Python `datetime.time` object. All values of time below are equivalent:

```python
...
    time=12,
...
    time=1200,
...
    time='12',
...
    time='1200',
...
    time=datetime.time(12),
...
```

| List of valid values for time |
| ----------------------------- |
| 0, 6, 12 and 18 |

If `time` is not specified, the time is extracted from the date.

```python
...
   date='2022-01-25 12:00:00',
...
```

is equivalent to:

```python
...
   date='2022-01-25',
   time=12,
...
```

If the `time` keyword is specified, it overrides any time given in the request.

```python
...
   date='2022-01-25 12:00:00',
   time=18,
...
```

is equivalent to:

```python
...
   date='2022-01-25',
   time=18,
...
```

As stated before, if `date` or both `date` and `time` are not specified, the library will query the server for the most recent matching data. The `date` and `time` of the downloaded forecast is returned by the `retrieve()` method:

Example without the `date` keyword:

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

result = client.retrieve(
    time=12,
    type="fc",
    param="2t",
    step="24",
    target="data.grib2",
)

print(result.datetime)

```

will print `2022-01-22 12:00:00` if run in the morning of 2022-01-23.

Example without the `date` and `time` keywords:

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

result = client.retrieve(
    type="fc",
    param="2t",
    step="24",
    target="data.grib2",
)

print(result.datetime)

```

will print `2022-01-23 00:00:00` if run in the morning of 2022-01-23.

### Stream and type

ECMWF runs several forecasting systems:

- [HRES](https://confluence.ecmwf.int/display/FUG/HRES+-+High-Resolution+Forecast): High Resolution Forecast.
- [ENS](https://confluence.ecmwf.int/display/FUG/ENS+-+Ensemble+Forecasts): Ensemble Forecasts.
- [SEAS](https://confluence.ecmwf.int/display/FUG/Long-Range+%28Seasonal%29+Forecast): Long-Range (Seasonal) Forecast.

Each of these forecasts also produces several types of products, that are referred to using the keywords
`stream` and `type`.

> Valid values for `type` are:

HRES:

- `fc`: Forecast.

ENS:

- `cf`: Control forecast.
- `pf`: Perturbed forecast.
- `em`: Ensemble mean.
- `es`: Ensemble standard deviation.
- `ep`: Probabilities.

> Valid values for `stream` are:

- `oper`: Atmospheric fields from HRES - 00 UTC and 12 UTC.
- `wave`: Ocean wave fields from HRES - 00 UTC and 12 UTC.
- `enfo`: Atmospheric fields from ENS.
- `waef`: Ocean wave fields from ENS.
- `scda`: Atmospheric fields from HRES - 06 UTC and 18 UTC.
- `scwv`: Ocean wave fields from HRES - 06 UTC and 18 UTC.

> 📌 **NOTE**: if the client's flag [`infer_stream_keyword`](#options) is set to `True`, the library will infer the stream from the `type` and `time`. In that case, you just need to specify `stream=wave` to access ocean wave products, and don't provide a value for `stream` in other cases.

### Time steps

To select a time step, use the `step` keyword:

```python
...
   step=24,
...
   step=[24, 48],
...
```

| Forecasting system | Time | List of time steps |
| -------- | ---- | ------------------ |
| HRES | 00 and 12 | 0 to 144 by 3, 144 to 240 by 6 |
| ENS | 00 and 12 | 0 to 144 by 3, 144 to 360 by 6 |
| HRES | 06 and 18 | 0 to 90 by 3 |
| ENS | 06 and 18 | 0 to 144 by 3 |
| Probabilities - Instantaneous weather events | 00 and 12 | 0 to 360 by 12 |
| Probabilities - Daily weather events | 00 and 12 | 0-24 to 336-360 by 12 |

> 📌 **NOTE**: Not specifying `step` will return all available time steps.

### Parameters and levels

To select a parameter, use the `param` keyword:

```python
...
   param="msl",
...
   param=["2t", "msl"]
...
```

for pressure level parameters, use the `levelist` keyword:

```python
...
   param="t",
   levelist=850,
...
   param=["u", "v"],
   levelist=[1000, 850, 500],
...
```

> 📌 **NOTE**: Not specifying `levelist` will return all available levels, and not specifying `param` will return all available parameters.

| List of pressure levels (hPa) |
| ----------------------------- |
|   1000, 925, 850, 700, 500, 300, 250, 200 and 50 |


Below is the list of all parameters:

> Atmospheric fields on pressure levels

| Parameter | Description | Units |
| --------- | ----------- | ----- |
| d | Divergence | s<sup>-1</sup> |
| gh | Geopotential height | gpm |
| q | Specific humidity | kg kg<sup>-1</sup> |
| r | Relative humidity | % |
| t | Temperature | K |
| u | U component of wind | m s<sup>-1</sup> |
| v | V component of wind | m s<sup>-1</sup> |
| vo | Vorticity (relative) | s<sup>-1</sup> |

> Atmospheric fields on a single level

| Parameter | Description | Units |
| --------- | ----------- | ----- |
| 10u | 10 metre U wind component | m s<sup>-1</sup> |
| 10v | 10 metre V wind component | m s<sup>-1</sup> |
| 2t | 2 metre temperature | K |
| msl | Mean sea level pressure | Pa |
| ro | Runoff | m |
| skt | Skin temperature | K |
| sp | Surface pressure | Pa |
| st | Soil Temperature | K |
| stl1 | Soil temperature level 1 | K |
| tcwv | Total column vertically-integrated water vapour | kg m<sup>-2</sup> |
| tp | Total Precipitation | m |

> Ocean waves fields

| Parameter | Description | Units |
| --------- | ----------- | ----- |
| mp2 | Mean zero-crossing wave period | s |
| mwd | Mean wave direction | Degree true |
| mwp | Mean wave period | s |
| pp1d | Peak wave period | s |
| swh | Significant height of combined wind waves and swell | m |

> Ensemble mean and standard deviation - pressure levels

| Parameter | Description | Units | Levels |
| --------- | ----------- | ----- | ------ |
| gh | Geopotential height | gpm | 300, 500, 1000 |
| t | Temperature | K | 250, 500, 850 |
| ws | Wind speed | m s<sup>-1</sup> | 250, 850 |

> Ensemble mean and standard deviation - single level

| Parameter | Description | Units |
| --------- | ----------- | ----- |
| msl | Mean sea level pressure | Pa |

> Instantaneous weather events - atmospheric fields - 850 hPa

| Parameter | Description | Units |
| --------- | ----------- | ----- |
| ptsa_gt_1p5stdev | Probability of temperature standardized anomaly greater than 1.5 standard deviation | % |
| ptsa_gt_1stdev | Probability of temperature standardized anomaly greater than 1 standard deviation | % |
| ptsa_gt_2stdev | Probability of temperature standardized anomaly greater than 2 standard deviation | % |
| ptsa_lt_1p5stdev | Probability of temperature standardized anomaly less than -1.5 standard deviation | % |
| ptsa_lt_1stdev | Probability of temperature standardized anomaly less than -1 standard deviation | % |
| ptsa_lt_2stdev | Probability of temperature standardized anomaly less than -2 standard deviation | % |

> Daily weather events - atmospheric fields - single level

| Parameter | Description | Units |
| --------- | ----------- | ----- |
| 10fgg10 | 10 metre wind gust of at least 10 m/s | % |
| 10fgg15 | 10 metre wind gust of at least 15 m/s | % |
| 10fgg25 | 10 metre wind gust of at least 25 m/s | % |
| tpg1 | Total precipitation of at least 1 mm | % |
| tpg10 | Total precipitation of at least 10 mm | % |
| tpg100 | Total precipitation of at least 100 mm | % |
| tpg20 | Total precipitation of at least 20 mm | % |
| tpg25 | Total precipitation of at least 25 mm | % |
| tpg5 | Total precipitation of at least 5 mm | % |
| tpg50 | Total precipitation of at least 50 mm | % |

> Instantaneous weather events - ocean waves fields

| Parameter | Description | Units |
| --------- | ----------- | ----- |
| swhg2 | Significant wave height of at least 2 m | % |
| swhg4 | Significant wave height of at least 4 m | % |
| swhg6 | Significant wave height of at least 6 m | % |
| swhg8 | Significant wave height of at least 8 m | % |

### Ensemble numbers

You can select individual members of the ensemble forecast use the keyword `number`.

```python
...
   stream="enfo",
   step=24,
   param="msl",
   number=1,
...
   stream="enfo",
   step=24,
   param="msl",
   number=[1, 10, 20],
...
```

| List of ensemble numbers |
| ----------------------------- |
|   1 to 50 |

> 📌 **NOTE**: Not specifying `number` will return all ensemble forecast members.

## Examples

### Download a single surface parameter at a single forecast step from ECMWF's 00UTC HRES forecast

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

client.retrieve(
    time=0,
    stream="oper",
    type="fc",
    step=24,
    param="2t",
    target="data.grib2",
)
```

### Download the tropical cyclone tracks from ECMWF's 00UTC HRES forecast

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

client.retrieve(
    time=0,
    stream="oper",
    type="tf",
    step=240,
    target="data.bufr",
)
```

- The downloaded data are encoded in BUFR edition 4
- For the HRES Tropical Cyclone tracks at time=06 and time=18 use:

```python
...
   step = 90,
...
```

> ❗ **NOTE:** Tropical cyclone tracks products are only available when there are tropical cyclones observed or forecast.

### Download a single surface parameter at a single forecast step for all ensemble members from ECMWF's 12UTC 00UTC ENS forecast

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

client.retrieve(
    time=0,
    stream="enfo",
    type="pf",
    param="msl",
    target="data.grib2",
)
```

- To download a single ensemble member, use the `number` keyword:  `number=1`.
- All of the odd numbered ensemble members use `number=[num for num in range(1,51,2)]`.
- To download the control member, use `type="cf"`.

### Download the Tropical Cyclone tracks from ECMWF's 00UTC ENS forecast

The Tropical Cyclone tracks are identified by the keyword `type="tf"`.

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

client.retrieve(
    time=0,
    stream="enfo",
    type="tf",
    step=240,
    target="data.bufr",
)
```

- The downloaded data are encoded in BUFR edition 4
- For the ENS Tropical Cyclone tracks at time=06 and time=18 replace `step=240` with `step=144`.

### Download the ensemble mean and standard deviation for all parameters at a single forecast step from ECMWF's 00UTC ENS forecast

The ensemble mean and standard deviation are identified by the keywords `type="em"`:

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

client.retrieve(
    time=0,
    stream="enfo",
    type="em",
    step=24,
    target="data.grib2",
)
```

and `type="es"`, respectively:

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

client.retrieve(
    time=0,
    stream="enfo",
    type="es",
    step=24,
    target="data.grib2",
)

```

### Download the ensemble probability products

The ensemble probability products are identified by the keyword `type="ep"`.  The probability products are available only for `time=00` and `time=12`.

Two different products are available.

#### Probabilities - Instantaneous weather events - Pressure levels

The probability of temperature standardized anomalies at a constant
pressure level of 850hPa are available at 12 hourly forecast steps.

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

client.retrieve(
    time=0,
    stream="enfo",
    type="ep",
    step=[i for i in range(12, 361, 12)],
    levelist=850,
    param=[
        "ptsa_gt_1stdev",
        "ptsa_gt_1p5stdev",
        "ptsa_gt_2stdev",
        "ptsa_lt_1stdev",
        "ptsa_lt_1p5stdev",
        "ptsa_lt_2stdev",
    ],
    target="data.grib2",
)
```

#### Probabilities - Daily weather events - Single level

The probabilities of total precipitation and wind gusts exceeding specified thresholds in a 24 hour period are available for step ranges 0-24 to 336-360 by 12​​.  These are specified in the retrieval request using, e.g.: `step=["0-24", "12-36", "24-48"]`.

```python
from ecmwf.opendata import Client

client = Client(source="ecmwf")

steps = [f"{12 * i}-{ 12 * i + 24}" for i in range(29)]

client.retrieve(
    time=0,
    stream="enfo",
    type="ep",
    step=steps,
    param=["tpg1", "tpg5", "10fgg10"],
    target="data.grib2",
)
```

### ECMWF open data license

By downloading data from the ECMWF open data dataset, you agree to the their terms: Attribution 4.0 International (CC BY 4.0). If you do not agree with such terms, do not download the data. Visit [this page](https://apps.ecmwf.int/datasets/licences/general/) for more information.

### License

[Apache License 2.0](LICENSE) In applying this licence, ECMWF does not waive the privileges and immunities
granted to it by virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ecmwf/ecmwf-opendata",
    "name": "ecmwf-opendata",
    "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/dc/3b/18cdf4a4e1f1511d58aa35124a37d4553645d9c8f59ce766ba87ab2fe9ed/ecmwf-opendata-0.3.10.tar.gz",
    "platform": null,
    "description": "# ecmwf-opendata\n\n`ecmwf-opendata` is a package to simplify the download of ECMWF [open data](https://www.ecmwf.int/en/forecasts/datasets/open-data). It implements a request-based interface to the dataset using ECMWF's MARS language to select meteorological fields, similar to the existing  [ecmwf-api-client](https://github.com/ecmwf/ecmwf-api-client) Python package.\n\nA collection of Jupyter Notebooks that make use of that package is available [here](https://github.com/ecmwf/notebook-examples/tree/master/opencharts).\n\n## Installation\n\nThe `ecmwf-opendata` Python package can be installed from PyPI with:\n\n```$ pip install ecmwf-opendata```\n\n## Usage\nThe example below will download the latest available 10-day forecast for the *mean sea level pressure* (`msl`) into a local file called `data.grib2`:\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client()\n\nclient.retrieve(\n    step=240,\n    type=\"fc\",\n    param=\"msl\",\n    target=\"data.grib2\",\n)\n```\n\n> \u2757 **NOTE:** This package is designed for users that want to download a subset of the whole dataset. If you plan to download a large percentage of each data file, it may be more efficient to download whole files and filter out the data you want locally. See the documentation on the [file naming convention](https://confluence.ecmwf.int/display/DAC/ECMWF+open+data:+real-time+forecasts) for more information. Alternatively, you can use this tool to download whole files by only specifying `date`, `time`, `step`, `stream` and `type`. Please be aware that all data for a full day is in the order of 726 GiB.\n\n\n## Options\n\nThe constructor of the client object takes the following options:\n\n```python\nclient = Client(\n    source=\"ecmwf\",\n    model=\"ifs\",\n    resol=\"0p25\",\n    preserve_request_order=False,\n    infer_stream_keyword=True,\n)\n```\n\nwhere:\n\n- `source` is either the name of server to contact or a fully qualified URL. Possible values are `ecmwf` to access ECMWF's servers, or `azure` to access data hosted on Microsoft's Azure. Default is `ecmwf`.\n\n- `model` is the name of the model that produced the data. Use `ifs` for the physics-driven model and `aifs` for the data-driven model. Please note that `aifs` is currently experimental and only produces a small subset of fields. Default is `ifs`.\n\n- `resol` specifies the resolution of the data. Default is `0p25` for 0.25 degree resolution, and is the only resolution that is currently available.\n\n- `preserve_request_order`. If this flag is set to `True`, the library will attempt to write the retrieved data into the target file in the order specified by the request. For example, if the request specifies `param=[2t,msl]` the library will ensure that the field `2t` is first in the target file, while with `param=[msl,2t]`, the field `msl` will be first. This also works across different keywords: `...,levelist=[500,100],param=[z,t],...` will produce different output to `...,param=[z,t],levelist=[500,100],...`\nIf the flag is set to `False`, the library will sort the request to minimise the number of HTTP requests made to the server, leading to faster download speeds. Default is `False`.\n\n- `infer_stream_keyword`. The `stream` keyword represents the ECMWF forecasting system that creates the data. Setting it properly requires knowledge of how ECMWF runs its operations. If this boolean is set to `True`, the library will try to infer the correct value for the `stream` keyword based on the rest of the request. Default is `True` if model is `ifs`.\n\n > \u26a0\ufe0f **NOTE:** It is recommended **not** to set the `preserve_request_order` flag to `True` when downloading a large number of fields as this will add extra load on the servers.\n\n## Methods\n\n> `Client.retrieve()`\n\nThe `Client.retrieve()` method takes request as input and will retrieve the corresponding data from the server and write them in the user's target file.\n\nA request is a list of keyword/value pairs used to select the desired data. It is possible to specify a list of values for a given keyword.\n\nThe request can either be specified as a dictionary:\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nrequest = {\n    \"time\": 0,\n    \"type\": \"fc\",\n    \"step\": 24,\n    \"param\": [\"2t\", \"msl\"],\n}\n\nclient.retrieve(request, \"data.grib2\")\n\n# or:\n\nclient.retrieve(\n    request=request,\n    target=\"data.grib2\",\n)\n```\n\nor directly as arguments to the `retrieve()` method:\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nclient.retrieve(\n    time=0,\n    type=\"fc\",\n    step=24,\n    param=[\"2t\", \"msl\"],\n    target=\"data.grib2\",\n)\n```\n\nThe `date` and `time` keyword are used to select the date and time of the forecast run (see [Date and time](#date-and-time) below). If `date` or both `date` and `time` are not specified, the library will query the server for the most recent matching data. The `date` and `time` of the downloaded forecast is returned by the `retrieve()` method.\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nresult = client.retrieve(\n    type=\"fc\",\n    step=24,\n    param=[\"2t\", \"msl\"],\n    target=\"data.grib2\",\n)\n\nprint(result.datetime)\n```\n\nmay print `2022-01-23 00:00:00`.\n\n> `Client.download()`\n\nThe `Client.download()` method takes the same parameters as the `Client.retrieve()` method, but will download the whole data files from the server, ignoring keywords like `param`, `levelist` or `number`.\n\nThe example below will download all field from the latest time step 24, ignoring the keyword `param`:\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nclient.download(\n    param=\"msl\",\n    type=\"fc\",\n    step=24,\n    target=\"data.grib2\",\n)\n\n```\n\n> `Client.latest()`\n\nThe `Client.latest()` method takes the same parameters as the `Client.retrieve()` method, and returns the date of the most recent matching forecast without downloading the data:\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nprint(client.latest(\n    type=\"fc\",\n    step=24,\n    param=[\"2t\", \"msl\"],\n    target=\"data.grib2\",\n))\n```\n\nmay print `2022-01-23 00:00:00`.\n\n> \u23f0 **NOTE**: The data is available between 7 and 9 hours after the forecast starting date and time, depending on the forecasting system and the time step specified.\n\n## Request keywords\n\nThe supported keywords are:\n\n- `type`: the type of data (compulsory, defaults to `fc`).\n- `stream`: the forecast system (optional if unambiguous, compulsory otherwise). See the `infer_stream_keyword` [above](#options).\n- `date`: the date at which the forecast starts.\n- `time`: the time at which the forecast starts.\n- `step`: the forecast time step in hours, or `fcmonth`, the time step in months for the seasonal forecast (compulsory, default to `0` and `1`, respectively).\n\nand (all optional, with no defaults):\n\n- `param`: the meteorological parameters, such as wind, pressure or humidity.\n- `levtype`: select between single level parameters and parameters on pressure levels.\n- `levelist`: the list of pressure levels when relevant.\n- `number`: the list of ensemble member numbers when relevant.\n\nThe keywords in the first list are used to identify which file to access, while the second list is used to identify which parts of the files need to be actually downloaded. Some HTTP servers are able to return multiple parts of a file, while other can only return a single part from a file. In the latter case, the library may perform many HTTP requests to the server. If you wish to download whole files, only provide keywords from the first list.\n\n### Date and time\n\nThe date and time parameters refer to the starting time of the forecast. All date and time are expressed in UTC.\n\nThere are several ways to specify the date and time in a request.\n\nDate can be specified using strings, numbers and Python `datetime.datetime` or `datetime.date` objects:\n\n```python\n...\n    date='20220125',\n    time=12,\n...\n    date='2022-01-25',\n    time=12,\n...\n    date='2022-01-25 12:00:00',\n...\n    date=20220125,\n    time=12,\n...\n    date=datetime.datetime(2022, 1, 25, 12, 0, 0),\n...\n    date=datetime.date(2022, 1, 25),\n    time=12,\n...\n```\n\nDates can also be given as a number less than or equal to zero. In this case, it is equivalent to the current UTC date minus the given number of days:\n\n```python\n...\n    date=0, # today\n    date=-1, # yesterday\n    date=-2, # the day before yesterday\n...\n```\n\nThe keyword `time` can be given as a string or an integer, or a Python `datetime.time` object. All values of time below are equivalent:\n\n```python\n...\n    time=12,\n...\n    time=1200,\n...\n    time='12',\n...\n    time='1200',\n...\n    time=datetime.time(12),\n...\n```\n\n| List of valid values for time |\n| ----------------------------- |\n| 0, 6, 12 and 18 |\n\nIf `time` is not specified, the time is extracted from the date.\n\n```python\n...\n   date='2022-01-25 12:00:00',\n...\n```\n\nis equivalent to:\n\n```python\n...\n   date='2022-01-25',\n   time=12,\n...\n```\n\nIf the `time` keyword is specified, it overrides any time given in the request.\n\n```python\n...\n   date='2022-01-25 12:00:00',\n   time=18,\n...\n```\n\nis equivalent to:\n\n```python\n...\n   date='2022-01-25',\n   time=18,\n...\n```\n\nAs stated before, if `date` or both `date` and `time` are not specified, the library will query the server for the most recent matching data. The `date` and `time` of the downloaded forecast is returned by the `retrieve()` method:\n\nExample without the `date` keyword:\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nresult = client.retrieve(\n    time=12,\n    type=\"fc\",\n    param=\"2t\",\n    step=\"24\",\n    target=\"data.grib2\",\n)\n\nprint(result.datetime)\n\n```\n\nwill print `2022-01-22 12:00:00` if run in the morning of 2022-01-23.\n\nExample without the `date` and `time` keywords:\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nresult = client.retrieve(\n    type=\"fc\",\n    param=\"2t\",\n    step=\"24\",\n    target=\"data.grib2\",\n)\n\nprint(result.datetime)\n\n```\n\nwill print `2022-01-23 00:00:00` if run in the morning of 2022-01-23.\n\n### Stream and type\n\nECMWF runs several forecasting systems:\n\n- [HRES](https://confluence.ecmwf.int/display/FUG/HRES+-+High-Resolution+Forecast): High Resolution Forecast.\n- [ENS](https://confluence.ecmwf.int/display/FUG/ENS+-+Ensemble+Forecasts): Ensemble Forecasts.\n- [SEAS](https://confluence.ecmwf.int/display/FUG/Long-Range+%28Seasonal%29+Forecast): Long-Range (Seasonal) Forecast.\n\nEach of these forecasts also produces several types of products, that are referred to using the keywords\n`stream` and `type`.\n\n> Valid values for `type` are:\n\nHRES:\n\n- `fc`: Forecast.\n\nENS:\n\n- `cf`: Control forecast.\n- `pf`: Perturbed forecast.\n- `em`: Ensemble mean.\n- `es`: Ensemble standard deviation.\n- `ep`: Probabilities.\n\n> Valid values for `stream` are:\n\n- `oper`: Atmospheric fields from HRES - 00 UTC and 12 UTC.\n- `wave`: Ocean wave fields from HRES - 00 UTC and 12 UTC.\n- `enfo`: Atmospheric fields from ENS.\n- `waef`: Ocean wave fields from ENS.\n- `scda`: Atmospheric fields from HRES - 06 UTC and 18 UTC.\n- `scwv`: Ocean wave fields from HRES - 06 UTC and 18 UTC.\n\n> \ud83d\udccc **NOTE**: if the client's flag [`infer_stream_keyword`](#options) is set to `True`, the library will infer the stream from the `type` and `time`. In that case, you just need to specify `stream=wave` to access ocean wave products, and don't provide a value for `stream` in other cases.\n\n### Time steps\n\nTo select a time step, use the `step` keyword:\n\n```python\n...\n   step=24,\n...\n   step=[24, 48],\n...\n```\n\n| Forecasting system | Time | List of time steps |\n| -------- | ---- | ------------------ |\n| HRES | 00 and 12 | 0 to 144 by 3, 144 to 240 by 6 |\n| ENS | 00 and 12 | 0 to 144 by 3, 144 to 360 by 6 |\n| HRES | 06 and 18 | 0 to 90 by 3 |\n| ENS | 06 and 18 | 0 to 144 by 3 |\n| Probabilities - Instantaneous weather events | 00 and 12 | 0 to 360 by 12 |\n| Probabilities - Daily weather events | 00 and 12 | 0-24 to 336-360 by 12 |\n\n> \ud83d\udccc **NOTE**: Not specifying `step` will return all available time steps.\n\n### Parameters and levels\n\nTo select a parameter, use the `param` keyword:\n\n```python\n...\n   param=\"msl\",\n...\n   param=[\"2t\", \"msl\"]\n...\n```\n\nfor pressure level parameters, use the `levelist` keyword:\n\n```python\n...\n   param=\"t\",\n   levelist=850,\n...\n   param=[\"u\", \"v\"],\n   levelist=[1000, 850, 500],\n...\n```\n\n> \ud83d\udccc **NOTE**: Not specifying `levelist` will return all available levels, and not specifying `param` will return all available parameters.\n\n| List of pressure levels (hPa) |\n| ----------------------------- |\n|   1000, 925, 850, 700, 500, 300, 250, 200 and 50 |\n\n\nBelow is the list of all parameters:\n\n> Atmospheric fields on pressure levels\n\n| Parameter | Description | Units |\n| --------- | ----------- | ----- |\n| d | Divergence | s<sup>-1</sup> |\n| gh | Geopotential height | gpm |\n| q | Specific humidity | kg kg<sup>-1</sup> |\n| r | Relative humidity | % |\n| t | Temperature | K |\n| u | U component of wind | m s<sup>-1</sup> |\n| v | V component of wind | m s<sup>-1</sup> |\n| vo | Vorticity (relative) | s<sup>-1</sup> |\n\n> Atmospheric fields on a single level\n\n| Parameter | Description | Units |\n| --------- | ----------- | ----- |\n| 10u | 10 metre U wind component | m s<sup>-1</sup> |\n| 10v | 10 metre V wind component | m s<sup>-1</sup> |\n| 2t | 2 metre temperature | K |\n| msl | Mean sea level pressure | Pa |\n| ro | Runoff | m |\n| skt | Skin temperature | K |\n| sp | Surface pressure | Pa |\n| st | Soil Temperature | K |\n| stl1 | Soil temperature level 1 | K |\n| tcwv | Total column vertically-integrated water vapour | kg m<sup>-2</sup> |\n| tp | Total Precipitation | m |\n\n> Ocean waves fields\n\n| Parameter | Description | Units |\n| --------- | ----------- | ----- |\n| mp2 | Mean zero-crossing wave period | s |\n| mwd | Mean wave direction | Degree true |\n| mwp | Mean wave period | s |\n| pp1d | Peak wave period | s |\n| swh | Significant height of combined wind waves and swell | m |\n\n> Ensemble mean and standard deviation - pressure levels\n\n| Parameter | Description | Units | Levels |\n| --------- | ----------- | ----- | ------ |\n| gh | Geopotential height | gpm | 300, 500, 1000 |\n| t | Temperature | K | 250, 500, 850 |\n| ws | Wind speed | m s<sup>-1</sup> | 250, 850 |\n\n> Ensemble mean and standard deviation - single level\n\n| Parameter | Description | Units |\n| --------- | ----------- | ----- |\n| msl | Mean sea level pressure | Pa |\n\n> Instantaneous weather events - atmospheric fields - 850 hPa\n\n| Parameter | Description | Units |\n| --------- | ----------- | ----- |\n| ptsa_gt_1p5stdev | Probability of temperature standardized anomaly greater than 1.5 standard deviation | % |\n| ptsa_gt_1stdev | Probability of temperature standardized anomaly greater than 1 standard deviation | % |\n| ptsa_gt_2stdev | Probability of temperature standardized anomaly greater than 2 standard deviation | % |\n| ptsa_lt_1p5stdev | Probability of temperature standardized anomaly less than -1.5 standard deviation | % |\n| ptsa_lt_1stdev | Probability of temperature standardized anomaly less than -1 standard deviation | % |\n| ptsa_lt_2stdev | Probability of temperature standardized anomaly less than -2 standard deviation | % |\n\n> Daily weather events - atmospheric fields - single level\n\n| Parameter | Description | Units |\n| --------- | ----------- | ----- |\n| 10fgg10 | 10 metre wind gust of at least 10 m/s | % |\n| 10fgg15 | 10 metre wind gust of at least 15 m/s | % |\n| 10fgg25 | 10 metre wind gust of at least 25 m/s | % |\n| tpg1 | Total precipitation of at least 1 mm | % |\n| tpg10 | Total precipitation of at least 10 mm | % |\n| tpg100 | Total precipitation of at least 100 mm | % |\n| tpg20 | Total precipitation of at least 20 mm | % |\n| tpg25 | Total precipitation of at least 25 mm | % |\n| tpg5 | Total precipitation of at least 5 mm | % |\n| tpg50 | Total precipitation of at least 50 mm | % |\n\n> Instantaneous weather events - ocean waves fields\n\n| Parameter | Description | Units |\n| --------- | ----------- | ----- |\n| swhg2 | Significant wave height of at least 2 m | % |\n| swhg4 | Significant wave height of at least 4 m | % |\n| swhg6 | Significant wave height of at least 6 m | % |\n| swhg8 | Significant wave height of at least 8 m | % |\n\n### Ensemble numbers\n\nYou can select individual members of the ensemble forecast use the keyword `number`.\n\n```python\n...\n   stream=\"enfo\",\n   step=24,\n   param=\"msl\",\n   number=1,\n...\n   stream=\"enfo\",\n   step=24,\n   param=\"msl\",\n   number=[1, 10, 20],\n...\n```\n\n| List of ensemble numbers |\n| ----------------------------- |\n|   1 to 50 |\n\n> \ud83d\udccc **NOTE**: Not specifying `number` will return all ensemble forecast members.\n\n## Examples\n\n### Download a single surface parameter at a single forecast step from ECMWF's 00UTC HRES forecast\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nclient.retrieve(\n    time=0,\n    stream=\"oper\",\n    type=\"fc\",\n    step=24,\n    param=\"2t\",\n    target=\"data.grib2\",\n)\n```\n\n### Download the tropical cyclone tracks from ECMWF's 00UTC HRES forecast\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nclient.retrieve(\n    time=0,\n    stream=\"oper\",\n    type=\"tf\",\n    step=240,\n    target=\"data.bufr\",\n)\n```\n\n- The downloaded data are encoded in BUFR edition 4\n- For the HRES Tropical Cyclone tracks at time=06 and time=18 use:\n\n```python\n...\n   step = 90,\n...\n```\n\n> \u2757 **NOTE:** Tropical cyclone tracks products are only available when there are tropical cyclones observed or forecast.\n\n### Download a single surface parameter at a single forecast step for all ensemble members from ECMWF's 12UTC 00UTC ENS forecast\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nclient.retrieve(\n    time=0,\n    stream=\"enfo\",\n    type=\"pf\",\n    param=\"msl\",\n    target=\"data.grib2\",\n)\n```\n\n- To download a single ensemble member, use the `number` keyword:  `number=1`.\n- All of the odd numbered ensemble members use `number=[num for num in range(1,51,2)]`.\n- To download the control member, use `type=\"cf\"`.\n\n### Download the Tropical Cyclone tracks from ECMWF's 00UTC ENS forecast\n\nThe Tropical Cyclone tracks are identified by the keyword `type=\"tf\"`.\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nclient.retrieve(\n    time=0,\n    stream=\"enfo\",\n    type=\"tf\",\n    step=240,\n    target=\"data.bufr\",\n)\n```\n\n- The downloaded data are encoded in BUFR edition 4\n- For the ENS Tropical Cyclone tracks at time=06 and time=18 replace `step=240` with `step=144`.\n\n### Download the ensemble mean and standard deviation for all parameters at a single forecast step from ECMWF's 00UTC ENS forecast\n\nThe ensemble mean and standard deviation are identified by the keywords `type=\"em\"`:\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nclient.retrieve(\n    time=0,\n    stream=\"enfo\",\n    type=\"em\",\n    step=24,\n    target=\"data.grib2\",\n)\n```\n\nand `type=\"es\"`, respectively:\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nclient.retrieve(\n    time=0,\n    stream=\"enfo\",\n    type=\"es\",\n    step=24,\n    target=\"data.grib2\",\n)\n\n```\n\n### Download the ensemble probability products\n\nThe ensemble probability products are identified by the keyword `type=\"ep\"`.  The probability products are available only for `time=00` and `time=12`.\n\nTwo different products are available.\n\n#### Probabilities - Instantaneous weather events - Pressure levels\n\nThe probability of temperature standardized anomalies at a constant\npressure level of 850hPa are available at 12 hourly forecast steps.\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nclient.retrieve(\n    time=0,\n    stream=\"enfo\",\n    type=\"ep\",\n    step=[i for i in range(12, 361, 12)],\n    levelist=850,\n    param=[\n        \"ptsa_gt_1stdev\",\n        \"ptsa_gt_1p5stdev\",\n        \"ptsa_gt_2stdev\",\n        \"ptsa_lt_1stdev\",\n        \"ptsa_lt_1p5stdev\",\n        \"ptsa_lt_2stdev\",\n    ],\n    target=\"data.grib2\",\n)\n```\n\n#### Probabilities - Daily weather events - Single level\n\nThe probabilities of total precipitation and wind gusts exceeding specified thresholds in a 24 hour period are available for step ranges 0-24 to 336-360 by 12\u200b\u200b.  These are specified in the retrieval request using, e.g.: `step=[\"0-24\", \"12-36\", \"24-48\"]`.\n\n```python\nfrom ecmwf.opendata import Client\n\nclient = Client(source=\"ecmwf\")\n\nsteps = [f\"{12 * i}-{ 12 * i + 24}\" for i in range(29)]\n\nclient.retrieve(\n    time=0,\n    stream=\"enfo\",\n    type=\"ep\",\n    step=steps,\n    param=[\"tpg1\", \"tpg5\", \"10fgg10\"],\n    target=\"data.grib2\",\n)\n```\n\n### ECMWF open data license\n\nBy downloading data from the ECMWF open data dataset, you agree to the their terms: Attribution 4.0 International (CC BY 4.0). If you do not agree with such terms, do not download the data. Visit [this page](https://apps.ecmwf.int/datasets/licences/general/) for more information.\n\n### License\n\n[Apache License 2.0](LICENSE) In applying this licence, ECMWF does not waive the privileges and immunities\ngranted to it by virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.\n",
    "bugtrack_url": null,
    "license": "Apache License Version 2.0",
    "summary": "A package to download ECMWF open data",
    "version": "0.3.10",
    "project_urls": {
        "Homepage": "https://github.com/ecmwf/ecmwf-opendata"
    },
    "split_keywords": [
        "tool"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc3b18cdf4a4e1f1511d58aa35124a37d4553645d9c8f59ce766ba87ab2fe9ed",
                "md5": "3fa3dbe052b67a3a36e055dfcc0b267e",
                "sha256": "7bc417f02f4f04b2ab1e4e98508b7c4ce5f5a0ca2bc82317a1a861f20aa54af4"
            },
            "downloads": -1,
            "filename": "ecmwf-opendata-0.3.10.tar.gz",
            "has_sig": false,
            "md5_digest": "3fa3dbe052b67a3a36e055dfcc0b267e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 23570,
            "upload_time": "2024-09-15T16:24:59",
            "upload_time_iso_8601": "2024-09-15T16:24:59.095008Z",
            "url": "https://files.pythonhosted.org/packages/dc/3b/18cdf4a4e1f1511d58aa35124a37d4553645d9c8f59ce766ba87ab2fe9ed/ecmwf-opendata-0.3.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-15 16:24:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ecmwf",
    "github_project": "ecmwf-opendata",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "ecmwf-opendata"
}
        
Elapsed time: 1.80392s