nguy / awot Goto Github PK
View Code? Open in Web Editor NEWAirborne Weather Observations Toolkit - A python-based package
Home Page: http://nguy.github.io/AWOT/
License: GNU General Public License v2.0
Airborne Weather Observations Toolkit - A python-based package
Home Page: http://nguy.github.io/AWOT/
License: GNU General Public License v2.0
Sometimes all we have from an aircraft is lat, lon, alt, and time. Or the data are otherwise too customized to bother with a universal reader. Maybe add a method that accepts a dictionary of various variables that someone else has already read in, and constructs the right AWOT objects for further analysis?
Fix the issue with grid displacement in the 3D track plot. An issue was opened on StackOverflow. The X/Y axes only line up with the ax.set_zlims
is set manually.
not able to open awot_cfad_demo.ipynb in jupyter notebook
Convert input to pandas Series for easy display. Use the already established netCDF4 read and couple with Pandas to make the time series plots even easier.
Hello, I am trying to plot a flight map and a time series of variables and am running into this error:
# Load the needed packages
import os
import matplotlib.pyplot as plt
import matplotlib as mpl # in python
import numpy as np
import matplotlib.colors as mcolors
import datetime
from netCDF4 import Dataset
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
from matplotlib import rcParams, colors, cm
from awot.graph.common import create_basemap
import awot
from awot.graph import FlightLevel, RadarVerticalPlot, RadarUtilityPlot
%matplotlib inline
# Set the project name
Project="OWLES"
# Set the path for data file
flname = "/data/keeling/a/cjjhnst2/a/data/UWYO_king_air/kadata/20140107a.c25.nc"
proj = 'cea'
Wbarb_Spacing = 300 # Spacing of wind barbs along flight path (sec)
# Choose the X-axis time step (in seconds) where major labels will be
XlabStride = 3600
# Should landmarks be plotted? [If yes, then modify the section below
Lmarks=True
# Optional variables that can be included with AWOT
# Start and end times for track in Datetime instance format
start_time = "2014-01-07 13:00:00"
end_time = "2014-01-07 16:45:00"
corners = [-79.,42.,-74.,44.]
fl = awot.io.read_netcdf(fname=flname, platform='uwka')
fig, ax = plt.subplots(1, 1, figsize=(9, 9))
bm = create_basemap(corners=corners, proj=proj, resolution='l', area_thresh=1.,ax=ax)
# Instantiate the Flight plotting routines
flp = FlightLevel(fl, basemap=bm)
flp.plot_trackmap(
# start_time=start_time, end_time=end_time,
color_by_altitude=True, track_cmap='spectral',
min_altitude=50., max_altitude= 4000.,
addlegend=True, addtitle=True)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-8-261d6e5e07d1> in <module>()
4
5 # Instantiate the Flight plotting routines
----> 6 flp = FlightLevel(fl, basemap=bm)
7 flp.plot_trackmap(
8 # start_time=start_time, end_time=end_time,
/data/keeling/a/cjjhnst2/anaconda2/lib/python2.7/site-packages/awot-0.2.12-py2.7.egg/awot/graph/flight_level.pyc in __init__(self, flightdata, basemap, lon_name, lat_name, alt_name, time_name, uwind_name, vwind_name)
105 # Calculate x,y map position coordinates
106 self.x, self.y = self.basemap(
--> 107 self.longitude['data'][:], self.latitude['data'][:])
108
109 #################
TypeError: 'NoneType' object has no attribute '__getitem__'
Any ideas to what might be going on?
For the statistical plots (mean/median/skewness/std. dev. of reflectivity and vertical velocity), is there a way to mask the heights on the statistical plot for each leg that is plotted (similar to what you just made for the fill cfads and quantiles methods)? When the statistics are calculated near the ground, the calculated mean/median/skewness/std. dev. reflectivity and vertical velocity increase substantially. I have attached an example image to show you what I mean.
AWOT appears to only ingest the data arrays, and not much metadata associated with each variable. I think it should try to use nested dictionaries like Py-ART to keep track of important metadata like units, full variable names, and other details. For example, instead of accessing the data like this:
fl['latitude']
You should access it like this:
fl['latitude']['data']
That way you could also get important info like fl['latitude']['units']
, fl['latitude']['full_name']
, etc.
The plotting routines could also take advantage of this when constructing default axis labels, titles, etc.
When using track_height_image, is there a way to convert the output on the x-axis to just be 0 km for start_time=s1 and whatever distance it is to end_time=e1 (say 25 km), instead of calculating the distance from the beginning of the netCDF file? Basically, is there a way to calculate the distance from start_time=s1 to end_time=e1? I have brute force changed the labels of the distance to say 0 at the beginning and X distance at the end depending on the end time for now.
labels = [item.get_text() for item in ax1.get_xticklabels()]
labels[0] = '0'
labels[1] = '5'
labels[2] = '10'
labels[3] = '15'
labels[4] = '20'
labels[5] = '25'
ax1.set_xticklabels(labels)
labels = [item.get_text() for item in ax2.get_xticklabels()]
labels[0] = '0'
labels[1] = '5'
labels[2] = '10'
labels[3] = '15'
labels[4] = '20'
labels[5] = '25'
ax2.set_xticklabels(labels)
Hello.
I tried using the new fill_between_quantiles qmask_above_height, qmask_between_height, and qmask_below_height. For some reason, it is masking the entire filled quantile area. Do you have any idea what might be going on?
figC, (ax1Z, ax1W) = plt.subplots(1, 2, figsize=(20,10))
ax1Z.set_axis_bgcolor('white')
ax1W.set_axis_bgcolor('white')
ax1Z.tick_params(axis='x', labelsize=16)
ax1W.tick_params(axis='x', labelsize=16)
ax1Z.tick_params(axis='y', labelsize=16)
ax1W.tick_params(axis='y', labelsize=16)
majorLocator = MultipleLocator(500)
majorFormatter = FormatStrFormatter('%d')
minorLocator = MultipleLocator(100)
ax1Z.yaxis.set_major_locator(majorLocator)
ax1W.yaxis.set_major_locator(majorLocator)
ax1Z.yaxis.set_major_formatter(majorFormatter)
ax1W.yaxis.set_major_formatter(majorFormatter)
ax1Z.yaxis.set_minor_locator(minorLocator)
ax1W.yaxis.set_minor_locator(minorLocator)
majorLocator = MultipleLocator(5)
majorFormatter = FormatStrFormatter('%d')
minorLocator = MultipleLocator(1)
ax1Z.xaxis.set_major_locator(majorLocator)
ax1Z.xaxis.set_major_formatter(majorFormatter)
ax1Z.xaxis.set_minor_locator(minorLocator)
majorLocator = MultipleLocator(1)
majorFormatter = FormatStrFormatter('%d')
minorLocator = MultipleLocator(0.2)
ax1W.xaxis.set_major_locator(majorLocator)
ax1W.xaxis.set_major_formatter(majorFormatter)
ax1W.xaxis.set_minor_locator(minorLocator)
levsWwcr = [.1, 1, 2, 5, 7, 10, 15, 20, 25]
cfadwcrZ = wcrut2.fill_between_quantiles('reflectivity', height_axis=1, #plot_percent=True,
x_min=-30., x_max=20., y_min=0., y_max = altmax, ypad=10,
xlab= r"Reflectivity (dB${Z}$$_{e}$)", ylab="Height above MSL (km)", xpad=10,
xlabFontSize=16, ylabFontSize=16,
#title="Reflectivity CFAD Flight Leg 1 IOP2b",
titleFontSize=16,
qmask_above_height = sfcleg1_maskabove,
qmask_between_height=sfcleg1_maskbetween,
qmask_below_height = sfcleg1_maskbelow,
#quantiles=[25, 50, 75], qcolor='none', qfillcolor='darkblue', qfillalpha=0.3,
quantiles=[25,50,75], qcolor='darkblue', qfillcolor='darkblue', qfillalpha=0.3,
start_time=s1, end_time=e1,
ax=ax1Z)
cfadwcrW = wcrut2.fill_between_quantiles('velocity_corrected', height_axis=1,
x_min=-6., x_max=6., y_min=0., y_max = altmax, ypad=10,
xlab= r"Vertical Radial Velocity (m s$^{-1}$)", xpad=10,
xlabFontSize=16, ylabFontSize=16,
#title="Vertical Radial Velocity CFAD Flight Leg 1 IOP2b",
titleFontSize=16,
qmask_above_height = sfcleg1_maskabove,
qmask_between_height=sfcleg1_maskbetween,
qmask_below_height = sfcleg1_maskbelow,
#quantiles=[25, 50, 75], qcolor='none', qfillcolor='darkblue', qfillalpha=0.3,
quantiles=[25,50,75], qcolor='darkblue', qfillcolor='darkblue', qfillalpha=0.3,
start_time=s1, end_time=e1,
ax=ax1W)
plt.hold(True)
cfadwcrZ = wcrut3.fill_between_quantiles('reflectivity', height_axis=1, #plot_percent=True,
x_min=-30., x_max=20., y_min=0., y_max = altmax, ypad=10,
xlab= r"Reflectivity (dB${Z}$$_{e}$)", ylab="Height above MSL (km)", xpad=10,
xlabFontSize=16, ylabFontSize=16,
#title="Reflectivity CFAD Flight Leg 1 IOP2b",
titleFontSize=16,
qmask_above_height = sfcleg5_maskabove,
qmask_between_height=sfcleg5_maskbetween,
qmask_below_height = sfcleg5_maskbelow,
#quantiles=[25, 50, 75], qcolor='none', qfillcolor='darkgreen', qfillalpha=0.3,
quantiles=[25,50,75], qcolor='darkgreen', qfillcolor='darkgreen', qfillalpha=0.3,
start_time=s5, end_time=e5,
ax=ax1Z)
cfadwcrW = wcrut3.fill_between_quantiles('velocity_corrected', height_axis=1,
x_min=-6., x_max=6., y_min=0., y_max = altmax, ypad=10,
xlab= r"Vertical Radial Velocity (m s$^{-1}$)", xpad=10,
xlabFontSize=16, ylabFontSize=16,
#title="Vertical Radial Velocity CFAD Flight Leg 1 IOP2b",
titleFontSize=16,
qmask_above_height = sfcleg5_maskabove,
qmask_between_height=sfcleg5_maskbetween,
qmask_below_height = sfcleg5_maskbelow,
#quantiles=[25, 50, 75], qcolor='none', qfillcolor='darkgreen', qfillalpha=0.3,
quantiles=[25, 50, 75], qcolor='darkgreen', qfillcolor='darkgreen', qfillalpha=0.3,
start_time=s5, end_time=e5,
ax=ax1W)
labels = [item.get_text() for item in ax1Z.get_yticklabels()]
labels[1] = '0'
labels[2] = '0.5'
labels[3] = '1.0'
labels[4] = '1.5'
labels[5] = '2.0'
labels[6] = '2.5'
ax1Z.set_yticklabels(labels)
labels = [item.get_text() for item in ax1W.get_yticklabels()]
labels[1] = '0'
labels[2] = '0.5'
labels[3] = '1.0'
labels[4] = '1.5'
labels[5] = '2.0'
labels[6] = '2.5'
ax1W.set_yticklabels(labels)
ax1Z.tick_params(axis='y', which='major', pad=4)
ax1W.tick_params(axis='y', which='major', pad=4)
ymax = (sfcleg1/altmax)
figC.tight_layout()
Now that #15 is merged, we should evaluate whether the T-28 reader and the general netCDF reader should ultimately be merged into a single routine. There are pros and cons to each approach, so I think a final decision will come from further experience with using AWOT. I am definitely open to #16 being addressed sooner than this, since this is a lower priority.
PR #29 introduced the ability to save KMZ files on an experimental basis. This could be extended to horizontal radar plots reasonably easily. Vertical plots may be more problematic and some research is needed for this.
Is the current structure good? I do not like the fact that the main class is initiated first and then calls are made from there. This design may be flawed.
@twisterkid thoughts?
For plotting the time height images, statistics images, and CFADs, is there a way to plot the y-axis ticks in kilometers instead of meters without having to brute force the tick labels on the y-axis like I have done here?
labels = [item.get_text() for item in ax1W.get_yticklabels()]
labels[1] = '0'
labels[2] = '0.5'
labels[3] = '1.0'
labels[4] = '1.5'
labels[5] = '2.0'
labels[6] = '2.5'
ax1W.set_yticklabels(labels)
Hello,
I am trying to use the plot_vp function and am running into an error. I have also attached my script to this issue. I am trying to plot the data using:
figC, (ax1, ax2, ax3, ax4) = plt.subplots(1, 4, figsize=(8,6))
wcrut2.plot_vp(vp_statwcrZ1, 'vp_mean', xlab='Mean Z', ylab='Height (km)', ax=ax1)
wcrut2.plot_vp(vp_statwcrZ1, 'vp_mean', color='b', xlab='Mean W', ax=ax2)
wcrut2.plot_vp(vp_statwcrZ1, 'vp_std_dev', color='g', ls=':', xlab='Std Dev', ax=ax3)
wcrut2.plot_vp(vp_statwcrZ1, 'vp_skew', title='Neato', xlab='Skewness', ax=ax4)
figC.tight_layout()
I get this error:
TypeError Traceback (most recent call last)
in ()
1 figC, (ax1, ax2, ax3, ax4) = plt.subplots(1, 4, figsize=(8,6))
2
----> 3 wcrut2.plot_vp(vp_statwcrZ1, 'vp_mean', xlab='Mean Z', ylab='Height (km)', ax=ax1)
4 wcrut2.plot_vp(vp_statwcrZ1, 'vp_mean', color='b', xlab='Mean W', ax=ax2)
5 wcrut2.plot_vp(vp_statwcrZ1, 'vp_std_dev', color='g', ls=':', xlab='Std Dev', ax=ax3)
/data/keeling/a/cjjhnst2/anaconda2/lib/python2.7/site-packages/awot-0.2.12-py2.7.egg/awot/graph/radar_utility.pyc in plot_vp(self, vp_dict, field, height_axis, color, lw, ls, marker, msize, mask_above_height, mask_below_height, mask_between_height, x_min, x_max, y_min, y_max, xlab, xlabFontSize, xpad, ylab, ylabFontSize, ypad, title, titleFontSize, ax)
855 ls = '-'
856 common.plot_xy(data, yarr, color=color, lw=lw, ls=ls, marker=marker,
--> 857 msize=msize, ax=ax)
858 return
859
/data/keeling/a/cjjhnst2/anaconda2/lib/python2.7/site-packages/awot-0.2.12-py2.7.egg/awot/graph/common.pyc in plot_xy(var1, var2, color, lw, ls, marker, msize, ax)
252
253 ax.plot(var1, var2, color=color, ls=ls, lw=lw,
--> 254 marker=marker, markersize=msize, markeredgecolor=color)
255 return
256
/data/keeling/a/cjjhnst2/anaconda2/lib/python2.7/site-packages/matplotlib/init.pyc in inner(ax, _args, *_kwargs)
1809 warnings.warn(msg % (label_namer, func.name),
1810 RuntimeWarning, stacklevel=2)
-> 1811 return func(ax, _args, *_kwargs)
1812 pre_doc = inner.doc
1813 if pre_doc is None:
/data/keeling/a/cjjhnst2/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in plot(self, _args, *_kwargs)
1425 kwargs['color'] = c
1426
-> 1427 for line in self._get_lines(_args, *_kwargs):
1428 self.add_line(line)
1429 lines.append(line)
/data/keeling/a/cjjhnst2/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _grab_next_args(self, _args, *_kwargs)
384 return
385 if len(remaining) <= 3:
--> 386 for seg in self._plot_args(remaining, kwargs):
387 yield seg
388 return
/data/keeling/a/cjjhnst2/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _plot_args(self, tup, kwargs)
372 ncx, ncy = x.shape[1], y.shape[1]
373 for j in xrange(max(ncx, ncy)):
--> 374 seg = func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)
375 ret.append(seg)
376 return ret
/data/keeling/a/cjjhnst2/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _makeline(self, x, y, kw, kwargs)
279 self._setdefaults(default_dict, kw, kwargs)
280 seg = mlines.Line2D(x, y, *_kw)
--> 281 self.set_lineprops(seg, *_kwargs)
282 return seg
283
/data/keeling/a/cjjhnst2/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in set_lineprops(self, line, **kwargs)
187 def set_lineprops(self, line, **kwargs):
188 assert self.command == 'plot', 'set_lineprops only works with "plot"'
--> 189 line.set(**kwargs)
190
191 def set_patchprops(self, fill_poly, **kwargs):
/data/keeling/a/cjjhnst2/anaconda2/lib/python2.7/site-packages/matplotlib/artist.pyc in set(self, **kwargs)
935 raise TypeError('There is no %s property "%s"' %
936 (self.class.name, k))
--> 937 ret.extend([func(v)])
938 return ret
939
/data/keeling/a/cjjhnst2/anaconda2/lib/python2.7/site-packages/matplotlib/lines.pyc in set_markersize(self, sz)
1127 ACCEPTS: float
1128 """
-> 1129 sz = float(sz)
1130 if self._markersize != sz:
1131 self.stale = True
TypeError: float() argument must be a string or a number
Add WCR2 and WCL read capabilities.
While Nappy is a nice was to read in the NASA Ames format, it is cumbersome with it's dependencies and is not easily available. Another option is another package called NAStools, but it does not appear to be complete or maintained.
It will likely be easier in the long run to port the code to read NASA Ames format over to AWOT.
@tjlang @swnesbitt Do either of you know a python package other than those mentioned above that reads NASA Ames format (if you're familiar with this)?
The skewt plot is not working correctly. Min/Max values are causing odd behavior.
@twisterkid
I am also having an issue with the qmask_above_height when plotting CFADs. I noticed that the data on both the reflectivity and vertical velocity CFADs are not masked correctly. I have specified that qmask_above_height = sfcleg7_maskabove, where sfcleg7_maskabove = 2470. For some reason, it is masking everything above 2370 m. This is for leg 7 in my code that I have attached. I have also attached the CFAD for leg 7 where this issue is occurring. Again I have attached my code as a .txt, so change the file name extension to .ipynb.
Hello,
Is there a way to change the color bars to have discrete values for the vertical reflectivity and vertical velocity flight leg plots?
I have attached both an example plot of vertical radial velocity (made with Matlab) that has a discrete color bar and the velocity color map I used to make the plot.
Thank you.
Implement Lidar plots in the 2D "curtain"-style plots.
I am also considering implementing this in PyART and calling the functions in as was done with the ground radar overlays.
There are a lot of negative values returned for topo
and height
variables for the HIWRAP radar. Calculations seem straight-forward, subtract range from aircraft altitude in 1D for topo and 2D for height. Data files for netcdf and hdf appear to be different (used GRIP and IPHEx, respectively), but tried to make the function as general as possible.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.