" 1. Open the results file in a text editor of your choice. How many columns are there? What does each column represent?\n",
" 2. Scroll through the results file and find out what the wind speed is at $t=60$ s. What are the responses at $t = 345$ s?\n",
" 3. Make a function that loads the results file and returns vectors t, u, x1 and x2.\n",
" 3. Make a function that (1) loads the results file, (2) removes 60 seconds at the beggining to eliminate transience and, and (3) returns vectors t, u, x1 and x2.\n",
" 4. Write a script that finds and prints the wind speed and responses at a selected time. Verify the output of your script with your answer to Exercise 2.\n",
" 5. Make a function that plots Turbie results versus time. The figure should have two subplots: the top showing the wind speed and the bottom showing the blade and tower deflections. Label the figure as you see fit. **Bonus points!** Allow the user to specify the time span (i.e., x-limits) of the plot, so they can zoom into a specific time if they like.\n",
" 6. Use your function to plot the given results file versus time. If you did the bonus exercise in Exercise 5, zoom in from 60 to 660. Your plot should look something like this:\n",
...
...
@@ -63,13 +63,13 @@
"source": [
"import numpy as np\n",
"\n",
"def load_results(path):\n",
"def load_results(path, t_start=60):\n",
" \"\"\"Load turbie results from text file.\n",
" Returns 4 [nt] arrays: t, u, x1 and x2.\n",
" \"\"\"\n",
" res_arr = np.loadtxt(path, skiprows=1)\n",
" t, u, x1, x2 = res_arr.T\n",
" return t, u, x1, x2"
" t, u, x1, x2 = np.loadtxt(path, skiprows=1, unpack=True)\n",
" mask = t >= t_start\n",
" return t[mask], u[mask], x1[mask], x2[mask]"
]
},
{
...
...
%% Cell type:markdown id:fa60cf2d tags:
# Loading and plotting
One of the most common exercises in engineering is to load saved data and visualize it in some way. In this demo, we will be loading examining a time-marching response to turbulent wind.
%% Cell type:raw id:f46c763b tags:
To do the exercises in this notebook, please download the results file and save it as ``res_12_ms_TI_0.1.txt``: :download:`download file <res_12_ms_TI_0.1.txt>`
%% Cell type:markdown id:18f29da9 tags:
### Exercises for the reader
1. Open the results file in a text editor of your choice. How many columns are there? What does each column represent?
2. Scroll through the results file and find out what the wind speed is at $t=60$ s. What are the responses at $t = 345$ s?
3. Make a function that loads the results file and returns vectors t, u, x1 and x2.
3. Make a function that (1) loads the results file, (2) removes 60 seconds at the beggining to eliminate transience and, and (3) returns vectors t, u, x1 and x2.
4. Write a script that finds and prints the wind speed and responses at a selected time. Verify the output of your script with your answer to Exercise 2.
5. Make a function that plots Turbie results versus time. The figure should have two subplots: the top showing the wind speed and the bottom showing the blade and tower deflections. Label the figure as you see fit. **Bonus points!** Allow the user to specify the time span (i.e., x-limits) of the plot, so they can zoom into a specific time if they like.
6. Use your function to plot the given results file versus time. If you did the bonus exercise in Exercise 5, zoom in from 60 to 660. Your plot should look something like this: