Permalink
Browse files

EXAMPLES: updated plotting examples

  • Loading branch information...
1 parent 082bd62 commit 8ab8fdfc25cbd208a3691dfae4bd8dcabc656c8b @jjhelmus jjhelmus committed Jan 16, 2014
View
@@ -117,6 +117,7 @@ examples/plotting/KATX20130717_195021_V06
examples/plotting/Level2_KATX_20130717_1950.ar2v
examples/plotting/sgpxsaprrhicmacI5.c0.20110524.015604_NC4.nc
examples/plotting/20110520100000_nex_3d.nc
+examples/plotting/narr-a_221_20110520_0000_000.nc
examples/correct/095636.mdv
examples/correct/sgpinterpolatedsondeC1.c1.20110510.000000.cdf
@@ -57,6 +57,11 @@
y_m = grid_date.strftime('%Y%m')
url = ('http://nomads.ncdc.noaa.gov/dods/NCEP_NARR_DAILY/' + y_m + '/' +
y_m_d + '/narr-a_221_' + y_m_d + '_0000_000')
+# Use a local copy of the online NCEP NARR data, this file can be created with
+# the command:
+# nccopy http://nomads.ncdc.noaa.gov/dods/NCEP_NARR_DAILY/201105/20110520/narr-a_221_20110520_0000_000?lon,lat,time,prmsl narr-a_221_20110520_0000_000.nc
+# comment out the next line to retrieve the data from the OPeNDAP server.
+url = 'narr-a_221_20110520_0000_000.nc'
data = Dataset(url)
# extract data at correct time
@@ -21,26 +21,26 @@
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(221)
-display.plot_ppi('velocity', 1, ax=ax, title='Doppler Velocity',
- colorbar_label='',
- axislabels=('', 'North South distance from radar (km)'))
+display.plot('velocity', 1, ax=ax, title='Doppler Velocity',
+ colorbar_label='',
+ axislabels=('', 'North South distance from radar (km)'))
display.set_limits((-300, 300), (-300, 300), ax=ax)
ax = fig.add_subplot(222)
-display.plot_ppi('differential_reflectivity', 0, ax=ax,
- title='Differential Reflectivity', colorbar_label='',
- axislabels=('', ''))
+display.plot('differential_reflectivity', 0, ax=ax,
+ title='Differential Reflectivity', colorbar_label='',
+ axislabels=('', ''))
display.set_limits((-300, 300), (-300, 300), ax=ax)
ax = fig.add_subplot(223)
-display.plot_ppi('differential_phase', 0, ax=ax,
- title='Differential Phase', colorbar_label='')
+display.plot('differential_phase', 0, ax=ax,
+ title='Differential Phase', colorbar_label='')
display.set_limits((-300, 300), (-300, 300), ax=ax)
ax = fig.add_subplot(224)
-display.plot_ppi('cross_correlation_ratio', 0, ax=ax,
- title='Correlation Coefficient', colorbar_label='',
- axislabels=('East West distance from radar (km)', ''))
+display.plot('cross_correlation_ratio', 0, ax=ax,
+ title='Correlation Coefficient', colorbar_label='',
+ axislabels=('East West distance from radar (km)', ''))
display.set_limits((-300, 300), (-300, 300), ax=ax)
plt.show()
@@ -23,8 +23,8 @@
# plot super resolution reflectivity
ax = fig.add_subplot(111)
-display.plot_ppi('reflectivity', 0, title='NEXRAD Reflectivity',
- colorbar_label='', ax=ax)
+display.plot('reflectivity', 0, title='NEXRAD Reflectivity',
+ vmin=-32, vmax=64, colorbar_label='', ax=ax)
display.plot_range_ring(radar.range['data'][-1]/1000., ax=ax)
display.set_limits(xlim=(-500, 500), ylim=(-500, 500), ax=ax)
plt.show()
@@ -17,25 +17,25 @@
filename = '110635.mdv'
-# create the plot using MdvDisplay
-mdvfile = pyart.io.mdv.MdvFile(filename)
-display = pyart.graph.MdvDisplay(mdvfile)
+# create the plot using RadarDisplay (the preferred method)
+radar = pyart.io.read_mdv(filename)
+display = pyart.graph.RadarDisplay(radar)
fig = plt.figure(figsize=[5, 5])
ax = fig.add_subplot(111, frameon=False)
-display.plot_ppi('DBZ_F', 0, mask_tuple=['NCP_F', 0.5],
- colorbar_flag=False, title_flag=False,
- axislabels_flag=False)
+display.plot('reflectivity', 0, vmin=-16., vmax=64,
+ mask_tuple=['normalized_coherent_power', 0.5],
+ colorbar_flag=False, title_flag=False,
+ axislabels_flag=False)
display.set_limits(ylim=[-120, 120], xlim=[-120, 120])
fig.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0)
plt.show()
-# create the plot using RadarDisplay
-radar = pyart.io.read_mdv(filename)
-display = pyart.graph.RadarDisplay(radar)
+# create the plot using MdvDisplay
+mdvfile = pyart.io.mdv.MdvFile(filename)
+display = pyart.graph.MdvDisplay(mdvfile)
fig = plt.figure(figsize=[5, 5])
ax = fig.add_subplot(111, frameon=False)
-display.plot_ppi('reflectivity', 0, vmin=-16., vmax=64,
- mask_tuple=['normalized_coherent_power', 0.5],
+display.plot_ppi('DBZ_F', 0, mask_tuple=['NCP_F', 0.5],
colorbar_flag=False, title_flag=False,
axislabels_flag=False)
display.set_limits(ylim=[-120, 120], xlim=[-120, 120])
@@ -21,7 +21,7 @@
display = pyart.graph.RadarDisplay(radar)
fig = plt.figure()
ax = fig.add_subplot(111)
-display.plot_ppi('reflectivity', 0, vmin=-32, vmax=64.)
+display.plot('reflectivity', 0, vmin=-32, vmax=64.)
display.plot_range_rings([10, 20, 30, 40])
display.plot_cross_hair(5.)
plt.show()
@@ -18,36 +18,37 @@
filename = 'sgpxsaprrhicmacI5.c0.20110524.015604_NC4.nc'
-# create the plot using CFRadialDisplay
-dataset = netCDF4.Dataset(filename, 'r')
-display = pyart.graph.CFRadialDisplay(dataset)
+# create the plot using RadarDisplay (recommended method)
+radar = pyart.io.read_cfradial(filename)
+radar.metadata['instrument_name'] = 'XSARP'
+display = pyart.graph.RadarDisplay(radar)
fig = plt.figure(figsize=[12, 17])
fig.subplots_adjust(hspace=0.4)
xlabel = 'Distance from radar (km)'
ylabel = 'Height agl (km)'
colorbar_label = 'Hz. Eq. Refl. Fac. (dBZ)'
-nplots = len(dataset.variables['sweep_number'])
+nplots = radar.nsweeps
-for snum in dataset.variables['sweep_number']:
+for snum in radar.sweep_number['data']:
- title = 'HSRHI Az=%.3f' % dataset.variables['fixed_angle'][snum]
+ fixed_angle = radar.fixed_angle['data'][snum]
+ title = 'HSRHI Az=%.3f' % (fixed_angle)
ax = fig.add_subplot(nplots, 1, snum+1)
- display.plot_rhi('reflectivity_horizontal', snum, vmin=-20, vmax=20,
- mask_outside=False, title=title,
- axislabels=(xlabel, ylabel),
- colorbar_label=colorbar_label, ax=ax)
+ display.plot('reflectivity_horizontal', snum, vmin=-20, vmax=20,
+ mask_outside=False, title=title,
+ axislabels=(xlabel, ylabel),
+ colorbar_label=colorbar_label, ax=ax)
display.set_limits(ylim=[0, 15], ax=ax)
figure_title = 'Time: ' + display.time_begin.isoformat() + 'Z'
fig.text(0.35, 0.92, figure_title)
plt.show()
-# create the plot using RadarDisplay
-radar = pyart.io.read_cfradial(filename)
-radar.metadata['instrument_name'] = 'XSARP'
-display = pyart.graph.RadarDisplay(radar)
+# create the plot using CFRadialDisplay
+dataset = netCDF4.Dataset(filename, 'r')
+display = pyart.graph.CFRadialDisplay(dataset)
fig = plt.figure(figsize=[12, 17])
fig.subplots_adjust(hspace=0.4)
@@ -56,10 +57,9 @@
colorbar_label = 'Hz. Eq. Refl. Fac. (dBZ)'
nplots = len(dataset.variables['sweep_number'])
-for snum in radar.sweep_number['data']:
+for snum in dataset.variables['sweep_number']:
- fixed_angle = radar.fixed_angle['data'][snum]
- title = 'HSRHI Az=%.3f' % (fixed_angle)
+ title = 'HSRHI Az=%.3f' % dataset.variables['fixed_angle'][snum]
ax = fig.add_subplot(nplots, 1, snum+1)
display.plot_rhi('reflectivity_horizontal', snum, vmin=-20, vmax=20,
mask_outside=False, title=title,
@@ -17,18 +17,18 @@
filename = '110041.mdv'
-# create the plot using MdvDisplay
-mdvfile = pyart.io.mdv.MdvFile(filename)
-display = pyart.graph.MdvDisplay(mdvfile)
+# create the plot using RadarDisplay (recommended)
+radar = pyart.io.read_mdv(filename)
+display = pyart.graph.RadarDisplay(radar)
fig = plt.figure(figsize=[5, 5])
ax = fig.add_subplot(111)
-display.plot_rhi('DBZ_F', 0, vmin=-16, vmax=64.0)
+display.plot('reflectivity', 0, vmin=-16, vmax=64.0)
plt.show()
-# create the plot using RadarDisplay
-radar = pyart.io.read_mdv(filename)
-display = pyart.graph.RadarDisplay(radar)
+# create the plot using MdvDisplay
+mdvfile = pyart.io.mdv.MdvFile(filename)
+display = pyart.graph.MdvDisplay(mdvfile)
fig = plt.figure(figsize=[5, 5])
ax = fig.add_subplot(111)
-display.plot_rhi('reflectivity', 0, vmin=-16, vmax=64.0)
+display.plot_rhi('DBZ_F', 0, vmin=-16, vmax=64.0)
plt.show()
@@ -17,20 +17,20 @@
filename = 'XSW110520113537.RAW7HHL'
-# create the plot using RslDisplay (this method is not recommended)
-rslradar = pyart.io._rsl_interface.RslFile(filename)
-display = pyart.graph.RslDisplay(rslradar)
+# create the plot using RadarDisplay (recommended method)
+radar = pyart.io.read_rsl(filename)
+display = pyart.graph.RadarDisplay(radar)
fig = plt.figure(figsize=[10, 4])
ax = fig.add_subplot(111)
-radar_name = rslradar.get_radar_header()['name']
+radar_name = radar.metadata['instrument_name']
time_text = ' ' + display.time_begin.isoformat() + 'Z '
-azimuth = rslradar.get_volume(4).get_sweep_azimuths()[0]
+azimuth = radar.fixed_angle['data'][0]
title = 'RHI ' + radar_name + time_text + 'Azimuth %.2f' % (azimuth)
-display.plot_rhi('ZT', 0, vmin=-32, vmax=64, title=title,
- colorbar_flag=False, ax=ax)
+display.plot('reflectivity', 0, vmin=-32, vmax=64,
+ title=title, colorbar_flag=False, ax=ax)
display.set_limits(ylim=[0, 17])
cax = fig.add_axes([.9, .1, 0.02, .8])
@@ -39,20 +39,20 @@
plt.show()
-# create the plot using RadarDisplay (recommended method)
-radar = pyart.io.read_rsl(filename)
-display = pyart.graph.RadarDisplay(radar)
+# create the plot using RslDisplay (this method is not recommended)
+rslradar = pyart.io._rsl_interface.RslFile(filename)
+display = pyart.graph.RslDisplay(rslradar)
fig = plt.figure(figsize=[10, 4])
ax = fig.add_subplot(111)
-radar_name = radar.metadata['instrument_name']
+radar_name = rslradar.get_radar_header()['name']
time_text = ' ' + display.time_begin.isoformat() + 'Z '
-azimuth = radar.fixed_angle['data'][0]
+azimuth = rslradar.get_volume(4).get_sweep_azimuths()[0]
title = 'RHI ' + radar_name + time_text + 'Azimuth %.2f' % (azimuth)
-display.plot_rhi('reflectivity', 0, vmin=-32, vmax=64,
- title=title, colorbar_flag=False, ax=ax)
+display.plot_rhi('ZT', 0, vmin=-32, vmax=64, title=title,
+ colorbar_flag=False, ax=ax)
display.set_limits(ylim=[0, 17])
cax = fig.add_axes([.9, .1, 0.02, .8])
@@ -35,7 +35,7 @@
vmin, vmax = ranges[plot_num]
plt.subplot(1, nplots, plot_num + 1)
- display.plot_rhi(field, 0, vmin=vmin, vmax=vmax, title_flag=False)
+ display.plot(field, 0, vmin=vmin, vmax=vmax, title_flag=False)
display.set_limits(ylim=[0, 17])
# set the figure title and show

0 comments on commit 8ab8fdf

Please sign in to comment.