Exemplo n.º 1
0
import matplotlib.pyplot as plt
import matplotlib.mlab as ml
import numpy as np
#from basemap import basemap_usgs
pydir='../'
sys.path.append(pydir)
from hx import getcodar_ctl_file_edge,getcodar_ctl_lalo,getcodar_ctl_id,getcodar_edge

###############################################
inputfilename='./getcodar_byrange_ctl.txt'
png_num=0 # for saving picture  
datetime_wanted,url,model_option,lat_max,lon_max,lat_min,lon_min,num,interval_dtime=getcodar_ctl_file_edge(inputfilename) # reads control file
for i in range(num): # loop through number of figures
  png_num=png_num+1 
  lat_max_i,lon_max_i,lat_min_i,lon_min_i=getcodar_ctl_lalo(model_option,lat_max,lon_max,lat_min,lon_min) # gets spatial index of box
  id=getcodar_ctl_id(model_option,url,datetime_wanted) # gets time index
  lat_vel,lon_vel,u,v=getcodar_edge(url,id,lat_max_i,lon_max_i,lat_min_i,lon_min_i) # gets actual values of lat, lon, U & V
  id=str(id)
  idg1=list(ml.find(np.array(u)<>-999.0/100.))   # index u values that are good
  idg2=list(ml.find(np.array(lat_vel)>=lat_min)) # index lats > lat_min
  idg12=list(set(idg1).intersection(set(idg2)))  # intersection of idg1 and idg2
  idg3=list(ml.find(np.array(lon_vel)>=lon_min)) # index lon > lon_min
  idg=list(set(idg12).intersection(set(idg3)))   # final intersection

  if len(idg)<>0:
    plt.title('') 
    plt.title(str(num2date(datetime_wanted).strftime("%d-%b-%Y %H"))+'h')
    pylab.ylim([lat_min-0.02,lat_max+0.02])
    pylab.xlim([lon_min-0.02,lon_max+0.02]) #enge
    q=plt.quiver(np.reshape(lon_vel,np.size(lon_vel))[idg],np.reshape(lat_vel,np.size(lat_vel))[idg],np.reshape(u,np.size(u))[idg],np.reshape(v,np.size(v))[idg],angles='xy',scale=3,color='b')
    p=plt.quiverkey(q,min(lon_vel[0])+.1,max(lat_vel[0])-.1,1.2,str(round(1.2,2))+"m/s",coordinates='data',color='r')     
Exemplo n.º 2
0
for i in range(5):  #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

(lat_max_i, lon_max_i, lat_min_i,
 lon_min_i) = getcodar_ctl_lalo(model_option, maxlat, maxlon, minlat,
                                minlon)  # get index of max min lat lon
gbox = [minlon - 0.03, maxlon + 0.03, minlat - 0.03,
        maxlat + 0.03]  # get edge for get sst
for x in range(num):

    id = getcodar_ctl_id(model_option, url,
                         datetime_wanted)  #get index of codar
    ask_input = num2date(datetime_wanted)  #get time for getsst
    (lat, lon, time1) = getdrift_raw(filename, id3, interval,
                                     datetime_wanted)  #get drifter data
    (lat_vel, lon_vel, u, v) = getcodar_edge(url, id, lat_max_i, lon_max_i,
                                             lat_min_i,
                                             lon_min_i)  #get codar data
    id = str(id)
    idg1 = list(ml.find(np.array(u) <> -999.0 / 100.))
    idg2 = list(ml.find(np.array(lat_vel) >= minlat))
    idg12 = list(set(idg1).intersection(set(idg2)))
    idg3 = list(ml.find(np.array(lon_vel) >= minlon))
    idg = list(set(idg12).intersection(
        set(idg3)))  #get index for codar data based on  edge and id(time)

    png_num = png_num + 1  #for save movie picture
Exemplo n.º 3
0
from hx import getcodar_ctl_file, getdrift_raw_range_latlon, getcodar_ctl_id
from hx import getdrift_raw, getcodar, gettrack_codar
#### input #########################################################
inputfilename = './getcodar_bydrifter_ctl.txt'
(datetime_wanted, filename, driftnumber, url, model_option, num,
 interval_dtime, interval, step_size) = getcodar_ctl_file(inputfilename)
startdate = datetime_wanted

id3 = int(driftnumber)  #change format
datetime_wanted_1 = datetime_wanted
(maxlon, minlon, maxlat,
 minlat) = getdrift_raw_range_latlon(filename, id3, interval,
                                     datetime_wanted_1, num, step_size)

id = getcodar_ctl_id(model_option, url, startdate)
(lat, lon, time) = getdrift_raw(filename, id3, interval,
                                datetime_wanted)  #drifter lat lon time
la = lat[0]
lo = lon[0]
lat_k, lon_k = [la], [lo]
uu, vv = [0], [0]
for q in range(interval):
    lat_vel, lon_vel, u, v = getcodar(url, id)
    lon_vel_list = lon_vel[0]
    lat_vel_list = []
    for g in range(len(lat_vel)):
        lat_vel_list.append(lat_vel[g][0])

    lat_k1, lon_k1, time1, uu, vv = gettrack_codar(lon_vel_list, lat_vel_list,
                                                   u, v, startdate, interval,
Exemplo n.º 4
0
#pydir='/net/home3/ocn/jmanning/py/huanxin/work'

#sys.path.append(pydir)

from hx import getcodar_ctl_file,getdrift_raw_range_latlon,getcodar_ctl_id
from hx import getdrift_raw,getcodar,gettrack_codar    
#### input #########################################################
inputfilename='getcodar_bydrifter_ctl.txt'
(datetime_wanted,filename,driftnumber,url,model_option,num,interval_dtime,interval,step_size)=getcodar_ctl_file(inputfilename)
startdate=datetime_wanted

id3=int(driftnumber)  #change format
datetime_wanted_1=datetime_wanted
(maxlon,minlon,maxlat,minlat)=getdrift_raw_range_latlon(filename,id3,interval,datetime_wanted_1,num,step_size)

id=getcodar_ctl_id(model_option,url,startdate)
(lat,lon,time)=getdrift_raw(filename,id3,interval,datetime_wanted) #drifter lat lon time
la=lat[0]
lo=lon[0] 
lat_k,lon_k=[la],[lo]
uu,vv=[0],[0]
for q in range(interval):
    lat_vel,lon_vel,u,v=getcodar(url,id)
    lon_vel_list=lon_vel[0]
    lat_vel_list=[]
    for g in range(len(lat_vel)):
        lat_vel_list.append(lat_vel[g][0])
       
    lat_k1,lon_k1,time1,uu,vv=gettrack_codar(lon_vel_list,lat_vel_list,u,v,startdate,interval,la,lo,uu,vv,q)
    la=lat_k1
    lo=lon_k1