One-dimensional data drawing (Ⅰ)
Import the packages and data needed for this issue
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
ds1 = xr.open_dataset("..\\air.2020.nc", drop_variables = ["time_bnds"]).sel(level = 850).rename({"air": "Tair"})
ds = ds1.sortby("lat", ascending= True)
r_equator = 6378.137e3
r_polor = 6356.752e3
dx = np.deg2rad(2.5) * r_equator * np.cos(ds.lat * np.pi / 180)
dy = np.deg2rad(2.5) * r_polor
ds["dTdx"] = ds.Tair.differentiate("lon") / dx
ds["dTdy"] = ds.Tair.differentiate("lat") / dy
ds.dTdx.attrs = {"long_name": "$∂T/∂x$", "units": "°C/m"}
ds.dTdy.attrs = {"long_name": "$∂T/∂y$", "units": "°C/m"}
Basic Line Drawing
xarray plt.plot()
implements the drawing of line graphs through the packaging of pairs. As mentioned earlier, axes
it can be marked with a variable so that it can be passed to the underlying layermatlibplot</