예제 #1
0
def load_2D_geometry_from_txt(num_x, num_y, folder_path, file_ext='.dat'):
    file_name = 'geometry'
    data = load_data_from_txt(folder_path, file_name, file_ext=file_ext)
    x = data[:, 0]
    y = data[:, 1]
    x_g = gc.togrid(x, num_x, num_y)
    y_g = gc.togrid(y, num_x, num_y)
    return x_g, y_g
예제 #2
0
def read_3C_velocity_downwards_flow(num_trials, num_snaps, num_x, num_y,
                                    num_vects, RAWdirs):
    u0, u1, u2 = read_3C_velocity(num_trials, num_snaps, num_vects, RAWdirs)
    u = u1
    u_g = -np.swapaxes(gc.togrid(u, num_x, num_y), 0, 1)
    v = u0
    v_g = np.swapaxes(gc.togrid(v, num_x, num_y), 0, 1)
    w = u2
    w_g = np.swapaxes(gc.togrid(w, num_x, num_y), 0, 1)
    return u_g, v_g, w_g
예제 #3
0
def read_2D_geometry_downwards_flow(num_trials, num_snaps, RAWdirs):
    I, J = read_IJ(RAWdirs[0])
    num_x = J
    num_y = I
    num_vects = num_x*num_y
    x0, x1 = read_2D_geometry(num_trials, num_snaps, num_vects, RAWdirs)
    x = x1
    x_g = np.fliplr(gc.togrid(x, num_x, num_y).T)
    y = x0
    y_g = gc.togrid(y, num_x, num_y).T
    return x_g, y_g, num_x, num_y, num_vects
예제 #4
0
def load_3C_velocity_snapshots_from_txt(num_x,
                                        num_y,
                                        folder_path,
                                        file_ext='.dat'):
    data = load_data_from_txt(folder_path, file_ext=file_ext)
    u = data[:, 0, :]
    v = data[:, 1, :]
    w = data[:, 2, :]
    u_g = gc.togrid(u, num_x, num_y)
    v_g = gc.togrid(v, num_x, num_y)
    w_g = gc.togrid(w, num_x, num_y)
    return u_g, v_g, w_g
예제 #5
0
def read_stereo_velocity_downwards_flow(num_trials, num_snaps, num_x, num_y,
                                        num_vects, RAWdirs):
    u0, u1, u2 = read_stereo_velocity(num_trials, num_snaps, num_vects,
                                      RAWdirs)
    u = u1
    #    print np.size(u)
    u_g = -np.swapaxes(gc.togrid(u, num_x, num_y), 0, 1)
    #    print u_g.shape()
    v = u0
    v_g = np.swapaxes(gc.togrid(v, num_x, num_y), 0, 1)
    w = u2
    w_g = np.swapaxes(gc.togrid(w, num_x, num_y), 0, 1)
    return u_g, v_g, w_g
def load_POD_2D(WRKSPCdirs, WRKSPCfilenames_both, I, J, B, num_geos,
                num_planes, num_modes):

    geo_inds = np.arange(num_geos)
    plane_inds = np.arange(num_planes)

    variable_names5 = ['akf', 'lambdaf',
                       'akf_sy', 'lambdaf_sy',
                       'akf_as', 'lambdaf_as',
                       'akf_sy_gaus', 'lambdaf_sy_gaus',
                       'akp_sy', 'lambdap_sy']
    akf = [[np.zeros((B[geo], num_modes))
            for plane in plane_inds] for geo in geo_inds]
    lambdaf = [[np.zeros((B[geo]))
                for plane in plane_inds] for geo in geo_inds]
    akf_sy = [[np.zeros((B[geo], num_modes))
               for plane in plane_inds] for geo in geo_inds]
    lambdaf_sy = [[np.zeros((B[geo]))
                   for plane in plane_inds] for geo in geo_inds]
    akf_as = [[np.zeros((B[geo], num_modes))
               for plane in plane_inds] for geo in geo_inds]
    lambdaf_as = [[np.zeros((B[geo]))
                   for plane in plane_inds] for geo in geo_inds]
    akf_sy_gaus = [[np.zeros((B[geo], num_modes))
                    for plane in plane_inds] for geo in geo_inds]
    lambdaf_sy_gaus = [[np.zeros((B[geo]))
                        for plane in plane_inds] for geo in geo_inds]
    akf_sy_harm = [[np.zeros((B[geo], num_modes))
                    for plane in plane_inds] for geo in geo_inds]
    lambdaf_sy_harm = [[np.zeros((B[geo]))
                        for plane in plane_inds] for geo in geo_inds]
    for geo, WRKSPCdir, WRKSPCfilenames in zip(geo_inds, WRKSPCdirs,
                                               WRKSPCfilenames_both):
        os.chdir(WRKSPCdir)
        for plane, WRKSPCfilename in zip(plane_inds, WRKSPCfilenames):
            matvariables = sio.loadmat(WRKSPCfilename,
                                       variable_names=variable_names5)
            print 'geo: %1.0f/%1.0f,  plane: %2.0f/%2.0f' % \
                (geo, num_geos - 1, plane, num_planes - 1)

            akf_temp = np.squeeze(matvariables['akf'])
            akf_sy_temp = np.squeeze(matvariables['akf_sy'])
            akf_as_temp = np.squeeze(matvariables['akf_as'])
            akf_sy_gaus_temp = np.squeeze(matvariables['akf_sy_gaus'])
            akf_sy_harm_temp = np.squeeze(matvariables['akp_sy'])

            akf[geo][plane] = akf_temp[:, 0:num_modes]
            akf_sy[geo][plane] = akf_sy_temp[:, 0:num_modes]
            akf_as[geo][plane] = akf_as_temp[:, 0:num_modes]
            akf_sy_gaus[geo][plane] = akf_sy_gaus_temp[:, 0:num_modes]
            akf_sy_harm[geo][plane] = akf_sy_harm_temp[:, 0:num_modes]

            lambdaf[geo][plane] = np.squeeze(matvariables['lambdaf'])
            lambdaf_sy[geo][plane] = np.squeeze(matvariables['lambdaf_sy'])
            lambdaf_as[geo][plane] = np.squeeze(matvariables['lambdaf_as'])
            lambdaf_sy_gaus[geo][plane] = np.squeeze(matvariables['lambdaf_sy_gaus'])
            lambdaf_sy_harm[geo][plane] = np.squeeze(matvariables['lambdap_sy'])

    variable_names = ['Psi_uf', 'Psi_vf',# 'Psi_wf',
                       'Psi_uf_sy', 'Psi_vf_sy',# 'Psi_wf_sy',
                       'Psi_uf_as', 'Psi_vf_as',# 'Psi_wf_as',
                       'Psi_uf_sy_gaus', 'Psi_vf_sy_gaus',# 'Psi_wf_sy_gaus',
                       'Psi_up_sy', 'Psi_vp_sy']#, 'Psi_wp_sy']
    Psi_uf_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
                 for plane in plane_inds] for geo in geo_inds]
    Psi_vf_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
                 for plane in plane_inds] for geo in geo_inds]
#    Psi_wf_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
#                 for plane in plane_inds] for geo in geo_inds]
    Psi_uf_sy_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
                    for plane in plane_inds] for geo in geo_inds]
    Psi_vf_sy_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
                    for plane in plane_inds] for geo in geo_inds]
#    Psi_wf_sy_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
#                    for plane in plane_inds] for geo in geo_inds]
    Psi_uf_as_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
                    for plane in plane_inds] for geo in geo_inds]
    Psi_vf_as_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
                    for plane in plane_inds] for geo in geo_inds]
#    Psi_wf_as_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
#                    for plane in plane_inds] for geo in geo_inds]
    Psi_uf_sy_gaus_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
                         for plane in plane_inds] for geo in geo_inds]
    Psi_vf_sy_gaus_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
                         for plane in plane_inds] for geo in geo_inds]
#    Psi_wf_sy_gaus_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
#                         for plane in plane_inds] for geo in geo_inds]
    Psi_uf_sy_harm_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
                         for plane in plane_inds] for geo in geo_inds]
    Psi_vf_sy_harm_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
                         for plane in plane_inds] for geo in geo_inds]
#    Psi_wf_sy_harm_g = [[np.zeros((J[geo].min(), I[geo].min(), num_modes))
#                         for plane in plane_inds] for geo in geo_inds]
    for geo, WRKSPCdir, WRKSPCfilenames in zip(geo_inds, WRKSPCdirs,
                                               WRKSPCfilenames_both):
        os.chdir(WRKSPCdir)
        for plane, WRKSPCfilename in zip(plane_inds, WRKSPCfilenames):
            matvariables = sio.loadmat(WRKSPCfilename,
                                       variable_names=variable_names)
            Psi_uf_temp = np.squeeze(matvariables['Psi_uf'])
            Psi_vf_temp = np.squeeze(matvariables['Psi_vf'])
#            Psi_wf_temp = np.squeeze(matvariables['Psi_wf'])
            Psi_uf_sy_temp = np.squeeze(matvariables['Psi_uf_sy'])
            Psi_vf_sy_temp = np.squeeze(matvariables['Psi_vf_sy'])
#            Psi_wf_sy_temp = np.squeeze(matvariables['Psi_wf_sy'])
            Psi_uf_as_temp = np.squeeze(matvariables['Psi_uf_as'])
            Psi_vf_as_temp = np.squeeze(matvariables['Psi_vf_as'])
#            Psi_wf_as_temp = np.squeeze(matvariables['Psi_wf_as'])
            Psi_uf_sy_gaus_temp = np.squeeze(matvariables['Psi_uf_sy_gaus'])
            Psi_vf_sy_gaus_temp = np.squeeze(matvariables['Psi_vf_sy_gaus'])
#            Psi_wf_sy_gaus_temp = np.squeeze(matvariables['Psi_wf_sy_gaus'])
            Psi_uf_sy_harm_temp = np.squeeze(matvariables['Psi_up_sy'])
            Psi_vf_sy_harm_temp = np.squeeze(matvariables['Psi_vp_sy'])
#            Psi_wf_sy_harm_temp = np.squeeze(matvariables['Psi_wp_sy'])

            Psi_uf_g_temp = gc.togrid(Psi_uf_temp, J[geo][plane],
                                      I[geo][plane])
            Psi_vf_g_temp = gc.togrid(Psi_vf_temp, J[geo][plane],
                                      I[geo][plane])
#            Psi_wf_g_temp = gc.togrid(Psi_wf_temp, J[geo][plane],
#                                      I[geo][plane])
            Psi_uf_sy_g_temp = gc.togrid(Psi_uf_sy_temp, J[geo][plane],
                                         I[geo][plane])
            Psi_vf_sy_g_temp = gc.togrid(Psi_vf_sy_temp, J[geo][plane],
                                         I[geo][plane])
#            Psi_wf_sy_g_temp = gc.togrid(Psi_wf_sy_temp, J[geo][plane],
#                                         I[geo][plane])
            Psi_uf_as_g_temp = gc.togrid(Psi_uf_as_temp, J[geo][plane],
                                         I[geo][plane])
            Psi_vf_as_g_temp = gc.togrid(Psi_vf_as_temp, J[geo][plane],
                                         I[geo][plane])
#            Psi_wf_as_g_temp = gc.togrid(Psi_wf_as_temp, J[geo][plane],
#                                         I[geo][plane])
            Psi_uf_sy_gaus_g_temp = gc.togrid(Psi_uf_sy_gaus_temp,
                                              J[geo][plane], I[geo][plane])
            Psi_vf_sy_gaus_g_temp = gc.togrid(Psi_vf_sy_gaus_temp,
                                              J[geo][plane], I[geo][plane])
#            Psi_wf_sy_gaus_g_temp = gc.togrid(Psi_wf_sy_gaus_temp,
#                                              J[geo][plane], I[geo][plane])
            Psi_uf_sy_harm_g_temp = gc.togrid(Psi_uf_sy_harm_temp,
                                              J[geo][plane], I[geo][plane])
            Psi_vf_sy_harm_g_temp = gc.togrid(Psi_vf_sy_harm_temp,
                                              J[geo][plane], I[geo][plane])
#            Psi_wf_sy_harm_g_temp = gc.togrid(Psi_wf_sy_harm_temp,
#                                              J[geo][plane], I[geo][plane])

            cut_row = (J[geo][plane] - J[geo].min())//2
            cut_col = (I[geo][plane] - I[geo].min())//2
            cut_row_f = cut_row
            cut_row_b = cut_row
            cut_col_f = cut_col
            cut_col_b = cut_col

            if cut_row_b == 0:
                cut_row_b = -J[geo][plane]
            if cut_col_b == 0:
                cut_col_b = -I[geo][plane]

            Psi_uf_g[geo][plane][:, :, :] \
                = Psi_uf_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
            Psi_vf_g[geo][plane][:, :, :] \
                = Psi_vf_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
#            Psi_wf_g[geo][plane][:, :, :] \
#                = Psi_wf_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
            Psi_uf_sy_g[geo][plane][:, :, :] \
                = Psi_uf_sy_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
            Psi_vf_sy_g[geo][plane][:, :, :] \
                = Psi_vf_sy_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
#            Psi_wf_sy_g[geo][plane][:, :, :] \
#                = Psi_wf_sy_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
            Psi_uf_as_g[geo][plane][:, :, :] \
                = Psi_uf_as_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
            Psi_vf_as_g[geo][plane][:, :, :] \
                = Psi_vf_as_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
#            Psi_wf_as_g[geo][plane][:, :, :] \
#                = Psi_wf_as_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
            Psi_uf_sy_gaus_g[geo][plane][:, :, :] \
                = Psi_uf_sy_gaus_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
            Psi_vf_sy_gaus_g[geo][plane][:, :, :] \
                = Psi_vf_sy_gaus_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
#            Psi_wf_sy_gaus_g[geo][plane][:, :, :] \
#                = Psi_wf_sy_gaus_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
            Psi_uf_sy_harm_g[geo][plane][:, :, :] \
                = Psi_uf_sy_harm_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
            Psi_vf_sy_harm_g[geo][plane][:, :, :] \
                = Psi_vf_sy_harm_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
#            Psi_wf_sy_harm_g[geo][plane][:, :, :] \
#                = Psi_wf_sy_harm_g_temp[cut_row_f:-cut_row_b, cut_col_f:-cut_col_b, 0:num_modes]
    return akf, akf_sy, akf_as, akf_sy_gaus, akf_sy_harm, \
        lambdaf, lambdaf_sy, lambdaf_as, lambdaf_sy_gaus, lambdaf_sy_harm, \
        Psi_uf_g, Psi_uf_sy_g, Psi_uf_as_g, Psi_uf_sy_gaus_g, Psi_uf_sy_harm_g, \
        Psi_vf_g, Psi_vf_sy_g, Psi_vf_as_g, Psi_vf_sy_gaus_g, Psi_vf_sy_harm_g#, \