Daily Aggregation
Use to_daily when you want one row per civil day with standard daily weather summaries. This is the right tool when the model expects daily weather inputs and the source data is sub-daily.
Build A Small Hourly Series
using PlantMeteo
using Dates
using Statistics
base = DateTime(2025, 7, 1)
hourly = Weather(map(base:Hour(1):(base + Hour(47))) do t
h = Dates.hour(t)
Atmosphere(
date = t,
duration = Hour(1),
T = 18.0 + 6.0 * sin(2pi * h / 24) + (Dates.day(t) - 1),
Wind = 1.5,
Rh = 0.60 - 0.10 * sin(2pi * h / 24),
P = 101.3,
Precipitations = h in (5, 6) ? 0.6 : 0.0,
Ri_SW_f = h in 6:18 ? 700.0 * sin(pi * (h - 6) / 12) : 0.0
)
end)
hourly[1:6]| TimeStepTable{Atmosphere{(:date, :duration,...}(6 x 22): | ||||||||||||||||||||||
| date | duration | T | Wind | P | Rh | Precipitations | Cₐ | e | eₛ | VPD | ρ | λ | γ | ε | Δ | clearness | Ri_SW_f | Ri_PAR_f | Ri_NIR_f | Ri_TIR_f | Ri_custom_f | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DateTime | Hour | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | |
| 1 | 2025-07-01T00:00:00 | 1 hour | 18.0 | 1.5 | 101.3 | 0.6 | 0.0 | 400.0 | 1.24297 | 2.07162 | 0.828646 | 1.21205 | 2.45843e6 | 0.0671074 | 0.568495 | 0.130635 | Inf | 0.0 | Inf | Inf | Inf | Inf |
| 2 | 2025-07-01T01:00:00 | 1 hour | 19.5529 | 1.5 | 101.3 | 0.574118 | 0.0 | 400.0 | 1.3106 | 2.2828 | 0.972203 | 1.20562 | 2.45476e6 | 0.0672078 | 0.572379 | 0.142236 | Inf | 0.0 | Inf | Inf | Inf | Inf |
| 3 | 2025-07-01T02:00:00 | 1 hour | 21.0 | 1.5 | 101.3 | 0.55 | 0.0 | 400.0 | 1.37299 | 2.49634 | 1.12335 | 1.19969 | 2.45134e6 | 0.0673017 | 0.575789 | 0.153823 | Inf | 0.0 | Inf | Inf | Inf | Inf |
| 4 | 2025-07-01T03:00:00 | 1 hour | 22.2426 | 1.5 | 101.3 | 0.529289 | 0.0 | 400.0 | 1.42562 | 2.69347 | 1.26784 | 1.19465 | 2.4484e6 | 0.0673825 | 0.578543 | 0.164402 | Inf | 0.0 | Inf | Inf | Inf | Inf |
| 5 | 2025-07-01T04:00:00 | 1 hour | 23.1962 | 1.5 | 101.3 | 0.513397 | 0.0 | 400.0 | 1.46515 | 2.85384 | 1.38868 | 1.1908 | 2.44614e6 | 0.0674446 | 0.580541 | 0.172931 | Inf | 0.0 | Inf | Inf | Inf | Inf |
| 6 | 2025-07-01T05:00:00 | 1 hour | 23.7956 | 1.5 | 101.3 | 0.503407 | 0.6 | 400.0 | 1.48952 | 2.95887 | 1.46935 | 1.1884 | 2.44472e6 | 0.0674837 | 0.581742 | 0.178483 | Inf | 0.0 | Inf | Inf | Inf | Inf |
Aggregate To One Row Per Day
daily = to_daily(hourly)| TimeStepTable{Atmosphere{(:date, :duration,...}(2 x 26): | ||||||||||||||||||||||||||
| date | duration | T | Wind | P | Rh | Precipitations | Cₐ | e | eₛ | VPD | ρ | λ | γ | ε | Δ | clearness | Ri_SW_f | Ri_PAR_f | Ri_NIR_f | Ri_TIR_f | Ri_custom_f | year | dayofyear | Tmin | Tmax | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Date | Day | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Int64 | Int64 | Float64 | Float64 | |
| 1 | 2025-07-01 | 1 day | 18.0 | 1.5 | 101.3 | 0.6 | 1.2 | 400.0 | 1.24239 | 2.13655 | 0.894158 | 1.21231 | 2.45843e6 | 0.0671086 | 0.567683 | 0.133681 | Inf | 19.1413 | Inf | Inf | Inf | Inf | 2025 | 182 | 12.0 | 24.0 |
| 2 | 2025-07-02 | 1 day | 19.0 | 1.5 | 101.3 | 0.6 | 1.2 | 400.0 | 1.32238 | 2.27357 | 0.951192 | 1.20816 | 2.45606e6 | 0.0671732 | 0.572507 | 0.141172 | Inf | 19.1413 | Inf | Inf | Inf | Inf | 2025 | 183 | 13.0 | 25.0 |
daily| TimeStepTable{Atmosphere{(:date, :duration,...}(2 x 26): | ||||||||||||||||||||||||||
| date | duration | T | Wind | P | Rh | Precipitations | Cₐ | e | eₛ | VPD | ρ | λ | γ | ε | Δ | clearness | Ri_SW_f | Ri_PAR_f | Ri_NIR_f | Ri_TIR_f | Ri_custom_f | year | dayofyear | Tmin | Tmax | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Date | Day | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Int64 | Int64 | Float64 | Float64 | |
| 1 | 2025-07-01 | 1 day | 18.0 | 1.5 | 101.3 | 0.6 | 1.2 | 400.0 | 1.24239 | 2.13655 | 0.894158 | 1.21231 | 2.45843e6 | 0.0671086 | 0.567683 | 0.133681 | Inf | 19.1413 | Inf | Inf | Inf | Inf | 2025 | 182 | 12.0 | 24.0 |
| 2 | 2025-07-02 | 1 day | 19.0 | 1.5 | 101.3 | 0.6 | 1.2 | 400.0 | 1.32238 | 2.27357 | 0.951192 | 1.20816 | 2.45606e6 | 0.0671732 | 0.572507 | 0.141172 | Inf | 19.1413 | Inf | Inf | Inf | Inf | 2025 | 183 | 13.0 | 25.0 |
The output has one row per day and includes standard daily summaries such as mean temperature, minimum temperature, maximum temperature, summed precipitation, and integrated radiation.
daily[1].Tmin12.0daily[1].Tmax24.0daily[1].T18.0daily[1].Precipitations1.2daily[1].Ri_SW_f19.14130036406738Add Or Override Daily Transformations
You can request additional daily variables or override a default aggregation:
daily_custom = to_daily(
hourly,
:T => mean => :Tmean,
:T => maximum => :Tpeak
)| TimeStepTable{Atmosphere{(:date, :duration,...}(2 x 28): | ||||||||||||||||||||||||||||
| date | duration | T | Wind | P | Rh | Precipitations | Cₐ | e | eₛ | VPD | ρ | λ | γ | ε | Δ | clearness | Ri_SW_f | Ri_PAR_f | Ri_NIR_f | Ri_TIR_f | Ri_custom_f | year | dayofyear | Tmin | Tmax | Tmean | Tpeak | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Date | Day | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Int64 | Int64 | Float64 | Float64 | Float64 | Float64 | |
| 1 | 2025-07-01 | 1 day | 18.0 | 1.5 | 101.3 | 0.6 | 1.2 | 400.0 | 1.24239 | 2.13655 | 0.894158 | 1.21231 | 2.45843e6 | 0.0671086 | 0.567683 | 0.133681 | Inf | 19.1413 | Inf | Inf | Inf | Inf | 2025 | 182 | 12.0 | 24.0 | 18.0 | 24.0 |
| 2 | 2025-07-02 | 1 day | 19.0 | 1.5 | 101.3 | 0.6 | 1.2 | 400.0 | 1.32238 | 2.27357 | 0.951192 | 1.20816 | 2.45606e6 | 0.0671732 | 0.572507 | 0.141172 | Inf | 19.1413 | Inf | Inf | Inf | Inf | 2025 | 183 | 13.0 | 25.0 | 19.0 | 25.0 |
daily_custom[1].Tmean18.0daily_custom[1].Tpeak24.0When to_daily Is The Right Tool
Use to_daily when:
- the source data is sub-daily
- the model wants one row per day
- standard daily summaries are enough
Use Weather Sampling instead when you need rolling windows, calendar windows other than simple daily reduction, custom reducers, or cached repeated queries during simulation.