Commit 64d25736 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

rmv gnuplot

parent 21381e90
Pipeline #73900 failed with stage
import re
import matplotlib.pyplot as plt
import os
import numpy as np
from operator import itemgetter
def build_string(_name_, _level_=-1, _sample_=-1, suffix=""):
if suffix != "":
_name_ += "_" + suffix
if _level_ != -1:
_name_ += "_" + str(_level_)
if _sample_ != -1:
_name_ += "_" + str(_sample_)
return _name_
def read_gp(_name_, _level_=-1, _sample_=-1, suffix=""):
_name_ = build_string(_name_, _level_, _sample_, suffix)
gp_file = '../build/data/gp/' + _name_ + '.gp'
if not os.path.exists(gp_file):
return False
with open(gp_file) as file:
content = file.readlines()
float_re = r'[+-]?[0-9]+[.]?[0-9]*[eE]?[+-]?[0-9]*'
pattern = re.compile(float_re)
entries = []
for line in content:
matches = pattern.findall(line)
if matches:
entries.append([float(match) for match in matches])
sorted_entries = sorted(entries, key=lambda k: [k[0], k[1]])
entries = []
for entry in sorted_entries:
if entry not in entries:
entries.append(entry)
var = [entry[space_dims:] for entry in entries]
if space_dims == 2:
size = int(np.sqrt(len(var)))
matrix = np.zeros(shape=(size, size))
for i in range(size):
for j in range(size):
matrix[j, i] = var[i + size * j][0]
matrix = np.rot90(matrix)
plt.imshow(matrix)
return True
if __name__ == "__main__":
space_dims = 2
components = 1
name = "u"
levels = [5]
samples = [0]
for level in levels:
for sample in samples:
if not read_gp(name, level, sample):
break
plt.title('')
plt.grid(True)
plt.show()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment