import xarray as xr
import matplotlib.pyplot as plt
ds = xr.open_dataset("smi.20260210.t12z.6000m.d-mssm.global.v0201.nc")
# Apply scale factor (xarray does this automatically if CF conventions are followed)
sm = ds["d_mssm"]
# Mask using the advisory flag
sm_masked = sm.where(ds["aflag"] == 0)
# Plot
sm_masked.plot(figsize=(12, 6), cmap="YlGnBu")
plt.title("D-MSSM — 2026-02-10")
plt.show()
import rasterio
import numpy as np
with rasterio.open("smi.20260210.t12z.6000m.d-mssm.global.v0201.tif") as src:
data = src.read(1)
# Apply scale factor
sm = np.where(data == 255, np.nan, data * 0.005)