예제 #1
0
def MakeTable(Obs_data, Obs_xml, filename):

    pressure_amanzi = []
    coordinates = []
    mymodel = model_linear_flux_head_1d.createFromXML(filename)

    for obs in Obs_data.observations.values():
        coordinates.append([obs.coordinate[0], obs.coordinate[2]])
        pressure_amanzi.append(str(obs.data).rstrip(']').lstrip('['))

    pressure_analytic = list(mymodel.pressure(numpy.array(coordinates)))

    x = prettytable.PrettyTable(
        ["x [m]", "z [m]", "Analytic [Pa]", "Amanzi [Pa]"])
    x.padding_width = 1
    x.hrules = 1
    for coords, p_analytic, p_amanzi in zip(coordinates, pressure_analytic,
                                            pressure_amanzi):
        x.add_row([
            coords[0], coords[1],
            "%.4f" % float(p_analytic),
            "%.4f" % float(p_amanzi)
        ])

    if os.path.exists("table_values.txt"):
        os.remove("table_values.txt")

    table_file = open("table_values.txt", "w+")
    table_file.write('.. tabularcolumns:: ' + '|R|C|C|C|' + '\n\n')
    table_file.write(x.get_string(sortby="x [m]"))
    table_file.write('\n')
    table_file.close()
예제 #2
0
def plotTestModel(filename, cmap, axes1, Obs_xml, Obs_data):

    # Instantiate the analytic solution
    mymodel = model_linear_flux_head_1d.createFromXML(filename)
    table_values = []

    # Create a set of points to plot the solution
    x = numpy.linspace(mymodel.x_0, mymodel.x_1, 11)
    coords = numpy.zeros((11, 2))
    coords[:, 0] = x

    # Plot a line for each z-coordinate in the observations
    for (z_val, color) in cmap.items():
        coords[:, 1] = z_val
        pressure = mymodel.pressure(coords)
        axes1.plot(x, pressure, color, label='$z = %0.2f $' % z_val)
        axes1.legend(loc="upper right", fancybox=True, shadow=True)