ERA5 to EPW Converter
A tool that fetches ERA5 data and generates a full year AMY (Actual Meteorological Year) EnergyPlus Weather file (EPW).
The tool takes care of fetching the necessary data from the Copernicus Climate Data Store (CDS) and the Copernicus Atmosphere Data Store (CAMS), processing it, and formatting it into the EPW format. It's designed for fast and efficient data retrieval.
Installation
Prerequisites
Make sure to register for an API key and validate licences at:
- https://cds.climate.copernicus.eu/ (ERA5 data)
- https://ads.atmosphere.copernicus.eu/ (Copernicus Atmosphere Data Store)
Before proceeding further, it is required to accept all the licenses in the section "Your profile" in the website of Copernicus.
CDS/ADS credentials
Passing the key as environment variable
This is the easiest method. Use:
import os
os.environ["CDSADS_API_KEY"] = "YOUR_KEY"
Installing the API key in your filesytem
Then create the file ~/.cdsapirc with the following content:
url: https://cds.climate.copernicus.eu/api/v2
key: <your_api_key>
Note: the URL will be dynamically managed by the script depending on the data source. The API key doesn't vary, it's the same for both ERA5 and CAMS data.
Earth Data Hub credentials (optional)
If you want to use the Earth Data Hub (EDH) as a data source instead of CDS, you need to set up your EDH personal access token.
Passing the token as environment variable
import os
os.environ["EDH_TOKEN"] = "edh_pat_..."
Or in the shell:
export EDH_TOKEN="edh_pat_..."
Installing the token in your filesystem
Create the file ~/.edh_token with your personal access token (plain text, first line):
edh_pat_...
Install the package
From PyPI
pip install era5epw
From source
Clone the current repository and install the required dependencies using Poetry:
git clone https://github.com/airboxlab/era5epw.git
poetry install
Usage
pip install ipywidgets
# optional, not needed with Jupyter Notebook 7+
jupyter nbextension enable --py widgetsnbextension
Generating EPW Files
Command line interface
Example usage:
# using poetry, execute in local repository
poetry run era5epw_download --year 2024 --latitude 49.4 --longitude 0.1 --city-name "Le Havre" --elevation 0 --time-zone 1
# using installed binary, after pypi package installation
era5epw_download --year 2024 --latitude 49.4 --longitude 0.1 --city-name "Le Havre" --elevation 0 --time-zone 1
# using Earth Data Hub as data source (faster downloads, requires EDH token)
era5epw_download --year 2024 --latitude 49.4 --longitude 0.1 --city-name "Le Havre" --elevation 0 --time-zone 1 --era5-data-source edh
By default, the time-zone argument is used only to populate the LOCATION header and data time is UTC. Use --apply-time-zone-to-data to apply it to the date and time fields (this will shift the UTC time by the provided time zone offset).
Use --help to have a list of available options.
Python API
Example usage:
from era5epw.main import download_and_make_epw
download_and_make_epw(
year=2025,
latitude=48.8,
longitude=2.4,
city_name="Paris",
time_zone=1,
elevation=0,
output_file="/tmp/era5epw_paris_2025.epw",
apply_time_zone_to_data=True,
)
# Or using Earth Data Hub as data source (faster downloads):
download_and_make_epw(
year=2025,
latitude=48.8,
longitude=2.4,
city_name="Paris",
time_zone=1,
elevation=0,
output_file="/tmp/era5epw_paris_2025.epw",
apply_time_zone_to_data=True,
era5_data_source="edh",
)
Reading EPW Files into a DataFrame
The package provides a reader to load EPW files into Pandas DataFrames for inspection, data analysis, and further processing.
Python API
from era5epw.reader import read_epw_file
# Load EPW file into a DataFrame
df = read_epw_file("path/to/file.epw")
# Inspect the data
print(df.head())
print(df.describe())
# Access specific weather series
print(df["Dry Bulb Temperature"].mean())
# Filter by date
january_data = df[df.index.month == 1]
Visualizing EPW Files
The package includes an interactive visualization tool for EPW files that supports four types of plots: 2D line charts, 3D surface plots, radar (polar) plots, and psychrometric charts.
The psychrometric chart shows each hourly record of the year as a point (outdoor dry bulb temperature vs. humidity ratio), colored by day of year. Saturation, relative humidity, enthalpy and dew point curves are drawn in distinct colors and can be toggled by clicking their legend entry. Hovering a point displays all measured and calculated values (dew point, relative humidity, pressure, humidity ratio, enthalpy, wet bulb temperature, vapor pressure, specific volume) with units.
Command line interface
# List available weather series in an EPW file
era5epw_visualize path/to/file.epw --list-series
# Create a 2D line plot (default)
era5epw_visualize path/to/file.epw --series "Dry Bulb Temperature" --type 2D
# Create a 3D surface plot
era5epw_visualize path/to/file.epw --series "Wind Speed" --type 3D
# Create a radar plot showing daily min/max values
era5epw_visualize path/to/file.epw --series "Global Horizontal Radiation" --type radar
# Create a psychrometric chart, with enthalpy and dew point curves initially shown
# (relative humidity curves are shown by default, use --no-relative-humidity to hide them)
era5epw_visualize path/to/file.epw --type psychrometric --enthalpy --dew-point
# Save visualization to HTML file
era5epw_visualize path/to/file.epw --series "Dry Bulb Temperature" --output visualization.html
Python API
Use in Jupyter notebooks or Python scripts:
from era5epw.visualize import visualize_epw
# Create interactive 2D plot
fig = visualize_epw(
epw_file_path="path/to/file.epw",
series_name="Dry Bulb Temperature",
plot_type="2D",
show=True # Display immediately in Jupyter
)
# Create 3D surface plot
fig = visualize_epw(
epw_file_path="path/to/file.epw",
series_name="Wind Speed",
plot_type="3D",
show=True
)
# Create radar plot
fig = visualize_epw(
epw_file_path="path/to/file.epw",
series_name="Global Horizontal Radiation",
plot_type="radar",
show=True
)
# Create psychrometric chart
fig = visualize_epw(
epw_file_path="path/to/file.epw",
plot_type="psychrometric",
show_relative_humidity=True,
show_enthalpy=True,
show_dew_point=False,
show=True
)
# Save to HTML file
fig.write_html("visualization.html")
Documentation
Datasets home pages:
- ERA5 hourly time-series data on single levels from 1940 to present (Experimental)
- ERA5 Land hourly time-series data from 1950 to present (Experimental)
- ERA5 hourly data on single levels from 1940 to present
- CAMS solar radiation time-series
- Earth Data Hub - ERA5 reanalysis single levels (License: Copernicus License)
View your API requests and download responses at:
Check CDS API status at CDS Live, it provides information about congestion for each dataset.
Metadata
Release files for era5epw 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| era5epw-0.8.0.tar.gz | 30.8 kB | Without provenance | Details for era5epw-0.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| era5epw-0.8.0-py3-none-any.whl | Python 3 | none | any | Details for era5epw-0.8.0-py3-none-any.whl |
Total release size: 64.4 kB
Release files / era5epw-0.8.0.tar.gz
| Download URL | era5epw-0.8.0.tar.gz |
|---|---|
| Size | 30.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed73c7f26913987ad43c2a2b7804ca9a98505b9b55e942e37eefcbd8668d14bd
|
|
BLAKE2b-256 checksum How to use checksums |
4a72d27d8fa4f1eac102e20b830c74aa92b21c06e516f6caf9751e01f7c7c4e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-146-generic
|
Release files / era5epw-0.8.0-py3-none-any.whl
| Download URL | era5epw-0.8.0-py3-none-any.whl |
|---|---|
| Size | 33.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23251417724ed1d4704077482d66e768b625e8e85c8a5fe8287375d429736c27
|
|
BLAKE2b-256 checksum How to use checksums |
b013ae8322677f07870f14d414b721baf18461aa4b864b78ab437018679e6e3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-146-generic
|
Security for era5epw 0.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.