Skip to content
Snippets Groups Projects
Commit fc4db609 authored by wilhelmk's avatar wilhelmk
Browse files

plot tweak for publication paper

parent 62f3aaa1
No related branches found
No related tags found
No related merge requests found
......@@ -285,14 +285,14 @@ def plot_convergence(resultspath, hyper=1):
imagepath, run_specifier = split(resultspath)
xticks = np.arange(1, len(iter_paths) + 1, 1)
w = 10
w = 7
h = w * (sqrt(5)-1.0)/2.0
plt.figure('Evaluations and global best trend', figsize=(w, h))
gbest_per_iter = np.roll(gbest_per_iter, -1)
gbest_per_iter[-1] = gbest_per_iter[-2]
plt.boxplot(eval_per_iter)
plt.plot(xticks, gbest_per_iter, color='green')
plt.title('particle test errors and global best trend')
#plt.title('particle test errors and global best trend')
plt.xticks(xticks[9::10], [str(s) for s in xticks[9::10]])
plt.xlabel('iteration')
plt.ylabel('mean MSE in K²')
......
......@@ -176,7 +176,7 @@ def plot_consistency_runs(path_to_models, title='consistency'):
plt.grid(True)
plt.ylabel('number of models')
#plt.xticks(np.arange(df.shape[1]) + 1, df.columns)
plt.xlabel('mean score in K²')
plt.xlabel('mean MSE in K²')
plt.title('scatter, {} samples'.format(df.shape[0]))
xmin, xmax = plt.xlim()
ymin, ymax = plt.ylim()
......
import matplotlib
import matplotlib.pyplot as plt
import matplotlib as mlp
import numpy as np
from mawk.trainer import Trainer
from mawk.datascript import DataPack
import argparse
import os
from os.path import join, splitext, split
from os import listdir
from math import ceil, sqrt
from os.path import split
import pandas as pd
from visuals import setup_vis_trainer, plot_net_prediction
from visuals import setup_vis_trainer
predictions_store = '/home/wilhelmk/MAWK_trainresults/pso/hdf/predictions'
evaluations_store = '/home/wilhelmk/MAWK_trainresults/pso/hdf/evaluations'
......@@ -26,10 +22,10 @@ winding_best_path = \
# get predictions and groundtruth
targets = [pm_best_path, yoke_best_path, teeth_best_path, winding_best_path]
target_labels = ['pm', 'statorjoch', 'statorzahn', 'statorwicklung']
target_labels_y = {'pm': ['$\\vartheta_{PM}$', 'permanent magnets'],
'statorjoch': ['$\\vartheta_{SY}$', 'stator yoke'],
'statorzahn': ['$\\vartheta_{ST}$', 'stator teeth'],
'statorwicklung': ['$\\vartheta_{SW}$', 'stator winding']}
target_labels_y = {'pm': ['$\\vartheta_{PM}$', 'Permanent Magnets'],
'statorjoch': ['$\\vartheta_{SY}$', 'Stator Yoke'],
'statorzahn': ['$\\vartheta_{ST}$', 'Stator Teeth'],
'statorwicklung': ['$\\vartheta_{SW}$', 'Stator Winding']}
target_predictions = []
target_groundtruths = []
for t in targets:
......@@ -79,13 +75,13 @@ assert len(target_groundtruths) == len(target_labels) and len(
datapack = DataPack(root='tp', xp=np)
x_test, y_test = datapack.load_profiles([20, ]) # load testset
motorspeed = [datapack._convert_namedtup2matrix(x_test[0].drehzahl),
'motor speed', '$n_{mech}$ in 1/min']
'Motor Speed', '$n_{mech}$ in 1/min']
torque = [datapack._convert_namedtup2matrix(x_test[0].T_ist),
'torque', '$T_x$ in Nm']
'Torque', '$T_x$ in Nm']
ambient = [datapack._convert_namedtup2matrix(x_test[0].ambient),
'ambient temperature', '$\\vartheta_a$ in °C']
'Ambient Temperature', '$\\vartheta_a$ in °C']
coolant = [datapack._convert_namedtup2matrix(x_test[0].vorlauf),
'coolant temperature', '$\\vartheta_c$ in °C']
'Coolant Temperature', '$\\vartheta_c$ in °C']
# prune uninteresting targets in stator prediction away
target_predictions = [target_predictions[0].ravel(),
......@@ -96,8 +92,11 @@ target_groundtruths = [target_groundtruths[0].ravel(),
target_groundtruths[1][0, :],
target_groundtruths[2][1, :],
target_groundtruths[3][2, :]]
# Plot everything
plt.figure('best predictions', figsize=(10, 10))
mlp.rcParams.update({'font.family': 'serif',
'font.size': 7})
plt.figure('best predictions', figsize=(7, 7), dpi=100)
time = np.arange(ambient[0].shape[1], dtype=np.float32)
time /= (2*60)
for i, (pred, truth) in enumerate(zip(target_predictions, target_groundtruths)):
......@@ -108,10 +107,10 @@ for i, (pred, truth) in enumerate(zip(target_predictions, target_groundtruths)):
plt.ylabel(target_labels_y[target_labels[i]][0] + ' in °C')
plt.xlim(xmax=max(time))
start, end = plt.ylim()
if title in ('permanent magnets', 'stator yoke'):
if title in ('Permanent Magnets', 'Stator Yoke'):
plt.ylim(ymax=end+3)
plt.yticks(np.arange(start, end+3, 20))
if title == 'stator winding':
if title == 'Stator Winding':
plt.yticks(np.arange(start, end, 25))
plt.title(title)
plt.grid(True)
......@@ -121,14 +120,16 @@ for i, (pred, truth) in enumerate(zip(target_predictions, target_groundtruths)):
plt.ylabel('$\Delta$'+target_labels_y[target_labels[i]][0] + ' in °C')
plt.xlim(xmax=max(time))
start, end = plt.ylim()
if title == 'stator teeth':
if title == 'Stator Yoke':
plt.yticks(np.arange(start, end+1, 3))
if title == 'Stator Teeth':
plt.yticks(np.arange(start, end, 4))
if title == 'stator winding':
if title == 'Stator Winding':
plt.yticks(np.arange(start, end + 4, 10))
if title == 'permanent magnets':
if title == 'Permanent Magnets':
plt.yticks(np.arange(start - 1, end, 8))
plt.title('deviation: ' + target_labels_y[target_labels[i]][1])
plt.title('Deviation: ' + target_labels_y[target_labels[i]][1])
plt.grid(True)
print('max. dev for {}: {} °C'.format(target_labels_y[target_labels[i]][1],
np.abs(pred-truth).max()))
......@@ -142,14 +143,14 @@ for m, m_title, m_ylb in [motorspeed, torque, ambient, coolant]:
plt.title(m_title)
plt.grid(True)
plt.xlim(xmax=max(time))
if m_title in ('motor speed', 'torque'):
if m_title in ('Motor Speed', 'Torque'):
plt.ylim(ymin=0)
start, end = plt.ylim()
if m_title == 'motor speed':
if m_title == 'Motor Speed':
plt.yticks(np.arange(start, end+500, 1500))
if m_title == 'ambient temperature':
if m_title == 'Ambient Temperature':
plt.yticks(np.arange(start, end, 4))
if m_title == 'coolant temperature':
if m_title == 'Coolant Temperature':
plt.yticks(np.arange(start, end + 2, 15))
if i > 10:
plt.xlabel('time in minutes')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment