示例#1
0
def index_of_value(dlist, dvalue):
    '''
    return the indices of dlist that equals dvalue
    '''
    index = []
    startindex = dlist.index(dvalue)
    i = startindex
    for v in dlist[startindex:]:
        if v == dvalue:
            index.append(i)
        i += 1
    return index


starttime = datetime(year=2013, month=9, day=29, hour=11, minute=46)
drifter_id = jata.input_with_default('drifter ID', 139420691)
filename = "/net/home3/ocn/jmanning/py/jc/web_track/drift_tcs_2013_1.dat"
time1 = time.time()

data = data_extracted(filename, drifter_id, starttime)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
minlat, maxlat = min(data['lat']), max(data['lat'])
minlon, maxlon = min(data['lon']), max(data['lon'])
bsmap = Basemap(projection='cyl',
                llcrnrlat=minlat - 1,
                urcrnrlat=maxlat + 1,
                llcrnrlon=minlon - 1,
                urcrnrlon=maxlon + 1,
                resolution='h',
                ax=ax)
    
    water_fvcom = water_fvcom(model)
    # dataloc, index = water_fvcom.get_interval(starttime)
    # data = water_fvcom.get_data()
    url  = water_fvcom.get_url(starttime, days)
    nodes = water_fvcom.waternode(lon, lat, depth, url)
    lonsize = min(nodes['lon'])-1, max(nodes['lon'])+1
    latsize = min(nodes['lat'])-1, max(nodes['lat'])+1
    fig = figure_with_basemap(lonsize, latsize)
    fig.ax.plot(nodes['lon'], nodes['lat'], 'ro-')
    plt.show()
'''

#######################################110410712,117400701 
# drifter_id = jata.input_with_default('drifter_id', )
drifter_id = jata.input_with_default('drifter_id', 106410712)
days = 3
model = '30yr'
# starttime = datetime.now().replace(hour=0,minute=0,second=0,microsecond=0)
# starttime = datetime(year=2013,month=9,day=22,hour=15,minute=47)

# starttime = '2011-10-10 15:47'           #if used, make sure it's in drifter period
starttime = '2010-07-25 00:00'
starttime = datetime.strptime(starttime, '%Y-%m-%d %H:%M')

# starttime = None
depth = -1

drifter = water_drifter(drifter_id)
if starttime:
    if days:
    url  = water_fvcom.get_url(starttime, days)
    nodes = water_fvcom.waternode(lon, lat, depth, url)
    lonsize = min(nodes['lon'])-1, max(nodes['lon'])+1
    latsize = min(nodes['lat'])-1, max(nodes['lat'])+1
    fig = figure_with_basemap(lonsize, latsize)
    fig.ax.plot(nodes['lon'], nodes['lat'], 'ro-')
    plt.show()
'''
########################main code###########################
drifter_id = 118410701
days = 3
depth = -1
starttime = '2011-08-02 00:00'

starttime = datetime.strptime(starttime, '%Y-%m-%d %H:%M')
drifter_id = jata.input_with_default('drifter_id', drifter_id)
drifter = water_drifter(drifter_id)
if starttime:
    if days:
        nodes_drifter = drifter.waternode(starttime,days)
    else:
        nodes_drifter = drifter.waternode(starttime)
else:
    nodes_drifter = drifter.waternode()

lon, lat = nodes_drifter['lon'][0], nodes_drifter['lat'][0]
starttime = nodes_drifter['time'][0]
endtime = nodes_drifter['time'][-1]

water_fvcom =  water_fvcom()
url_fvcom = water_fvcom.get_url(starttime, endtime)
示例#4
0
    return data
def index_of_value(dlist,dvalue):
    '''
    return the indices of dlist that equals dvalue
    '''
    index = []
    startindex = dlist.index(dvalue)
    i = startindex
    for v in dlist[startindex:]:
        if v == dvalue:
            index.append(i)
        i+=1
    return index
      
starttime = datetime(year=2013, month=9, day=29, hour=11, minute=46)
drifter_id = jata.input_with_default('drifter ID', 139420691)
filename = "/net/home3/ocn/jmanning/py/jc/web_track/drift_tcs_2013_1.dat"
time1 =time.time()

data = data_extracted(filename, drifter_id, starttime)
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
minlat, maxlat = min(data['lat']), max(data['lat'])
minlon, maxlon = min(data['lon']), max(data['lon'])
bsmap = Basemap(projection='cyl',
                llcrnrlat=minlat-1, urcrnrlat=maxlat+1,
                llcrnrlon=minlon-1, urcrnrlon=maxlon+1,
                resolution='h',ax=ax)
bsmap.drawparallels(range(int(minlat), int(maxlat)+1), labels=[1,0,0,0])
bsmap.drawmeridians(range(int(minlon), int(maxlon)+1), labels=[0,0,0,1])
bsmap.drawcoastlines()