Skip to content

Commit

Permalink
Added basic plotting example for Python.
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanHehnen committed Jun 19, 2024
1 parent 501db64 commit 4a970a2
Show file tree
Hide file tree
Showing 4 changed files with 22,824 additions and 96 deletions.
106 changes: 38 additions & 68 deletions book/content/examples/01_basic/06_basic_example_da_i.ipynb

Large diffs are not rendered by default.

80 changes: 52 additions & 28 deletions book/content/examples/01_basic/07_basic_example_da_ii.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,6 @@
"import os\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Fig16_LoveSeat.txt', 'Fig16_Sofa.txt', 'Fig16_SingleChair.txt']\n"
]
}
],
"source": [
"folder_path='data/Furniture_calorimetry'\n",
"files = os.listdir(folder_path)\n",
"print(files)"
]
},
{
"cell_type": "code",
"execution_count": 3,
Expand All @@ -107,10 +88,37 @@
"source": [
"#Describe the Design fire HRR:\n",
"time_series = np.linspace(0,130)#creating time series\n",
"alpha=0.19\n",
"alpha=0.19 # ultra fast\n",
"HRR = alpha_t_squared(time_series, alpha)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Fig16_LoveSeat.txt', 'Fig16_Sofa.txt', 'Fig16_SingleChair.txt']\n"
]
}
],
"source": [
"# Check files with experiment data.\n",
"folder_path='./data/Furniture_calorimetry'\n",
"files = os.listdir(folder_path)\n",
"print(files)"
]
},
{
"cell_type": "code",
"execution_count": 6,
Expand All @@ -130,26 +138,42 @@
"source": [
"# Read the data from the experiments.\n",
"for file in files:\n",
" # Filter out specific type of files.\n",
" if file.endswith('.txt'):\n",
" file_path = os.path.join(folder_path,file)\n",
" # Create data series label.\n",
" label = os.path.splitext(file )[0].split('_')[-1] # Extract label from filename\n",
" df = pd.read_csv(file_path, header=0)\n",
" \n",
" # Read file.\n",
" file_path = os.path.join(folder_path,file)\n",
" furniture_df = pd.read_csv(file_path, header=0)\n",
" \n",
" if \"Chair\" in file:\n",
" # Shift data series such that the increasing slopes align.\n",
" plt.plot(df['Time'] - 60, df['HRR'], label=label.capitalize())\n",
" time_shift = 60\n",
" else:\n",
" plt.plot(df['Time'], df['HRR'], label=label.capitalize())\n",
" time_shift = 0\n",
" \n",
" # Plot data series.\n",
" plt.plot(furniture_df['Time'] - time_shift, \n",
" furniture_df['HRR'], \n",
" label=label.capitalize())\n",
"\n",
"# Assuming alpha_t_squared function results are stored in variables time_series and HRR\n",
"plt.plot(time_series + 90, HRR, color='k', linestyle='-.', label=\"Ultra fast\")\n",
"# Plot alpha_t_squared function results.\n",
"virtual_ignition_time = 90\n",
"plt.plot(time_series + virtual_ignition_time, \n",
" HRR, \n",
" color='k', linestyle='-.', \n",
" label=\"Ultra fast\")\n",
"\n",
"\n",
"# Plot meta data.\n",
"plt.xlabel(\"Time / s\")\n",
"plt.ylabel(\"Heat Release Rate / kW\")\n",
"plt.grid()\n",
"plt.legend()\n",
"plt.show()"
"plt.grid()\n",
"\n",
"# Show plot.\n",
"plt.show() "
]
}
],
Expand Down
Loading

0 comments on commit 4a970a2

Please sign in to comment.