-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrfplot.py
43 lines (32 loc) · 1.01 KB
/
wrfplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 12 13:13:27 2021
@author: ghost
"""
"""
TODO List:
1. Remove the unncessary statics such as lon and lat limits.
2. Add new fuctions based on NCL and MetPy
"""
import wrf
import proplot as pplt
import cartopy.crs as crs
from netCDF4 import Dataset
def quickplot(ncfile, wrfvar, time=0):
ncf = Dataset(ncfile)
var = wrf.getvar(ncf, wrfvar, timeidx=time)
# Get the latitude and longitude points
lats, lons = wrf.latlon_coords(var)
# Get the cartopy mapping object
cart_proj = wrf.get_cartopy(var)
# Creating Figures
fig, axs = pplt.subplots(proj=cart_proj)
axs.format(
coast=True, #latlines=10, lonlines=10,
lonlabels='b', latlabels='l',
)
m = axs.contourf(wrf.to_np(lons), wrf.to_np(lats), wrf.to_np(var), transform=crs.PlateCarree(), cmap='sunset')
fig.colorbar(m, label=var.description, loc='r')
axs.set_xlim(wrf.cartopy_xlim(var))
axs.set_ylim(wrf.cartopy_ylim(var))