Fixed ibox caption and label.

Fixed python pathes.
This commit is contained in:
Jan Benda 2015-11-10 10:13:34 +01:00
parent fc8308110b
commit 9525d2995d
6 changed files with 51 additions and 43 deletions

View File

@ -238,11 +238,10 @@
\newenvironment{ibox}[2][tp] \newenvironment{ibox}[2][tp]
{\SetupFloatingEnvironment{iboxf}{placement=#1}% {\SetupFloatingEnvironment{iboxf}{placement=#1}%
\begin{iboxf}% \begin{iboxf}%
\stepcounter{iboxf}% \captionsetup{singlelinecheck=off,labelfont={large,sf,it,bf},font={large,sf,it,bf}}
\captionof{iboxf}{#2}%
\begin{mdframed}[linecolor=yellow!40,linewidth=1ex,% \begin{mdframed}[linecolor=yellow!40,linewidth=1ex,%
backgroundcolor=yellow!15,font={\sffamily},% backgroundcolor=yellow!15,font={\sffamily},%
frametitle={Info Box \theiboxf: #2},frametitlefont={\large\sffamily\itshape\bfseries},% frametitle={\caption{#2}},frametitleaboveskip=-1ex,%
frametitlebackgroundcolor=yellow!40]}% frametitlebackgroundcolor=yellow!40]}%
{\end{mdframed}% {\end{mdframed}%
\end{iboxf}} \end{iboxf}}

View File

@ -6,10 +6,11 @@ fig = plt.figure()
ax = fig.add_subplot(111) ax = fig.add_subplot(111)
y = np.asarray([-10, 10]) * 2.**16/20. y = np.asarray([-10, 10]) * 2.**16/20.
ax.plot([-10, 10], y, color='dodgerblue', lw=1.5) ax.plot([-10, 10], y, color='dodgerblue', lw=1.5)
ax.set_xlabel('measured voltage [V]') ax.set_xlabel('Measured voltage [V]')
ax.set_ylabel('digitized value') ax.set_ylabel('Digitized value')
ax.set_xlim([-10.05, 10.05]) ax.set_xlim([-10.05, 10.05])
ax.set_ylim([-2**15, 2**15 + 1]) ax.set_ylim([-2**15, 2**15-1])
ax.set_yticks([-2**15, -2**14, 0, 2**14, 2**15-1])
ax.spines["right"].set_visible(False) ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False) ax.spines["top"].set_visible(False)
ax.yaxis.set_ticks_position('left') ax.yaxis.set_ticks_position('left')
@ -20,8 +21,8 @@ ax.tick_params(direction="out", width=1.25)
ax.tick_params(direction="out", width=1.25) ax.tick_params(direction="out", width=1.25)
ax.grid() ax.grid()
fig.set_facecolor("white") fig.set_facecolor("white")
fig.set_size_inches(5., 5.) fig.set_size_inches(4., 3.6)
fig.tight_layout() fig.tight_layout()
fig.savefig("images/data_acquisition.pdf") fig.savefig("data_acquisition.pdf")
plt.close() plt.close()

View File

@ -27,6 +27,6 @@ ax.set_xlabel("time [s]")
ax.set_ylabel("intensity") ax.set_ylabel("intensity")
ax.legend(fontsize=8) ax.legend(fontsize=8)
fig.tight_layout() fig.tight_layout()
fig.savefig("images/logicalIndexingTime.pdf") fig.savefig("logicalIndexingTime.pdf")

View File

@ -131,9 +131,9 @@ interpretiert werden. Die wichtigsten Datentpyen sind folgende:
Unter den numerischen Datentypen gibt es verschiedene Arten mit Unter den numerischen Datentypen gibt es verschiedene Arten mit
unterschiedlichem Speicherbedarf und Wertebreich. unterschiedlichem Speicherbedarf und Wertebreich.
\begin{table}[] \begin{table}[!h]
\centering \centering
\titlecaption{Grundlegende Datentypen und ihr Wertebereich.} \titlecaption{Grundlegende Datentypen und ihr Wertebereich.}{}
\label{dtypestab} \label{dtypestab}
\begin{tabular}{llcl}\hline \begin{tabular}{llcl}\hline
Datentyp & Speicherbedarf & Wertebereich & Beispiel \rule{0pt}{2.5ex} \\ \hline Datentyp & Speicherbedarf & Wertebereich & Beispiel \rule{0pt}{2.5ex} \\ \hline
@ -147,7 +147,7 @@ unterschiedlichem Speicherbedarf und Wertebreich.
Daten gespeichert werden. Dennoch lohnt es sich, sich ein wenig mit Daten gespeichert werden. Dennoch lohnt es sich, sich ein wenig mit
den Datentypen auseinanderzusetzen (Box \ref{daqbox}). den Datentypen auseinanderzusetzen (Box \ref{daqbox}).
\begin{ibox}[tp]{Digitalisierung von Messdaten}\label{daqbox} \begin{ibox}[tp]{\label{daqbox}Digitalisierung von Messdaten}
Szenario: Die elektrische Aktivit\"at (z.B. die Membranspannung) Szenario: Die elektrische Aktivit\"at (z.B. die Membranspannung)
einer Nervenzelle wird gemessen. Die gemessene Spannung wird mittels einer Nervenzelle wird gemessen. Die gemessene Spannung wird mittels
Messkarte digitalisiert und auf dem Computer f\"ur weitere Analysen Messkarte digitalisiert und auf dem Computer f\"ur weitere Analysen
@ -159,14 +159,16 @@ den Datentypen auseinanderzusetzen (Box \ref{daqbox}).
Werte abgebildet.\vspace{0.25cm} Werte abgebildet.\vspace{0.25cm}
\begin{minipage}{0.5\textwidth} \begin{minipage}{0.5\textwidth}
\includegraphics[width=0.9\columnwidth]{images/data_acquisition} \includegraphics[width=0.9\columnwidth]{data_acquisition}
\end{minipage} \end{minipage}
\begin{minipage}{0.5\textwidth} \begin{minipage}{0.5\textwidth}
Um die Spannung auf den \code{int16} Datentyp abzubilden: Um die Spannung auf den \code{int16} Datentyp abzubilden:
\[ y = x \cdot 2^{16}/20\] mit $x$ der gemessenen Spannung und $y$ \[ y = x \cdot 2^{16}/20\] mit $x$ der gemessenen Spannung und $y$
dem digitalisierten Wert bei einem Spannungsbereich von dem digitalisierten Wert bei einem Spannungsbereich von
$\pm10$\,V.\\ $\pm10$\,V. Das ergibt ganzzahlige Werte zwischen $-2^{15}=-32768$
Durch Umgekehrung kann der digitalisierte Wert wieder und $2^{15}-1 = 32767$.
Durch Umkehrung kann der digitalisierte Wert wieder
in eine Spannung zur\"uckgewandelt werden: in eine Spannung zur\"uckgewandelt werden:
\[ x = y \cdot 20/2^{16} \] \[ x = y \cdot 20/2^{16} \]
\end{minipage}\vspace{0.25cm} \end{minipage}\vspace{0.25cm}
@ -174,8 +176,8 @@ den Datentypen auseinanderzusetzen (Box \ref{daqbox}).
Um Speicherplatz zu sparen ist es sinnvoll, die gemessenen Daten als Um Speicherplatz zu sparen ist es sinnvoll, die gemessenen Daten als
``int16'' anstelle der ``double'' Werte im Rechner abzulegen. Die ``int16'' anstelle der ``double'' Werte im Rechner abzulegen. Die
Daten als ``echte'' Spannungen, also als Flie{\ss}kommawerte, Daten als ``echte'' Spannungen, also als Flie{\ss}kommawerte,
abzulegen ben\"otigt den 4-fachen Speicherplatz und bietet keine abzulegen ben\"otigt den 4-fachen Speicherplatz (8 statt 2 Bytes)
zus\"atzliche Information. und bietet keine zus\"atzliche Information.
\end{ibox} \end{ibox}

View File

@ -1,11 +1,11 @@
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from IPython import embed from matplotlib.transforms import Bbox
def create_data(): def create_data():
m = 0.75 m = 0.75
n= -30 n= -40
x = np.arange(0.,101., 2.5) x = np.arange(5.,115., 2.5)
y = m * x + n; y = m * x + n;
noise = np.random.randn(len(x))*15 noise = np.random.randn(len(x))*15
y += noise y += noise
@ -13,79 +13,85 @@ def create_data():
def plot_data(x, y): def plot_data(x, y):
plt.xkcd()
plt.scatter(x, y, marker='o', color='dodgerblue', s=40) plt.scatter(x, y, marker='o', color='dodgerblue', s=40)
plt.xlabel("Input x")
plt.ylabel("Output y")
plt.xlim([-2.5, 102.5])
ax = plt.gca() ax = plt.gca()
ax.spines["right"].set_visible(False) ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False) ax.spines["top"].set_visible(False)
ax.yaxis.set_ticks_position('left') ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom') ax.xaxis.set_ticks_position('bottom')
ax.xaxis.linewidth=1.5
ax.yaxis.linewidth=1.5
ax.tick_params(direction="out", width=1.25) ax.tick_params(direction="out", width=1.25)
ax.tick_params(direction="out", width=1.25) ax.tick_params(direction="out", width=1.25)
ax.set_xlabel('Input x')
ax.set_ylabel('Output y')
ax.set_xlim(0, 120)
ax.set_ylim(-80, 80)
ax.set_xticks(np.arange(0,121, 40))
ax.set_yticks(np.arange(-80,81, 40))
fig = plt.gcf() fig = plt.gcf()
fig.set_facecolor("white") fig.set_facecolor("white")
fig.set_size_inches(3., 3.) fig.set_size_inches(3., 3.)
fig.savefig("figures/lin_regress.pdf") plt.tight_layout()
fig.savefig("lin_regress.pdf")
plt.close() plt.close()
def plot_data_slopes(x, y, m, n): def plot_data_slopes(x, y, m, n):
plt.xkcd()
plt.scatter(x, y, marker='o', color='dodgerblue', s=40) plt.scatter(x, y, marker='o', color='dodgerblue', s=40)
for i in np.linspace(m/4, m*1.5, 5): for i in np.linspace(m/4, m*1.5, 5):
plt.plot(x, i*x+n, color="r", lw=2) plt.plot(x, i*x+n, color="r", lw=2)
plt.xlabel("Input x")
plt.ylabel("Output y")
plt.xlim([-2.5, 102.5]) plt.xlim([-2.5, 102.5])
ax = plt.gca() ax = plt.gca()
ax.spines["right"].set_visible(False) ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False) ax.spines["top"].set_visible(False)
ax.yaxis.set_ticks_position('left') ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom') ax.xaxis.set_ticks_position('bottom')
ax.xaxis.linewidth=1.5
ax.yaxis.linewidth=1.5
ax.tick_params(direction="out", width=1.25) ax.tick_params(direction="out", width=1.25)
ax.tick_params(direction="out", width=1.25) ax.tick_params(direction="out", width=1.25)
ax.set_xlabel('Input x')
ax.set_ylabel('Output y')
ax.set_xlim(0, 120)
ax.set_ylim(-80, 80)
ax.set_xticks(np.arange(0,121, 40))
ax.set_yticks(np.arange(-80,81, 40))
fig = plt.gcf() fig = plt.gcf()
fig.set_facecolor("white") fig.set_facecolor("white")
fig.set_size_inches(3., 3.) fig.set_size_inches(3., 3.)
fig.savefig("figures/lin_regress_slope.pdf") plt.tight_layout()
fig.savefig("lin_regress_slope.pdf")
plt.close() plt.close()
def plot_data_intercepts(x, y, m, n): def plot_data_intercepts(x, y, m, n):
plt.xkcd()
plt.scatter(x, y, marker='o', color='dodgerblue', s=40) plt.scatter(x, y, marker='o', color='dodgerblue', s=40)
for i in np.linspace(n-n/2, n+n/2, 5): for i in np.linspace(n-n/2, n+n/2, 5):
plt.plot(x, m * x + i, color="r", lw=2) plt.plot(x, m * x + i, color="r", lw=2)
plt.xlabel("Input x")
plt.ylabel("Output y")
plt.xlim([-2.5, 102.5]) plt.xlim([-2.5, 102.5])
ax = plt.gca() ax = plt.gca()
ax.spines["right"].set_visible(False) ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False) ax.spines["top"].set_visible(False)
ax.yaxis.set_ticks_position('left') ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom') ax.xaxis.set_ticks_position('bottom')
ax.xaxis.linewidth=1.5
ax.yaxis.linewidth=1.5
ax.tick_params(direction="out", width=1.25) ax.tick_params(direction="out", width=1.25)
ax.tick_params(direction="out", width=1.25) ax.tick_params(direction="out", width=1.25)
ax.set_xlabel('Input x')
ax.set_ylabel('Output y')
ax.set_xlim(0, 120)
ax.set_ylim(-80, 80)
ax.set_xticks(np.arange(0,121, 40))
ax.set_yticks(np.arange(-80,81, 40))
fig = plt.gcf() fig = plt.gcf()
fig.set_facecolor("white") fig.set_facecolor("white")
fig.set_size_inches(3., 3.) fig.set_size_inches(3., 3.)
fig.savefig("figures/lin_regress_intercept.pdf") plt.tight_layout()
fig.savefig("lin_regress_intercept.pdf")
plt.close() plt.close()
if __name__ == "__main__": if __name__ == "__main__":
x, y, m, n = create_data() x, y, m, n = create_data()
plt.xkcd()
plot_data(x,y) plot_data(x,y)
plot_data_slopes(x,y,m,n) plot_data_slopes(x,y,m,n)
plot_data_intercepts(x,y,m,n) plot_data_intercepts(x,y,m,n)

View File

@ -10,9 +10,9 @@ ein Optimierungsproblem, der besser als Kurvenfit bekannt ist
(\enterm{curve fitting}). (\enterm{curve fitting}).
\begin{figure}[tp] \begin{figure}[tp]
\includegraphics[width=0.32\columnwidth]{lin_regress}\hfill \includegraphics[width=0.33\columnwidth]{lin_regress}\hfill
\includegraphics[width=0.32\columnwidth]{lin_regress_slope}\hfill \includegraphics[width=0.33\columnwidth]{lin_regress_slope}\hfill
\includegraphics[width=0.32\columnwidth]{lin_regress_intercept} \includegraphics[width=0.33\columnwidth]{lin_regress_intercept}
\titlecaption{.}{F\"ur eine Reihe von Eingangswerten $x$, \titlecaption{.}{F\"ur eine Reihe von Eingangswerten $x$,
z.B. Stimulusintensit\"aten, wurden die Antworten $y$ eines z.B. Stimulusintensit\"aten, wurden die Antworten $y$ eines
Systems gemessen (links). Der postulierte lineare Zusammenhang hat Systems gemessen (links). Der postulierte lineare Zusammenhang hat