Set the log path variable below to a valid path and your choice of filename.
The only other configuration needed is to choose the sample data file and corresponding field name to use if you don't want to analyze cells based on flash extent density.
In [1]:
log_path = '/Users/ebruning/Desktop/YW-NCGridLassoLog.txt'
In [2]:
import os, glob
import tables, pandas
import numpy as np
import warnings
# warnings.filterwarnings('ignore')
warnings.filterwarnings('ignore', category=DeprecationWarning, module='.*/IPython/.*')
In [3]:
%matplotlib qt4
import matplotlib.pyplot as plt
In [4]:
from lmatools.grid.grid_collection import LMAgridFileCollection
def get_sample_data_path():
import lmatools.sampledata
data_path = os.path.abspath(lmatools.sampledata.__path__[0])
folder = 'flashsort-solution' #inside data_path
path = os.path.join(data_path, folder)
return path
#"/path/to/lmatools/testing/flashsort-solution"
results_dir = get_sample_data_path()
nc_filenames=glob.glob(os.path.join(results_dir, "grid_files/2014/May/26/*_flash_extent.nc"))
nc_field = 'flash_extent'
# print nc_filenames
NCs = LMAgridFileCollection(nc_filenames, nc_field, x_name='longitude', y_name='latitude')
geosys, mapproj = NCs.get_projection()
In [5]:
# This cell is not necessary for the lasso analysis, but shows how
# one might overlay additional data on the plot in order to guide
# the lasso analyses - in this case, which cell was being sampled by
# two radars scanning in RHI mode?
ka1_loc = -102.13410, 33.30546, 1004.0
ka2_loc = -102.09339, 33.40950, 1018.0
ka1_az = 180. + 163. - 360.0
ka2_az = 0. + 249.
radar_dist = 20.0e3
ka1_dx = radar_dist * np.cos(np.deg2rad(90.0-ka1_az))
ka1_dy = radar_dist * np.sin(np.deg2rad(90.0-ka1_az))
ka2_dx = radar_dist * np.cos(np.deg2rad(90.0-ka2_az))
ka2_dy = radar_dist * np.sin(np.deg2rad(90.0-ka2_az))
ka1_xyz = mapproj.fromECEF(*geosys.toECEF(*ka1_loc))
ka2_xyz = mapproj.fromECEF(*geosys.toECEF(*ka2_loc))
ka1_radial = [[ka1_xyz[0], ka1_xyz[0]+ka1_dx],
[ka1_xyz[1], ka1_xyz[1]+ka1_dy]
]
ka2_radial = [[ka2_xyz[0], ka2_xyz[0]+ka2_dx],
[ka2_xyz[1], ka2_xyz[1]+ka2_dy]
]
def plot_ka(lasso_widget, ax):
ax.plot(ka1_radial[0], ka1_radial[1], 'k')
ax.annotate('Ka1', xy=(ka1_radial[0][0], ka1_radial[1][0]))
ax.plot(ka2_radial[0], ka2_radial[1], 'k')
ax.annotate('Ka2', xy=(ka2_radial[0][0], ka2_radial[1][0]))
ax.axis((-75e3, 0e3, -75e3, 0e3))
ax.tick_params(axis='both', labelsize=12)
In [ ]:
In [6]:
# from ipywidgets import interactive
from IPython.display import display
In [7]:
from GridLassoTools import NCgridLasso, NCgridLassoWidgets
nclasso = NCgridLasso(NCs, log_path=log_path)
widget = NCgridLassoWidgets(nclasso) #, overplot_func = plot_ka)
display(widget.container)
In [ ]: