Esempio n. 1
0
writefile_T_surf_var.description = 'surface absolute temperature'

writefile_w_ls_var = writefile_forcing_grp.createVariable(
    'w_ls', 'f4', (
        'levels',
        'time',
    ))
writefile_w_ls_var[:] = w_sub
writefile_w_ls_var.units = 'm s^-1'
writefile_w_ls_var.description = 'large scale vertical velocity'

#convert to w
omega = np.zeros((levels.size, time.size), dtype=float)
T_abs = ffc.theta_to_T(thetal, levels)
for t in range(time.size):
    omega[:, t] = ffc.w_to_omega(w_sub[:, t], levels, T_abs)

writefile_omega_var = writefile_forcing_grp.createVariable(
    'omega', 'f4', (
        'levels',
        'time',
    ))
writefile_omega_var[:] = omega
writefile_omega_var.units = 'Pa s^-1'
writefile_omega_var.description = 'large scale pressure velocity'

#ASTEX input file has one value per time for the following variables; need to expand the dimenions of the array to have levels and times
ug_tile = np.tile(u_g.transpose(), (len(levels), 1))
writefile_u_g_var = writefile_forcing_grp.createVariable(
    'u_g', 'f4', (
        'levels',
v_ls = np.zeros((z_wrf.size, w_ls_force_grid.shape[0]),dtype=float)
omega = np.zeros((z_wrf.size, w_ls_force_grid.shape[0]),dtype=float)
theta_nudge = np.zeros((z_wrf.size, w_ls_force_grid.shape[0]),dtype=float)
T_nudge = np.zeros((z_wrf.size, w_ls_force_grid.shape[0]),dtype=float) #not needed
qv_nudge = np.zeros((z_wrf.size, w_ls_force_grid.shape[0]),dtype=float)
h_advec_thil = np.zeros((z_wrf.size, w_ls_force_grid.shape[0]),dtype=float)
h_advec_qt = np.zeros((z_wrf.size, w_ls_force_grid.shape[0]),dtype=float)
v_advec_thil = np.zeros((z_wrf.size, w_ls_force_grid.shape[0]),dtype=float) #not needed if w_ls is specified
v_advec_qt = np.zeros((z_wrf.size, w_ls_force_grid.shape[0]),dtype=float) #not needed if w_ls is specified
rad_heating = np.zeros((z_wrf.size, w_ls_force_grid.shape[0]),dtype=float) #not needed if active rad
time = np.zeros((w_ls_force_grid.shape[0]),dtype=float)
for t in range(w_ls_force_grid.shape[0]):
    time[t] = (data_date[t] - data_date[0]).total_seconds()
    w_ls_f = scipy.interpolate.interp1d(z_ls[t,:], w_ls_force_grid[t,:])
    w_ls[:,t] = w_ls_f(z_wrf)
    omega[:,t] = ffc.w_to_omega(w_ls[:,t], levels, T)
    u_ls_f = scipy.interpolate.interp1d(z_ls[t,:], u_ls_force_grid[t,:])
    u_ls[:,t] = u_ls_f(z_wrf)
    v_ls_f = scipy.interpolate.interp1d(z_ls[t,:], v_ls_force_grid[t,:])
    v_ls[:,t] = v_ls_f(z_wrf)
    theta_nudge_f = scipy.interpolate.interp1d(z_ls[t,:], theta_nudge_force_grid[t,:])
    theta_nudge[:,t] = theta_nudge_f(z_wrf)
    qv_nudge_f = scipy.interpolate.interp1d(z_ls[t,:], qv_nudge_force_grid[t,:])
    qv_nudge[:,t] = qv_nudge_f(z_wrf)
    h_advec_thil_f = scipy.interpolate.interp1d(z_ls[t,:], h_advec_thil_force_grid[t,:])
    h_advec_thil[:,t] = h_advec_thil_f(z_wrf)
    h_advec_qt_f = scipy.interpolate.interp1d(z_ls[t,:], h_advec_qt_force_grid[t,:])
    h_advec_qt[:,t] = h_advec_qt_f(z_wrf)

#gspr.contour_plot_firl(time, levels, omega, np.amin(omega), np.amax(omega), 'omega', 'time', 'levels', 'omega.pdf', y_inverted = 1)
#gspr.contour_plot_firl(time, levels, h_advec_thil, np.amin(h_advec_thil), np.amax(h_advec_thil), 'h-advec-thil', 'time', 'levels', 'h_advec_thil.pdf', y_inverted = 1)