'89398', '91191', '96101', '96102', '96104', '96105', '96107', '96108', '96111', '96112', '96113', '96114', '96201', '96301', '96302', '96303', '97101', '971010', '97102', '97103', '97104', '97105', '97106', '97107', '97108', '97109', '97111', '97112', '97113', '97114', '97201', '97202', '97301', '97302', '974207010', '974207011', '974207012', '98101', '98102', '98103', '98104', '98105', '98201', '98301', '98302', '99301', '994207010', '994207011', '994207012', '994207013', '994207014', '994207015', '994207016', '994207017', '994207018' ] # id list, if you are not clear dedicated id, let id=[] id = [int(a) for a in id] '125450842' '125450841' #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑Input values↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑# if id == []: time, ids, lat, lon = getobs_drift_byrange( gbox, input_time) #get and organize data else: every_time_total, id_s = [], [] totalday = 0 region = 'wv' lat_data, lon_data = get_coastline_coordinate( region) #gets coastline coordinate for q in range(len(id)): #print id[q] time, ids, lat, lon = getobs_drift_byid( id[q], input_time) #get and organize data distance = 0 for z in range(len(lat_data)): if haversine( lon_data[z], lat_data[z], lon[-1], lat[-1]
ops=os.defpath pydir='../' sys.path.append(pydir) #################Input values############################################# #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑Input values↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑# drifter_name=['Rachel','Eddie','Cassie','Irina'] # names of 4 subplots , they can be changed fig, axes = plt.subplots(nrows=2, ncols=2,figsize=(20,12)) axes = axes.ravel() #get axes for y in range(len(ids)): id=[int(a) for a in ids[y]] # convert to ints if id==[]: time,ids_un,lat,lon=getobs_drift_byrange(gbox,input_time) #get and organize data else: every_time_total,id_s=[],[] totalday=0;total_drifter=0 region='wv' lat_data, lon_data=get_coastline_coordinate(region) # gets coastline coordinate for q in range(len(id)): print id[q] time,id_un,lat,lon=getobs_drift_byid(id[q],input_time) #get and organize data distance=0 for z in range(len(lat_data)): if haversine(lon_data[z], lat_data[z], lon[-1], lat[-1])< 0.5: #1.0 represent 1 kilometer , get rid of landed drifter #print haversine(lon_data[z], lat_data[z], lon[-1], lat[-1]) distance=1 break
ops=os.defpath pydir='../' sys.path.append(pydir) #################Input values############################################# input_time=[dt.datetime(2012,1,1,0,0,0,0,pytz.UTC),dt.datetime(2013,7,1,0,0,0,0,pytz.UTC)] # start time and end time gbox=[-70.035594,-70.597883,42.766619,42.093197] # maxlon, minlon,maxlat,minlat id=[] # id list, if you are not clear dedicated id, let id=[] #'125450842''125450841' #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑Input values↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑# fig = plt.figure() ax = fig.add_subplot(111) polygon=[(gbox[0],gbox[2]),(gbox[0],gbox[3]),(gbox[1],gbox[3]),(gbox[1],gbox[2])] if id==[]: time,ids,lats,lons=getobs_drift_byrange(gbox,input_time) id=list(set(ids)) rgbcolors=colors(len(id)) for k in range(len(id)): time,ids,lat,lon=getobs_drift_byid(id[k],input_time) for z in range(len(lat)): inside=point_in_poly(lon[z],lat[z],polygon) if inside == True: break lat=lat[z:] lon=lon[z:] plt.plot(lon[0],lat[0],'.',markersize=30,color=rgbcolors[k+1],label=str(id[k])) plt.plot(np.reshape(lon,np.size(lon)),np.reshape(lat,np.size(lat)),color=rgbcolors[k+1]) else:
sys.path.append(pydir) #################Input values############################################# input_time = [ dt.datetime(1980, 1, 1, 0, 0, 0, 0, pytz.UTC), dt.datetime(2014, 10, 15, 0, 0, 0, 0, pytz.UTC) ] # start time and end time gbox = [-70.035594, -70.597883, 42.766619, 42.093197] # maxlon, minlon,maxlat,minlat id = [] # id list, if you are not clear dedicated id, let id=[] #'125450842''125450841' #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑Input values↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑# polygon = [(gbox[0], gbox[2]), (gbox[0], gbox[3]), (gbox[1], gbox[3]), (gbox[1], gbox[2])] #set polygon if id == []: time, ids, lats, lons = getobs_drift_byrange(gbox, input_time) mymap = basemap_xu.maps(np.mean(lats), np.mean(lons), 12) #set center point of the map id = list(set(ids)) colors = hexcolors(len(id)) #get hex colors,like '00FF00' for k in range(len(id)): time, ids, lat, lon = getobs_drift_byid(id[k], input_time) # get data by id for z in range(len(lat)): # make plotting drifter start in gbox inside = point_in_poly(lon[z], lat[z], polygon) if inside == True: break if z > 1: lat = lat[0:z - 1] #get rid of drifters which start from the polygon lon = lon[0:z - 1]