metoffice-weather-datahub


Namemetoffice-weather-datahub JSON
Version 1.2.3 PyPI version JSON
download
home_page
SummaryPython wrapper for the UK Met Office Weather DataHub API
upload_time2023-07-05 10:28:07
maintainer
docs_urlNone
authorPeter Dudfield
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MetOfficeDataHub
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
Python wrapper around MetOffice Atmospheric Model Data REST API

[![codecov](https://codecov.io/gh/openclimatefix/MetOfficeDataHub/branch/main/graph/badge.svg?token=64JOBKZNCI)](https://codecov.io/gh/openclimatefix/MetOfficeDataHub)
[![Lint Python](https://github.com/openclimatefix/MetOfficeDataHub/actions/workflows/linters.yaml/badge.svg)](https://github.com/openclimatefix/MetOfficeDataHub/actions/workflows/linters.yaml)

MetOfficeDataHub is a simple wrapper for [the API provided by the British Met Office](https://metoffice.apiconnect.ibmcloud.com/metoffice/production/) known as Weather DataHub.
It can be used to retrieve weather observations and forecasts. The aim is to focus on the AMD -
Atmosphere Model Data REST API
<https://metoffice.apiconnect.ibmcloud.com/metoffice/production/product/17502/api/16908>

This wrapper currently only downloads the latest results. No historic data can be fetched.
The timestamp can be seen in the grib/xarray files.

> ⚠️ This (unofficial) library has been built and is maintained by [Open Climate Fix](https://openclimatefix.org), not the [UK MetOffice](https://www.metoffice.gov.uk/).

## Access
You [need to register with the Weather DataHub](https://metoffice.apiconnect.ibmcloud.com/metoffice/production/user/login) and obtain an API key and secret. These should be placed in environment variables
as `API_KEY` and `API_SECRET`.

## Python

### Installation

Install directly from pypi using
```pip install metoffice-weather-datahub```

### Example

```python
from metofficedatahub.multiple_files import MetOfficeDataHub

# 1. Get data from API, download grib files
datahub = MetOfficeDataHub(client_id="fake", client_secret="fake")
datahub.download_all_files(order_ids=["test_order_id"])

# 2. load grib files to one Xarray Dataset
data = datahub.load_all_files()
```

### CLI

You can run the script directly as a CLI using:
```bash
python3 metofficedatahub/app.py --save-dir="s3://bucket/folder"
```
which will download all the files from Weather DataHub, join them together into a xarray dataset, and then save them.

You can set the environmental variable `LOG_LEVEL` to define what [log level](https://docs.python.org/3.9/library/logging.html) you would like.

It may also be worth setting 'RAW_DIR' so that the raw files are saved to a certain folder,
and not downloded again if they are already there.

## Docker
The application can be run using docker

You can pull the production docker image from docker hub using
```bash
docker pull openclimatefix/metoffice_weather_datahub
```

### local
You can also build your own docker image locally using
```bash
docker build -t metofficedatahub -f infrastructure/docker/Dockerfile .
```
and then to run the docker file use
```bash
docker run -it -e API_KEY=change -e API_SECRET=change -e SAVE_DIR='save_dir' -e ORDER_IDS='id1 id2 id3' metofficedatahub
```

# Data variables

When the data is loaded they are given a short name. Here is are some common examples:
- lcc   : Low-level cloud cover in %.
- mcc   : Medium-level cloud cover in %.
- hcc   : High-level cloud cover in %.
- sde   : Snow depth in meters.
- dlwrf : Downward longwave radiation flux - ground
- t     : Air temperature at 1 meter above surface in Kelvin.
- r     : Relative humidty in %.
- vis   : Visibility in meters.
- si10  : Wind speed in meters per second, 10 meters above surface.
- prate : Precipitation rate at the surface in kg/m^2/s.

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tr>
    <td align="center"><a href="https://github.com/peterdudfield"><img src="https://avatars.githubusercontent.com/u/34686298?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Peter Dudfield</b></sub></a><br /><a href="https://github.com/openclimatefix/MetOfficeDataHub/commits?author=peterdudfield" title="Code">💻</a></td>
    <td align="center"><a href="https://github.com/flowirtz"><img src="https://avatars.githubusercontent.com/u/6052785?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Flo</b></sub></a><br /><a href="https://github.com/openclimatefix/MetOfficeDataHub/commits?author=flowirtz" title="Code">💻</a></td>
    <td align="center"><a href="http://jack-kelly.com"><img src="https://avatars.githubusercontent.com/u/460756?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jack Kelly</b></sub></a><br /><a href="https://github.com/openclimatefix/MetOfficeDataHub/pulls?q=is%3Apr+reviewed-by%3AJackKelly" title="Reviewed Pull Requests">👀</a></td>
    <td align="center"><a href="https://www.jacobbieker.com"><img src="https://avatars.githubusercontent.com/u/7170359?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jacob Bieker</b></sub></a><br /><a href="https://github.com/openclimatefix/MetOfficeDataHub/pulls?q=is%3Apr+reviewed-by%3Ajacobbieker" title="Reviewed Pull Requests">👀</a></td>
  </tr>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "metoffice-weather-datahub",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Peter Dudfield",
    "author_email": "info@openclimatefix.org",
    "download_url": "https://files.pythonhosted.org/packages/5f/73/475488eb49979032dc52084d53a9734ef4b7f557b767edfd63909bfd970e/metoffice-weather-datahub-1.2.3.tar.gz",
    "platform": null,
    "description": "# MetOfficeDataHub\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\nPython wrapper around MetOffice Atmospheric Model Data REST API\n\n[![codecov](https://codecov.io/gh/openclimatefix/MetOfficeDataHub/branch/main/graph/badge.svg?token=64JOBKZNCI)](https://codecov.io/gh/openclimatefix/MetOfficeDataHub)\n[![Lint Python](https://github.com/openclimatefix/MetOfficeDataHub/actions/workflows/linters.yaml/badge.svg)](https://github.com/openclimatefix/MetOfficeDataHub/actions/workflows/linters.yaml)\n\nMetOfficeDataHub is a simple wrapper for [the API provided by the British Met Office](https://metoffice.apiconnect.ibmcloud.com/metoffice/production/) known as Weather DataHub.\nIt can be used to retrieve weather observations and forecasts. The aim is to focus on the AMD -\nAtmosphere Model Data REST API\n<https://metoffice.apiconnect.ibmcloud.com/metoffice/production/product/17502/api/16908>\n\nThis wrapper currently only downloads the latest results. No historic data can be fetched.\nThe timestamp can be seen in the grib/xarray files.\n\n> \u26a0\ufe0f This (unofficial) library has been built and is maintained by [Open Climate Fix](https://openclimatefix.org), not the [UK MetOffice](https://www.metoffice.gov.uk/).\n\n## Access\nYou [need to register with the Weather DataHub](https://metoffice.apiconnect.ibmcloud.com/metoffice/production/user/login) and obtain an API key and secret. These should be placed in environment variables\nas `API_KEY` and `API_SECRET`.\n\n## Python\n\n### Installation\n\nInstall directly from pypi using\n```pip install metoffice-weather-datahub```\n\n### Example\n\n```python\nfrom metofficedatahub.multiple_files import MetOfficeDataHub\n\n# 1. Get data from API, download grib files\ndatahub = MetOfficeDataHub(client_id=\"fake\", client_secret=\"fake\")\ndatahub.download_all_files(order_ids=[\"test_order_id\"])\n\n# 2. load grib files to one Xarray Dataset\ndata = datahub.load_all_files()\n```\n\n### CLI\n\nYou can run the script directly as a CLI using:\n```bash\npython3 metofficedatahub/app.py --save-dir=\"s3://bucket/folder\"\n```\nwhich will download all the files from Weather DataHub, join them together into a xarray dataset, and then save them.\n\nYou can set the environmental variable `LOG_LEVEL` to define what [log level](https://docs.python.org/3.9/library/logging.html) you would like.\n\nIt may also be worth setting 'RAW_DIR' so that the raw files are saved to a certain folder,\nand not downloded again if they are already there.\n\n## Docker\nThe application can be run using docker\n\nYou can pull the production docker image from docker hub using\n```bash\ndocker pull openclimatefix/metoffice_weather_datahub\n```\n\n### local\nYou can also build your own docker image locally using\n```bash\ndocker build -t metofficedatahub -f infrastructure/docker/Dockerfile .\n```\nand then to run the docker file use\n```bash\ndocker run -it -e API_KEY=change -e API_SECRET=change -e SAVE_DIR='save_dir' -e ORDER_IDS='id1 id2 id3' metofficedatahub\n```\n\n# Data variables\n\nWhen the data is loaded they are given a short name. Here is are some common examples:\n- lcc   : Low-level cloud cover in %.\n- mcc   : Medium-level cloud cover in %.\n- hcc   : High-level cloud cover in %.\n- sde   : Snow depth in meters.\n- dlwrf : Downward longwave radiation flux - ground\n- t     : Air temperature at 1 meter above surface in Kelvin.\n- r     : Relative humidty in %.\n- vis   : Visibility in meters.\n- si10  : Wind speed in meters per second, 10 meters above surface.\n- prate : Precipitation rate at the surface in kg/m^2/s.\n\n## Contributors \u2728\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tr>\n    <td align=\"center\"><a href=\"https://github.com/peterdudfield\"><img src=\"https://avatars.githubusercontent.com/u/34686298?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Peter Dudfield</b></sub></a><br /><a href=\"https://github.com/openclimatefix/MetOfficeDataHub/commits?author=peterdudfield\" title=\"Code\">\ud83d\udcbb</a></td>\n    <td align=\"center\"><a href=\"https://github.com/flowirtz\"><img src=\"https://avatars.githubusercontent.com/u/6052785?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Flo</b></sub></a><br /><a href=\"https://github.com/openclimatefix/MetOfficeDataHub/commits?author=flowirtz\" title=\"Code\">\ud83d\udcbb</a></td>\n    <td align=\"center\"><a href=\"http://jack-kelly.com\"><img src=\"https://avatars.githubusercontent.com/u/460756?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Jack Kelly</b></sub></a><br /><a href=\"https://github.com/openclimatefix/MetOfficeDataHub/pulls?q=is%3Apr+reviewed-by%3AJackKelly\" title=\"Reviewed Pull Requests\">\ud83d\udc40</a></td>\n    <td align=\"center\"><a href=\"https://www.jacobbieker.com\"><img src=\"https://avatars.githubusercontent.com/u/7170359?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Jacob Bieker</b></sub></a><br /><a href=\"https://github.com/openclimatefix/MetOfficeDataHub/pulls?q=is%3Apr+reviewed-by%3Ajacobbieker\" title=\"Reviewed Pull Requests\">\ud83d\udc40</a></td>\n  </tr>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python wrapper for the UK Met Office Weather DataHub API",
    "version": "1.2.3",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5b65e62fe169f330260cb85a93c8c0196edae6944ec310e6a324cd8b280d1cd9",
                "md5": "797faa15b2916e444bbb438a1de65cfd",
                "sha256": "c172b8a919ac0a4dbf324ff9e6681c0b570e2691d906b4ee578b6772cc6bc3db"
            },
            "downloads": -1,
            "filename": "metoffice_weather_datahub-1.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "797faa15b2916e444bbb438a1de65cfd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 15011,
            "upload_time": "2023-07-05T10:28:06",
            "upload_time_iso_8601": "2023-07-05T10:28:06.442827Z",
            "url": "https://files.pythonhosted.org/packages/5b/65/e62fe169f330260cb85a93c8c0196edae6944ec310e6a324cd8b280d1cd9/metoffice_weather_datahub-1.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5f73475488eb49979032dc52084d53a9734ef4b7f557b767edfd63909bfd970e",
                "md5": "ae2e53d04ed45c06c06d6dbf625cb0cd",
                "sha256": "fe96755372e2455218bf76c68ded7503f446a0b3597dea418ee3d8df8df80d72"
            },
            "downloads": -1,
            "filename": "metoffice-weather-datahub-1.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ae2e53d04ed45c06c06d6dbf625cb0cd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 14686,
            "upload_time": "2023-07-05T10:28:07",
            "upload_time_iso_8601": "2023-07-05T10:28:07.872024Z",
            "url": "https://files.pythonhosted.org/packages/5f/73/475488eb49979032dc52084d53a9734ef4b7f557b767edfd63909bfd970e/metoffice-weather-datahub-1.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-05 10:28:07",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "metoffice-weather-datahub"
}
        
Elapsed time: 0.34887s