Exemplo n.º 1
0
Arquivo: util.py Projeto: B4dWo1f/RUN
def cross_path(start, end):
    # start = 41.260096661378306, -3.6981749563104716
    # end = 40.78691893349439, -3.6903966736445306
    # cross_path(start,end)
    start = wrf.ll_to_xy(ncfile, start[0], start[1])
    end = wrf.ll_to_xy(ncfile, end[0], end[1])

    start_point = wrf.CoordPair(x=start[0], y=start[1])
    end_point = wrf.CoordPair(x=end[0], y=end[1])

    levels = np.linspace(900, 3000, 100)
    p_vert = wrf.vertcross(wspd,
                           heights,
                           start_point=start_point,
                           end_point=end_point,
                           levels=levels,
                           latlon=True)
    fig, ax = plt.subplots()
    dx = 0, p_vert.shape[1]
    ax.imshow(p_vert, origin='lower', extent=[*dx, 900, 3000])
    ax.set_aspect(1 / 100)
    ax.set_title('Wind speed')
    fig.tight_layout()
    plt.show()
Exemplo n.º 2
0
        var_cross_filled[0:first_idx, i] = var_cross_filled[first_idx, i]

    return var_cross_filled


#%%
if __name__ == '__main__':
    data_dir1 = '/home/zzhzhao/Model/wrfout/test-10'
    data_dir2 = '/home/zzhzhao/Model/wrfout/test-10-removelake'
    u1, v1, w1, qv1, h, ter, lats, lons, time, wrflist = load_wrfdata_windspeed(
        data_dir1)

    NamCo_ll = (30.75, 90.9)
    # NamCo_xy = w.ll_to_xy(wrflist, NamCo_ll[0], NamCo_ll[1])

    start_point = w.CoordPair(lat=NamCo_ll[0] + 0.5, lon=NamCo_ll[1] - 0.5)
    end_point = w.CoordPair(lat=NamCo_ll[0] - 0.5, lon=NamCo_ll[1] + 0.5)

    u1_cross = w.vertcross(u1,
                           h,
                           wrfin=wrflist,
                           start_point=start_point,
                           end_point=end_point,
                           latlon=True,
                           meta=True)
    v1_cross = w.vertcross(v1,
                           h,
                           wrfin=wrflist,
                           start_point=start_point,
                           end_point=end_point,
                           latlon=True,
Exemplo n.º 3
0
                                       scale='50m',
                                       facecolor='none',
                                       name='admin_1_states_provinces_shp')

# limites X e Y das coordenadas projetadas
xlims = wrf.cartopy_xlim(wrfin=arq)
ylims = wrf.cartopy_ylim(wrfin=arq)

# criando gráfico
ax = plt.axes(projection=projWRF)
ax.coastlines('50m', linewidth=0.8)
ax.gridlines(color='black', linestyle='dotted')
ax.add_feature(estados, linewidth=0.5, edgecolor='black')

# obtendo domínio em torno do estado do RS
RS = wrf.GeoBounds(wrf.CoordPair(lat=-35.0, lon=-60.0),
                   wrf.CoordPair(lat=-26.0, lon=-48.0))
ax.set_xlim(wrf.cartopy_xlim(wrfin=arq, geobounds=RS))
ax.set_ylim(wrf.cartopy_ylim(wrfin=arq, geobounds=RS))
ax.set_title(
    'Comparação INMET (vermelho) x WRF (verde)\n PCWRF/CPMet/FAMET/UFPel')

# adicionando pontos das estações INMET
ax.scatter(estacoes_met.iloc[:, 2].tolist(),
           estacoes_met.iloc[:, 1].tolist(),
           marker='o',
           color='red',
           transform=ccrs.PlateCarree(),
           label='INMET')
# adicionando pontos de grade das extrações
ax.scatter(lat_lon_gridpoints[1, :],
Exemplo n.º 4
0
z = 'z'
ter = 'ter'
uvmet_wspd_wdir = 'uvmet_wspd_wdir'
uvmet = 'uvmet'
TKE_PBL = 'TKE_PBL'
x, y, lat, lon = 'x', 'y', 'lat', 'lon'
xy_loc = 'xy_loc'

d3_vars = [ua, va, wa, uvmet, uvmet_wspd_wdir, z, TKE_PBL]
d2_vars = [ter, pblh]
all_vars = [*d3_vars, *d2_vars]

cross_line = 'cross_line_ll'
bottom_top_stag = 'bottom_top_stag'

end_point = wrf.CoordPair(lat=CHC_LAT, lon=CHC_LON)
start_point = wrf.CoordPair(lat=LPB_LAT, lon=LPB_LON)


def get_ver_cross(path):
    ncfile = Dataset(path, mode='r')
    ds = extract_all_vars(TKE_PBL, all_vars, ncfile)
    ver_cross = cross_3d_vars(cross_line, d3_vars, ds, end_point, start_point, z, ncfile)
    line_cross = cross_2d_vars(cross_line, d2_vars, ds, end_point, start_point, ncfile)
    ver_cross = merge_cross(d2_vars, line_cross, ver_cross)
    ver_cross = fix_xy_loc(lat, lon, ver_cross, x, xy_loc, y)
    ver_cross = get_rid_of_attrs(ver_cross)
    return ver_cross


def get_rid_of_attrs(ver_cross):