def makeLinePlots(base_name, y_labels, scaling_factors, y_bounds_list, legend_locations, var_name_lists, set_label_lists, block_names): n_blocks = len(block_names) # load data data = list() for i, block_name in enumerate(block_names): data.append(dict()) for var_name_list in var_name_lists: for var_name in var_name_list: file_name = base_name + "_" + var_name + "_" + block_name + ".csv" block_data = readCSVFile(file_name) data[i]["x"] = block_data["x"] data[i][var_name] = block_data[var_name] # make plots def makeLinePlot(y_label, var_name_list, set_label_list, scaling, y_bounds, leg_loc): plotter = Plotter("$x$", y_label) for i in xrange(n_blocks): x = data[i]["x"] for j, var_name in enumerate(var_name_list): plotter.addSet(x, data[i][var_name], set_label_list[j] + ", Mesh " + str(i + 1), color=i + 1, linetype=j, marker=i + 1, scale=scaling) if y_bounds: plotter.setYRange(y_bounds[0], y_bounds[1]) plotter.setLegendLocation(leg_loc) plotter.save(base_name + "_" + var_name_list[0] + ".pdf") for y_label, var_name_list, set_label_list, scaling, y_bounds, leg_loc in \ zip(y_labels, var_name_lists, set_label_lists, scaling_factors, y_bounds_list, legend_locations): makeLinePlot(y_label, var_name_list, set_label_list, scaling, y_bounds, leg_loc)
def testReadCSVData(self): input_file = "testing/tests/file_utilities/gold/test_data.csv" data = readCSVFile(input_file) self.assertTrue(data["header2"][1] == 5)
# USAGE: python plot.py <var> # <var> Variable to plot # import argparse from file_utilities import readCSVFile from error_utilities import raiseException from PlotterLine import PlotterLine parser = argparse.ArgumentParser(description='Plots solutions') parser.add_argument('variable', help='Variable to plot') parsed = parser.parse_args() variable = parsed.variable data = readCSVFile("output.csv") data_names = { "A": ("Area", "A"), "r": ("Density", "\\rho"), "u": ("Velocity", "u"), "p": ("Pressure", "p"), "T": ("Temperature", "T"), "a_liq": ("Liquid Volume Fraction", "\\alpha_\\ell"), "a_vap": ("Vapor Volume Fraction", "\\alpha_v"), "r_liq": ("Liquid Density", "\\rho_\\ell"), "r_vap": ("Vapor Density", "\\rho_v"), "u_liq": ("Liquid Velocity", "u_\\ell"), "u_vap": ("Vapor Velocity", "u_v"), "p_liq": ("Liquid Pressure", "p_\\ell"), "p_vap": ("Vapor Pressure", "p_v"),
#!/usr/bin/python from file_utilities import readCSVFile from PlotterLine import PlotterLine solution = readCSVFile("output.csv") u_plotter = PlotterLine("Position", "Velocity [m/s]") u_plotter.addSet(solution["x"], solution["u_liq"], "$u_\\ell$", color=4, linetype=2) u_plotter.addSet(solution["x"], solution["u_vap"], "$u_v$", color=1, linetype=2) u_plotter.save("velocity.png") p_plotter = PlotterLine("Position", "Pressure [MPa]") p_plotter.addSet(solution["x"], solution["p_liq"], "$p_\\ell$", color=4, linetype=2, scale=1e-6) p_plotter.addSet(solution["x"], solution["p_vap"], "$p_v$", color=1,
#!/usr/bin/python import numpy as np from file_utilities import readCSVFile from PlotterLine import PlotterLine exact = readCSVFile("exact.csv") solution = readCSVFile("output.csv") r_plotter = PlotterLine("Position", "Density") r_plotter.addSet(exact["x"], exact["r"], "$\\rho_\\ell$, Exact", color=4, linetype=1) r_plotter.addSet(exact["x"], np.flip(exact["r"]), "$\\rho_v$, Exact", color=1, linetype=1) r_plotter.addSet(solution["x"], solution["r_liq"], "$\\rho_\\ell$, Computed", color=4, linetype=2) r_plotter.addSet(solution["x"], solution["r_vap"], "$\\rho_v$, Computed", color=1, linetype=2)