Validation of ERA5 and ERA5-Land reanalysis data (code)
Published:
Matching Timezone and calendar of station and ERA5-Land data
Timezone of ERA5-Land was converted to local UTC+6 time zone and calendar type of BMD data matches with ERA5 Land data
import xarray as xr
import pandas as pd
import numpy as np
ERA5_Land = xr.open_dataset(r"D:\CMIP6 Project\Thesis work\Data Analysis\Data\ERA5Land_Data\merged_data\ERA5_Land_Daily_Tmin_Tmax_1950_2019(unmasked_localized).nc",
chunks = {"time": 365})
ERA5_Land
<xarray.Dataset> Size: 625MB
Dimensions: (latitude: 65, longitude: 47, valid_time: 25568)
Coordinates:
* latitude (latitude) float64 520B 27.0 26.9 26.8 26.7 ... 20.8 20.7 20.6
* longitude (longitude) float64 376B 88.0 88.1 88.2 88.3 ... 92.4 92.5 92.6
number int64 8B ...
* valid_time (valid_time) datetime64[ns] 205kB 1950-01-01 ... 2020-01-01
Data variables:
t2m_min (valid_time, latitude, longitude) float32 312MB dask.array<chunksize=(25568, 65, 47), meta=np.ndarray>
t2m_max (valid_time, latitude, longitude) float32 312MB dask.array<chunksize=(25568, 65, 47), meta=np.ndarray>25568 * 59 * 46
69391552
BMD_temp_data = pd.read_csv(r"D:\CMIP6 Project\Thesis work\BMD_stations Data\BMD_temp_data_cleaned(2).csv")
BMD_temp_data
| Station_ID | Tmax | Date | Tmin | Latitude | Longitude | |
|---|---|---|---|---|---|---|
| 0 | 11111 | 26.4 | 1989-01-01 | 14.7 | 23.78 | 90.39 |
| 1 | 11111 | 27.8 | 1989-02-01 | 11.6 | 23.78 | 90.39 |
| 2 | 11111 | 33.0 | 1989-03-01 | 19.7 | 23.78 | 90.39 |
| 3 | 11111 | 33.3 | 1989-04-01 | 22.3 | 23.78 | 90.39 |
| 4 | 11111 | 33.3 | 1989-05-01 | 24.4 | 23.78 | 90.39 |
| ... | ... | ... | ... | ... | ... | ... |
| 350247 | 11929 | 34.0 | 2019-05-31 | 27.0 | 20.87 | 92.26 |
| 350248 | 11929 | 31.2 | 2019-07-31 | 24.5 | 20.87 | 92.26 |
| 350249 | 11929 | 32.8 | 2019-08-31 | 25.5 | 20.87 | 92.26 |
| 350250 | 11929 | 32.5 | 2019-10-31 | 24.5 | 20.87 | 92.26 |
| 350251 | 11929 | 28.6 | 2019-12-31 | 14.5 | 20.87 | 92.26 |
350252 rows × 6 columns
BMD_temp_data["Date"] = pd.to_datetime(BMD_temp_data["Date"])
era5_start = pd.to_datetime(ERA5_Land.valid_time.min().values)
era5_end = pd.to_datetime(ERA5_Land.valid_time.max().values)
bmd_start = BMD_temp_data["Date"].min()
bmd_end = BMD_temp_data["Date"].max()
start = max(era5_start, bmd_start)
end = min(era5_end, bmd_end)
print("Overlap:", start, "to", end)
Overlap: 1989-01-01 00:00:00 to 2019-12-31 00:00:00
ERA5_Land = ERA5_Land.sel(valid_time = slice(start, end))
BMD_temp_data = BMD_temp_data.query("Date >= @start and Date <= @end")
Station Location
ERA5_Land.valid_time
<xarray.DataArray 'valid_time' (valid_time: 11322)> Size: 91kB
array(['1989-01-01T00:00:00.000000000', '1989-01-02T00:00:00.000000000',
'1989-01-03T00:00:00.000000000', ..., '2019-12-29T00:00:00.000000000',
'2019-12-30T00:00:00.000000000', '2019-12-31T00:00:00.000000000'],
dtype='datetime64[ns]')
Coordinates:
number int64 8B ...
* valid_time (valid_time) datetime64[ns] 91kB 1989-01-01 ... 2019-12-31import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
# ------------------------------------------
# 2. Select 1 day (example: 2005-06-15)
# ------------------------------------------
date = "2012-12-31T00:00:00.000000000"
tmax = ERA5_Land["t2m_max"].sel(valid_time=date) # change variable name if needed
# ----------------------l--------------------
# 3. Clip the data to Bangladesh extent
# ------------------------------------------
bd_extent = {
"lon_min": 88.0,
"lon_max": 93.0,
"lat_min": 20.5,
"lat_max": 26.7
}
# ------------------------------------------
# 4. Plot map
# ------------------------------------------
plt.figure(figsize=(10, 8))
ax = plt.axes(projection=ccrs.PlateCarree())
# Plot temperature data
temp_plot = tmax.plot(
ax=ax,
transform=ccrs.PlateCarree(),
cmap="coolwarm",
cbar_kwargs={"label": "Daily Max Temperature (°C)"}
)
# Add borders and coastlines
ax.add_feature(cfeature.BORDERS, linewidth=1)
ax.add_feature(cfeature.COASTLINE, linewidth=1)
# Set map extent to Bangladesh
ax.set_extent([
bd_extent["lon_min"],
bd_extent["lon_max"],
bd_extent["lat_min"],
bd_extent["lat_max"]
], crs=ccrs.PlateCarree())
# ------------------------------------------
# 5. Add station locations
# ------------------------------------------
# Plot station points
ax.scatter(
BMD_temp_data["Longitude"],
BMD_temp_data["Latitude"],
color="black",
s= 5,
marker="o",
transform=ccrs.PlateCarree(),
zorder=5,
label="Stations"
)
lons = BMD_temp_data["Longitude"].values
lats = BMD_temp_data["Latitude"].values
ids = BMD_temp_data["Station_ID"].values
# # Faster annotation loop (zip is faster than iterrows)
# for lon, lat, sid in zip(lons, lats, ids):
# ax.annotate(
# sid,
# xy=(lon, lat),
# xytext=(3, 3), # offset in points (better than adding 0.05 degrees)
# textcoords="offset points",
# fontsize=7,
# transform=ccrs.PlateCarree(),
# zorder=6
# )
# Title
plt.title(f"ERA5-Land Daily Maximum Temperature (Clipped) — {date}")
plt.show()

Spatial Matching
stations = pd.DataFrame({
"station": BMD_temp_data["Station_ID"],
"lat": BMD_temp_data["Latitude"],
"lon": BMD_temp_data["Longitude"]
}).drop_duplicates().sort_values("station")
stations = stations.set_index("station")
Bilinear Interpolation to match ERA5 Land with BMD
ERA5_interpolated = ERA5_Land.interp(
latitude = xr.DataArray(stations["lat"], dims="station"),
longitude=xr.DataArray(stations["lon"], dims="station"),
method="linear"
)
ERA5_interpolated
<xarray.Dataset> Size: 3MB
Dimensions: (valid_time: 11322, station: 31)
Coordinates:
number int64 8B ...
* valid_time (valid_time) datetime64[ns] 91kB 1989-01-01 ... 2019-12-31
latitude (station) float64 248B 25.63 25.72 24.35 ... 24.15 23.64 22.43
longitude (station) float64 248B 88.66 89.26 88.56 ... 89.55 88.84 89.66
* station (station) int64 248B 10120 10208 10320 ... 41909 41926 41958
Data variables:
t2m_min (valid_time, station) float32 1MB dask.array<chunksize=(11322, 31), meta=np.ndarray>
t2m_max (valid_time, station) float32 1MB dask.array<chunksize=(11322, 31), meta=np.ndarray>ERA5_interpolated_df = ERA5_interpolated.to_dataframe().reset_index().copy()
ERA5_interpolated_df.query("station == 10724").isnull().sum()
valid_time 0
station 0
number 0
t2m_min 0
t2m_max 0
latitude 0
longitude 0
dtype: int64
ERA5_interpolated_df.groupby("station").agg({
't2m_min': ['min', 'max', 'mean', 'std'],
't2m_max': ['min', 'max', 'mean', 'std']
}).sort_values("station")
| t2m_min | t2m_max | |||||||
|---|---|---|---|---|---|---|---|---|
| min | max | mean | std | min | max | mean | std | |
| station | ||||||||
| 10120 | 6.412379 | 28.491783 | 20.257843 | 5.286250 | 16.551578 | 42.772448 | 29.296266 | 3.785527 |
| 10208 | 6.322086 | 28.380123 | 20.373954 | 5.087419 | 16.131735 | 42.586959 | 29.050219 | 3.478245 |
| 10320 | 6.700494 | 30.944928 | 21.271502 | 5.178701 | 15.995563 | 43.347028 | 29.989999 | 4.078047 |
| 10408 | 6.154918 | 29.357701 | 20.625156 | 5.201029 | 16.048512 | 42.540719 | 29.566232 | 3.591045 |
| 10609 | 6.615167 | 28.250275 | 20.491554 | 4.943889 | 17.064716 | 39.282672 | 29.214862 | 3.192209 |
| 10705 | 7.010919 | 27.096500 | 19.938147 | 5.042058 | 15.921823 | 36.444723 | 28.313082 | 3.051478 |
| 10724 | 7.161569 | 27.963370 | 20.600480 | 4.916576 | 16.259147 | 37.779030 | 29.067945 | 3.141100 |
| 10910 | 6.554049 | 31.218561 | 21.222470 | 5.201077 | 16.450416 | 42.501608 | 29.928881 | 3.822689 |
| 11111 | 7.718297 | 29.686793 | 21.546357 | 4.871126 | 17.077047 | 39.126959 | 29.582719 | 3.204785 |
| 11313 | 6.950573 | 28.728336 | 21.072713 | 4.921459 | 17.327682 | 38.998668 | 29.452167 | 2.984413 |
| 11316 | 9.774635 | 29.395602 | 22.273267 | 4.410081 | 17.833815 | 38.058146 | 29.202964 | 3.057549 |
| 11407 | 7.077291 | 30.774073 | 21.438167 | 5.245564 | 16.693766 | 41.306920 | 30.231537 | 3.553976 |
| 11505 | 8.928385 | 30.255504 | 22.051437 | 4.609079 | 16.493546 | 39.976578 | 29.620647 | 3.461003 |
| 11513 | 8.612526 | 29.877614 | 21.797809 | 4.730350 | 17.527203 | 39.711149 | 29.714050 | 3.267853 |
| 11604 | 8.815924 | 30.452545 | 22.065483 | 4.857384 | 17.398102 | 40.336383 | 30.015319 | 3.320520 |
| 11610 | 9.215221 | 30.768600 | 22.591497 | 4.736520 | 17.368649 | 39.986505 | 29.969724 | 3.428891 |
| 11704 | 9.271344 | 29.680182 | 22.244039 | 4.550566 | 17.913727 | 38.773688 | 29.508578 | 3.126911 |
| 11706 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 11805 | 7.403014 | 28.553590 | 21.252864 | 4.910786 | 17.918053 | 39.111979 | 29.392524 | 2.783592 |
| 11809 | 8.200573 | 29.069928 | 21.657615 | 4.883584 | 17.970065 | 38.980914 | 29.227233 | 2.738281 |
| 11912 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 11925 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 11927 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 11929 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 12007 | 10.781818 | 27.833893 | 21.472983 | 4.041542 | 17.580621 | 38.572223 | 29.217029 | 3.034111 |
| 12103 | 9.213492 | 29.808073 | 22.183727 | 4.712824 | 17.706227 | 39.206989 | 29.573670 | 2.967243 |
| 12110 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 41858 | 6.183942 | 28.256549 | 20.259963 | 5.156502 | 16.273297 | 42.776959 | 29.128408 | 3.599653 |
| 41909 | 7.383209 | 30.576080 | 21.373266 | 5.030683 | 16.713043 | 41.350800 | 29.707446 | 3.597685 |
| 41926 | 6.560924 | 31.327760 | 21.306985 | 5.249911 | 15.735485 | 42.600719 | 30.132265 | 3.895679 |
| 41958 | 9.880143 | 30.354303 | 22.474237 | 4.517624 | 17.658937 | 39.786930 | 29.724687 | 3.264485 |
Missing values are only for coastal regions as bilinear interpolatin is picking null grid cells. (6 regions in total)
Using KDTree to bypass nearest null grid cells
mask = ~ERA5_Land["t2m_min"].isel(valid_time = 0).isnull()
lats = ERA5_Land.latitude.values
lons = ERA5_Land.longitude.values
lon2d, lat2d = np.meshgrid(lons, lats)
valid_lats = lat2d[mask.values]
valid_lons = lon2d[mask.values]
from scipy.spatial import cKDTree
coords = np.column_stack([valid_lats, valid_lons])
tree = cKDTree(coords)
station_coords = np.column_stack([
stations["lat"].values,
stations["lon"].values
])
dist, idx = tree.query(station_coords)
nearest_lat = valid_lats[idx]
nearest_lon = valid_lons[idx]
era_sel_valid = ERA5_Land.sel(
latitude = xr.DataArray(nearest_lat, dims="station"),
longitude = xr.DataArray(nearest_lon, dims="station"),
method="nearest"
)
Using nearest neighbors where bilinear fails
ERA5_final = ERA5_interpolated.where(~ERA5_interpolated.isnull(), era_sel_valid)
ERA5_final
<xarray.Dataset> Size: 3MB
Dimensions: (valid_time: 11322, station: 31)
Coordinates:
number int64 8B 0
* valid_time (valid_time) datetime64[ns] 91kB 1989-01-01 ... 2019-12-31
* station (station) int64 248B 10120 10208 10320 ... 41909 41926 41958
Data variables:
t2m_min (valid_time, station) float32 1MB dask.array<chunksize=(11322, 31), meta=np.ndarray>
t2m_max (valid_time, station) float32 1MB dask.array<chunksize=(11322, 31), meta=np.ndarray>Bilinear Interpolation was failing for more than 12 stations because of missing grid cells. Moreover, for nearest neighbors six stations were giving negative values due to nearest neighbor being a null grid cell. KDTree is utilized to select nearest non-negative cells.
Validation of the ERA5 Land
Station wise min-max temperature.
ERA5_final.to_dataframe().reset_index().groupby("station").agg({
't2m_min': ['min', 'max', 'mean', 'std'],
't2m_max': ['min', 'max', 'mean', 'std']
}).sort_values("station")
| t2m_min | t2m_max | |||||||
|---|---|---|---|---|---|---|---|---|
| min | max | mean | std | min | max | mean | std | |
| station | ||||||||
| 10120 | 6.412379 | 28.491783 | 20.257843 | 5.286250 | 16.551578 | 42.772448 | 29.296266 | 3.785527 |
| 10208 | 6.322086 | 28.380123 | 20.373954 | 5.087419 | 16.131735 | 42.586959 | 29.050219 | 3.478245 |
| 10320 | 6.700494 | 30.944928 | 21.271502 | 5.178701 | 15.995563 | 43.347028 | 29.989999 | 4.078047 |
| 10408 | 6.154918 | 29.357701 | 20.625156 | 5.201029 | 16.048512 | 42.540719 | 29.566232 | 3.591045 |
| 10609 | 6.615167 | 28.250275 | 20.491554 | 4.943889 | 17.064716 | 39.282672 | 29.214862 | 3.192209 |
| 10705 | 7.010919 | 27.096500 | 19.938147 | 5.042058 | 15.921823 | 36.444723 | 28.313082 | 3.051478 |
| 10724 | 7.161569 | 27.963370 | 20.600480 | 4.916576 | 16.259147 | 37.779030 | 29.067945 | 3.141100 |
| 10910 | 6.554049 | 31.218561 | 21.222470 | 5.201077 | 16.450416 | 42.501608 | 29.928881 | 3.822689 |
| 11111 | 7.718297 | 29.686793 | 21.546357 | 4.871126 | 17.077047 | 39.126959 | 29.582719 | 3.204785 |
| 11313 | 6.950573 | 28.728336 | 21.072713 | 4.921459 | 17.327682 | 38.998668 | 29.452167 | 2.984413 |
| 11316 | 9.774635 | 29.395602 | 22.273267 | 4.410081 | 17.833815 | 38.058146 | 29.202964 | 3.057549 |
| 11407 | 7.077291 | 30.774073 | 21.438167 | 5.245564 | 16.693766 | 41.306920 | 30.231537 | 3.553976 |
| 11505 | 8.928385 | 30.255504 | 22.051437 | 4.609079 | 16.493546 | 39.976578 | 29.620647 | 3.461003 |
| 11513 | 8.612526 | 29.877614 | 21.797809 | 4.730350 | 17.527203 | 39.711149 | 29.714050 | 3.267853 |
| 11604 | 8.815924 | 30.452545 | 22.065483 | 4.857384 | 17.398102 | 40.336383 | 30.015319 | 3.320520 |
| 11610 | 9.215221 | 30.768600 | 22.591497 | 4.736520 | 17.368649 | 39.986505 | 29.969724 | 3.428891 |
| 11704 | 9.271344 | 29.680182 | 22.244039 | 4.550566 | 17.913727 | 38.773688 | 29.508578 | 3.126911 |
| 11706 | 10.488922 | 29.530182 | 22.794556 | 4.221715 | 18.256989 | 38.422516 | 29.036763 | 2.969537 |
| 11805 | 7.403014 | 28.553590 | 21.252864 | 4.910786 | 17.918053 | 39.111979 | 29.392524 | 2.783592 |
| 11809 | 8.200573 | 29.069928 | 21.657615 | 4.883584 | 17.970065 | 38.980914 | 29.227233 | 2.738281 |
| 11912 | 12.255768 | 28.853668 | 22.574561 | 3.789379 | 17.785553 | 38.077301 | 28.306954 | 2.480430 |
| 11925 | 12.271637 | 28.850250 | 22.944027 | 3.486472 | 19.248199 | 34.793365 | 27.767918 | 2.476537 |
| 11927 | 11.933258 | 28.517731 | 22.767665 | 3.395087 | 19.673737 | 35.697662 | 28.224306 | 2.491416 |
| 11929 | 13.353180 | 28.346100 | 22.840709 | 3.212529 | 20.769684 | 36.162506 | 28.431334 | 2.156101 |
| 12007 | 10.781818 | 27.833893 | 21.472983 | 4.041542 | 17.580621 | 38.572223 | 29.217029 | 3.034111 |
| 12103 | 9.213492 | 29.808073 | 22.183727 | 4.712824 | 17.706227 | 39.206989 | 29.573670 | 2.967243 |
| 12110 | 12.133453 | 30.245026 | 23.475727 | 4.092068 | 18.591461 | 37.176666 | 28.696625 | 2.544665 |
| 41858 | 6.183942 | 28.256549 | 20.259963 | 5.156502 | 16.273297 | 42.776959 | 29.128408 | 3.599653 |
| 41909 | 7.383209 | 30.576080 | 21.373266 | 5.030683 | 16.713043 | 41.350800 | 29.707446 | 3.597685 |
| 41926 | 6.560924 | 31.327760 | 21.306985 | 5.249911 | 15.735485 | 42.600719 | 30.132265 | 3.895679 |
| 41958 | 9.880143 | 30.354303 | 22.474237 | 4.517624 | 17.658937 | 39.786930 | 29.724687 | 3.264485 |
BMD_temp_data.groupby("Station_ID").agg({
'Tmin': ['min', 'max', 'mean', 'std'],
'Tmax': ['min', 'max', 'mean', 'std']
}).sort_values("Station_ID")
| Tmin | Tmax | |||||||
|---|---|---|---|---|---|---|---|---|
| min | max | mean | std | min | max | mean | std | |
| Station_ID | ||||||||
| 10120 | 3.2 | 29.8 | 20.165044 | 5.959467 | 11.0 | 41.4 | 30.143516 | 4.190926 |
| 10208 | 3.5 | 30.5 | 20.383087 | 5.655361 | 10.9 | 39.8 | 29.710768 | 3.934541 |
| 10320 | 3.4 | 30.2 | 20.585100 | 6.100116 | 12.6 | 43.7 | 31.368947 | 4.462741 |
| 10408 | 4.5 | 30.0 | 21.137493 | 5.538622 | 11.0 | 44.0 | 30.812219 | 3.827229 |
| 10609 | 4.7 | 30.6 | 20.929267 | 5.443022 | 12.7 | 38.1 | 29.930125 | 3.484783 |
| 10705 | 3.4 | 29.4 | 20.813694 | 4.650099 | 15.0 | 39.6 | 30.398621 | 3.413802 |
| 10724 | 4.0 | 29.0 | 19.584097 | 5.948212 | 15.0 | 39.2 | 30.676571 | 3.481706 |
| 10910 | 3.9 | 31.0 | 20.648286 | 6.113454 | 13.5 | 43.0 | 31.154891 | 4.265283 |
| 11111 | 6.5 | 30.3 | 22.032806 | 5.058577 | 13.4 | 40.2 | 30.873182 | 3.622845 |
| 11313 | 5.3 | 30.2 | 21.138808 | 5.210189 | 15.2 | 39.2 | 30.405040 | 3.297922 |
| 11316 | 7.2 | 29.7 | 22.083627 | 4.793834 | 15.0 | 40.0 | 30.713029 | 3.488855 |
| 11407 | 4.2 | 30.0 | 20.982325 | 5.922744 | 13.6 | 43.2 | 31.906020 | 3.938520 |
| 11505 | 5.6 | 30.0 | 21.420237 | 5.369222 | 13.3 | 41.2 | 30.844090 | 3.802004 |
| 11513 | 6.0 | 29.5 | 21.484272 | 5.400612 | 14.5 | 39.7 | 31.025556 | 3.523218 |
| 11604 | 6.4 | 30.0 | 21.904400 | 5.391311 | 13.6 | 40.7 | 31.419321 | 3.707221 |
| 11610 | 5.5 | 31.3 | 21.694822 | 5.639526 | 13.5 | 43.4 | 31.391827 | 3.715452 |
| 11704 | 6.5 | 29.8 | 21.445988 | 5.428201 | 15.8 | 39.4 | 30.821382 | 3.236582 |
| 11706 | 7.2 | 30.4 | 21.745178 | 5.254986 | 15.2 | 38.9 | 30.569686 | 3.069304 |
| 11805 | 6.1 | 30.0 | 21.320725 | 4.962469 | 16.3 | 39.4 | 30.422788 | 3.081824 |
| 11809 | 8.5 | 29.8 | 22.296520 | 4.638249 | 15.5 | 39.3 | 30.493828 | 3.386917 |
| 11912 | 5.7 | 31.0 | 20.995132 | 5.427792 | 17.2 | 40.2 | 30.964749 | 2.813139 |
| 11925 | 10.0 | 32.0 | 22.354721 | 4.252070 | 18.2 | 38.5 | 30.093878 | 2.704971 |
| 11927 | 10.3 | 31.0 | 22.458922 | 3.959521 | 19.7 | 39.5 | 30.925062 | 2.563048 |
| 11929 | 9.7 | 29.5 | 22.173823 | 4.271971 | 21.0 | 38.0 | 30.429290 | 2.242611 |
| 12007 | 5.5 | 28.8 | 20.866150 | 4.763227 | 16.5 | 41.1 | 30.957360 | 3.275935 |
| 12103 | 7.4 | 30.0 | 22.067839 | 4.974604 | 15.4 | 39.5 | 30.876540 | 3.233258 |
| 12110 | 7.7 | 30.4 | 22.223292 | 5.046664 | 15.6 | 40.0 | 30.619346 | 2.907762 |
| 41858 | 2.9 | 31.0 | 20.219003 | 5.760257 | 11.6 | 41.0 | 30.112208 | 4.101184 |
| 41909 | 5.1 | 31.0 | 20.883697 | 5.577681 | 13.5 | 40.5 | 30.678590 | 3.928976 |
| 41926 | 3.9 | 30.0 | 20.878134 | 6.053535 | 12.5 | 43.5 | 31.610638 | 4.298561 |
| 41958 | 7.2 | 30.5 | 22.533336 | 4.819382 | 14.8 | 40.5 | 31.127363 | 3.602428 |
After observing the above statistics, I can say that there is a warm-bias in ERA5.
Time series Plot ERA5 VS Observational data
ERA5_final
<xarray.Dataset> Size: 3MB
Dimensions: (valid_time: 11322, station: 31)
Coordinates:
number int64 8B 0
* valid_time (valid_time) datetime64[ns] 91kB 1989-01-01 ... 2019-12-31
* station (station) int64 248B 10120 10208 10320 ... 41909 41926 41958
Data variables:
t2m_min (valid_time, station) float32 1MB dask.array<chunksize=(11322, 31), meta=np.ndarray>
t2m_max (valid_time, station) float32 1MB dask.array<chunksize=(11322, 31), meta=np.ndarray>ERA5_final_df = ERA5_final.to_dataframe().reset_index().copy().drop(columns = ['number'])
ERA5_final_df.rename(columns = {"t2m_min": "Tmin", "t2m_max": "Tmax",
"valid_time": "Date", "station": "Station_ID"}, inplace = True)
# Save this file for later use (Extreme Indices, and Statistical Test):
# ERA5_final_df.to_csv(r"D:\CMIP6 Project\Thesis work\Data Analysis\Data\ERA5Land_Data\interpolated data\ERA5_Land_interpolated.csv", index = False)
Visual Inspection:
import matplotlib.pyplot as plt
# Select data for a specific station:
station_id = 11111
df_era5 = ERA5_final_df.query("Station_ID == @station_id")
df_bmd = BMD_temp_data.query("Station_ID == @station_id")
# Convert "Date" columns to datetime and sort by date
df_era5["Date"] = pd.to_datetime(df_era5["Date"])
df_era5 = df_era5.sort_values("Date")
df_bmd["Date"] = pd.to_datetime(df_bmd["Date"])
df_bmd = df_bmd.sort_values("Date")
# Create figure
plt.figure(figsize=(12, 6))
# Plot ERA5 (Red, Dotted)
plt.plot(
df_era5['Date'],
df_era5['Tmax'],
color='red',
linestyle='-',
alpha=0.5,
label='ERA5-Land Tmax'
)
# Plot BMD (Blue, Solid)
plt.plot(
df_bmd['Date'],
df_bmd['Tmax'],
color='blue',
linestyle='-',
alpha=0.3,
label='BMD Tmax'
)
# Labels and title
plt.xlabel('Date')
plt.ylabel('Maximum Temperature (°C)')
plt.title(f'Daily Maximum Temperature: ERA5-Land vs BMD - Station ID: {station_id}')
# Legend
plt.legend()
# Improve layout
plt.tight_layout()
# Show plot
plt.show()

Dark shaded color means complete alignment.
# Create figure
plt.figure(figsize=(12, 6))
# Plot ERA5 (Red, Dotted)
plt.plot(
df_era5['Date'],
df_era5['Tmin'],
color='red',
linestyle='-',
alpha=0.5,
label='ERA5-Land Tmin'
)
# Plot BMD (Blue, Solid)
plt.plot(
df_bmd['Date'],
df_bmd['Tmin'],
color='blue',
linestyle='-',
alpha=0.3,
label='BMD Tmin'
)
# Labels and title
plt.xlabel('Date')
plt.ylabel('Minimum Temperature (°C)')
plt.title(f'Daily Minimum Temperature: ERA5-Land vs BMD - Station ID: {station_id}')
# Legend
plt.legend()
# Improve layout
plt.tight_layout()
# Show plot
plt.show()

Stationwise correlation, RMSE, and Mean Bias
df_merged = pd.merge(
BMD_temp_data,
ERA5_final_df,
on=['Station_ID', 'Date'],
suffixes=('_bmd', '_era5'),
how='inner'
)
df_merged.isna().sum()
Station_ID 0
Tmax_bmd 1233
Date 0
Tmin_bmd 1362
Latitude 0
Longitude 0
Tmin_era5 0
Tmax_era5 0
dtype: int64
df_merged = df_merged.dropna(subset=['Tmin_bmd', 'Tmin_era5', 'Tmax_bmd', 'Tmax_era5'])
bmd_st_name = pd.read_csv(r"D:\CMIP6 Project\Thesis work\BMD_stations Data\MaxTempAverRain (1).csv")
df_merged = pd.merge(
df_merged,
bmd_st_name.loc[:, ["Stn_Name", "Stn_ID"]],
left_on="Station_ID",
right_on="Stn_ID",
how="left"
)
import numpy as np
from scipy.stats import pearsonr
def rmse(obs, sim):
return np.sqrt(np.mean((sim - obs) ** 2))
def bias(obs, sim):
return np.mean(sim - obs)
def corr(obs, sim):
return pearsonr(obs, sim)[0]
def mae(obs, sim):
return np.mean(np.abs(sim - obs))
results = []
for station, group in df_merged.groupby('Stn_Name'):
obs = group['Tmax_bmd']
sim = group['Tmax_era5']
r = corr(obs, sim)
r_rmse = rmse(obs, sim)
r_mae = mae(obs, sim)
r_bias = bias(obs, sim)
results.append({
'station_id': station,
'Correlation': r,
'RMSE (°C)': r_rmse,
"MAE (°C)": r_mae,
'Mean Bias (°C)': r_bias,
'Missing Days': 11321 - len(group)
})
df_metrics = pd.DataFrame(results)
print("Overall Metrics for Tmax:")
df_metrics
Overall Metrics for Tmax:
| station_id | Correlation | RMSE (°C) | MAE (°C) | Mean Bias (°C) | Missing Days | |
|---|---|---|---|---|---|---|
| 0 | Barisal | 0.899101 | 1.943085 | 1.637737 | -1.312560 | 14 |
| 1 | Bhola | 0.895486 | 2.068009 | 1.789841 | -1.536216 | 241 |
| 2 | Bogra | 0.893167 | 2.132864 | 1.785701 | -1.249413 | 53 |
| 3 | Chandpur | 0.904391 | 2.121893 | 1.801667 | -1.506347 | 79 |
| 4 | Chuadanga | 0.937204 | 2.113695 | 1.782615 | -1.484119 | 16 |
| 5 | Comilla | 0.874059 | 1.866869 | 1.540787 | -0.952655 | 16 |
| 6 | Cox's Bazar | 0.868301 | 2.996366 | 2.750040 | -2.700266 | 28 |
| 7 | Dhaka | 0.922925 | 1.906563 | 1.603062 | -1.292344 | 5 |
| 8 | Dinajpur | 0.901994 | 2.000067 | 1.617733 | -0.851832 | 22 |
| 9 | Faridpur | 0.927449 | 1.877200 | 1.563969 | -1.224177 | 25 |
| 10 | Feni | 0.869745 | 1.844985 | 1.526159 | -1.038716 | 99 |
| 11 | Ishurdi | 0.939958 | 1.917720 | 1.583985 | -1.233522 | 17 |
| 12 | Jessore | 0.926002 | 2.249131 | 1.915988 | -1.686008 | 38 |
| 13 | Khepupara | 0.903524 | 2.299527 | 2.046775 | -1.930730 | 36 |
| 14 | Khulna | 0.910232 | 2.082155 | 1.723965 | -1.405709 | 10 |
| 15 | Kutubdia | 0.887875 | 2.636019 | 2.384397 | -2.322544 | 134 |
| 16 | Madaripur | 0.912839 | 1.971950 | 1.663936 | -1.341305 | 338 |
| 17 | MaijdeeCourt | 0.883857 | 2.041308 | 1.667049 | -1.263498 | 169 |
| 18 | Mongla | 0.915524 | 2.018248 | 1.677803 | -1.404491 | 13 |
| 19 | Mymensingh | 0.885133 | 1.775353 | 1.411911 | -0.714661 | 9 |
| 20 | Patuakhali | 0.895704 | 1.941002 | 1.614801 | -1.302138 | 12 |
| 21 | Rajshahi | 0.939609 | 2.068394 | 1.723744 | -1.389242 | 34 |
| 22 | Rangamati | 0.896204 | 2.261545 | 1.944847 | -1.728864 | 178 |
| 23 | Rangpur | 0.893970 | 1.883619 | 1.490916 | -0.661474 | 12 |
| 24 | Satkhira | 0.926908 | 1.996473 | 1.682351 | -1.428754 | 20 |
| 25 | Sitakunda | 0.880597 | 2.975434 | 2.738066 | -2.659711 | 193 |
| 26 | Srimangal | 0.902426 | 2.202529 | 1.908509 | -1.611512 | 106 |
| 27 | Syedpur | 0.895177 | 2.074865 | 1.690975 | -0.978229 | 769 |
| 28 | Sylhet | 0.885027 | 2.621758 | 2.318249 | -2.084910 | 10 |
| 29 | Tangail | 0.910102 | 1.896549 | 1.549974 | -0.972465 | 8 |
| 30 | Teknaf | 0.840256 | 2.354036 | 2.075474 | -1.995419 | 174 |
Overall, there is a good alignment of ERA5 Land with BMD station data
The validation results indicate strong agreement between ERA5-Land and BMD observations, with correlation coefficients ranging from 0.87 to 0.94 and RMSE values mostly below 2.5°C. A systematic negative bias (–1 to –2.7°C) was observed, indicating underestimation of Tmax by ERA5-Land. These results demonstrate that ERA5-Land reliably represents the temporal variability of daily maximum temperature and is suitable as a reference dataset for bias correction of CMIP6 outputs.
Station wise Comparison for Tmin
results = []
for station, group in df_merged.groupby('Stn_Name'):
obs = group['Tmin_bmd']
sim = group['Tmin_era5']
r = corr(obs, sim)
r_rmse = rmse(obs, sim)
r_mae = mae(obs, sim)
r_bias = bias(obs, sim)
results.append({
'station_id': station,
'Correlation': r,
'RMSE (°C)': r_rmse,
'MAE (°C)': r_mae,
'Mean Bias (°C)': r_bias,
'Missing Days': 11321 - len(group)
})
df_metrics_min = pd.DataFrame(results)
print("Overall Metrics for Tmin:")
df_metrics_min
Overall Metrics for Tmin:
| station_id | Correlation | RMSE (°C) | MAE (°C) | Mean Bias (°C) | Missing Days | |
|---|---|---|---|---|---|---|
| 0 | Barisal | 0.967247 | 1.738818 | 1.285983 | 0.797960 | 14 |
| 1 | Bhola | 0.966740 | 1.905052 | 1.380481 | 1.038662 | 241 |
| 2 | Bogra | 0.972833 | 1.393051 | 1.123921 | -0.516531 | 53 |
| 3 | Chandpur | 0.964391 | 1.297924 | 0.964366 | 0.189379 | 79 |
| 4 | Chuadanga | 0.973229 | 1.591065 | 1.222485 | 0.428231 | 16 |
| 5 | Comilla | 0.964721 | 1.377464 | 1.050279 | -0.067933 | 16 |
| 6 | Cox's Bazar | 0.955526 | 1.268859 | 0.932709 | 0.310247 | 28 |
| 7 | Dhaka | 0.959329 | 1.508846 | 1.214102 | -0.486744 | 5 |
| 8 | Dinajpur | 0.975210 | 1.422448 | 1.119306 | 0.092067 | 22 |
| 9 | Faridpur | 0.964188 | 1.658198 | 1.251539 | 0.632643 | 25 |
| 10 | Feni | 0.962588 | 1.354687 | 0.983305 | -0.078106 | 99 |
| 11 | Ishurdi | 0.973922 | 1.679059 | 1.292877 | 0.573197 | 17 |
| 12 | Jessore | 0.972443 | 1.545053 | 1.171778 | 0.459551 | 38 |
| 13 | Khepupara | 0.961261 | 2.013808 | 1.504338 | 1.244820 | 36 |
| 14 | Khulna | 0.963596 | 1.489717 | 1.134981 | 0.162243 | 10 |
| 15 | Kutubdia | 0.948595 | 1.568917 | 1.158132 | 0.595911 | 134 |
| 16 | Madaripur | 0.965035 | 1.523270 | 1.166498 | 0.290087 | 338 |
| 17 | MaijdeeCourt | 0.951949 | 1.594563 | 1.239393 | -0.576673 | 169 |
| 18 | Mongla | 0.965309 | 1.266866 | 0.956352 | -0.057047 | 13 |
| 19 | Mymensingh | 0.969525 | 1.442319 | 1.172017 | -0.436755 | 9 |
| 20 | Patuakhali | 0.966823 | 1.279948 | 0.943418 | 0.117011 | 12 |
| 21 | Rajshahi | 0.973142 | 1.736140 | 1.326564 | 0.681853 | 34 |
| 22 | Rangamati | 0.961789 | 1.564727 | 1.162497 | 0.661660 | 178 |
| 23 | Rangpur | 0.972084 | 1.388900 | 1.088237 | -0.009215 | 12 |
| 24 | Satkhira | 0.965819 | 1.856273 | 1.393382 | 0.896819 | 20 |
| 25 | Sitakunda | 0.962004 | 2.571498 | 1.865894 | 1.546527 | 193 |
| 26 | Srimangal | 0.972348 | 1.915190 | 1.427218 | 0.992119 | 106 |
| 27 | Syedpur | 0.971117 | 1.443901 | 1.133046 | 0.056812 | 769 |
| 28 | Sylhet | 0.963773 | 1.618981 | 1.320147 | -0.877004 | 10 |
| 29 | Tangail | 0.970051 | 1.490004 | 1.125666 | 0.490330 | 8 |
| 30 | Teknaf | 0.948770 | 1.712345 | 1.255294 | 0.649354 | 174 |
df_metrics_min.to_csv(r"D:\CMIP6 Project\Thesis work\Data Analysis\Data\Error metrics\ERA5L_Tmin_metrics.csv", index = False)
Hexbin Density Plot
from scipy.stats import linregress
from scipy.stats import linregress
import matplotlib.pyplot as plt
def density_scatter_plot(
x, y,
title="",
xlabel="",
ylabel="",
panel_label=None,
ax=None,
label_fontsize=14,
tick_fontsize=12,
title_fontsize=14,
panel_fontsize=16
):
if ax is None:
fig, ax = plt.subplots(figsize=(7, 6))
# Hexbin density plot
hb = ax.hexbin(
x, y,
gridsize=80,
bins='log',
cmap='viridis',
mincnt=1
)
# Colorbar
cb = plt.colorbar(hb, ax=ax)
cb.set_label("Collocation Count (log scale)", fontsize=12)
cb.ax.tick_params(labelsize=11)
# 1:1 line
min_val = min(x.min(), y.min())
max_val = max(x.max(), y.max())
ax.plot(
[min_val, max_val],
[min_val, max_val],
'b--',
lw=2,
label='1:1 Line'
)
# Regression line
slope, intercept, r, p, _ = linregress(x, y)
ax.plot(
x,
slope * x + intercept,
'r',
lw=2,
label='Regression'
)
# Axis labels
ax.set_xlabel(xlabel, fontsize=label_fontsize)
ax.set_ylabel(ylabel, fontsize=label_fontsize)
# Tick font size
ax.tick_params(axis='both', labelsize=tick_fontsize)
# Title
ax.set_title(
f"{title}\nSlope = {slope:.2f}",
fontsize=title_fontsize
)
# Panel label (a), (b), (c), ...
if panel_label is not None:
ax.text(
-0.12, 1.08, # x, y position (outside upper-left corner)
f"({panel_label})",
transform=ax.transAxes,
fontsize=panel_fontsize,
fontweight="bold",
va="top",
ha="left",
clip_on=False # ensures the label isn't clipped
)
ax.legend(fontsize=11)
return ax
fig, ax = plt.subplots(figsize=(7, 6))
density_scatter_plot(
df_merged['Tmax_bmd'],
df_merged['Tmax_era5'],
xlabel="BMD Tmax (°C)",
ylabel="ERA5-Land Tmax (°C)",
panel_label="b",
ax=ax
)
plt.tight_layout()
fig.savefig(
"D:\CMIP6 Project\Thesis work\Table and Charts\Modifed charts\ERA5Land_tmax_density_scatter_plot.png",
dpi=600,
bbox_inches="tight"
)

The hexbin density scatter plot indicates strong agreement between ERA5-Land and BMD observations, with a high correlation coefficient (r = 0.893). The majority of data points are concentrated along the 1:1 line, particularly in the range of 25–35°C, demonstrating good performance under typical climatic conditions. The regression slope (0.82) and the position of the fitted line below the 1:1 line indicate a systematic underestimation of Tmax by ERA5-Land, especially at higher temperatures. The relatively narrow spread around the regression line suggests moderate random error, while deviations at extreme values reflect reduced performance during heatwave events. Overall, the consistent and linear error structure supports the suitability of ERA5-Land as a reference dataset for bias correction
fig, ax = plt.subplots(figsize=(7, 6))
density_scatter_plot(
df_merged['Tmin_bmd'],
df_merged['Tmin_era5'],
xlabel = "BMD Tmin (°C)",
ylabel = "ERA5-Land Tmin (°C)",
panel_label="b",
ax=ax
)
plt.tight_layout()
fig.savefig(
"D:\CMIP6 Project\Thesis work\Table and Charts\Modifed charts\ERA5-Land_tmin_density_scatter_plot.png",
dpi=600,
bbox_inches="tight"
)

Seasonal Evaluation
I will divide dataset into four seasons: Winter (Dec-Feb), Pre-Moonsoon (March-May), Moonsoon (June-Auguest), Post-Moonsoon (Oct-Nov)
df = df_merged.copy()
df['month'] = df['Date'].dt.month
def get_season(month):
if month in [12, 1, 2]:
return 'Winter (DJF)'
elif month in [3, 4, 5]:
return 'Pre-monsoon (MAM)'
elif month in [6, 7, 8, 9]:
return 'Monsoon (JJAS)'
else:
return 'Post-monsoon (ON)'
df['season'] = df['month'].apply(get_season)
Seasonal Metrics (All Stations Combined)
For Tmax
seasonal_results = []
for season, g in df.groupby('season'):
obs = g['Tmax_bmd']
sim = g['Tmax_era5']
seasonal_results.append({
'Season': season,
'Correlation': corr(obs, sim),
'RMSE (°C)': rmse(obs, sim),
'MAE (°C)': mae(obs, sim),
'Bias (°C)': bias(obs, sim)
})
print("Sesonal Metrics for Tmax:")
df_seasonal_max = pd.DataFrame(seasonal_results)
df_seasonal_max
Sesonal Metrics for Tmax:
| Season | Correlation | RMSE (°C) | MAE (°C) | Bias (°C) | |
|---|---|---|---|---|---|
| 0 | Monsoon (JJAS) | 0.758526 | 2.312071 | 2.020203 | -1.831061 |
| 1 | Post-monsoon (ON) | 0.844551 | 2.403183 | 2.164631 | -2.068258 |
| 2 | Pre-monsoon (MAM) | 0.812826 | 2.015210 | 1.630170 | -1.053579 |
| 3 | Winter (DJF) | 0.834527 | 1.873233 | 1.480978 | -0.960740 |
obs = df["Tmax_bmd"]
sim = df["Tmax_era5"]
overall_metrics_Tmax = pd.DataFrame({
'Season': "Overall",
'Correlation': corr(obs, sim),
'RMSE (°C)': rmse(obs, sim),
'MAE (°C)': mae(obs, sim),
'Bias (°C)': bias(obs, sim)
}, index = [0])
df_Tmax = pd.concat([df_seasonal_max, overall_metrics_Tmax], ignore_index=True).round(3)
df_Tmax
| Season | Correlation | RMSE (°C) | MAE (°C) | Bias (°C) | |
|---|---|---|---|---|---|
| 0 | Monsoon (JJAS) | 0.759 | 2.312 | 2.020 | -1.831 |
| 1 | Post-monsoon (ON) | 0.845 | 2.403 | 2.165 | -2.068 |
| 2 | Pre-monsoon (MAM) | 0.813 | 2.015 | 1.630 | -1.054 |
| 3 | Winter (DJF) | 0.835 | 1.873 | 1.481 | -0.961 |
| 4 | Overall | 0.897 | 2.154 | 1.813 | -1.460 |
# df_Tmax.to_csv(r"D:\CMIP6 Project\Thesis work\Table and Charts\ERA5-Land_Tmax_metrics_seasonal_overall.csv", index = False)
For Tmin:
seasonal_results = []
for season, g in df.groupby('season'):
obs = g['Tmin_bmd']
sim = g['Tmin_era5']
seasonal_results.append({
'Season': season,
'Correlation': corr(obs, sim),
'RMSE (°C)': rmse(obs, sim),
'MAE (°C)': mae(obs, sim),
'Bias (°C)': bias(obs, sim)
})
print("Sesonal Metrics for Tmin:")
df_seasonal_min = pd.DataFrame(seasonal_results)
df_seasonal_min
Sesonal Metrics for Tmin:
| Season | Correlation | RMSE (°C) | MAE (°C) | Bias (°C) | |
|---|---|---|---|---|---|
| 0 | Monsoon (JJAS) | 0.530839 | 1.085342 | 0.831987 | -0.288820 |
| 1 | Post-monsoon (ON) | 0.914902 | 1.386063 | 1.081253 | -0.156158 |
| 2 | Pre-monsoon (MAM) | 0.864068 | 1.826284 | 1.367359 | 0.647656 |
| 3 | Winter (DJF) | 0.836893 | 2.046812 | 1.628293 | 1.113549 |
obs = df["Tmin_bmd"]
sim = df["Tmin_era5"]
overall_metrics_Tmin = pd.DataFrame({
'Season': "Overall",
'Correlation': corr(obs, sim),
'RMSE (°C)': rmse(obs, sim),
'MAE (°C)': mae(obs, sim),
'Bias (°C)': bias(obs, sim)
}, index = [0])
df_Tmin = pd.concat([df_seasonal_min, overall_metrics_Tmin], ignore_index=True).round(3)
df_Tmin
| Season | Correlation | RMSE (°C) | MAE (°C) | Bias (°C) | |
|---|---|---|---|---|---|
| 0 | Monsoon (JJAS) | 0.531 | 1.085 | 0.832 | -0.289 |
| 1 | Post-monsoon (ON) | 0.915 | 1.386 | 1.081 | -0.156 |
| 2 | Pre-monsoon (MAM) | 0.864 | 1.826 | 1.367 | 0.648 |
| 3 | Winter (DJF) | 0.837 | 2.047 | 1.628 | 1.114 |
| 4 | Overall | 0.958 | 1.609 | 1.205 | 0.316 |
df_Tmin.to_csv(r"D:\CMIP6 Project\Thesis work\Table and Charts\ERA5Land_Tmin_metrics_seasonal_overall.csv", index = False)
Seasonal Hexabin Plots:
def seasonal_hexbin(df, var1, var2, season, ax, var3):
d = df[df['season'] == season]
density_scatter_plot(
d[var1],
d[var2],
title= f"{season}",
ax=ax,
)
seasons = df['season'].unique()
fig, ax = plt.subplots(2, 2, figsize=(10,8))
ax = ax.flatten()
for i, s in enumerate(seasons):
seasonal_hexbin(df, "Tmax_bmd", "Tmax_era5",s, ax[i], "Tmax")
fig.supxlabel("BMD Tmax (°C)", fontsize=12)
fig.supylabel("ERA5-Land Tmax (°C)", fontsize=12)
# fig.suptitle("Seasonal Validation of ERA5-Land Tmax", fontsize=16, weight="bold")
plt.tight_layout()
plt.show()

seasons = df['season'].unique()
fig, ax = plt.subplots(2, 2, figsize=(10,8))
ax = ax.flatten()
for i, s in enumerate(seasons):
seasonal_hexbin(df, "Tmin_bmd", "Tmin_era5",s, ax[i], "Tmin")
fig.supxlabel("BMD Tmin (°C)", fontsize=14)
fig.supylabel("ERA5-Land Tmin (°C)", fontsize=14)
plt.tight_layout()
plt.show()

Seasonal Metrics (Station Wise) For Maximum Temperature
season_station = []
for (st, season), g in df.groupby(['Stn_Name', 'season']):
obs = g['Tmax_bmd']
sim = g['Tmax_era5']
season_station.append({
'Station': st,
'Season': season,
'Correlation': corr(obs, sim),
'RMSE': rmse(obs, sim),
'MAE': mae(obs, sim),
'Bias': bias(obs, sim)
})
# print("Station wise Seasonal Metrics for Tmax:")
df_season_station = pd.DataFrame(season_station)
# # pd.set_option('display.max_rows', 500)
# df_season_station
season_order = [
'Winter (DJF)',
'Pre-monsoon (MAM)',
'Monsoon (JJAS)',
'Post-monsoon (ON)'
]
df_season_station['Season'] = pd.Categorical(
df_season_station['Season'],
categories=season_order,
ordered=True
)
Seasonal Comparison by Boxplot
Tmax
import seaborn as sns
# Set style
sns.set_style("whitegrid")
sns.set_context("talk") # bigger fonts
# Create figure
fig, axes = plt.subplots(
nrows=4,
ncols=1,
figsize=(10, 12),
sharex=True
)
# -----------------------------
# 1. Correlation
# -----------------------------
sns.boxplot(
data=df_season_station,
x="Season",
y="Correlation",
ax=axes[0],
width=0.6,
showfliers=False,
palette="Blues"
)
axes[0].set_ylabel("Correlation (r)")
axes[0].set_title("Seasonal Validation of ERA5-Land Tmax", fontsize=16, weight="bold")
# -----------------------------
# 2. RMSE
# -----------------------------
sns.boxplot(
data=df_season_station,
x="Season",
y="RMSE",
ax=axes[1],
width=0.6,
showfliers=False,
palette="Blues"
)
axes[1].set_ylabel("RMSE (°C)")
#---------------------
# 3. MAE
#---------------------
sns.boxplot(
data=df_season_station,
x="Season",
y="MAE",
ax=axes[2],
width=0.6,
showfliers=False,
palette="Blues"
)
axes[2].set_ylabel("MAE (°C)")
# -----------------------------
# 3. Bias
# -----------------------------
sns.boxplot(
data=df_season_station,
x="Season",
y="Bias",
ax=axes[3],
width=0.6,
showfliers=False,
palette="Blues"
)
axes[3].set_ylabel("Bias (°C)")
axes[3].set_xlabel("Season")
# Enable x labels
axes[3].tick_params(labelbottom=True)
# Add zero line for bias
axes[3].axhline(0, color="black", linestyle="--", linewidth=1)
# -----------------------------
# Final Layout
# -----------------------------
plt.tight_layout()
plt.show()
C:\Users\Anwoy\AppData\Local\Temp\ipykernel_17300\2471159410.py:17: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
sns.boxplot(
C:\Users\Anwoy\AppData\Local\Temp\ipykernel_17300\2471159410.py:34: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
sns.boxplot(
C:\Users\Anwoy\AppData\Local\Temp\ipykernel_17300\2471159410.py:50: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
sns.boxplot(
C:\Users\Anwoy\AppData\Local\Temp\ipykernel_17300\2471159410.py:65: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
sns.boxplot(

Boxplot for Tmin:
season_station = []
for (st, season), g in df.groupby(['Stn_Name', 'season']):
obs = g['Tmin_bmd']
sim = g['Tmin_era5']
season_station.append({
'Station': st,
'Season': season,
'Correlation': corr(obs, sim),
'RMSE': rmse(obs, sim),
'MAE': mae(obs, sim),
'Bias': bias(obs, sim)
})
# print("Station wise Seasonal Metrics for Tmin:")
df_season_station_Tmin = pd.DataFrame(season_station)
# # pd.set_option('display.max_rows', 500)
# df_season_station_Tmin
season_order = [
'Winter (DJF)',
'Pre-monsoon (MAM)',
'Monsoon (JJAS)',
'Post-monsoon (ON)'
]
df_season_station_Tmin['Season'] = pd.Categorical(
df_season_station_Tmin['Season'],
categories=season_order,
ordered=True
)
import seaborn as sns
# Set style
sns.set_style("whitegrid")
sns.set_context("talk") # bigger fonts
# Create figure
fig, axes = plt.subplots(
nrows=4,
ncols=1,
figsize=(10, 12),
sharex=True
)
# -----------------------------
# 1. Correlation
# -----------------------------
sns.boxplot(
data=df_season_station_Tmin,
x="Season",
y="Correlation",
ax=axes[0],
width=0.6,
showfliers=False,
palette="Blues"
)
axes[0].set_ylabel("Correlation (r)")
axes[0].set_title("Seasonal Validation of ERA5-Land Tmin", fontsize=16, weight="bold")
# -----------------------------
# 2. RMSE
# -----------------------------
sns.boxplot(
data=df_season_station_Tmin,
x="Season",
y="RMSE",
ax=axes[1],
width=0.6,
showfliers=False,
palette="Blues"
)
axes[1].set_ylabel("RMSE (°C)")
#---------------------
# 3. MAE
#---------------------
sns.boxplot(
data=df_season_station_Tmin,
x="Season",
y="MAE",
ax=axes[2],
width=0.6,
showfliers=False,
palette="Blues"
)
axes[2].set_ylabel("MAE (°C)")
# -----------------------------
# 3. Bias
# -----------------------------
sns.boxplot(
data=df_season_station_Tmin,
x="Season",
y="Bias",
ax=axes[3],
width=0.6,
showfliers=False,
palette="Blues"
)
axes[3].set_ylabel("Bias (°C)")
axes[3].set_xlabel("Season")
# Enable x labels
axes[3].tick_params(labelbottom=True)
# Add zero line for bias
axes[3].axhline(0, color="black", linestyle="--", linewidth=1)
# -----------------------------
# Final Layout
# -----------------------------
plt.tight_layout()
plt.show()
C:\Users\Anwoy\AppData\Local\Temp\ipykernel_17300\2815008242.py:17: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
sns.boxplot(
C:\Users\Anwoy\AppData\Local\Temp\ipykernel_17300\2815008242.py:34: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
sns.boxplot(
C:\Users\Anwoy\AppData\Local\Temp\ipykernel_17300\2815008242.py:50: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
sns.boxplot(
C:\Users\Anwoy\AppData\Local\Temp\ipykernel_17300\2815008242.py:65: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
sns.boxplot(

