示例#1
0
def test_single_run():
    Output = main()
    assert hasattr(Output, "Basin")
    assert hasattr(Output, "Inlets")
    assert hasattr(Output, "Ocean")
    assert hasattr(Output, "Pars")

    Input = ModelData("testkees")
    Input, Output = multirun.run_model()
    assert hasattr(Input, "Basin")
    assert hasattr(Input, "Inlets")
    assert hasattr(Input, "Ocean")
    assert hasattr(Input, "Pars")
    assert hasattr(Output, "Basin")
    assert hasattr(Output, "Inlets")
    assert hasattr(Output, "Ocean")
    assert hasattr(Output, "Pars")

    Output = rec_model(Input)
    assert hasattr(Output, "Basin")
    assert hasattr(Output, "Inlets")
    assert hasattr(Output, "Ocean")
    assert hasattr(Output, "Pars")

    Input = ModelData("testkees")
    Input.Inlets.widths = [nan, nan, nan]
    with py.test.raises(NameError):
        Output = rec_model(Input)
示例#2
0
def test_evo_plot():
    Input = ModelData("testkees")
    Input.Inlets.wit = np.repeat(Input.Inlets.widths, 2, axis=0)
    plt.ion()
    fig = plt.figure()
    ax = Axes3D(fig)
    assert Input.evolution_plot(ax=ax)[0]
    assert Input.evolution_plot()[0]
    plt.close("all")
示例#3
0
def test_evo_plot_3p():
    Input = ModelData("testkees")
    Input.Inlets.wit = np.repeat(Input.Inlets.widths, 3, axis=0)
    Input.Inlets.wit[:, 2] = Input.Inlets.wit[:, 2] * 0
    plt.ion()
    assert Input.evolution_plot_3p(orientation="h")[0]
    assert Input.evolution_plot_3p(orientation="v")[0]
    with py.test.raises(NameError):
        assert Input.evolution_plot_3p(orientation="aap")[0]
    plt.close("all")
示例#4
0
def test_import():
    Input = ModelData("testkees")
    assert hasattr(Input, "Basin")
    assert hasattr(Input, "Inlets")
    assert hasattr(Input, "Ocean")
    assert hasattr(Input, "Pars")

    Input = ModelData("testlocation")
    assert hasattr(Input, "Basin")
    assert hasattr(Input, "Inlets")
    assert hasattr(Input, "Ocean")
    assert hasattr(Input, "Pars")

    with py.test.raises(NameError):
        assert ModelData("AaP")
示例#5
0
def run_model(seed=None, location="testkees"):

    # Prepare input data
    Input = ModelData(location, seed=seed)

    # Run the model
    Output = rec_model(Input, silent=1)
    return Input, Output
示例#6
0
def test_amp_plot():
    Input = ModelData("testkees")
    # Decrease resolution
    Pars = Input.Pars
    Pars.mtrunc = 5
    Pars.ntrunc = 5
    Pars.mrange = np.arange(Pars.mtrunc + 1)
    Pars.nrange = np.arange(Pars.ntrunc + 1)
    Pars.nrange = Pars.nrange[np.newaxis, :]
    Pars.kmn2 = (Pars.mrange[:, np.newaxis] * np.pi / Input.Basin.length) ** 2 + (
        Pars.nrange * np.pi / Input.Basin.width
    ) ** 2

    uj = np.zeros(Input.Basin.numinlets) + 1
    Input.Inlets.uj = uj[np.newaxis, :]
    Input.Basin.mub = 1 - 1j * (8 / (3 * np.pi) * Input.Basin.cd * 0.4) / (
        Input.Ocean.tidefreq * Input.Basin.depth
    )
    plt.ion()
    fig = plt.figure()
    ax = Axes3D(fig)
    assert Input.zeta_amplitude_plot(ax=ax)[0]
    assert Input.zeta_amplitude_plot()[0]
    assert Input.u_amplitude_plot(ax=ax)[0]
    assert Input.u_amplitude_plot()[0]
    plt.close("all")
示例#7
0
def main(location="testkees"):

    # Start timer
    start_time = time.time()

    # Prepare input data
    Input = ModelData(location)

    # Run the model
    Output = rec_model(Input, silent=True)

    # Plot results
    Output.evolution_plot_3p(orientation="h")

    # Print elapsed time
    print("%s seconds" % (time.time() - start_time))
    return Output
示例#8
0
def test_geometry_plot():
    Input = ModelData("testkees")
    Input.Inlets.wit = np.repeat(Input.Inlets.widths, 2, axis=0)
    plt.ion()
    assert Input.geometry_plot(0)[0]
    plt.close("all")
示例#9
0
def run_model():
    Input = ModelData("testkees")
    Output = rec_model(Input, silent=1)
    return Input, Output