or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

climate-normals.mddaily-data.mddata-processing.mdgeographic-points.mdhourly-data.mdindex.mdmonthly-data.mdunit-conversions.mdweather-stations.md

monthly-data.mddocs/

0

# Monthly Weather Data

1

2

The Monthly class provides access to monthly aggregated weather statistics, offering long-term climate patterns and trends. Monthly data is ideal for climate analysis, seasonal comparisons, and understanding regional weather patterns over extended periods.

3

4

## Capabilities

5

6

### Monthly Data Initialization

7

8

Create a monthly time series for weather stations or geographic points with flexible time range options.

9

10

```python { .api }

11

class Monthly:

12

def __init__(self, loc: Union[pd.DataFrame, Point, list, str], start: datetime = None, end: datetime = None, model: bool = True, flags: bool = False) -> None:

13

"""

14

Initialize monthly 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, optional start of time period (day will be set to 1st)

23

- end: datetime, optional end of time period

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 monthly observations for the defined time period.

32

33

```python { .api }

34

def expected_rows(self) -> int:

35

"""

36

Return expected number of monthly rows for the date range.

37

38

Returns:

39

int, expected number of monthly observations

40

"""

41

```

42

43

## Data Columns

44

45

Monthly data includes the following aggregated meteorological parameters:

46

47

```python { .api }

48

# Temperature measurements (°C)

49

tavg: float # Average temperature for the month

50

tmin: float # Average minimum temperature

51

tmax: float # Average maximum temperature

52

53

# Precipitation

54

prcp: float # Total precipitation amount (mm)

55

56

# Wind measurements

57

wspd: float # Average wind speed (km/h)

58

59

# Atmospheric pressure

60

pres: float # Average sea level pressure (hPa)

61

62

# Solar radiation

63

tsun: float # Total sunshine duration (hours)

64

65

# Data quality flags (when flags=True)

66

tavg_flag: str # Average temperature data source flag

67

tmin_flag: str # Minimum temperature data source flag

68

tmax_flag: str # Maximum temperature data source flag

69

# ... (additional _flag columns for each parameter)

70

```

71

72

## Usage Examples

73

74

### Basic Monthly Data Retrieval

75

76

```python

77

from datetime import datetime

78

from meteostat import Point, Monthly

79

80

# Set time period for recent years

81

start = datetime(2015, 1, 1)

82

end = datetime(2020, 12, 31)

83

84

# Create point for Rome, Italy

85

rome = Point(41.9028, 12.4964, 20)

86

87

# Get monthly data

88

data = Monthly(rome, start, end)

89

monthly_data = data.fetch()

90

91

print(f"Retrieved {len(monthly_data)} monthly observations")

92

print(monthly_data[['tavg', 'tmin', 'tmax', 'prcp']].head())

93

```

94

95

### Long-Term Climate Trends

96

97

```python

98

from datetime import datetime

99

from meteostat import Point, Monthly

100

import matplotlib.pyplot as plt

101

102

# Analyze temperature trends for central England

103

central_england = Point(52.0, -2.0)

104

105

# Get 50 years of monthly data

106

start = datetime(1970, 1, 1)

107

end = datetime(2020, 12, 31)

108

109

data = Monthly(central_england, start, end)

110

monthly_data = data.fetch()

111

112

# Calculate annual temperature anomalies

113

baseline_period = monthly_data['1981':'2010']

114

baseline_temp = baseline_period['tavg'].mean()

115

116

annual_temps = monthly_data.groupby(monthly_data.index.year)['tavg'].mean()

117

temperature_anomalies = annual_temps - baseline_temp

118

119

print("Temperature anomalies relative to 1981-2010 baseline:")

120

print(temperature_anomalies.tail(10))

121

```

122

123

### Seasonal Climate Analysis

124

125

```python

126

from datetime import datetime

127

from meteostat import Point, Monthly

128

import pandas as pd

129

130

# Analyze seasonal patterns for Moscow

131

moscow = Point(55.7558, 37.6173, 156)

132

133

# Get 30 years of data

134

start = datetime(1990, 1, 1)

135

end = datetime(2020, 12, 31)

136

137

data = Monthly(moscow, start, end)

138

monthly_data = data.fetch()

139

140

# Calculate seasonal averages

141

monthly_data['season'] = monthly_data.index.month.map({

142

12: 'Winter', 1: 'Winter', 2: 'Winter',

143

3: 'Spring', 4: 'Spring', 5: 'Spring',

144

6: 'Summer', 7: 'Summer', 8: 'Summer',

145

9: 'Fall', 10: 'Fall', 11: 'Fall'

146

})

147

148

seasonal_climate = monthly_data.groupby('season').agg({

149

'tavg': ['mean', 'std'],

150

'prcp': ['mean', 'std'],

151

'tsun': 'mean'

152

})

153

154

print("30-year seasonal climate summary for Moscow:")

155

print(seasonal_climate)

156

```

157

158

### Regional Climate Comparison

159

160

```python

161

from datetime import datetime

162

from meteostat import Stations, Monthly

163

164

# Compare climate between different regions

165

northern_stations = Stations().region('NO').fetch(3) # Norway

166

southern_stations = Stations().region('ES').fetch(3) # Spain

167

168

# Get climate data for comparison period

169

start = datetime(2000, 1, 1)

170

end = datetime(2020, 12, 31)

171

172

# Northern Europe climate

173

north_data = Monthly(northern_stations, start, end).fetch()

174

north_climate = north_data.groupby(north_data.index.month).agg({

175

'tavg': 'mean', 'prcp': 'mean'

176

})

177

178

# Southern Europe climate

179

south_data = Monthly(southern_stations, start, end).fetch()

180

south_climate = south_data.groupby(south_data.index.month).agg({

181

'tavg': 'mean', 'prcp': 'mean'

182

})

183

184

print("Climate comparison - Average monthly temperature (°C):")

185

comparison = pd.DataFrame({

186

'Northern Europe': north_climate['tavg'],

187

'Southern Europe': south_climate['tavg']

188

})

189

print(comparison)

190

```

191

192

### Drought Analysis

193

194

```python

195

from datetime import datetime

196

from meteostat import Point, Monthly

197

198

# Analyze drought conditions for California

199

california = Point(36.7783, -119.4179)

200

201

# Get monthly precipitation data

202

start = datetime(1950, 1, 1)

203

end = datetime(2020, 12, 31)

204

205

data = Monthly(california, start, end)

206

monthly_data = data.fetch()

207

208

# Calculate standardized precipitation index (simple version)

209

monthly_precip = monthly_data['prcp']

210

211

# Calculate long-term monthly averages

212

monthly_normals = monthly_precip.groupby(monthly_precip.index.month).mean()

213

214

# Identify drought years (annual precipitation < 75% of normal)

215

annual_precip = monthly_precip.groupby(monthly_precip.index.year).sum()

216

normal_annual = monthly_normals.sum()

217

drought_threshold = normal_annual * 0.75

218

219

drought_years = annual_precip[annual_precip < drought_threshold]

220

print(f"Drought years (< 75% of normal precipitation):")

221

print(drought_years.sort_values())

222

```

223

224

## Data Source Flags

225

226

When `flags=True`, each meteorological parameter includes a corresponding source flag indicating data quality and origin:

227

228

```python { .api }

229

# Source flag meanings for monthly data

230

"A": str # High-quality monthly climate observations

231

"C": str # Aggregated from high-quality daily observations

232

"D": str # GHCN-M global historical climatology network monthly data

233

"E": str # Aggregated from hourly observations

234

"F": str # ISD aggregated observations

235

"G": str # SYNOP aggregated observations

236

"H": str # METAR aggregated aviation reports

237

"I": str # Model/reanalysis data (ERA5, NCEP, etc.)

238

```

239

240

## Monthly Aggregation Methods

241

242

Monthly values are calculated using appropriate aggregation methods:

243

244

```python { .api }

245

# Default aggregation functions

246

aggregations = {

247

"tavg": "mean", # Average of daily mean temperatures

248

"tmin": "mean", # Average of daily minimum temperatures

249

"tmax": "mean", # Average of daily maximum temperatures

250

"prcp": "sum", # Total monthly precipitation

251

"wspd": "mean", # Average wind speed

252

"pres": "mean", # Average pressure

253

"tsun": "sum" # Total monthly sunshine hours

254

}

255

```

256

257

## Climate Analysis Applications

258

259

Monthly data is particularly useful for:

260

261

### Climate Normals Calculation

262

```python

263

# Calculate 30-year climate normals

264

baseline_data = monthly_data['1981':'2010']

265

climate_normals = baseline_data.groupby(baseline_data.index.month).mean()

266

```

267

268

### Seasonal Cycle Analysis

269

```python

270

# Analyze the annual temperature cycle

271

monthly_cycle = monthly_data.groupby(monthly_data.index.month)['tavg'].mean()

272

temperature_range = monthly_cycle.max() - monthly_cycle.min()

273

```

274

275

### Climate Change Detection

276

```python

277

# Detect long-term trends using linear regression

278

from scipy import stats

279

280

annual_temps = monthly_data.groupby(monthly_data.index.year)['tavg'].mean()

281

years = annual_temps.index.values

282

temps = annual_temps.values

283

284

slope, intercept, r_value, p_value, std_err = stats.linregress(years, temps)

285

print(f"Temperature trend: {slope:.3f}°C per year (p={p_value:.4f})")

286

```

287

288

## Time Series Processing

289

290

Monthly data objects inherit all time series processing methods:

291

292

```python { .api }

293

# Data retrieval and analysis

294

def fetch(self) -> pd.DataFrame: ...

295

def count(self) -> int: ...

296

def coverage(self): ...

297

298

# Data processing

299

def normalize(self): ...

300

def interpolate(self, limit: int = 3): ...

301

def aggregate(self, freq: str, spatial: bool = False): ...

302

def convert(self, units: dict): ...

303

304

# Utility methods

305

def stations(self) -> pd.Index: ...

306

def clear_cache(self): ...

307

```

308

309

## Data Quality Considerations

310

311

Monthly data quality depends on:

312

313

- **Completeness**: Months with insufficient daily observations may be excluded

314

- **Spatial Coverage**: Point interpolation requires nearby stations with data

315

- **Temporal Consistency**: Long-term records may have instrumentation changes

316

- **Model Integration**: Recent periods may include reanalysis data for gap-filling