Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
syedhamidali
GitHub Repository: syedhamidali/Weather-Radar-PPI-RHI-Plotting-by-PYART
Path: blob/main/Untitled7.ipynb
188 views
Kernel: Python 3 (ipykernel)
import xarray as xr import numpy as np import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore')
ds = xr.open_dataset('/home/PDTC/PDTCHACPL/MCRKalapureddy/Desktop/PTN200611125230-IMD-B.nc')
ds
def radar_coords_to_cart(rng, az, ele ,debug=False): theta_e = ele * np.pi / 180.0 # elevation angle in radians. theta_a = az * np.pi / 180.0 # azimuth angle in radians. R = 6371.0 * 1000.0 * 4.0 / 3.0 # effective radius of earth in meters. r = rng*1000 # distances to gates in meters. z = (r ** 2 + R ** 2 + 2.0 * r * R * np.sin(theta_e)) ** 0.5 - R s = R * np.arcsin(r * np.cos(theta_e) / (R + z)) # arc length in m. x = s.reshape(-1,1) * np.sin(theta_a) y = s.reshape(-1,1) * np.cos(theta_a) return x, y, z

if it is full volume scan containing 10 sweeps having 100 bins for each scan

el = ds['elevationList'].values az = ds.radialAzim.values
si = np.arange(0,1000,100) ei = np.arange(99,1000,100) def idx(sweep): return slice(si[sweep],ei[sweep]+1)
idx(sweep=0)
slice(0, 100, None)
rng = np.linspace(0,127,100) for sweep in range(10): x,y,z = radar_coords_to_cart(rng, az, el[sweep]) plt.contourf(x/1e3, y/1e3, ds.Z[:,idx(sweep)].T,cmap='jet') plt.title(str(el[sweep])) plt.colorbar() plt.show()
Image in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebook

if it is only one sweep

sweep =0 rng = np.linspace(0,127,1000) x,y,z = radar_coords_to_cart(rng, az, el[sweep]) plt.contourf(x/1e3, y/1e3, ds.Z.T,cmap='jet') plt.title(str(el[sweep])) plt.colorbar() plt.show()
Image in a Jupyter notebook