Skip to content

Commit

Permalink
[NF] Added components description to tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
helene-t committed May 14, 2020
1 parent 2e9f0c6 commit f3ee880
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
Binary file modified Tutorials/_static/UML_Data_Object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 37 additions & 5 deletions Tutorials/tuto1_Create.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -105,7 +105,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -138,7 +138,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -179,7 +179,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -221,7 +221,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -238,6 +238,38 @@
"#---------------------------------------------------------------"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 6. How to store a field with multiple components\n",
"It is more efficient to store all the **components** of a same field (e.g. $x$, $y$, $z$ components of a vector field, phases of a signal, etc.) in the same `Data` object. To do so, the `is_components` key can be used to easily recognize it, and strings can be used as values."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"from numpy import roll, array\n",
"\n",
"fieldB = roll(field, 100, axis=0)\n",
"fieldC = roll(field, 200, axis=0)\n",
"new_field = array([field, fieldB, fieldC])\n",
"\n",
"#---------------------------------------------------------------\n",
"Phases = Data1D(name=\"phases\", unit=\"\", values=[\"Phase A\",\"Phase B\",\"Phase C\"], is_components=True)\n",
"Br = DataTime(\n",
" name=\"Airgap radial flux density\",\n",
" unit=\"T\",\n",
" symbol=\"B_r\",\n",
" axes=[Phases, Time, Angle],\n",
" values=new_field,\n",
" )\n",
"#---------------------------------------------------------------"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit f3ee880

Please sign in to comment.