1
0
Fork 0
mirror of https://github.com/Findus23/Bachelors-Thesis.git synced 2024-08-27 19:52:12 +02:00

add plots

This commit is contained in:
Lukas Winkler 2019-08-20 16:32:22 +02:00
parent e9e62791ba
commit e9609ff1c9
Signed by: lukas
GPG key ID: 54DE4D798D244853
12 changed files with 87 additions and 17 deletions

View file

@ -7,11 +7,25 @@ One of the easiest ways to interpolate a new value between two known values is l
In one dimension linear interpolation is pretty trivial. For example, let's assume that we have 20 random points $P$ between 0 and 1 (\textcolor{Red}{\textbullet} and \textcolor{Blue}{\textbullet} in Figure \ref{fig:one-dim-interpolation}) and have a new point $I$ (\textcolor{Green}{\textbullet}) at $0.4$ for which we want to interpolate. Finding the two closest points \textcolor{Red}{\textbullet} above and below is trivial as there is only one dimension to compare. Now, if we have measured a value $f(P)$ for each of these points, a straight line (\textcolor{LightGreen}{\textbf{|}}) between the two closest values can be drawn and an interpolated value for $f(I)$ can be found.
\begin{figure}[h] % TODO: h is temporary
\begin{figure}[h] % also temporary
\centering
\includegraphics[width=0.8\linewidth]{images/vis1d.pdf}
\caption{one-dimensional example of linear interpolation}
\label{fig:one-dim-interpolation}
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{images/vis1d.pdf}
\caption{one-dimensional example of linear interpolation}
\label{fig:one-dim-interpolation}
\end{subfigure}%
~
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{images/vis2d1.pdf}
\caption{Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum}
\label{fig:3dinterpolate-1}
\end{subfigure}
\caption{}
\end{figure}
In two dimensions things get more complicated as we now have a set of points with $X$ and $Y$ coordinates (Figure \ref{fig:3dinterpolate-1}). One fast way to find the closest points to the point that should be interpolated is using Delaunay triangulation. This separates the space between the points into triangles while trying to maximize their smallest angle. Afterwards the closest three points can be found very quickly by checking the nodes of the surrounding triangle (Figure \ref{fig:3dinterpolate-2}). If we now again have a function $f(X,Y)$ similar to the one-dimensional example (Figure \ref{fig:3dinterpolate-3}), we can create a unique plain through the three points and get the interpolated value for any $X$ and $Y$ on this layer.
@ -21,32 +35,46 @@ In two dimensions things get more complicated as we now have a set of points wit
\centering
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{images/vis2d1.pdf}
\includegraphics[width=\linewidth]{images/vis2d2.pdf}
\caption{Lorem ipsum}
\label{fig:3dinterpolate-1}
\label{fig:3dinterpolate-3}
\end{subfigure}%
~
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{images/vis2d2.pdf}
\includegraphics[width=\linewidth]{images/vis2d3.pdf}
\caption{Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum}
\label{fig:3dinterpolate-2}
\end{subfigure}
\caption{Caption place holder}
\caption{}
\end{figure}
\begin{figure}[h] % TODO: h is temporary
\centering
\includegraphics[width=0.8\linewidth]{images/vis2d3.pdf}
\caption{two-dimensional example of linear interpolation}
\label{fig:3dinterpolate-3}
\end{figure}
This approach has the advantage that it can be extended in more than two dimensions by replacing the triangle in the Delaunay triangulation with an n-simplex in n dimensions. The \texttt{scipy.spatial.Delaunay} python function allows to quickly calculate it thanks to the \texttt{Qhull} library\footnote{\url{http://www.qhull.org/}}. One noticeable limitation of this method is that data can't be extrapolated. Therefore the possible output is limited to the convex hull of the input parameter space (as seen in Figure \ref{fig:3dinterpolate-2}).
\subsection{Implementation}
\label{sec:griddata-implementation}
For doing the actual interpolations, the \texttt{scipy.interpolate.griddata} function is used with the \texttt{method="linear"} argument which itself uses \texttt{scipy.interpolate.LinearNDInterpolator} to do an interpolation similar to the one described above. The function is given a $6\times n$ matrix of the six parameters and an $n$-sized list of the water retention fraction for those $n$ simulations. In addition, \texttt{griddata} supports not only calculating interpolations for one set of parameters, but also for lists of parameters which allows to quickly generate 2d diagrams as seen in \ref{the_chapter_where_I_show_the_v_alpha_plots}.
For doing the actual interpolations, the \texttt{scipy.interpolate.griddata} function is used with the \texttt{method="linear"} argument which itself uses \texttt{scipy.interpolate.LinearNDInterpolator} to do an interpolation similar to the one described above. The function is given a $6\times n$ matrix of the six parameters and an $n$-sized list of the water retention fraction for those $n$ simulations. In addition, \texttt{griddata} supports not only calculating interpolations for one set of parameters, but also for lists of parameters which allows to quickly generate 2d diagrams as seen in Figure \ref{fig:griddataresults}.
\subsection{Results}
\subsection{Results}
\begin{figure}[h!] % also temporary
\centering
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{images/plots/griddata1.pdf}
\caption{$m_{total}=\num{e22}$, $\gamma=0.6$, $wt=wp=0.15$}
\label{fig:griddata1}
\end{subfigure}%
~
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{images/plots/griddata2.pdf}
\caption{$m_{total}=\num{e24}$, $\gamma=0.6$, $wt=wp=0.15$}
\label{fig:griddata2}
\end{subfigure}
\caption{Interpolation result using griddata}
\label{fig:griddataresults}
\end{figure}

View file

@ -116,3 +116,22 @@ Applying the same method to a list of random points allows to interpolate their
The scipy function \texttt{scipy.interpolate.Rbf} allows directly interpolating a value similar to \texttt{griddata} in Section \ref{sec:griddata-implementation}. A difference in usage is that it only allows interpolating a single value, but as it is pretty quick it is possible to calculate multiple values sequentially.
\subsection{Results}
\begin{figure}[h!] % also temporary
\centering
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{images/plots/rbf1.pdf}
\caption{$m_{total}=\num{e22}$, $\gamma=0.6$, $wt=wp=0.15$}
\label{fig:rbf1}
\end{subfigure}%
~
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{images/plots/rbf2.pdf}
\caption{$m_{total}=\num{e24}$, $\gamma=0.6$, $wt=wp=0.15$}
\label{fig:rbf2}
\end{subfigure}
\caption{Interpolation result using Radial Basis Functions}
\label{fig:rbfresults}
\end{figure}

View file

@ -94,3 +94,22 @@ After the training the resulting model can be saved in a small \texttt{HDF5} fil
\subsection{Results}
\begin{figure}[h!] % also temporary
\centering
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{images/plots/nn1.pdf}
\caption{$m_{total}=\num{e22}$, $\gamma=0.6$, $wt=wp=0.15$}
\label{fig:nn1}
\end{subfigure}%
~
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{images/plots/nn2.pdf}
\caption{$m_{total}=\num{e24}$, $\gamma=0.6$, $wt=wp=0.15$}
\label{fig:nn2}
\end{subfigure}
\caption{Interpolation result using the trained neural network}
\label{fig:nnresults}
\end{figure}

Binary file not shown.

BIN
images/plots/griddata1.pdf Normal file

Binary file not shown.

BIN
images/plots/griddata2.pdf Normal file

Binary file not shown.

BIN
images/plots/nn1.pdf Normal file

Binary file not shown.

BIN
images/plots/nn2.pdf Normal file

Binary file not shown.

BIN
images/plots/rbf1.pdf Normal file

Binary file not shown.

BIN
images/plots/rbf2.pdf Normal file

Binary file not shown.

View file

@ -12,6 +12,7 @@
\date{1. September 2019}
\begin{document}
\maketitle

View file

@ -23,7 +23,7 @@ american, % language of the document
% required for proper characters
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\DeclareUnicodeCharacter{2212}{-}
% helps with equations
\usepackage{amsmath,amssymb,amstext}
@ -60,6 +60,9 @@ american, % language of the document
\usepackage{tabularx}
\usepackage{booktabs} % nicer table seperations
\usepackage{todonotes}
\usepackage{pgf}
%----------------------------------- Style decisions -----------------------------------
\hyphenpenalty=750 % break less words than default - try different values for success