Skip to content
Snippets Groups Projects
Commit d64b0591 authored by gospodnetic's avatar gospodnetic
Browse files

Arrange logs per models and output graphs ind data/ folder

parent 088310b7
No related branches found
No related tags found
No related merge requests found
...@@ -19,10 +19,6 @@ class LogContainer: ...@@ -19,10 +19,6 @@ class LogContainer:
for method in self.methods_per_approach[approach]: for method in self.methods_per_approach[approach]:
self.approaches_per_method[method] = approach self.approaches_per_method[method] = approach
pp = pprint.PrettyPrinter(indent=4)
print("Methods per approach:")
pp.pprint (self.methods_per_approach)
def add_log(self, log): def add_log(self, log):
method = log.VPC["method"] method = log.VPC["method"]
if method in self.approaches_per_method: if method in self.approaches_per_method:
...@@ -38,3 +34,8 @@ class LogContainer: ...@@ -38,3 +34,8 @@ class LogContainer:
def print_status(self): def print_status(self):
for approach in self.logs_per_approach: for approach in self.logs_per_approach:
print("Approach '{}' has {} logs".format(approach, len(self.logs_per_approach[approach]))) print("Approach '{}' has {} logs".format(approach, len(self.logs_per_approach[approach])))
def print_methods_per_approache(self):
pp = pprint.PrettyPrinter(indent=4)
print("Methods per approach:")
pp.pprint (self.methods_per_approach)
...@@ -7,12 +7,14 @@ import numpy as np ...@@ -7,12 +7,14 @@ import numpy as np
class Vis: class Vis:
def set_logs(self, log_container): def set_logs(self, log_container):
self.log_container = log_container self.log_container = log_container
self.figures = []
def generate_graphs(self): def generate_graphs(self):
for approach in self.log_container.logs_per_approach: for approach in self.log_container.logs_per_approach:
logs = self.log_container.logs_per_approach[approach] logs = self.log_container.logs_per_approach[approach]
plt.figure(num=approach) fig = plt.figure()
ax = fig.add_subplot(111)
for log in logs: for log in logs:
per_method_coverage = [] per_method_coverage = []
per_method_coverage.append( per_method_coverage.append(
...@@ -20,11 +22,27 @@ class Vis: ...@@ -20,11 +22,27 @@ class Vis:
log.get_cumulative_coverage_per_vp())) log.get_cumulative_coverage_per_vp()))
y = np.array(per_method_coverage[-1]) y = np.array(per_method_coverage[-1])
x = np.array(range(len(y))) x = np.array(range(len(y)))
plt.plot(x, y, c="0.4", alpha=0.2) ax.plot(x, y, c="0.4", alpha=0.2)
plt.xlim(0,45) ax.set_xlim(0,45)
plt.ylim(0,100) ax.set_ylim(0,100)
plt.xlabel("Number of viewpoints") ax.set_xlabel("Number of viewpoints")
plt.ylabel("Coverage [%]") ax.set_ylabel("Coverage [%]")
fig.suptitle(approach)
self.figures.append(fig)
# It will show all currently created figures.
def show_graphs(self):
plt.show() plt.show()
def save_graphs(self, prefix="", output_path=""):
for idx, figure in enumerate(self.figures):
label = figure._suptitle.get_text()
figure.suptitle("")
if prefix != "":
filename = output_path + prefix + "-" + label
else:
filename = output_path + label
figure.savefig(filename)
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"UniformSphereCentroid"], "UniformSphereCentroid"],
"VertexBased": [ "VertexBased": [
"VertexCentroid", "VertexCentroid",
"VertexBBoxCenter",
"VertexNormal"], "VertexNormal"],
"GeometryBased": [ "GeometryBased": [
"Area", "Area",
......
...@@ -20,26 +20,38 @@ def main(): ...@@ -20,26 +20,38 @@ def main():
with open(methods_per_approach_filename) as methods_per_approach_file: with open(methods_per_approach_filename) as methods_per_approach_file:
methods_per_approach = json.load(methods_per_approach_file) methods_per_approach = json.load(methods_per_approach_file)
log_container = LogContainer(methods_per_approach) # log_container = LogContainer(methods_per_approach)
log_containers_per_model = {}
logs = [] logs = []
for filename in ovp_paths: for filename in ovp_paths:
log = Log(filename)
try: try:
logs.append(Log(filename)) logs.append(log)
except Exception as e: except Exception as e:
print("Error: {}\nSkipping file".format(e)) print("Error: {}\nSkipping file".format(e))
continue continue
model_name = log.model["name"]
if model_name not in log_containers_per_model:
print(model_name)
log_containers_per_model[model_name] = LogContainer(methods_per_approach)
try: try:
log_container.add_log(Log(filename)) log_containers_per_model[model_name].add_log(log)
except Exception as e: except Exception as e:
print("Error: {}\nSkipping file".format(e)) print("Error: {}\nSkipping file".format(e))
continue continue
print("Loaded {} log files.".format(len(logs))) print("Loaded {} log files.".format(len(logs)))
log_container.print_status()
vis = Vis() vis = Vis()
vis.set_logs(log_container) for model in log_containers_per_model:
print("Model name: {}".format(model))
log_containers_per_model[model].print_status()
vis.set_logs(log_containers_per_model[model])
vis.generate_graphs()
vis.save_graphs(prefix=model, output_path="./data/")
# vis.show_graphs()
vis.generate_graphs()
if __name__ == "__main__": if __name__ == "__main__":
main() main()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment