Rename folder and change "LC" to "Stage" all over

pull/14/head
Tim Skov Jacobsen 2020-02-18 16:54:55 +01:00
parent 99b65310ed
commit 2be7201e69
7 changed files with 32 additions and 33 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -35,10 +35,10 @@
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>LC</th>\n",
" <th>LC-title</th>\n",
" <th>NR</th>\n",
" <th>NG</th>\n",
" <th>stage</th>\n",
" <th>stage_title</th>\n",
" <th>element_no</th>\n",
" <th>group</th>\n",
" <th>vx[kN/m]</th>\n",
" </tr>\n",
" </thead>\n",
@ -88,12 +88,12 @@
"</div>"
],
"text/plain": [
" LC LC-title NR NG vx[kN/m]\n",
"0 4031 Shear keys - BS - 2553/2554 20101 201 2.33\n",
"1 4031 Shear keys - BS - 2553/2554 20102 201 1.29\n",
"2 4031 Shear keys - BS - 2553/2554 20103 201 0.87\n",
"3 4031 Shear keys - BS - 2553/2554 20104 201 0.74\n",
"4 4031 Shear keys - BS - 2553/2554 20105 201 0.64"
" stage stage_title element_no group vx[kN/m]\n",
"0 4031 Shear keys - BS - 2553/2554 20101 201 2.33\n",
"1 4031 Shear keys - BS - 2553/2554 20102 201 1.29\n",
"2 4031 Shear keys - BS - 2553/2554 20103 201 0.87\n",
"3 4031 Shear keys - BS - 2553/2554 20104 201 0.74\n",
"4 4031 Shear keys - BS - 2553/2554 20105 201 0.64"
]
},
"execution_count": 1,
@ -110,7 +110,7 @@
"# Set style for matplotlib plots\n",
"plt.style.use('seaborn-whitegrid') \n",
"\n",
"# Dictionary for mapping node numbers to user chosen shear key names\n",
"# Dictionary for mapping element numbers to user chosen shear key names\n",
"shear_keys = { \n",
" # Shear key in Base Slab 101\n",
" 'BS101': range(10101, 10199), \n",
@ -138,7 +138,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@ -146,20 +146,20 @@
"# %%capture prevent plots from showing as cell output\n",
"# ------------------------------------------------------\n",
"\n",
"# Contruct a dictionary that maps load case numbers to titles (auto removes duplicates)\n",
"lc_no_to_title_map = dict(zip(df['LC'], df['LC-title'])) \n",
"# Contruct a dictionary that maps stage numbers to titles (auto removes duplicates)\n",
"stage_no_to_title_map = dict(zip(df['stage'], df['stage_title'])) \n",
"\n",
"# Loop over all shear key names and their corresponding node numbers \n",
"for shear_key, nodes in shear_keys.items():\n",
"# Loop over all shear key names and their corresponding element numbers \n",
"for shear_key, elem_no in shear_keys.items():\n",
"\n",
" # Loop over all load cases, create plots and save them to a png-file\n",
" for lc in df['LC'].unique():\n",
" # Loop over all construction stages, create plots and save them to a png-file\n",
" for stage in df['stage'].unique():\n",
"\n",
" # Get title of current load case from mapping dictionary\n",
" lc_title = lc_no_to_title_map[lc]\n",
" # Get title of current stage from mapping dictionary\n",
" stage_title = stage_no_to_title_map[stage]\n",
" \n",
" # Filter dataframe based on load case and nodes in shear key\n",
" df_filtered = df[(df['LC'] == lc) & (df['NR'].isin(nodes))]\n",
" # Filter dataframe based on stage and element numbers in shear key\n",
" df_filtered = df[(df['stage'] == stage) & (df['element_no'].isin(elem_no))]\n",
" \n",
" # Create figure\n",
" plt.figure(figsize=(12, 5))\n",
@ -190,12 +190,12 @@
" \n",
" # Set titles and x- and y-labels\n",
" plt.title(f'Shear force $vx$ [kN/m] for base slab shear key ${shear_key}$' + '\\n' +\n",
" f'{lc_title} $(LC: {lc}) ({version_number})$', fontsize=18)\n",
" f'{stage_title} $(Stage: {stage}) ({version_number})$', fontsize=16)\n",
" plt.xlabel('Points along shear key', fontsize=14)\n",
" plt.ylabel('Slab shear force $vx$ [kN/m]', fontsize=14)\n",
" \n",
" # Save figure to png-file with meaningful name that varies in every loop\n",
" plt.savefig(f'Plots/{version_number}/{shear_key}_{lc}.png')"
" plt.savefig(f'Plots/{version_number}/{shear_key}_{stage}.png')"
]
},
{
@ -204,7 +204,7 @@
"source": [
"## Explanations to some of the code lines are given below\n",
"\n",
"* **Line with `df_filtered = ...`:** The dataframe `df_filtered` is uniqie in every loop, since it is filtered based on the current load case and the nodes in the current shear key. The filtering is done based on the original large dataframe. Every operation from here on out inside the loop must use `df_filtered` and not the original dataframe. For filtering based on the nodes in the shear key `.isin` is used. This is a good way to filter based on values in a list. And the nodes for each shear key is is stored in the loop variable `nodes` as a list.\n",
"* **Line with `df_filtered = ...`:** The dataframe `df_filtered` is uniqie in every loop, since it is filtered based on the current stage and the element numbers in the current shear key. The filtering is done based on the original large dataframe. Every operation from here on out inside the loop must use `df_filtered` and not the original dataframe. For filtering based on the element numbers in the shear key `.isin` is used. This is a good way to filter based on values in a list. And the element numbers for each shear key is is stored in the loop variable `elem_no` as a list/range.\n",
"\n",
"\n",
"* **Line with `x = ...`:** This generates the x-values, which will just be increasing numbers from 1 and up. Note that `range(start, stop)` goes from `start` to `stop-1`. \n",

View File

@ -26,14 +26,14 @@
"\n",
"Each plot will look something like this, which shows the forces in shear key \"BS301\" for Construction Stage number 4069: \n",
"\n",
"![title](BS301_LC4069.png)\n",
"![plot](BS301_LC4069.png)\n",
"\n",
"Some plots will be almost empty as loads are close to zero in some Stages. \n",
"\n",
"> **Note:** Understanding the structural context of the dataset is not important for solving the exercise. The same concepts could be used for all other types of datasets. If you will, you can look at it as generic data which is to be filtered and plotted. \n",
"\n",
"### The dataset\n",
"The dataset is called `shear_keys_base_slab_v20.txt`. To get the file go [here](https://raw.githubusercontent.com/Python-Crash-Course/Python101/master/Session%206%20-%20Exercise%20\\(shear%20key%20plots\\)/shear_keys_base_slab_v20.txt), right-click and choose \"save as\". Select `.txt` as file format. Save the file in the same folder as your script for this exercise. \n",
"The dataset is called `shear_keys_base_slab_v20.txt`. To get the file go [here](https://raw.githubusercontent.com/Python-Crash-Course/Python101/master/Session%206%20-%20Practical_Exercise%20/shear_keys_base_slab_v20.txt), right-click and choose \"save as\". Select `.txt` as file format. Save the file in the same folder as your script for this exercise. \n",
"\n",
"\n",
"## The exercise\n",
@ -61,7 +61,7 @@
"# Set style for matplotlib plots\n",
"plt.style.use('seaborn-whitegrid') \n",
"\n",
"# Dictionary for mapping node numbers to user chosen shear key names\n",
"# Dictionary for mapping beam element numbers to user chosen shear key names\n",
"shear_keys = { \n",
" # Shear key in Base Slab 101\n",
" 'BS101': range(10101, 10199), \n",
@ -89,8 +89,8 @@
"# Construct a dictionary that maps load case numbers to titles (dict auto removes duplicates)\n",
"lc_no_to_title_map = dict(zip(df['LC'], df['LC-title'])) \n",
" \n",
"# Loop over all shear key names and their corresponding node numbers \n",
"for shear_key, nodes in shear_keys.items():\n",
"# Loop over all shear key names and their corresponding element numbers \n",
"for shear_key, element in shear_keys.items():\n",
" \n",
" # Loop over all load cases, create plots and save them to a png-file\n",
" for lc in df['LC'].unique():\n",
@ -98,7 +98,7 @@
" # Get title of current load case from mapping dictionary\n",
" # <Code here!> (see hint 1 below)\n",
" \n",
" # Filter dataframe based on load case and nodes in shear key\n",
" # Filter dataframe based on load case and element numbers in shear key\n",
" # <Code here!> (see hint 2 below)\n",
" \n",
" # Create figure\n",
@ -120,7 +120,6 @@
" # Extract y-values where y-values are negative and positive, respectively\n",
" y_neg, y_pos = np.take(y, idx_neg)[0], np.take(y, idx_pos)[0]\n",
" \n",
" # Plot points for negative and positve values as two separate lines\n",
" # <Code here!> \n",
" \n",
" # Fill between y=0 and the lines where y-values are negative and positive, respectively \n",

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

View File

@ -1,4 +1,4 @@
LC,LC-title,NR,NG,vx[kN/m]
stage,stage_title,element_no,group,vx[kN/m]
4031,Shear keys - BS - 2553/2554,20101,201,2.33
4031,Shear keys - BS - 2553/2554,20102,201,1.29
4031,Shear keys - BS - 2553/2554,20103,201,0.87