def MakeTable(Obs_data, Obs_xml, filename): head_amanzi = [] coordinates = [] mymodel = model_unconfined_seepage_1d.createFromXML(filename) for obs in Obs_data.observations.itervalues(): coordinates.append([obs.coordinate[0], obs.coordinate[1]]) head_amanzi.append(str(obs.data).rstrip(']').lstrip('[')) head_analytic = list(mymodel.head(numpy.array(coordinates))) x = prettytable.PrettyTable( ["x [m]", "z [m]", "Analytic [m]", "Amanzi [m]"]) x.padding_width = 2 x.hrules = 1 x.horizontal_header_char = "=" for coords, h_analytic, h_amanzi in zip(coordinates, head_analytic, head_amanzi): x.add_row([ coords[0], coords[1], "%.4f" % float(h_analytic), "%.4f" % float(h_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()
def plotTestModel(filename, cmap, axes1, Obs_xml, Obs_data): # Instantiate the analytic solution mymodel = model_unconfined_seepage_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.iteritems(): coords[:, 1] = z_val head = mymodel.head(coords) axes1.plot(x, head, color, label='$z = %0.2f $' % z_val) axes1.legend(loc="upper right", fancybox=True, shadow=True)