Commit afe4fbec authored by Daniel Boeckenhoff's avatar Daniel Boeckenhoff
Browse files

new version of presentation

parent 8be419f8
......@@ -44,9 +44,10 @@
},
"source": [
"### Pypi:\n",
"'''bash\n",
"\n",
"```bash\n",
"pip install tfields\n",
"'''"
"```"
]
},
{
......@@ -58,9 +59,9 @@
},
"source": [
"### Git:\n",
"'''bash\n",
"```bash\n",
"git clone https://gitlab.mpcdf.mpg.de/dboe/tfields.git\n",
"'''"
"```"
]
},
{
......
%% Cell type:markdown id: tags:
 
# tfields
## Tensors, Tensor Fields, Mesh Manipulation and More
### A Library by Daniel Böckenhoff
 
%% Cell type:markdown id: tags:
 
# Overview
 
%% Cell type:markdown id: tags:
 
## Installation
 
%% Cell type:markdown id: tags:
 
### Pypi:
'''bash
```bash
pip install tfields
'''
```
 
%% Cell type:markdown id: tags:
 
### Git:
'''bash
```bash
git clone https://gitlab.mpcdf.mpg.de/dboe/tfields.git
'''
```
 
%% Cell type:markdown id: tags:
 
## Standards
 
%% Cell type:markdown id: tags:
 
python > 2.7
 
%% Cell type:markdown id: tags:
 
Tested on Linux / Windows / Mac
 
%% Cell type:markdown id: tags:
 
Unit tested with **~ 80 % coverage**
 
%% Cell type:markdown id: tags:
 
# Introduction
 
%% Cell type:markdown id: tags:
 
## Base Objects: Tensors of any dimension
 
%% Cell type:code id: tags:
 
``` python
import tfields
```
 
%% Cell type:code id: tags:
 
``` python
scalars = tfields.Tensors([0, 1, 2.])
scalars.rank, scalars.dim
```
 
%%%% Output: execute_result
 
(0, 1)
 
%% Cell type:code id: tags:
 
``` python
vectors = tfields.Tensors([[0, 0, 0],
[0, 0, 1],
[0, -1, 0.]])
vectors.rank, vectors.dim
```
 
%%%% Output: execute_result
 
(1, 3)
 
%% Cell type:code id: tags:
 
``` python
# Levi-Zivita Tensor
matrices = tfields.Tensors([[[0, 0, 0], [0, 0, 1], [0, -1, 0]],
[[0, 0, -1], [0, 0, 0], [1, 0, 0]],
[[0, 1, 0], [-1, 0, 0], [0, 0, 0]]])
matrices.rank, matrices.dim
```
 
%%%% Output: execute_result
 
(2, 3)
 
%% Cell type:markdown id: tags:
 
# Symbolic Coordinate System and Transformation
 
%% Cell type:markdown id: tags:
 
## Coordinate System as attribute
 
%% Cell type:code id: tags:
 
``` python
vectors.coord_sys # Default
```
 
%%%% Output: execute_result
 
'cartesian'
 
%% Cell type:code id: tags:
 
``` python
vectors_cylinder = tfields.Tensors([[1, 1, 1]], coord_sys='cylinder') # Initialization with different base
vectors_cylinder.coord_sys
```
 
%%%% Output: execute_result
 
'cylinder'
 
%% Cell type:markdown id: tags:
 
## Numerically Precise Transformations
 
%% Cell type:code id: tags:
 
``` python
orig = vectors.copy()
vectors.transform('spherical')
vectors.transform('cylinder')
vectors.transform('cartesian')
vectors.equal(orig)
```
 
%%%% Output: execute_result
 
True
 
%% Cell type:code id: tags:
 
``` python
import numpy as np
import matplotlib.pyplot as plt
```
 
%% Cell type:code id: tags:
 
``` python
vectors = tfields.Tensors([[0, 0, 0],
[0, 0, 1],
[0, -1, 0]])
```
 
%% Cell type:code id: tags:
 
``` python
vectors.coord_sys
```
 
%%%% Output: execute_result
 
'cartesian'
 
%% Cell type:markdown id: tags:
 
## Transformations
 
%% Cell type:code id: tags:
 
``` python
vectors.transform('cylinder')
vectors
```
 
%%%% Output: execute_result
 
Tensors([[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
[ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00],
[ 1.00000000e+00, -1.57079633e+00, 6.12323400e-17]])
 
%% Cell type:markdown id: tags:
 
# Tensor Fields
 
%% Cell type:code id: tags:
 
``` python
scalar_field = tfields.TensorFields(vectors, scalars)
```
 
%% Cell type:markdown id: tags:
 
Slicing, Indexing and Comparison e.g.
 
%% Cell type:code id: tags:
 
``` python
vectors.equal(scalar_field)
```
 
%%%% Output: execute_result
 
True
 
%% Cell type:code id: tags:
 
``` python
scalar_field[:2].fields[0]
```
 
%%%% Output: execute_result
 
Tensors([ 0., 1.])
 
%% Cell type:markdown id: tags:
 
# Tensor Maps (Graph Theory)
 
%% Cell type:markdown id: tags:
 
Tensors considered as Nodes → Maps define Connections
 
%% Cell type:code id: tags:
 
``` python
maps = [tfields.TensorFields([[0, 1, 2]])] # very simple map that connects the first three nodes
graph = tfields.TensorMaps(scalar_field, maps=maps)
```
 
%% Cell type:markdown id: tags:
 
This is the special case of a **3D CAD mesh**
 
%% Cell type:code id: tags:
 
``` python
mesh = tfields.Mesh3D(scalar_field, maps=maps)
 
%matplotlib notebook
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
mesh.plot(axis=ax, color='b', edgecolor='k')
```
 
%%%% Output: display_data
 
 
%%%% Output: display_data
 
 
%%%% Output: stream
 
[(0.0, 0.0, 1.0, 1)]
 
%%%% Output: execute_result
 
<mpl_toolkits.mplot3d.art3d.Poly3DCollection at 0x7fdf05c8f438>
 
%% Cell type:markdown id: tags:
 
# Glimpses
 
%% Cell type:markdown id: tags:
 
## Approximated sphere translated in y
 
%% Cell type:code id: tags:
 
``` python
%matplotlib notebook
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
 
sphere = tfields.Mesh3D.grid((1, 1, 1),
(-np.pi, np.pi, 12),
(-np.pi / 2, np.pi / 2, 12),
coord_sys='spherical')
sphere.transform('cartesian')
sphere[:, 1] += 3
artist = sphere.plot(axis=ax,
color='b',
edgecolor='k')
```
 
%%%% Output: display_data
 
 
%%%% Output: display_data
 
 
%%%% Output: stream
 
[(0.0, 0.0, 1.0, 1)]
 
%% Cell type:markdown id: tags:
 
## Oktaeder
 
%% Cell type:code id: tags:
 
``` python
%matplotlib notebook
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
 
oktaeder = tfields.Mesh3D.grid((1, 1, 1),
(-np.pi, np.pi, 5),
(-np.pi / 2, np.pi / 2, 3),
coord_sys='spherical')
oktaeder.transform('cartesian')
artist = oktaeder.plot(axis=ax,
color='r',
edgecolor='k')
```
 
%%%% Output: display_data
 
 
%%%% Output: display_data
 
 
%%%% Output: stream
 
[(1.0, 0.0, 0.0, 1)]
 
%% Cell type:markdown id: tags:
 
# Merging
 
%% Cell type:code id: tags:
 
``` python
%matplotlib notebook
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
 
complex = tfields.Mesh3D.merged(sphere, oktaeder)
complex.plot(axis=ax, edgecolor='k')
```
 
%%%% Output: display_data
 
 
%%%% Output: display_data
 
 
%%%% Output: stream
 
[(0.5019607843137255, 0.5019607843137255, 0.5019607843137255, 1.0)]
 
%%%% Output: execute_result
 
<mpl_toolkits.mplot3d.art3d.Poly3DCollection at 0x7fdf042ddda0>
 
%% Cell type:markdown id: tags:
 
# Splitting using fast algorithms from Graph Theory (Disjoint Groups)
 
%% Cell type:code id: tags:
 
``` python
map_description = complex.disjoint_map(0)
parts = complex.parts(map_description)
parts[0].equal(sphere), parts[1].equal(oktaeder)
```
 
%%%% Output: execute_result
 
(True, True)
 
%% Cell type:markdown id: tags:
 
# Cutting using Symbolic Maths
 
%% Cell type:code id: tags:
 
``` python
%matplotlib notebook
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
tfields.plotting.set_aspect_equal(ax)
 
import sympy
x, y, z = sympy.symbols('x y z')
halfed = sphere.cut(x>0, at_intersection='remove')
halfed.plot(axis=ax, edgecolor='k')
```
 
%%%% Output: display_data
 
 
%%%% Output: display_data
 
 
%%%% Output: stream
 
[(0.5019607843137255, 0.5019607843137255, 0.5019607843137255, 1.0)]
 
%%%% Output: execute_result
 
<mpl_toolkits.mplot3d.art3d.Poly3DCollection at 0x7fdf05ba1f60>
 
%% Cell type:markdown id: tags:
 
# Templates
Such cuts or disjonts can be used as templates with decision trees -> Huge speedup
......
......@@ -13259,9 +13259,8 @@ a.anchor-link {
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Pypi:">Pypi:<a class="anchor-link" href="#Pypi:">&#182;</a></h3><p>'''bash
pip install tfields
'''</p>
<h3 id="Pypi:">Pypi:<a class="anchor-link" href="#Pypi:">&#182;</a></h3><div class="highlight"><pre><span></span>pip install tfields
</pre></div>
 
</div>
</div>
......@@ -13269,9 +13268,8 @@ pip install tfields
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Git:">Git:<a class="anchor-link" href="#Git:">&#182;</a></h3><p>'''bash
git clone <a href="https://gitlab.mpcdf.mpg.de/dboe/tfields.git">https://gitlab.mpcdf.mpg.de/dboe/tfields.git</a>
'''</p>
<h3 id="Git:">Git:<a class="anchor-link" href="#Git:">&#182;</a></h3><div class="highlight"><pre><span></span>git clone https://gitlab.mpcdf.mpg.de/dboe/tfields.git
</pre></div>
 
</div>
</div>
......@@ -13817,10 +13815,10 @@ git clone <a href="https://gitlab.mpcdf.mpg.de/dboe/tfields.git">https://gitlab.
 
 
 
<div id="689048f2-fb7d-4373-bd59-46ee661ac039"></div>
<div id="3cf0690c-5fba-4c8c-9e9d-513f0f0e95df"></div>
<div class="output_subarea output_javascript ">
<script type="text/javascript">
var element = $('#689048f2-fb7d-4373-bd59-46ee661ac039');
var element = $('#3cf0690c-5fba-4c8c-9e9d-513f0f0e95df');
/* Put everything inside the global mpl namespace */
window.mpl = {};
 
......@@ -14686,10 +14684,10 @@ if (IPython.notebook.kernel != null) {
 
 
 
<div id="87a77583-a14b-4077-ac28-25633c86e1ff"></div>
<div id="a459e119-9453-43c0-8ef1-0703257c60e6"></div>
<div class="output_subarea output_javascript ">
<script type="text/javascript">
var element = $('#87a77583-a14b-4077-ac28-25633c86e1ff');
var element = $('#a459e119-9453-43c0-8ef1-0703257c60e6');
/* Put everything inside the global mpl namespace */
window.mpl = {};
 
......@@ -15534,10 +15532,10 @@ if (IPython.notebook.kernel != null) {
 
 
 
<div id="f1cd1d2c-2508-4df6-aa90-de89695b9b87"></div>
<div id="32f92965-2df2-4719-bcb9-eac44689a568"></div>
<div class="output_subarea output_javascript ">
<script type="text/javascript">
var element = $('#f1cd1d2c-2508-4df6-aa90-de89695b9b87');
var element = $('#32f92965-2df2-4719-bcb9-eac44689a568');
/* Put everything inside the global mpl namespace */
window.mpl = {};
 
......@@ -16376,10 +16374,10 @@ if (IPython.notebook.kernel != null) {
 
 
 
<div id="2e29f46c-9ae1-40e9-ac46-d326add3e1d4"></div>
<div id="4de30ffe-f90b-40cd-a170-785e48be5131"></div>
<div class="output_subarea output_javascript ">
<script type="text/javascript">
var element = $('#2e29f46c-9ae1-40e9-ac46-d326add3e1d4');
var element = $('#4de30ffe-f90b-40cd-a170-785e48be5131');
/* Put everything inside the global mpl namespace */
window.mpl = {};
 
......@@ -17276,10 +17274,10 @@ if (IPython.notebook.kernel != null) {
 
 
 
<div id="5597f816-32e9-457a-b09e-a0d474503b1f"></div>
<div id="dd701d8d-ff2e-4a04-86a9-d459b7838f24"></div>
<div class="output_subarea output_javascript ">
<script type="text/javascript">
var element = $('#5597f816-32e9-457a-b09e-a0d474503b1f');
var element = $('#dd701d8d-ff2e-4a04-86a9-d459b7838f24');
/* Put everything inside the global mpl namespace */
window.mpl = {};
 
......
Supports Markdown
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