Get started with the LMR Seasonal Dataset in minutes
To work with the LMR Seasonal dataset, you'll need Python with the following packages:
# Install via conda (recommended)
conda install -c conda-forge xarray netcdf4 matplotlib cartopy numpy pandas
# Or via pip
pip install xarray netcdf4 matplotlib cartopy numpy pandas
xarray
for working with NetCDF files as it provides labeled multi-dimensional arrays and is specifically designed for climate data.
Let's start by loading the surface air temperature data (tas_mean.nc
):
import xarray as xr
import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
# Load the surface air temperature data
ds = xr.open_dataset('data/mean/tas_mean.nc')
# Display basic information about the dataset
print(ds)
# Check the time range
print(f"Time range: {ds.time.min().values} to {ds.time.max().values}")
# Check spatial coverage
print(f"Latitude range: {ds.lat.min().values}° to {ds.lat.max().values}°")
print(f"Longitude range: {ds.lon.min().values}° to {ds.lon.max().values}°")
# Get temperature data
tas = ds.tas
# Check temperature units and statistics
print(f"Temperature units: {tas.attrs.get('units', 'Not specified')}")
print(f"Temperature range: {tas.min().values:.2f} to {tas.max().values:.2f}")
print(f"Mean temperature: {tas.mean().values:.2f}")
Create a global map showing the mean temperature for the year 1850:
# Calculate the 1850CE temperature
tas_1850 = tas.sel(time=slice('1850-01-01', '1850-12-31')).mean(dim='time')
# Create a global map
fig = plt.figure(figsize=(12, 8))
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
# Plot the temperature data
im = ax.contourf(ds.lon, ds.lat, tas_1850,
levels=20, transform=ccrs.PlateCarree(),
cmap='RdYlBu_r', extend='both')
# Add map features
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(cfeature.BORDERS)
ax.add_feature(cfeature.OCEAN, color='lightblue', alpha=0.5)
ax.add_feature(cfeature.LAND, color='lightgray', alpha=0.5)
# Add gridlines
ax.gridlines(draw_labels=True, dms=True, x_inline=False, y_inline=False)
# Add colorbar
plt.colorbar(im, ax=ax, orientation='horizontal', pad=0.1,
label=f'Temperature ({tas.attrs.get("units", "K")})')
plt.title('LMR Seasonal: Mean Surface Air Temperature (1850)',
fontsize=14, pad=20)
plt.tight_layout()
plt.show()
Example output: Global surface air temperature distribution for the year 1850 CE
data/members/
to analyze reconstruction uncertainty