MCPcopy Create free account
hub / github.com/NCAR/wrf-python / make_test

Function make_test

test/misc/projtest.py:133–199  ·  view source on GitHub ↗
(wrf_file=None, fixed_case=None)

Source from the content-addressed store, hash-verified

131
132
133def make_test(wrf_file=None, fixed_case=None):
134 if wrf_file is not None:
135 ncfile = NetCDF(wrf_file)
136 lats, lons, proj_params = get_proj_params(ncfile)
137 proj = getproj(lats=lats, lons=lons, **proj_params)
138 name_suffix = basename(wrf_file)
139 elif fixed_case is not None:
140 name_suffix = fixed_case
141 if fixed_case == "south_rot":
142 lats, lons, proj = nz_proj()
143 elif fixed_case == "arg_rot":
144 lats, lons, proj = argentina_proj()
145 elif fixed_case == "south_polar":
146 lats, lons, proj = south_polar_proj()
147 elif fixed_case == "north_polar":
148 lats, lons, proj = north_polar_proj()
149 elif fixed_case == "dateline_rot":
150 lats, lons, proj = dateline_rot_proj()
151
152 print("wrf proj4: {}".format(proj.proj4()))
153 if PYNGL:
154 # PyNGL plotting
155 wks_type = bytes("png")
156 wks = Ngl.open_wks(wks_type, bytes("pyngl_{}".format(name_suffix)))
157 mpres = proj.pyngl()
158 map = Ngl.map(wks, mpres)
159
160 Ngl.delete_wks(wks)
161
162 if BASEMAP:
163 # Basemap plotting
164 fig = plt.figure(figsize=(10, 10))
165 ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
166
167 # Define and plot the meridians and parallels
168 min_lat = np.amin(lats)
169 max_lat = np.amax(lats)
170 min_lon = np.amin(lons)
171 max_lon = np.amax(lons)
172
173 parallels = np.arange(np.floor(min_lat), np.ceil(max_lat),
174 (max_lat - min_lat)/5.0)
175 meridians = np.arange(np.floor(min_lon), np.ceil(max_lon),
176 (max_lon - min_lon)/5.0)
177
178 bm = proj.basemap()
179 bm.drawcoastlines(linewidth=.5)
180 # bm.drawparallels(parallels,labels=[1,1,1,1],fontsize=10)
181 # bm.drawmeridians(meridians,labels=[1,1,1,1],fontsize=10)
182 print("basemap proj4: {}".format(bm.proj4string))
183 plt.savefig("basemap_{}.png".format(name_suffix))
184 plt.close(fig)
185
186 if CARTOPY:
187 # Cartopy plotting
188 fig = plt.figure(figsize=(10, 10))
189 ax = plt.axes([0.1, 0.1, 0.8, 0.8], projection=proj.cartopy())
190 print("cartopy proj4: {}".format(proj.cartopy().proj4_params))

Callers 1

projtest.pyFile · 0.70

Calls 13

get_proj_paramsFunction · 0.90
getprojFunction · 0.90
nz_projFunction · 0.85
argentina_projFunction · 0.85
south_polar_projFunction · 0.85
north_polar_projFunction · 0.85
dateline_rot_projFunction · 0.85
proj4Method · 0.80
pynglMethod · 0.80
basemapMethod · 0.80
cartopyMethod · 0.80
cartopy_xlimMethod · 0.80

Tested by

no test coverage detected