Skip to main content

perfectdays

perfectdays retrieves the hourly temperature and irradiance for any point in Europe, and compress it into typical periods, ideal to reduce data dimensionality in modelling.

Landscape, Qian Du

It is developed by EPFL (Switzerland), within the Industrial Process and Energy Systems Engineering (IPESE) group.

This package is the weather module of models developed within the laboratory, such as REHO or PinchSmall - that you are encouraged to explore as well. Indeed, those models help taking decisions in the planning of energy systems - at the district-scale for REHO - where external conditions are critical. Moreover, those decisions span over several long period of time, from 20 to 40 years, and therefore need forecasting of those conditions.

To this end the package has two purposes: providing reliable weather data, now and in the future, and compact them into typical periods.

This first aspect addresses:

  • the lack of precision unveiled from common sources such as ERA5, a project where the grid resolution is at 30 km, which is not sufficient in the Alpine terrain where the temperature elevation gradient can change drastically within that distance.
  • the absence of data at short time horizon (until 2050).

SwissWeatherGrid

This package gives therefore the possibility to build a 1km grid, SwissWeatherGrid, now or under a climate scenario (RCPs), reusing the interpolation methodology from MeteoSwiss [1]. This interpolation method is then reused to create a grid for the climate change scenarios from CH2025 and WSL's downscaling [2].

Documentation

https://perfectdays.readthedocs.io/

Use

1. Install

pip install perfectdays

To read grids from PostgreSQL, install the optional extra:

pip install "perfectdays[postgres]"

Two more extras: plotting (matplotlib) draws the clustering-quality figures, and build holds what producing the Swiss grid needs (netCDF4, matplotlib, PostgreSQL). Reading the grid and clustering need neither.

pip install "perfectdays[build]"    # maintainers: python -m perfectdays.swissweathergrid.grid_building

2. Typical periods anywhere in Europe

from perfectdays import get_typical_periods

tp = get_typical_periods(46.52, 6.63, periods=10)              # Lausanne
tp, quality = get_typical_periods(48.85, 2.35, years=[2019, 2020],
                                  periods=10, clustering_evaluation=True)
quality.stability.plot()

See the Typical periods page of the documentation.

3. Hourly data for one Swiss point

from perfectdays.swissweathergrid import get_cell_weather

df = get_cell_weather(46.52, 6.63, 2023)   # Lausanne, 8760 rows

Coordinates are WGS84 degrees; the point is snapped to the 1 km cell containing it. You get an hourly frame for the whole calendar year — 8760 rows, 8784 in a leap year:

column unit source
temperature °C the KED grid
beam, diffuse W/m² PVGIS, for the plane you asked for
global_horizontal W/m² beam + diffuse

Pass irradiance=False for temperature only, or slope= and azimuth= for a tilted plane.

4. Choose a scenario

df = get_cell_weather(46.52, 6.63, 2023, scenario="rcp45_2040")

A scenario is named {pathway}_{year}. A pathway says how the world gets warmer, a year says when you are looking. Neither alone fixes a climate.

part values meaning
pathway rcp26, rcp45, rcp85 CH2018 emission pathway, 12 / 25 / 31 model chains
year 1990–2100 resolved to the WSL decade containing it

"current" is the observed year, unwarmed.

The published grid holds the years 2030, 2040 and 2050 of each pathway, on the base year 2023; any other year has to be built first.

The year argument stays the base year — the observed year being warmed. So scenario="rcp45_2040", year=2023 means "2023's weather, moved to the climate of the 2040s under RCP4.5". The change is measured between the decade containing your base year and the decade containing the scenario year, taken from the same model chains, so the historical record cancels and only the climate signal survives.

5. What a scenario series may be used for

Each delivered year is a continuous 8760-hour series with real day-to-day persistence, because the scenario warms an observed year rather than synthesising one. What it is not is a moment in a trajectory.

No transient series. WSL provides decade snapshots, not a continuous run through the century. The authors: "only snapshots for the future are provided with discontinuities between them." Two scenario years are two separate stationary climates, not two points on a path.

No climate signal in the sub-daily cycle. The delta is applied to a historical hourly record, so the diurnal shape is inherited from the past. What the method gets right is leaving that shape undistorted; what it cannot tell you is how the shape itself changes.

Only the change is usable. The signal is a difference taken inside WSL, between two decades of the same model chain, which cancels the bias of the underlying record. Absolute scenario values do not carry over; differences and ratios do.

In practice:

you want do
typical days, duration curves, monthly or seasonal statistics fine — these use the distribution
a design day, a heating or cooling degree-hour total fine
"what does 14 July 2045 look like" no — the day order carries no information
a 2030 → 2040 → 2050 trajectory no — the decades are separate stationary climates
a change in the shape of the daily cycle no — inherited from the historical record

Structure

folder what it does
perfectdays/clients/ hourly years from the Swiss grid, PVGIS or your files in one shape, and prices from ENTSO-E and the SFOE
perfectdays/clusteringfactory/ typical periods by k-medoids (PAM), and their quality
perfectdays/api/ get_weather, get_typical_periods: source choice, fallback, output formats
perfectdays/api/reho.py REHO's weather step, with REHO's arguments
perfectdays/swissweathergrid/core/ HTTP caching, LV95 coordinates, elevation, grid definition
perfectdays/swissweathergrid/interpolation_method/ rebuilds and validates the method of Frey & Frei (2025)
perfectdays/swissweathergrid/grid_building/ applies it to produce national grids per scenario and year
perfectdays/swissweathergrid/cell_access/ queries a grid for one location, and adds irradiance

References

  1. Frey, L. & Frei, C. (2025). Interpolation of Hourly Surface Air Temperature — Application of a Spatio-Temporal Statistical Model in Complex Terrain. International Journal of Climatology, 45(7). https://doi.org/10.1002/joc.8796
  2. Michel, A., Sharma, V., Lehning, M. & Huwald, H. (2021). Climate change scenarios at hourly time-step over Switzerland from an enhanced temporal downscaling approach. International Journal of Climatology, 41(6), 3503–3522. https://doi.org/10.1002/joc.7032
  3. Loustau, J. (2026). SwissWeatherGrid: hourly air temperature on a 1 km grid for Switzerland [Dataset, CC BY 4.0]. Zenodo. https://doi.org/10.5281/zenodo.23674731

Main contributors

  • Joseph Loustau, IPESE, EPFL

License

Code: Apache License 2.0 — see LICENSE. Data: CC BY 4.0, see the Zenodo record.

Metadata

Release files for perfectdays 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for perfectdays 0.0.4
File Size Uploaded Provenance Actions
perfectdays-0.0.4.tar.gz 2.5 MB Without provenance Details for perfectdays-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for perfectdays 0.0.4
File Interpreter ABI Platform Actions
perfectdays-0.0.4-py3-none-any.whl Python 3 none any Details for perfectdays-0.0.4-py3-none-any.whl

Total release size: 5.0 MB

Release files / perfectdays-0.0.4.tar.gz

Download URL perfectdays-0.0.4.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
d34135fb9b9a1bb80ec66ec868542e57f9d89da419d63f53b680f069e05a3fa6
BLAKE2b-256 checksum
How to use checksums
2303f36ac4bd7a5edb7d2e18978ebd7598192f36da34831e061a6be6b85f09e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / perfectdays-0.0.4-py3-none-any.whl

Download URL perfectdays-0.0.4-py3-none-any.whl
Size 2.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
99e4364980e86c0099326a9fc2aab42267f857305e07b54b3237b66350bc669f
BLAKE2b-256 checksum
How to use checksums
043e01de69aed1ee6545c4bd3937ef2a2859ddf9b836acd6e4252cd24c5dd780
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Security for perfectdays 0.0.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page