|
| 1 | + |
| 2 | +import pandas as pd |
| 3 | +import numpy as np |
| 4 | +import os |
| 5 | +import matplotlib.pyplot as plt |
| 6 | + |
| 7 | +# include FDS plot styles, etc. |
| 8 | +import fdsplotlib |
| 9 | + |
| 10 | +# Get plot style parameters |
| 11 | +plot_style = fdsplotlib.get_plot_style('fds') |
| 12 | + |
| 13 | +expdir = '../../../exp/Sandia_Jets_Pools_Fireballs/' |
| 14 | +outdir = '../../../out/Sandia_Jets_Pools_Fireballs/' |
| 15 | +figdir = '../../Manuals/FDS_Validation_Guide/SCRIPT_FIGURES/Sandia_Jets_Pools_Fireballs/' |
| 16 | + |
| 17 | +E_file = ['ethane_pool.csv','ethylene_pool.csv','propane_pool.csv','isopentane_pool.csv'] |
| 18 | +M_file = ['ethane_pool_cat_devc.csv','ethylene_pool_cat_devc.csv','propane_pool_cat_devc.csv','isopentane_pool_cat_devc.csv'] |
| 19 | + |
| 20 | +marker = ['ko','ro','go','bo'] |
| 21 | +label = ['Ethane','Ethylene','Propane','Isopentane'] |
| 22 | + |
| 23 | +git_file = os.path.join(outdir, f'ethane_pool_cat_git.txt') |
| 24 | +version_string = fdsplotlib.get_version_string(git_file) |
| 25 | + |
| 26 | +fig = fdsplotlib.plot_to_fig([0,50],[0,50], |
| 27 | + x_min=0, x_max=50, y_min=0, y_max=50, |
| 28 | + figure_size=(plot_style['Scat_Paper_Width'],plot_style['Scat_Paper_Height']), |
| 29 | + legend_location='upper left', |
| 30 | + revision_label=version_string, |
| 31 | + xlabel='Measured Heat Flux (kW/m$^2$)', |
| 32 | + ylabel='Predicted Heat Flux (kW/m$^2$)') |
| 33 | + |
| 34 | +for i in range(4): |
| 35 | + |
| 36 | + # Read first CSV file and extract second column into array E |
| 37 | + df1 = pd.read_csv(expdir + E_file[i], skiprows=0) |
| 38 | + E = df1.iloc[:,1].values # Second column (index 1) |
| 39 | + #col1 = df1.iloc[:,1].values # Second column (index 1) |
| 40 | + #col2 = df1.iloc[:,2].values # Third column (index 2) |
| 41 | + #E = np.concatenate([col1, col2]) # Combine both columns into single array |
| 42 | + |
| 43 | + # Read second CSV file, skip first two rows, and extract last row into array M |
| 44 | + df2 = pd.read_csv(outdir + M_file[i], skiprows=2) |
| 45 | + M = df2.iloc[-1,1:].values # Last row, all columns |
| 46 | + |
| 47 | + # Remove NaN values by creating a mask for valid (non-NaN) values in both arrays |
| 48 | + # Ensure both arrays have the same length by taking the minimum length |
| 49 | + min_length = min(len(E), len(M)) |
| 50 | + E = E[:min_length] |
| 51 | + M = M[:min_length] |
| 52 | + |
| 53 | + # Create mask for non-NaN values in both arrays |
| 54 | + valid_mask = ~(np.isnan(E) | np.isnan(M)) |
| 55 | + E_clean = E[valid_mask] |
| 56 | + M_clean = M[valid_mask] |
| 57 | + |
| 58 | + # Add data to scatterplot |
| 59 | + fig = fdsplotlib.plot_to_fig(E_clean, M_clean,figure_handle=fig, |
| 60 | + marker_style=marker[i], |
| 61 | + data_label=label[i]) |
| 62 | + |
| 63 | +# Save as PDF |
| 64 | +fig_file = os.path.join(figdir, f'Sandia_Pools.pdf') |
| 65 | +fig.savefig(fig_file, format='pdf') |
| 66 | + |
0 commit comments