# HYCOM and ROMS # Dimensions are time, elevation, lat, lon d = u[0, 0:1, :, :].data # Find the closest non-land point from a structured grid model. if len(lon.shape) == 1: lon, lat = np.meshgrid(lon, lat) j, i, dd = find_ij(lon, lat, d, obs_lon, obs_lat) for n in range(nsta): # Only use if model cell is within max_dist of station if dd[n] <= max_dist: u_arr = u[istart:istop, 0:1, j[n], i[n]].data v_arr = v[istart:istop, 0:1, j[n], i[n]].data arr = np.sqrt(u_arr ** 2 + v_arr ** 2) if u_arr.std() >= min_var: c = mod_df(arr, timevar, istart, istop, mod_name, ts) name = obs_df[n].name model_df[n] = pd.concat([model_df[n], c], axis=1) model_df[n].name = name else: print "min_var error" else: print "Max dist error" if len(r) == 3: # NECOFS print ("[Structured grid model]:", url) d = u[0, 0:1, :].data # Find the closest non-land point from a structured grid model. index, dd = nearxy(lon.flatten(), lat.flatten(), obs_lon, obs_lat) # Keep the lat lon of the grid point
if istart != istop: nsta = len(station_list) if len(r) == 3: print('[Structured grid model]:', url) d = a[0, :, :].data # Find the closest non-land point from a structured grid model. if len(lon.shape) == 1: lon, lat = np.meshgrid(lon, lat) j, i, dd = find_ij(lon, lat, d, obs_lon, obs_lat) for n in range(nsta): # Only use if model cell is within 0.04 degree of requested # location. if dd[n] <= max_dist: arr = a[istart:istop, j[n], i[n]].data if arr.std() >= min_var: c = mod_df(arr, timevar, istart, istop, mod_name, ts) name = station_list[n]['long_name'] model_df[n] = pd.concat([model_df[n], c], axis=1) model_df[n].name = name elif len(r) == 2: print('[Unstructured grid model]:', url) # Find the closest point from an unstructured grid model. index, dd = nearxy(lon.flatten(), lat.flatten(), obs_lon, obs_lat) for n in range(nsta): # Only use if model cell is within 0.04 degree of requested # location. if dd[n] <= max_dist: arr = a[istart:istop, index[n]].data if arr.std() >= min_var: