コード例 #1
0
def generate_data(N, trans, sample_rate, Ngrid, def_param=(shared_input_data, shared_data)):
    data = None

    if direction == "u":
        if not os.path.exists("../../cache/barkley/raw/{0}_{1}.uv.dat.npy".format(N, Ngrid)):
            data = bh.generate_data(N, 20000, 5, Ngrid=Ngrid)
            np.save("../../cache/barkley/raw/{0}_{1}.uv.dat.npy".format(N, Ngrid), data)
        else:
            data = np.load("../../cache/barkley/raw/{0}_{1}.uv.dat.npy".format(N, Ngrid))
    else:
        if not os.path.exists("../../cache/mitchell/raw/{0}_{1}.vh.dat.npy".format(N, Ngrid)):
            data = mh.generate_data(N, 20000, 50, Ngrid=Ngrid)
            np.save("../../cache/mitchell/raw/{0}_{1}.vh.dat.npy".format(N, Ngrid), data)
        else:
            data = np.load("../../cache/mitchell/raw/{0}_{1}.vh.dat.npy".format(N, Ngrid))

    data = data[0, :]

    input_y, input_x, output_y, output_x = hp.create_patch_indices(
        (center - (half_inner_size+border_size), center + (half_inner_size+border_size) + right_border_add),
        (center - (half_inner_size+border_size), center + (half_inner_size+border_size) + right_border_add),
        (center - (half_inner_size), center + (half_inner_size) + right_border_add),
        (center - (half_inner_size), center + (half_inner_size) + right_border_add))

    input_data = data[:, input_y, input_x].reshape(ndata, -1)
    if prediction_mode in ["NN", "RBF"]:
        shared_input_data[:] = hp.create_1d_delay_coordinates(input_data, delay_dimension=ddim, tau=tau[direction]).reshape((ndata, -1))
    else:
        shared_input_data[:] = input_data[:]

    shared_data[:] = data[:]
    prediction[:] = data[trainLength:trainLength+predictionLength]
    prediction[:, output_y, output_x] = 0.0
コード例 #2
0
else:
    direction = args.direction[0]

if (direction == "u"):
    if (os.path.exists("../../cache/barkley/raw/{0}_{1}.uv.dat.npy".format(
            ndata, N)) == False):
        data = bh.generate_data(ndata, 20000, 5, Ngrid=N)
        np.save("../../cache/barkley/raw/{0}_{1}.uv.dat.npy".format(ndata, N),
                data)
    else:
        data = np.load("../../cache/barkley/raw/{0}_{1}.uv.dat.npy".format(
            ndata, N))
else:
    if (os.path.exists("../../cache/mitchell/raw/{0}_{1}.vh.dat.npy".format(
            ndata, N)) == False):
        data = mh.generate_data(ndata, 20000, 50, Ngrid=N)
        np.save("../../cache/mitchell/raw/{0}_{1}.vh.dat.npy".format(ndata, N),
                data)
    else:
        data = np.load("../../cache/mitchell/raw/{0}_{1}.vh.dat.npy".format(
            ndata, N))

data = data[0]


def create_data(innerSize, borderSize, data):
    halfInnerSize = int(np.floor(innerSize / 2))
    borderSize = 1
    center = N // 2
    rightBorderAdd = 1 if innerSize != 2 * halfInnerSize else 0