0
# Daily Weather Data
1
2
The Daily class provides access to daily weather summaries including temperature extremes, precipitation totals, wind averages, and sunshine duration. Historical daily data is available from 1781 for some locations, making it ideal for long-term climate analysis.
3
4
## Capabilities
5
6
### Daily Data Initialization
7
8
Create a daily time series for weather stations or geographic points with comprehensive historical coverage.
9
10
```python { .api }
11
class Daily:
12
def __init__(self, loc: Union[pd.DataFrame, Point, list, str], start=datetime(1781, 1, 1, 0, 0, 0), end=datetime.combine(datetime.today().date() + timedelta(days=10), datetime.max.time()), model=True, flags=False) -> None:
13
"""
14
Initialize daily weather data retrieval.
15
16
Parameters:
17
- loc: Union[pd.DataFrame, Point, list, str]
18
- pd.DataFrame: Station data from Stations.fetch()
19
- Point: Geographic point for automatic station selection
20
- list: List of station IDs
21
- str: Single station ID
22
- start: datetime, start of time period (default: 1781-01-01)
23
- end: datetime, end of time period (default: 10 days from today)
24
- model: bool, whether to include model/reanalysis data (default: True)
25
- flags: bool, whether to include data source flags (default: False)
26
"""
27
```
28
29
### Row Count Estimation
30
31
Calculate expected number of daily observations for the defined time period.
32
33
```python { .api }
34
def expected_rows(self) -> int:
35
"""
36
Return expected number of daily rows for the date range.
37
38
Returns:
39
int, expected number of daily observations
40
"""
41
```
42
43
## Data Columns
44
45
Daily data includes the following aggregated meteorological parameters:
46
47
```python { .api }
48
# Temperature measurements (°C)
49
tavg: float # Average temperature
50
tmin: float # Minimum temperature
51
tmax: float # Maximum temperature
52
53
# Precipitation
54
prcp: float # Total precipitation amount (mm)
55
56
# Snow and winter weather
57
snow: float # Snow depth (mm)
58
59
# Wind measurements
60
wdir: float # Prevailing wind direction (degrees, 0-360)
61
wspd: float # Average wind speed (km/h)
62
wpgt: float # Peak wind gust (km/h)
63
64
# Atmospheric pressure
65
pres: float # Average sea level pressure (hPa)
66
67
# Solar radiation
68
tsun: float # Total sunshine duration (minutes)
69
70
# Data quality flags (when flags=True)
71
tavg_flag: str # Average temperature data source flag
72
tmin_flag: str # Minimum temperature data source flag
73
tmax_flag: str # Maximum temperature data source flag
74
# ... (additional _flag columns for each parameter)
75
```
76
77
## Usage Examples
78
79
### Basic Daily Data Retrieval
80
81
```python
82
from datetime import datetime
83
from meteostat import Point, Daily
84
85
# Set time period for 2020
86
start = datetime(2020, 1, 1)
87
end = datetime(2020, 12, 31)
88
89
# Create point for London, UK
90
london = Point(51.5074, -0.1278, 11)
91
92
# Get daily data
93
data = Daily(london, start, end)
94
daily_data = data.fetch()
95
96
print(f"Retrieved {len(daily_data)} daily observations")
97
print(daily_data[['tavg', 'tmin', 'tmax', 'prcp']].head())
98
```
99
100
### Long-Term Historical Analysis
101
102
```python
103
from datetime import datetime
104
from meteostat import Stations, Daily
105
106
# Get stations with long historical records
107
stations = Stations().region('GB').inventory('daily', True).fetch(5)
108
109
# Analyze temperature trends over 50 years
110
start = datetime(1970, 1, 1)
111
end = datetime(2020, 12, 31)
112
113
data = Daily(stations, start, end)
114
historical_data = data.fetch()
115
116
# Calculate annual averages
117
annual_temps = historical_data.groupby(historical_data.index.year)['tavg'].mean()
118
print("50-year temperature trend:")
119
print(annual_temps.head(10))
120
```
121
122
### Seasonal Climate Analysis
123
124
```python
125
from datetime import datetime
126
from meteostat import Point, Daily
127
import pandas as pd
128
129
# Analyze seasonal patterns for Chicago
130
chicago = Point(41.8781, -87.6298, 182)
131
132
# Get 10 years of data
133
start = datetime(2010, 1, 1)
134
end = datetime(2019, 12, 31)
135
136
data = Daily(chicago, start, end)
137
daily_data = data.fetch()
138
139
# Calculate seasonal averages
140
daily_data['season'] = daily_data.index.month.map({
141
12: 'Winter', 1: 'Winter', 2: 'Winter',
142
3: 'Spring', 4: 'Spring', 5: 'Spring',
143
6: 'Summer', 7: 'Summer', 8: 'Summer',
144
9: 'Fall', 10: 'Fall', 11: 'Fall'
145
})
146
147
seasonal_stats = daily_data.groupby('season').agg({
148
'tavg': 'mean',
149
'tmin': 'mean',
150
'tmax': 'mean',
151
'prcp': 'sum'
152
})
153
154
print("Seasonal climate summary for Chicago:")
155
print(seasonal_stats)
156
```
157
158
### Multi-Station Comparison
159
160
```python
161
from datetime import datetime
162
from meteostat import Stations, Daily
163
164
# Compare daily temperatures across multiple cities
165
city_stations = Stations().nearby(40.7128, -74.0060, 10000).fetch(1) # NYC
166
city_stations = city_stations.append(Stations().nearby(34.0522, -118.2437, 10000).fetch(1)) # LA
167
168
# Get summer 2020 data
169
start = datetime(2020, 6, 1)
170
end = datetime(2020, 8, 31)
171
172
data = Daily(city_stations, start, end)
173
city_data = data.fetch()
174
175
# Compare average temperatures by station
176
temp_comparison = city_data.groupby('station')[['tavg', 'tmin', 'tmax']].mean()
177
print("Summer 2020 temperature comparison:")
178
print(temp_comparison)
179
```
180
181
### Precipitation Analysis
182
183
```python
184
from datetime import datetime
185
from meteostat import Point, Daily
186
187
# Analyze precipitation patterns for Seattle
188
seattle = Point(47.6062, -122.3321, 56)
189
190
# Get recent year of data
191
start = datetime(2020, 1, 1)
192
end = datetime(2020, 12, 31)
193
194
data = Daily(seattle, start, end)
195
daily_data = data.fetch()
196
197
# Precipitation statistics
198
rainy_days = (daily_data['prcp'] > 0).sum()
199
total_precip = daily_data['prcp'].sum()
200
max_daily_precip = daily_data['prcp'].max()
201
202
print(f"Seattle 2020 precipitation summary:")
203
print(f"Rainy days: {rainy_days}")
204
print(f"Total precipitation: {total_precip:.1f} mm")
205
print(f"Maximum daily precipitation: {max_daily_precip:.1f} mm")
206
```
207
208
## Data Source Flags
209
210
When `flags=True`, each meteorological parameter includes a corresponding source flag indicating data quality and origin:
211
212
```python { .api }
213
# Source flag meanings for daily data
214
"A": str # High-quality daily observations from national weather services
215
"B": str # GHCN-D global historical climatology network data
216
"C": str # Aggregated from high-quality hourly observations
217
"D": str # ISD Lite aggregated observations
218
"E": str # SYNOP aggregated observations
219
"F": str # METAR aggregated aviation reports
220
"G": str # Model/reanalysis data (ERA5, GFS, etc.)
221
```
222
223
## Temperature Processing
224
225
Daily temperature processing follows meteorological standards:
226
227
- **tavg**: Calculated as the mean of hourly temperatures or (tmax + tmin) / 2
228
- **tmin**: Minimum temperature recorded during the 24-hour period
229
- **tmax**: Maximum temperature recorded during the 24-hour period
230
231
## Precipitation Accumulation
232
233
Daily precipitation represents the total accumulation over the 24-hour period ending at the observation time (typically midnight local time).
234
235
```python
236
# Analyze precipitation patterns
237
wet_days = daily_data[daily_data['prcp'] > 0.1] # Days with measurable precipitation
238
dry_spells = daily_data[daily_data['prcp'] == 0] # Dry days
239
```
240
241
## Time Series Processing
242
243
Daily data objects inherit all time series processing methods:
244
245
```python { .api }
246
# Data retrieval and analysis
247
def fetch(self) -> pd.DataFrame: ...
248
def count(self) -> int: ...
249
def coverage(self): ...
250
251
# Data processing
252
def normalize(self): ...
253
def interpolate(self, limit: int = 3): ...
254
def aggregate(self, freq: str, spatial: bool = False): ...
255
def convert(self, units: dict): ...
256
257
# Utility methods
258
def stations(self) -> pd.Index: ...
259
def clear_cache(self): ...
260
```
261
262
## Aggregation to Other Frequencies
263
264
Daily data can be aggregated to longer time periods:
265
266
```python
267
# Aggregate to monthly values
268
monthly_data = daily_data.aggregate('MS') # Month start frequency
269
270
# Aggregate to annual values
271
annual_data = daily_data.aggregate('AS') # Year start frequency
272
273
# Custom aggregations with spatial averaging
274
regional_monthly = daily_data.aggregate('MS', spatial=True)
275
```