Beispiel #1
0
    qa = np.zeros((jtot_hm, itot_hm))

    interp_z(ua, hm_u['ua'][t_hm, ::-1, :, :].values, z_hm[::-1, :, :],
             z_les[k_les], itot_hm, jtot_hm, ktot_hm)
    interp_z(va, hm_v['va'][t_hm, ::-1, :, :].values, z_hm[::-1, :, :],
             z_les[k_les], itot_hm, jtot_hm, ktot_hm)
    interp_z(qa, hm_q['hus'][t_hm, ::-1, :, :].values, z_hm[::-1, :, :],
             z_les[k_les], itot_hm, jtot_hm, ktot_hm)

    vmin, vmax = minmax(calc_abs(ua, va))

    #
    # Interpolate HARMONIE to LES grid
    #
    intp = ip.Grid_interpolator(hm_u['x'].values, hm_u['y'].values, None,
                                LES_grid.x, LES_grid.y, None, LES_grid.xh,
                                LES_grid.yh, None, x0, y0)

    ua_at_les = intp.interpolate_2d(ua, 'x', 'y')
    va_at_les = intp.interpolate_2d(va, 'x', 'y')

    if True:
        # Plot!
        pl.figure(figsize=(10, 4))

        ax = setup_map(subplot=131)
        plot_LES_domain(lon, lat, 'r')

        ax.pcolormesh(hm_u['lon'],
                      hm_u['lat'],
                      calc_abs(ua, va),
Beispiel #2
0
    # Select a sub-area around the LES domain, to speed up
    # calculations done over the entire HARMONIE grid
    def sel_sub_area(ds, x0, y0, xsize, ysize, margin=2500):
        return ds.sel(x=slice(x0-margin, x0+xsize+margin), y=slice(y0-margin, y0+ysize+margin))

    u  = sel_sub_area(u,  x0, y0, xsize, ysize)['ua' ]
    v  = sel_sub_area(v,  x0, y0, xsize, ysize)['va' ]
    T  = sel_sub_area(T,  x0, y0, xsize, ysize)['ta' ]
    q  = sel_sub_area(q,  x0, y0, xsize, ysize)['hus']
    ql = sel_sub_area(ql, x0, y0, xsize, ysize)['clw']
    ps = sel_sub_area(ps, x0, y0, xsize, ysize)['ps' ]
    Ts = sel_sub_area(Ts, x0, y0, xsize, ysize)['sst']

    # Store lat/lon on LES grid (to-do: use proj.4 to simply re-create HARMONIE projection on LES grid..)
    intp = ip.Grid_interpolator(u['x'].values, u['y'].values, None, grid.x, grid.y, None, grid.xh, grid.yh, None, x0, y0)
    lon_LES = intp.interpolate_2d(u['lon'].values, 'x', 'y')
    lat_LES = intp.interpolate_2d(u['lat'].values, 'x', 'y')
    np.save('{}/lon_LES'.format(output_dir), lon_LES)
    np.save('{}/lat_LES'.format(output_dir), lat_LES)

    if True:
        # Create hourly boundaries:
        for t in range(t0, t1+1):
            print('Processing t={0:>2d}:00 UTC'.format(t))
            start_time = datetime.datetime.now()

            # Load data from current time step (not really necessary, but otherwise
            # from here on some variable do have a time dimension, and some dont't....)
            # Also, nice time to drop the no longer necessary xarray stuff with `.values`
            u_t  = u [t,:,:,:].values