' ', 'Wind speed(m/s)', 'Wave height(m)', 'Bottom temperature(degC)', 'current' ] dist_emolt, data_emolt, emolt_name = get_emolt_data(alon, alat) start_time, end_time = min(data_emolt['time']), max(data_emolt['time']) if method == 'bottom temperature': url = 'http://tds.marine.rutgers.edu:8080/thredds/dodsC/roms/mabgom/v6/avg' try: nc = netCDF4.Dataset(url) lons = nc.variables['lon_rho'][:] lats = nc.variables['lat_rho'][:] time = nc.variables['ocean_time'][:] temp = nc.variables['temp'] Dist = [] for i in range(len(lons[:])): Dist.append(DIST(lons[i], lats[i], alon, alat)) #calculate distance index_nearest = np.argmin(Dist) #find index of nearest distance index_one, index_two = index_nearest / len( lons[0]), index_nearest % len(lons[0]) depth_model = nc.variables['h'][index_one][ index_two] #get depth of roms t1 = (start_time - datetime.datetime(1858, 11, 17)).total_seconds() t2 = (end_time - datetime.datetime(1858, 11, 17)).total_seconds() print('bb') nearest_s, nearest_e = np.argmin(abs(time - t1)), np.argmin( abs(time - t2)) T = [] for i in time[nearest_s:nearest_e]: t = datetime.datetime(1858, 11, 17) + datetime.timedelta(seconds=i) T.append(t.date()) TEMP = temp[nearest_s:nearest_e, -1, index_one, index_two]
'current' ] way = ['', 'wind', 'wave', 'bottom_temp', 'current'] dist_emolt, data_emolt, emolt_name = get_emolt_data(alon, alat) start_time, end_time = min(data_emolt['time']), max(data_emolt['time']) if method == 'bottom temperature': url = 'http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3/mean' try: nc = netCDF4.Dataset(url) lons = nc.variables['lon'][:] lats = nc.variables['lat'][:] time = nc.variables['time'][:] temp = nc.variables['temp'] Dist = [] for i in range(len(lons[:])): Dist.append(DIST(lons[i], lats[i], alon, alat)) index_nearest = np.argmin(Dist) depth_fvcom = nc.variables['h'][index_nearest] #get depth of fvcom t1 = (start_time - datetime.datetime(1858, 11, 17)).total_seconds() / 3600 / 24 t2 = (end_time - datetime.datetime(1858, 11, 17)).total_seconds() / 3600 / 24 nearest_s, nearest_e = np.argmin(abs(time - t1)), np.argmin( abs(time - t2)) T = [] for i in time[nearest_s:nearest_e]: t = datetime.datetime(1858, 11, 17) + datetime.timedelta(days=int(i)) T.append(t.date()) TEMP = temp[nearest_s:nearest_e, -1, index_nearest] TEMP_f = []
] way = ['', 'wind', 'wave', 'bottom_temp', 'current'] if method == 'wind': url = 'http://www.smast.umassd.edu:8080/thredds/dodsC/models/fvcom/NECOFS/Forecasts/NECOFS_MET_FORECAST.nc' try: nc = netCDF4.Dataset(url) lons = nc.variables['XLONG'][:] lats = nc.variables['XLAT'][:] time = nc.variables['Times'][:] u = nc.variables['U10'][:] v = nc.variables['V10'][:] Dist = [] for i in range(len(lons[:])): for j in range(len(lons[0])): Dist.append( DIST(lons[i][j], lats[i][j], lon_i[sites[site][0]], lat_i[sites[site][1]])) index_nearest = np.argmin(Dist) # get smallest one index_one, index_two = index_nearest / len( lons[0]), index_nearest % (len(lons[0])) wind = [] for i in range(len(time)): U = u[i][index_one][index_two] V = v[i][index_one][index_two] s = np.sqrt(U * U + V * V) wind.append(s) T = [] for i in range(len(time)): t = '' for j in range(len(time[i])): t = t + str(time[i][j]) t = datetime.datetime.strptime(t, "%Y-%m-%d_%H:%M:%S")