import Ngl default_type = "numpy" import numpy from utils import * plat = 0.0 plon = -2.0 lat = [0.0, 1.0, 0.0, -1.0, 0.0] lon = [-3.0, -2.0, -1.0, -2.0, -3.0] inout1 = Ngl.gc_inout(0.0, -2.0, lat, lon) inout2 = Ngl.gc_inout(0.0, 0.0, lat, lon) test_value( "gc_inout", inout1, True, ) test_value("gc_inout", inout2, False) lat = [[[ 0.0, 0.0, 2.0], [ 0.0, 0.0, 1.0] ], \ [[ 0.0, 0.0, 2.0], [ 0.0, 0.0, 1.0] ], \ [[ 89.0, 89.0, 89.0], [ 0.0, 0.0, 80.0] ]] lon = [[[ 0.0, 2.0, 1.0], [ -1.0, 1.0, -1.0] ], \ [[ 0.0, 2.0, 1.0], [ -1.0, 1.0, -1.0] ], \ [[ 0.0, 120.0, 240.0], [ 0.0, 90.0, 45.0] ]] p0_lat = numpy.array([[ 1.0, 0.0], \ [ 1.0, -0.1], \ [90.0, 45.0]]) p0_lon = numpy.array([[ 1.0, 0.0], \
min_mrb_lon = min(mrb_lon) max_mrb_lon = max(mrb_lon) ilt_min = numpy.greater_equal(lat1d,min_mrb_lat).tolist().index(True) ilt_max = numpy.less_equal(lat1d,max_mrb_lat).tolist().index(False)-1 iln_min = numpy.greater_equal(lon1d,min_mrb_lon).tolist().index(True) iln_max = numpy.less_equal(lon1d,max_mrb_lon).tolist().index(False)-1 # # Loop through area of interest, and create a mask for values # inside the MRB area. # mask = numpy.ones(data.shape) for ilt in range(ilt_min,ilt_max+1): for iln in range(iln_min,iln_max+1): if(Ngl.gc_inout(lat1d[ilt],lon1d[iln],mrb_lat,mrb_lon) != 0): mask[ilt][iln] = 0 #---Mask original data array against mask array data_mask = ma.array(data,mask=mask) #---Change the main title res.tiMainString = "Contours masked by Mississippi River Basin" #---Create contours of masked array and add MRB outline map = Ngl.contour_map(wks,data_mask,res) lines = add_mrb_lines(wks,map,mrb_lat,mrb_lon) #---Draw masked contours and advance frame Ngl.draw(map) Ngl.frame(wks)
radius=radius_in_meters, n_samples=n_points, endpoint=False) circle_array = np.asarray(circle_points) #create circle and extract circle latitude and longitudes into separate arrays circle_lats = circle_array[:, 1] circle_lons = circle_array[:, 0] #create empty arrays for holding storms indices within circle storm_in_range = [] times_in_range = [] for i in range(nstorms): #loop through storms tmp = [] for j in range(ntimes): #loop through times if Ngl.gc_inout(clats[i, j], clons[i, j], circle_lats, circle_lons) == 1: #if track crosses inside circle storm_in_range.append(i) #append the storm index to list tmp.append( j ) #append the time indices when the storm is within the circle times_in_range.append(tmp) storms = np.unique(storm_in_range) #get rid of repeating storms print(len(storms)) out_precip = [] out_wind = [] out_gusts = [] out_distance = [] out_category = [] out_years = []