Skip to content

Commit ac415d1

Browse files
authored
Merge pull request #14805 from rmcdermo/master
Python: start enabling parsing of data headers via pipe | for dataplot.
2 parents b9a4d01 + 90ae152 commit ac415d1

File tree

2 files changed

+34
-25
lines changed

2 files changed

+34
-25
lines changed

Utilities/Python/FDS_verification_script.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import fdsplotlib
77
import importlib
88
importlib.reload(fdsplotlib) # use for development (while making changes to fdsplotlib.py)
9+
print("Using:", fdsplotlib.__file__)
910

1011
# Scripts to run prior to dataplot
1112

Utilities/Python/fdsplotlib.py

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def dataplot(config_filename,**kwargs):
6565

6666
if kwargs.get('plot_range'):
6767
plot_range_in = kwargs.get('plot_range')
68-
plot_range = range(plot_range_in[0]-2,plot_range_in[-1])
68+
plot_range = range(plot_range_in[0]-2,plot_range_in[-1]-1)
6969

7070
# read the config file
7171
df = pd.read_csv(configdir+config_filename, sep=',', engine='python', comment='#', quotechar='"')
@@ -103,19 +103,24 @@ def dataplot(config_filename,**kwargs):
103103
# read data from exp file
104104
# set header to the row where column names are stored (Python is 0 based)
105105
E = pd.read_csv(expdir+pp.d1_Filename, header=int(pp.d1_Col_Name_Row-1), sep=',', engine='python', comment='#', quotechar='"')
106+
106107
x = E[pp.d1_Ind_Col_Name].values[:].astype(float)
107-
y = E[pp.d1_Dep_Col_Name].values[:].astype(float)
108+
# y = E[pp.d1_Dep_Col_Name].values[:].astype(float)
109+
col_names = [c.strip() for c in pp.d1_Dep_Col_Name.split('|')]
110+
# print(col_names)
111+
y = E[col_names].values.astype(float)
108112

109-
# plot the exp data
110-
f = plot_to_fig(x_data=x, y_data=y,
111-
data_label=pp.d1_Key,
112-
x_label=pp.Ind_Title,
113-
y_label=pp.Dep_Title,
114-
marker_style=pp.d1_Style,
115-
x_min=pp.Min_Ind,x_max=pp.Max_Ind,
116-
y_min=pp.Min_Dep,y_max=pp.Max_Dep,
117-
legend_location=pp.Key_Position
118-
)
113+
for i, label in enumerate(col_names):
114+
# plot the exp data
115+
f = plot_to_fig(x_data=x, y_data=y[:, i],
116+
data_label=pp.d1_Key,
117+
x_label=pp.Ind_Title,
118+
y_label=pp.Dep_Title,
119+
marker_style=pp.d1_Style,
120+
x_min=pp.Min_Ind,x_max=pp.Max_Ind,
121+
y_min=pp.Min_Dep,y_max=pp.Max_Dep,
122+
legend_location=pp.Key_Position
123+
)
119124

120125
# plt.figure(f.number) # make figure current
121126
# plt.show()
@@ -145,7 +150,9 @@ def dataplot(config_filename,**kwargs):
145150
# get the model results
146151
M = pd.read_csv(cmpdir+pp.d2_Filename, header=int(pp.d2_Col_Name_Row-1), sep=',', engine='python', comment='#', quotechar='"')
147152
x = M[pp.d2_Ind_Col_Name].values[:].astype(float)
148-
y = M[pp.d2_Dep_Col_Name].values[:].astype(float)
153+
# y = M[pp.d2_Dep_Col_Name].values[:].astype(float)
154+
col_names = [c.strip() for c in pp.d2_Dep_Col_Name.split('|')]
155+
y = M[col_names].values.astype(float)
149156

150157
version_string = revision
151158
if (pp.VerStr_Filename):
@@ -154,18 +161,19 @@ def dataplot(config_filename,**kwargs):
154161
version_string = Lines[0].strip()
155162
file1.close()
156163

157-
f = plot_to_fig(x_data=x, y_data=y,
158-
revision_label=version_string,
159-
figure_handle=f,
160-
x_label=pp.Ind_Title,
161-
y_label=pp.Dep_Title,
162-
data_label=pp.d2_Key,
163-
line_style=pp.d2_Style,
164-
x_min=pp.Min_Ind,x_max=pp.Max_Ind,
165-
y_min=pp.Min_Dep,y_max=pp.Max_Dep,
166-
legend_location=pp.Key_Position,
167-
plot_title=pp.Plot_Title
168-
)
164+
for i, label in enumerate(col_names):
165+
f = plot_to_fig(x_data=x, y_data=y[:, i],
166+
revision_label=version_string,
167+
figure_handle=f,
168+
x_label=pp.Ind_Title,
169+
y_label=pp.Dep_Title,
170+
data_label=pp.d2_Key,
171+
line_style=pp.d2_Style,
172+
x_min=pp.Min_Ind,x_max=pp.Max_Ind,
173+
y_min=pp.Min_Dep,y_max=pp.Max_Dep,
174+
legend_location=pp.Key_Position,
175+
plot_title=pp.Plot_Title
176+
)
169177

170178
plt.figure(f.number) # make figure current
171179
# plt.show()

0 commit comments

Comments
 (0)