Code Monkey home page Code Monkey logo

awot's People

Contributors

nguy avatar swnesbitt avatar tjlang avatar twisterkid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

awot's Issues

API for pre-read flight data

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?

3D plotting

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.

Pandas Series

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.

awot_time_series_flight_data.ipynb

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?

Masking statistical data

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.

mean_reflectivity

Keep track of metadata better

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.

Possible change to track_height_image

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.

Force change labels for x-axis

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)

Force change labels for x-axis

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)

fill_between_quantiles

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?

TEST BLOCK

Plot color filled (between quantile 25 and 75) CFADs (reflectivity and vertical radial velocity) for flight legs 1 and 5

figC, (ax1Z, ax1W) = plt.subplots(1, 2, figsize=(20,10))

ax1Z.set_axis_bgcolor('white')
ax1W.set_axis_bgcolor('white')

ax1Z.set_title(r"Reflectivity CFAD", y=1.01, fontsize=16)

ax1W.set_title(r"Vertical Radial Velocity CFAD", y=1.01, fontsize=16)

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)

Force change labels for x-axis

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)

Force change labels for x-axis

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)

ax1Z.grid(True)

ax1Z.grid(color='black', linestyle=':', linewidth=0.5)

ax1W.grid(True)

ax1W.grid(color='black', linestyle=':', linewidth=0.5)

ymax = (sfcleg1/altmax)

yunder = (htmax1/altmax)

ax1Z.axvspan(-30, 20, ymin=0, ymax=ymax, zorder=200000, edgecolor='white', facecolor='white')

ax1W.axvspan(-8., 8., ymin=0, ymax=ymax, zorder=200000, edgecolor='white', facecolor='white')

ax1Z.axvspan(-30, 20, ymin=yunder, ymax=1, zorder=200000, edgecolor='white', facecolor='white')

figC.tight_layout()

fill_between_quantiles

Merge T-28 reader and netCDF reader?

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.

Extend KMZ save file to radar class plots.

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.

Revisit the package structure

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?

Plotting y-axis ticks in km

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?

Force change labels for y-axis

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)

plot_vp

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

statistics_thesis_script_iop1_dec07.txt

Replace Nappy

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)?

Issue with qmask_above_height

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.

cfad_leg7

CFAD_thesis_script_rf01_iop1_dec07.txt

Discrete value color bar in awot_plot_wcr2.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.

vertical_radial_velocity_example

vel_colortable.xlsx

Lidar plotting

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.

HIWRAP topo and height variable calculations

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.

WCR Plotting

screen shot 2016-10-08 at 12 55 23 am

Hello,

I am having an issue when plotting WCR cross sections with the fill_surface=True function of .time_height_image. The fill surface seems to be filling areas randomly above ground. I have tried rerunning my program, however, that does not help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.