diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-02-13 16:26:34 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-02-13 16:26:34 -0500 |
commit | 0c28870f3f9dd5fe3c029a63ab4149de5f2beb59 (patch) | |
tree | 99165eb68239f6629a02d755889d5f385f3c3e69 /plot_exps.py | |
parent | 4a1c47705868ce2c48f1c57a7190d435e16c3ce8 (diff) |
Removed TupleTable calculation from plot_exps.py
Diffstat (limited to 'plot_exps.py')
-rwxr-xr-x | plot_exps.py | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/plot_exps.py b/plot_exps.py index bb6a707..b17cd36 100755 --- a/plot_exps.py +++ b/plot_exps.py | |||
@@ -7,9 +7,8 @@ import shutil as sh | |||
7 | import sys | 7 | import sys |
8 | from collections import namedtuple | 8 | from collections import namedtuple |
9 | from optparse import OptionParser | 9 | from optparse import OptionParser |
10 | from parse.col_map import ColMap | 10 | from parse.col_map import ColMap,ColMapBuilder |
11 | from parse.dir_map import DirMap | 11 | from parse.dir_map import DirMap |
12 | from parse.tuple_table import ReducedTupleTable | ||
13 | from plot.style import StyleMap | 12 | from plot.style import StyleMap |
14 | 13 | ||
15 | def parse_args(): | 14 | def parse_args(): |
@@ -39,26 +38,32 @@ def get_details(path, out_dir): | |||
39 | 38 | ||
40 | return ExpDetails(variable, value, title, out) | 39 | return ExpDetails(variable, value, title, out) |
41 | 40 | ||
42 | def plot_by_variable(plot_node, col_map, details): | 41 | def plot_by_variable(plot_node, details): |
43 | '''Plot each .csv files under @plot_node as a line on a shared plot.''' | 42 | '''Plot each .csv files under @plot_node as a line on a shared plot.''' |
44 | 43 | ||
44 | builder = ColMapBuilder() | ||
45 | config_nodes = [] | ||
46 | |||
45 | # Generate mapping of (column)=>(line property to vary) for consistently | 47 | # Generate mapping of (column)=>(line property to vary) for consistently |
46 | # formatted plots | 48 | # formatted plots |
47 | columns = list(col_map.columns()) | 49 | for line_path, line_node in plot_node.children.iteritems(): |
48 | if details.variable and details.variable in columns: | 50 | encoded = line_path[:line_path.index(".csv")] |
49 | columns.remove(details.variable) | 51 | line_config = ColMap.decode(encoded) |
50 | style_map = StyleMap(columns, col_map.get_values()) | 52 | |
53 | for k, v in line_config.iteritems(): | ||
54 | builder.try_add(k, v) | ||
55 | config_nodes += [(line_config, line_node)] | ||
56 | |||
57 | col_map = builder.build() | ||
58 | style_map = StyleMap(col_map.columns(), col_map.get_values()) | ||
51 | 59 | ||
52 | figure = plot.figure() | 60 | figure = plot.figure() |
53 | axes = figure.add_subplot(111) | 61 | axes = figure.add_subplot(111) |
54 | 62 | ||
55 | # Create a line for each file node | 63 | # Create a line for each file node and its configuration |
56 | for line_path, line_node in plot_node.children.iteritems(): | 64 | for line_config, line_node in config_nodes: |
57 | # Create line style to match this configuration | 65 | # Create line style to match this configuration |
58 | encoded = line_path[:line_path.index(".csv")] | 66 | style = style_map.get_style(line_config) |
59 | config = ColMap.decode(encoded) | ||
60 | style = style_map.get_style(config) | ||
61 | |||
62 | values = sorted(line_node.values, key=lambda tup: tup[0]) | 67 | values = sorted(line_node.values, key=lambda tup: tup[0]) |
63 | xvalues, yvalues = zip(*values) | 68 | xvalues, yvalues = zip(*values) |
64 | 69 | ||
@@ -81,8 +86,6 @@ def plot_dir(data_dir, out_dir, force): | |||
81 | dir_map = DirMap.read(data_dir) | 86 | dir_map = DirMap.read(data_dir) |
82 | 87 | ||
83 | sys.stderr.write("Creating column map...\n") | 88 | sys.stderr.write("Creating column map...\n") |
84 | tuple_table = ReducedTupleTable.from_dir_map(dir_map) | ||
85 | col_map = tuple_table.get_col_map() | ||
86 | 89 | ||
87 | if not os.path.exists(out_dir): | 90 | if not os.path.exists(out_dir): |
88 | os.mkdir(out_dir) | 91 | os.mkdir(out_dir) |
@@ -97,7 +100,7 @@ def plot_dir(data_dir, out_dir, force): | |||
97 | details = get_details(plot_path, out_dir) | 100 | details = get_details(plot_path, out_dir) |
98 | 101 | ||
99 | if force or not os.path.exists(details.out): | 102 | if force or not os.path.exists(details.out): |
100 | plot_by_variable(plot_node, col_map, details) | 103 | plot_by_variable(plot_node, details) |
101 | 104 | ||
102 | plot_num += 1 | 105 | plot_num += 1 |
103 | 106 | ||