In [4]:
import sys,os
import numpy as np
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import matplotlib.colors as colors
#this works apparently only for savefig stuff
mpl.rcParams['figure.figsize']=(16.0,8.0) #(6.0,4.0)
mpl.rcParams['font.size']=12 #10
mpl.rcParams['savefig.dpi']=100 #72
mpl.rcParams['figure.subplot.bottom']=.1 #.125
plt.rc('font', family='serif')
plt.rc('text', usetex=True)
#inline Shit
%matplotlib inline
%config InlineBackend.figure_format='svg'
%config InlineBackend.rc = {'figure.facecolor': 'white', 'figure.subplot.bottom': 0.125, 'figure.edgecolor': 'white', 'savefig.dpi': 300, 'figure.figsize': (12.0, 8.0), 'font.size': 10}
#GUi shit
%matplotlib tk
mpl.get_configdir()
%load_ext autoreload
%autoreload 2
# Import General Packages from me
from Tools.Parsers import *
from Tools.BoundingBox import *
from Tools.Transformations import *
In [5]:
def plotBodies():
plt.close('all')
def getMarkesOpt1(colorVal):
return { 'linestyle': '-', 'marker': '.',
'color': colorVal,
'linewidth': 2,
'markersize':3,
'markeredgecolor' : colorVal,
'markerfacecolor' : colorVal,
'markeredgewidth': 1
}
def getMarkesOpt2(colorVal):
return { 'color': colorVal,
'linestyle': ':', 'marker': '.',
'linewidth': 2,
'markersize':7,
'markeredgecolor' : colorVal,
'markerfacecolor' : 'none',
'markeredgewidth': 1
}
nBodies = bodyRange[1] - bodyRange[0] + 1
jet = plt.get_cmap('jet')
cNorm = colors.Normalize(vmin=0, vmax=nBodies)
scalarMap = cm.ScalarMappable(norm=cNorm, cmap=jet)
fig1 = plt.figure()
ax10 = plt.subplot(2,1,1);
# Position
for i,body in dynState1.bodies.items():
ax10.plot(dynState1.t, body[0][:,0:3], label=label1, **getMarkesOpt1(scalarMap.to_rgba(i)) );
ax10.plot(dynState2.t, dynState2.bodies[i][0][:,0:3], label=label2, **getMarkesOpt2(scalarMap.to_rgba(i)) );
ax11 = plt.subplot(2,1,2, sharex= ax10);
for i,body in dynState1.bodies.items():
ax11.plot(dynState1.t, body[0][:,3:7], **getMarkesOpt1(scalarMap.to_rgba(i)) );
ax11.plot(dynState2.t, dynState2.bodies[i][0][:,3:7], **getMarkesOpt2(scalarMap.to_rgba(i)) );
ax10.legend()
ax10.grid(True)
ax10.set_title('Position');
ax10.set_ylabel('\mathbf{r}_S(t)');
ax10.set_ymargin(0.2)
ax10.autoscale(True,'both',False)
ax11.grid(True)
ax11.set_title('Quaternion');
ax11.set_ylabel('\mathbf{a}_{KI}(t)');
ax11.set_ymargin(0.2)
ax11.autoscale(True,'both',False)
# Velocity
fig2 = plt.figure()
ax20 = plt.subplot(2,1,1);
for i,body in dynState1.bodies.items():
ax20.plot(dynState1.t, body[1][:,0:3],**getMarkesOpt1(scalarMap.to_rgba(i)) );
ax20.plot(dynState2.t, dynState2.bodies[i][1][:,0:3],**getMarkesOpt2(scalarMap.to_rgba(i)) );
ax21 = plt.subplot(2,1,2, sharex=ax20);
for i,body in dynState1.bodies.items():
ax21.plot(dynState1.t, body[1][:,3:6], **getMarkesOpt1(scalarMap.to_rgba(i)) );
ax21.plot(dynState2.t, dynState2.bodies[i][1][:,3:6], **getMarkesOpt2(scalarMap.to_rgba(i)) );
ax20.grid(True)
ax20.set_title('Velocity');
ax20.set_ylabel('\mathbf{v}_S(t)');
ax20.set_xmargin(0.0)
ax20.set_ymargin(0.1)
ax21.grid(True)
ax21.set_title('Angular Velocity');
ax21.set_ylabel('\mathbf{\omega}_{KI}(t)');
ax21.set_xmargin(0.0)
ax21.set_ymargin(0.1)
In [6]:
scriptpath = "./"
# Add the directory containing your module to the Python path (wants absolute paths)
sys.path.append(os.path.abspath(scriptpath))
bodyRange = [0,1]
label1='GUI';
label2='MPI';
timeRange = [0,50]
folderNumber = 0
#For single file which contains multiple bodies
dynState1 = SimFileReader.ReadInSimFile("./../SimFiles/SimDataRECORDGUI_%d/SimState.sim" % folderNumber ,timeRange,bodyRange,False)
print(dynState1)
#print(dynState1.bodies)
folderNumber = 2
dynState2 = SimFileReader.ReadInSimFile("./../SimFiles/SimDataRECORDGUI_%d/SimState.sim" % folderNumber ,timeRange,bodyRange,False)
#dynState2 = SimFileReader.("./../GlobalFolder/SimFiles/SimDataRECORDMPI_%d/SimState.sim" % folderNumber, timeRange , bodyRange , False)
print(dynState2)
#print(dynState2.bodies)
plotBodies();
In [ ]: