def get_track(self, starttime=None, days=None): ''' return drifter nodes if starttime is given, return nodes started from starttime if both starttime and days are given, return nodes of the specific time period ''' nodes = {} temp = getdrift(self.drifter_id) nodes['lon'] = np.array(temp[1]) nodes['lat'] = np.array(temp[0]) nodes['time'] = np.array(temp[2]) starttime = np.array(temp[2][0]) if bool(starttime): if bool(days): endtime = starttime + timedelta(days=days) i = self.__cmptime(starttime, nodes['time']) j = self.__cmptime(endtime, nodes['time']) nodes['lon'] = nodes['lon'][i:j+1] nodes['lat'] = nodes['lat'][i:j+1] nodes['time'] = nodes['time'][i:j+1] else: i = self.__cmptime(starttime, nodes['time']) nodes['lon'] = nodes['lon'][i:-1] nodes['lat'] = nodes['lat'][i:-1] nodes['time'] = nodes['time'][i:-1] return nodes
def get_track(self, starttime=None, days=None): ''' return drifter nodes if starttime is given, return nodes started from starttime if both starttime and days are given, return nodes of the specific time period ''' if filename: temp=getrawdrift(self.drifter_id,self.filename) else: temp = getdrift(self.drifter_id) nodes = {} nodes['lon'] = np.array(temp[1]) nodes['lat'] = np.array(temp[0]) nodes['time'] = np.array(temp[2]) #starttime = np.array(temp[2][0]) starttime = np.array(temp[2][-1]- timedelta(days=2)) # make start day 3 days before last fix print starttime if bool(starttime): if bool(days): endtime = starttime + timedelta(days=days) i = self.__cmptime(starttime, nodes['time']) j = self.__cmptime(endtime, nodes['time']) nodes['lon'] = nodes['lon'][i:j+1] nodes['lat'] = nodes['lat'][i:j+1] nodes['time'] = nodes['time'][i:j+1] else: i = self.__cmptime(starttime, nodes['time']) nodes['lon'] = nodes['lon'][i:-1] nodes['lat'] = nodes['lat'][i:-1] nodes['time'] = nodes['time'][i:-1] return nodes
def waternode(self, starttime=None, days=None): ''' return drifter nodes if starttime is given, return nodes started from starttime if both starttime and days are given, return nodes of the specific time period ''' nodes = {} temp = getdrift(self.drifter_id) nodes['lon'] = np.array(temp[1]) nodes['lat'] = np.array(temp[0]) nodes['time'] = np.array(temp[2]) if bool(starttime): if bool(days): endtime = starttime + timedelta(days=days) i = self.__cmptime(starttime, nodes['time']) j = self.__cmptime(endtime, nodes['time']) nodes['lon'] = nodes['lon'][i:j+1] nodes['lat'] = nodes['lat'][i:j+1] nodes['time'] = nodes['time'][i:j+1] else: i = self.__cmptime(starttime, nodes['time']) nodes['lon'] = nodes['lon'][i:-1] nodes['lat'] = nodes['lat'][i:-1] nodes['time'] = nodes['time'][i:-1] return nodes
def waternode(self, starttime=None, days=None): ''' return drifter nodes if starttime is given, return nodes started from starttime if both starttime and days are given, return nodes of the specific time period ''' # self.drifter_id = jata.input_with_default('drifter ID', 139420691) # self.starttime = datetime(year=2013, month=9, day=29, hour=11,minute=46) # nodes = jata.data_extracted(self.dataloc, self.drifter_id, self.starttime) nodes = {} temp = getdrift(self.drifter_id) nodes['lon'] = temp[1] nodes['lat'] = temp[0] nodes['time'] = temp[2] if bool(starttime): if bool(days): endtime = starttime + timedelta(days=days) i = self.__cmptime(starttime, nodes['time']) j = self.__cmptime(endtime, nodes['time']) nodes['lon'] = nodes['lon'][i:j+1] nodes['lat'] = nodes['lat'][i:j+1] nodes['time'] = nodes['time'][i:j+1] else: i = self.__cmptime(starttime, nodes['time']) nodes['lon'] = nodes['lon'][i:-1] nodes['lat'] = nodes['lat'][i:-1] nodes['time'] = nodes['time'][i:-1] return nodes
lat,lon=[],[] for q in range(len(lon1)): lat.append(float(lat1[q])) lon.append(float(lon1[q])) maxlon=max(lon1) minlon=min(lon1) maxlat=max(lat1) minlat=min(lat1) if option=='3': inputfilename='getcodar_bydrifter_ctl.txt' #default control file (datetime_wanted,filename,driftnumber,url,model_option,num,interval_dtime,interval,step_size)=getcodar_ctl_file(inputfilename) if drifter=='raw': maxlon,minlon,maxlat,minlat,lat,lon=range_latlon(filename,driftnumber) else: [lat, lon, datet, dep, time0, yearday]=getdrift(driftnumber) #uses pydap to get remote drifter data maxlon=max(lon) minlon=min(lon) maxlat=max(lat) minlat=min(lat) #make sure the picture can show lat and lon clearly if maxlat-minlat<=0.1: maxlat=maxlat+0.01 minlat=minlat-0.01 if maxlon-minlon<=0.1: maxlon=maxlon+0.01 minlon=minlon-0.01 gbox=[minlon-1.0,maxlon+1.0, minlat-0.03, maxlat+0.03] # get edge for get sst
utc = pytz.timezone('UTC') png_num = 0 #for save picture #option=raw_input("If you have a file of column lat and lon,please input '1'\nIf you want to input points' location, please input '2'\n" #"If you want to use the control file,please input '3'\n") if option == '3': inputfilename = 'getcodar_bydrifter_ctl.txt' #default control file (datetime_wanted, filename, driftnumber, url, model_option, num, interval_dtime, interval, step_size) = getcodar_ctl_file(inputfilename) if drifter == 'raw': maxlon, minlon, maxlat, minlat, lat, lon = range_latlon( filename, driftnumber) else: [lat, lon, datet, dep, time0, yearday ] = getdrift(driftnumber) #uses pydap to get remote drifter data maxlon = max(lon) minlon = min(lon) maxlat = max(lat) minlat = min(lat) if option == '2': datetime_wanted = date2num( dt.datetime.strptime( raw_input( "please input datetime you wanted, the format like: 2012,8,26,0,0\n" ), '%Y,%m,%d,%H,%M')) lat_list = raw_input( "Please input points SW & NE latitude in order,and split them by ',':") lon_list = raw_input( "Please input points lon in order,and split them by ',':") lat1 = lat_list[0:].split(',')
import matplotlib.pyplot as plt import pylab #id=raw_input("please input id,(example: 115361221 ): ") ids=[55201,55202,55203] #linecol=['red','green','blue'] linecol=['green','red','blue'] ndays_label=10 #basemap_JiM([40,43],[-72,-67],False,False) basemap_usgs([40.25,43],[-72,-67],True,True) for k in range(len(ids)): #get lat,lon,time use function "getdrift" (lat,lon,datet,dep)=getdata.getdrift(ids[k]) #plot lat,lon, and add text of time in the figure if ids[k]==55201: daymth=['5/10','5/21','5/22','7/3','7/16'] elif ids[k]==55202: daymth=['5/10','5/22','6/1','6/10'] elif ids[k]==55203: daymth=['5/18','6/1','6/10'] plot_latlon(lat,lon,datet,ids[k],ndays_label,linecol[k],daymth) plt.text(-71.95,42.8,'NewHampshire',color='white',fontweight='bold') plt.text(-71.95,42.15,'Massachusetts',color='white',fontweight='bold') plt.text(-71.95,41.8,'Rhode Island',color='white',fontweight='bold') plt.text(-68.5,40.8,'Georges Bank',color='black',rotation=20,fontweight='bold')