dev:plotting_elem_counts
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dev:plotting_elem_counts [2014/10/26 20:54] – jvick3 | dev:plotting_elem_counts [2014/10/26 21:01] (current) – jvick3 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | The // | + | The // |
- | # | + | sudo apt-get install |
- | # Reads .mfs files in a directory and makes plots of | + | Example usage: |
- | # particular elements (Data, Isolator) in them | + | |
- | # Work-in-progress. | + | |
- | | + | ./ |
- | | + | |
- | # Idea: keep a mapping somewhere (file?) of Element name to color | + | <code python> |
- | # | + | #!/ |
- | def plot_mfs_data(filePath, | + | # This script plots the counts of the specified elements against AEPS, |
- | | + | # each plot having the specified title. |
+ | |||
+ | 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, | ||
+ | with open(filePath, | ||
| | ||
- | # Read header and AEPS column | + | |
- | | + | header = inFile.readline().split() |
- | | + | header.remove("#" |
- | | + | AEPS_index = header.index(" |
- | | + | 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, |
- | | + | plt.xlabel(' |
- | | + | plt.ylabel(" |
- | | + | plt.title(plot_title) |
- | # Show all figures/ | + | |
- | | + | plt.show() |
| | ||
- | # When run as a script | + | # When run as a script |
- | if __name__ == " | + | if __name__ == " |
- | | + | if len(sys.argv) < 4: |
- | | + | print " |
- | | + | else: |
- | | + | plot_mfs_data(sys.argv[1], |
- | + | </ | |
dev/plotting_elem_counts.1414356841.txt.gz · Last modified: 2014/10/26 20:54 by jvick3