Fast interpolation for ERA5 data with Zarr
Project description
Fast Meteo
A super-fast Python package to obtain meteorological parameters for your flight trajectories.
Data
fastmeteo
uses Analysis-Ready, Cloud Optimized (ARCO) ERA5 data from Google's Public datasets,
which in turn is derived from Copernicus ERA5.
Copernicus ERA5 data span from 1940 to present.
Beware that Google's ARCO ERA5 may not include more recent months.
You can discover the time interval covered as follows:
import xarray as xr
from fastmeteo.grid import arco_era5_url
dd = xr.open_zarr(arco_era5_url, chunks={"time": 48}, consolidated=True)
dd.coords
Checklist
Here are a few things you should know first:
-
Synchronization of the data from the Google ARCO ERA5 store can be a little slow, as each hour of data is about 250MB.
-
Once the data is available locally, the code is blazing fast.
-
To share access for your group, a good practice is to set up fastmeteo on a server and use it in Server-Client mode.
-
You can pre-sync the data using
fastmeteo-sync
command
Install
stable version
pip install fastmeteo
development version
pip install git+https://github.com/open-aviation/fastmeteo
or, if you prefer poetry
:
git clone https://github.com/open-aviation/fastmeteo
cd fastmeteo
poetry install
Usage
Local mode
You can get the weather information for a given flight or position with the following code. Basic information on time, latitude, longitude, and altitude is needed.
import pandas as pd
from fastmeteo import Grid
flight = pd.DataFrame(
{
"timestamp": ["2021-10-12T01:10:00", "2021-10-12T01:20:00"],
"latitude": [40.3, 42.5],
"longitude": [4.2, 6.6],
"altitude": [25_000, 30_000],
}
)
fmg = Grid(local_store="/tmp/era5-zarr")
# Obtain weather information.
flight_new = fmg.interpolate(flight)
Server-client mode
When running the tool in a server-client mode. The following script can be used to start a FastAPI service on the server. It handles the flight date request and obtains Google ARCO data if the partition is not on the server. After that, it will perform the interpolation of weather data and return the final data to the client.
fastmeteo-serve --local-store /tmp/era5-zarr
At the client side, the following code can be used to submit and get the process flight with meteorology data.
import pandas as pd
from fastmeteo import Client
flight = pd.DataFrame(
{
"timestamp": ["2021-10-12T01:10:00", "2021-10-12T01:20:00"],
"latitude": [40.3, 42.5],
"longitude": [4.2, 6.6],
"altitude": [25_000, 30_000],
}
)
# define the client object
client = Client()
# send the flight and receive the new DataFrame
flight_new = client.submit_flight(flight)
Pre-sync your data
You can use the following command to pre-sync the data:
fastmeteo-sync --local-store /tmp/era5-zarr/ --start 2022-01-01 --stop 2022-02-01
Above example will download the data for January 2022 to your /tmp/era5-zarr/
folder.
Options
Meteorological features
If you want more or different meteorological features than wind, temperature and humidity, specify the desired feature list as follows:
features = [
"u_component_of_wind",
"v_component_of_wind",
"convective_available_potential_energy",
]
fmg = Grid(local_store="/tmp/era5-zarr", features=features)
flight_new = fmg.interpolate(flight)
All available parameters can be found at: https://codes.ecmwf.int/grib/param-db/
You should use feature names in lower case with underscores for the list of features in fastmeteo
.
Pressure levels
By default, fastmeteo
extracts features for the following pressure levels (hPa), out of all available levels:
100, 125, 150, 175, 200, 225, 250, 300, 350, 400, 450,
500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000
You can also customize the desired levels (sorted), for example, as follows:
levels = [500, 600, 700, 800, 900, 1000]
fmg = Grid(local_store="/tmp/era5-zarr", levels=levels)
flight_new = fmg.interpolate(flight)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fastmeteo-0.2.1.tar.gz
.
File metadata
- Download URL: fastmeteo-0.2.1.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.1 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e83c091f5b4e89bcc78a171cd2cbf64f295aff006dceee139af72d7f0f08e92c |
|
MD5 | dbcf4589bf9a12571b02847999020330 |
|
BLAKE2b-256 | f982825a4407b299b7a11bda17e3c2a05745368ec9259d8d1d9e670a99b6de21 |
File details
Details for the file fastmeteo-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: fastmeteo-0.2.1-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.1 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f3e68ac3f56eb094f9b36318a4531d4e4ff400b51e0607c4596a12ba6d47d90 |
|
MD5 | 18b9cfc476b6a2f5f1af5268c08a0dee |
|
BLAKE2b-256 | 7dea098f376c3d6c6d02cf65435c2e4d7d1bcbc5e0d8f14340afe746ab54714d |