Skip to content

Commit 851025c

Browse files
fixed bug with loading multicomposites
1 parent 65f7844 commit 851025c

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

python/composite.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ def load_simple_composite(self,composite: SimpleComposite):
5757
j += 1
5858
self.individual_files[composite.id] = composite
5959
# Loads dictionary from parse_multiple_composites
60-
def load_composite_dict(self,compositeDict: dict):
61-
for composite in compositeDict:
60+
def load_composite_dict(self,composite_dict: dict):
61+
for key in composite_dict:
62+
composite = composite_dict[key]
6263
# If no files, initialize sense and anti arrays; otherwise, pad sense and anti arrays to new xdomain
6364
self.xmin = min(composite.xmin, self.xmin)
6465
self.xmax = max(composite.xmax, self.xmax)
@@ -74,6 +75,7 @@ def load_composite_dict(self,compositeDict: dict):
7475
self.anti = prefix + self.anti + suffix
7576
# Update sense and anti arrays
7677
j = composite.xmin - self.xmin
78+
print(composite.sense)
7779
while j <= composite.xmax - composite.xmin:
7880
idx = composite.xmin - self.xmin + j
7981
self.sense[idx] += composite.sense[j]

python/plot.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Class that generates composite and reference lines svg elements
99
class Plot:
1010
def __init__(self, title=None, xmin=None, xmax=None, ymin=None, ymax=None, xlabel=None, ylabel=None,
11-
opacity=None, smoothing=None, bp_shift=None, combined=False, color_trace=False, hide_legend=True):
11+
opacity=None, smoothing=None, bp_shift=None, combined=False, color_trace=False, hide_legend=False):
1212
# Set variables to defaults if argument passed into constructor was None
1313
self.title = title if title is not None else "Composite plot"
1414
self.xmin = xmin if xmin is not None else -500
@@ -147,7 +147,7 @@ def plot_composite(self, xmin, xmax, sense, anti, scale=1, color=None, secondary
147147
self.plot.appendChild(self.gradients_group)
148148
self.plot.appendChild(self.composite_group)
149149

150-
# Creates a composite svg element from a composite_group object, like plotting a row form the settings table
150+
# Creates a composite svg element from a composite object, like plotting a row form the settings table
151151
def plot_composite(self, composite):
152152
# Set parameters to global values if not specified
153153
opacity = composite.opacity if composite.opacity is not None else self.opacity
@@ -177,7 +177,7 @@ def plot_composite(self, composite):
177177
composite_fill_top = document.createElement("polygon")
178178
composite_fill_top.setAttribute("points", " ".join(points := [f"{self.xscale.get(d)},{self.yscale.get(scaled_occupancy[j])}" for j, d in enumerate(truncated_xdomain)]) + f" {self.xscale.get(truncated_xdomain[-1])},{self.yscale.get(0)} {self.xscale.get(truncated_xdomain[0])},{self.yscale.get(0)}")
179179
composite_fill_top.setAttribute("fill", "url(#composite-gradient-top" + str(i) + ")")
180-
self.composite.appendChild(composite_fill_top)
180+
self.composite_group.appendChild(composite_fill_top)
181181
#Create outline
182182
wide_trace = document.createElement("path")
183183
wide_trace.setAttribute("stroke-width", "1")
@@ -334,18 +334,18 @@ def create_legend(self):
334334
legend = document.createElement('g')
335335
legend.setAttribute("transform", "translate(" + str(self.width - self.margins.get("right") + 25) + " " + str(self.margins.get("top")) + ")")
336336
i = 0
337-
for composite_group in self.composites:
337+
for composite in self.composites:
338338
# Creates legend entries for each composite
339339
legend_element = document.createElement("g")
340340
legend_element.setAttribute("transform", "translate(0," + str(24 * i) + ")")
341341
legend_color_sense = document.createElement("polygon")
342342
legend_color_sense.setAttribute("points", "0,0 15,0 15,15 0,15")
343-
legend_color_sense.setAttribute("fill", composite_group.color)
343+
legend_color_sense.setAttribute("fill", composite.color)
344344
legend_element.appendChild(legend_color_sense)
345345
legend_color_anti = document.createElement("polygon")
346346
legend_color_anti.setAttribute("points", "0,0 15,0 15,15 0,15")
347347
legend_element.appendChild(legend_color_anti)
348-
legend_color_anti.setAttribute("fill", composite_group.secondary_color)
348+
legend_color_anti.setAttribute("fill", composite.secondary_color)
349349
legend_border = document.createElement("rect")
350350
legend_border.setAttribute("width", "15")
351351
legend_border.setAttribute("height", "15")
@@ -356,7 +356,7 @@ def create_legend(self):
356356
id.setAttribute("x", "20")
357357
id.setAttribute("y", "10")
358358
id.setAttribute("font-size", "10")
359-
id.appendChild(document.createTextNode(str(composite_group.name)))
359+
id.appendChild(document.createTextNode(str(composite.name)))
360360
legend_element.appendChild(id)
361361
legend.appendChild(legend_element)
362362
i += 1

python/plotter.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def main():
5858
plot_parser.add_argument("--ylabel", nargs="+")
5959
plot_parser.add_argument("--color-trace", action="store_true", default=False)
6060
plot_parser.add_argument("--combined", action="store_true", default=False)
61-
plot_parser.add_argument("--hide-legend", action="store_false", default=True)
61+
plot_parser.add_argument("--hide-legend", action="store_true", default=False)
6262
plot_parser.add_argument("--no-resize", action="store_true", default=False)
6363
plot_parser.add_argument("--no-shrink", action="store_true", default=False)
6464
plot_parser.add_argument("--reference-line", nargs=3, action='append')
@@ -102,8 +102,9 @@ def main():
102102
composite.load_simple_composite(sc)
103103
else:
104104
prefixes = parseComposite.get_prefixes_from_multiple_composites(c)
105-
composites = parseComposite.parse_multiple_composite(c, prefixes)
106-
composite.load_composite_dict(composites)
105+
print(prefixes)
106+
cd = parseComposite.parse_multiple_composite(c, prefixes[0])
107+
composite.load_composite_dict(cd)
107108
p.add_composite_group(composite)
108109
i += 1
109110
# If --no-shrink is specified, don't change y-axis but resize x-axis

0 commit comments

Comments
 (0)