###############################################
inputfilename='./getcodar_bydrifter_ctl.txt'
#################Input values#############################################
input_time=[dt.datetime(2013,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.0,-72.0,42.0,40.0] #  maxlon, minlon,maxlat,minlat
id=[134410701] # id list, if you are not clear dedicated id, let id=[]
#'125450842''125450841'
#↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑Input values↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑#
if id==[]:
    
    time,ids,lats,lons=getobs_drift_byrange(gbox,input_time)
    id=list(set(ids))
    rgbcolors=colors(len(id))
    mymap = pygmaps.maps(np.mean(lats), np.mean(lons), 12)
    for k in range(len(id)):
        time,ids,lat,lon=getobs_drift_byidrange(id[k],gbox,input_time)
        
        path=[]
        for i in range(len(lat)):
          path.append((lat[i],lon[i]))
          mymap.addpoint(lat[i],lon[i],'black')
  #mymap.addradpoint(drifter_data[lat][0],drifter_data[1][0], 95, "#FF0000","my-location")
        mymap.addradpoint(lat[0],lon[0], 295, "red")
        mymap.addradpoint(lat[-1],lon[-1], 295, "blue")
        mymap.addpath(path,rgbcolors[k])#00FF00
  #mymap.coloricon
  #mymap.getcycle
  #mymap.zoom    

  #mymap.setgrids(37.42, 43.43, 0.1, -70.15, -60.14, 0.1)
else:
id=[] # id list, if you are not clear dedicated id, let id=[]
#'125450842''125450841'
#↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑Input values↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑#

#fig = plt.figure()
#ax = fig.add_subplot(111)  
ask_input=input_time[0]
plot_getsst(ask_input,utc,sorted(gbox))    # get sst data and polt it

if id==[]:
    
    time,ids,lats,lons=getobs_drift_byrange(gbox,input_time)
    id=list(set(ids))
    rgbcolors=colors(len(id))   # set different colors to different drifter
    for k in range(len(id)):
        time,ids,lat_d,lon_d=getobs_drift_byidrange(id[k],gbox,input_time)   #get drifters' data
        plt.plot(lon_d[0],lat_d[0],'.',markersize=30,color=rgbcolors[k+1],label=str(id[k]))
        plt.plot(np.reshape(lon_d,np.size(lon_d)),np.reshape(lat_d,np.size(lat_d)),color=rgbcolors[k+1]) #plot
else:
    lats,lons=[],[]
    rgbcolors=colors(len(id))  # set different colors to different drifter
    for m in range(len(id)):
        time,ids,lat_d,lon_d=getobs_drift_byid(id[m],input_time)  #get drifters' data by id
        plt.plot(lon_d[0],lat_d[0],'.',markersize=30,color=rgbcolors[m+1],label=str(id[m]))
        plt.plot(np.reshape(lon_d,np.size(lon_d)),np.reshape(lat_d,np.size(lat_d)),color=rgbcolors[m+1])
        for n in range(len(lat_d)):  
            lats.append(lat_d[n])
            lons.append(lon_d[n])
    
plt.title(str(time[0].strftime("%d-%b-%Y %H"))+'h') 
pylab.ylim([sorted(gbox)[2]+0.01,sorted(gbox)[3]-0.01])  # set range area .