dev:plotting_elem_counts
This is an old revision of the document!
The plot_element_counts.py script:
#!/usr/bin/env python # Reads .mfs files in a directory and makes plots of # particular elements (Data, Isolator) in them # Work-in-progress. import sys import matplotlib.pyplot as plt # Idea: keep a mapping somewhere (file?) of Element name to color # to use with plot def plot_mfs_data(filePath, plot_title, elem_names): with open(filePath, "r") as inFile: # Read header and AEPS column header = inFile.readline().split() header.remove("#") # there is a column named as "# AEPS", bad AEPS_index = header.index("AEPS") lines = inFile.readlines() AEPS = [] for l in lines: entries = l.split() AEPS.append(entries[AEPS_index]) ############################## # Read data lines of file, get element counts, make plots for each fig_index = 0 for elem in elem_names: col_index = header.index(elem) counts = [] for l in lines: entries = l.split() counts.append(entries[col_index]) # Make plots for this Element fig = plt.figure(fig_index) fig_index += 1 plt.plot(AEPS, counts) plt.xlabel('AEPS') plt.ylabel("Number of " + elem) plt.title(plot_title) # Show all figures/plots plt.show() # When run as a script if __name__ == "__main__": if len(sys.argv) < 4: print "Usage: <tbd data file> <plot_title> <list of Element names>" else: plot_mfs_data(sys.argv[1], sys.argv[2], sys.argv[3:])
dev/plotting_elem_counts.1414357042.txt.gz · Last modified: 2014/10/26 20:57 by jvick3