コード例 #1
0
def getFVcom(latpt, lonpt, time_roms, depth_roms):
    url = "http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3/mean"
    nc = netCDF4.Dataset(url)
    lat = nc.variables["lat"][:]
    lon = nc.variables["lon"][:]
    Depth = nc.variables["h"][:]
    siglay = nc.variables["siglay"][:]
    time = nc.variables["time"][:]
    modtemp = nc.variables["temp"]
    modtime = []
    for i in range(len(time)):
        t = timedelta(days=float(time[i])).total_seconds()
        modtime.append(t)  # change time days to seconds
    depth = (-Depth * siglay).transpose()  # each layer`s depth
    distance = dist(lonpt, latpt, lon, lat)
    node = np.argmin(distance)  # get nearest node
    layer = []
    for i in depth_roms[0 : len(depth_roms) + 1]:
        layer.append(np.argmin(abs(i - depth[node])))  # get layer of depth
    t_diff = (time_roms - datetime(1858, 11, 17)).total_seconds()  # 1858,11,17 is FVCOM`s start time
    TIME = np.argmin(abs(t_diff - np.array(modtime)))
    Temp = []
    for i in range(len(layer)):
        t = modtemp[TIME][i][node]
        Temp.append(t)
    Temp.reverse()
    return Temp
コード例 #2
0
def getFVcom(latpt, lonpt, time_roms, depth_roms):
    url = 'http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3/mean'
    nc = netCDF4.Dataset(url)
    lat = nc.variables['lat'][:]
    lon = nc.variables['lon'][:]
    Depth = nc.variables['h'][:]
    siglay = nc.variables['siglay'][:]
    time = nc.variables['time'][:]
    modtemp = nc.variables['temp']
    modtime = []
    for i in range(len(time)):
        t = timedelta(days=float(time[i])).total_seconds()
        modtime.append(t)  #change time days to seconds
    depth = (-Depth * siglay).transpose()  #each layer`s depth
    distance = dist(lonpt, latpt, lon, lat)
    node = np.argmin(distance)  #get nearest node
    layer = []
    for i in depth_roms[0:len(depth_roms) + 1]:
        layer.append(np.argmin(abs(i - depth[node])))  #get layer of depth
    t_diff = (time_roms - datetime(
        1858, 11, 17)).total_seconds()  #1858,11,17 is FVCOM`s start time
    TIME = np.argmin(abs(t_diff - np.array(modtime)))
    Temp = []
    for i in range(len(layer)):
        t = modtemp[TIME][i][node]
        Temp.append(t)
    Temp.reverse()
    return Temp
コード例 #3
0
LON_interval, LAT_interval = (
    (input_value_1_lon - input_value_0_lon) / 10.0,
    (input_value_1_lat - input_value_0_lat) / 10.0,
)
LON, LAT = (
    np.arange(input_value_0_lon, input_value_1_lon, LON_interval),
    np.arange(input_value_0_lat, input_value_1_lat, LAT_interval),
)
# just ten points between start point and end point
LAT_roms = []
LON_roms = []
H_roms = []
Temp_roms = []
for i in range(len(LON)):  # get ten points` temperature of ROMS
    temp_roms = []
    distance = dist(LON[i], LAT[i], lons_roms, lats_roms)
    node = np.argmin(distance)  # get nearest node
    index_one, index_two = int(node / len(lons_roms[0])), node % len(lons_roms[0])  # change list to list of list
    LAT_roms.append(lats_roms[index_one, index_two])
    LON_roms.append(lons_roms[index_one, index_two])  # get nearest point`s lat,lon
    H_roms.append(h_roms[index_one, index_two])
    for j in range(len(s_rho)):  # this is roms`s layers
        temp_roms.append(temps_roms[TIME][j][index_one, index_two])
    Temp_roms.append(temp_roms)

ttt_roms = np.array(Temp_roms).transpose()
"""
 change [[layer1,lyaer2,,,last layer],[layer1,lyaer2,,,last layer],,,,[layer1,lyaer2,,,last layer]]
 to  [[layer1,layer1,,,layer1],[layer2,layer2,,,layer2],,,[last layer,last layer,,,last layer]]
 use in griddata later
"""
コード例 #4
0

## example 2.12:Bernoulli distribution
import numpy as np
import matplotlib.pyplot as plt
from math import sqrt
T=1000;repetition=500
y=np.empty(T)
y_hat=np.empty(repetition)
for j in range(repetition):
    theta=np.random.uniform(0,1,T)
    for i in range(T):
        y[i]=np.random.binomial(1,theta[i])
    y_hat[j]=sqrt(T)*(np.mean(y-theta)/np.mean(theta*(1-theta)))
from my_modules import distribution as dist
dist(y_hat).hist(disp_norm=1)














コード例 #5
0
    input('please input end site lon(for example:-71.72):'))
input_value_1_lat = float(
    input('please input end site lon(for example: 40.09):'))  #end point
LON_interval, LAT_interval = (input_value_1_lon - input_value_0_lon) / 10.0, (
    input_value_1_lat - input_value_0_lat) / 10.0
LON, LAT = np.arange(input_value_0_lon, input_value_1_lon,
                     LON_interval), np.arange(input_value_0_lat,
                                              input_value_1_lat, LAT_interval)
#just ten points between start point and end point
LAT_roms = []
LON_roms = []
H_roms = []
Temp_roms = []
for i in range(len(LON)):  #get ten points` temperature of ROMS
    temp_roms = []
    distance = dist(LON[i], LAT[i], lons_roms, lats_roms)
    node = np.argmin(distance)  #get nearest node
    index_one, index_two = int(node / len(lons_roms[0])), node % len(
        lons_roms[0])  # change list to list of list
    LAT_roms.append(lats_roms[index_one, index_two])
    LON_roms.append(lons_roms[index_one,
                              index_two])  #get nearest point`s lat,lon
    H_roms.append(h_roms[index_one, index_two])
    for j in range(len(s_rho)):  #this is roms`s layers
        temp_roms.append(temps_roms[TIME][j][index_one, index_two])
    Temp_roms.append(temp_roms)

ttt_roms = np.array(Temp_roms).transpose()
'''
 change [[layer1,lyaer2,,,last layer],[layer1,lyaer2,,,last layer],,,,[layer1,lyaer2,,,last layer]]
 to  [[layer1,layer1,,,layer1],[layer2,layer2,,,layer2],,,[last layer,last layer,,,last layer]]