-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_article2_routines.py
389 lines (314 loc) · 12.4 KB
/
run_article2_routines.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
def get_relevant_wall_normal_data_from_pandas_hdf(exceptions = []):
import article2_time_resolved_routines as trr
import case_dict_overall_correction as cdoc
from os.path import join
from numpy import arange
root = '/media/carlos/6E34D2CD34D29783/2015-02_SerrationPIV/'\
+'TR_Data_Location_Calibrated'
case_dict = cdoc.return_case_df()
for case in case_dict.iterrows():
case_file = case[1].file
skip = False
if len(exceptions):
for ex in exceptions:
if ex in case_file:
skip = True
if not skip:
#x_locs = [float(f) for f in case[1].x_loc.split(',')]
if 'z00' in case_file and 'Sr' in case_file:
x_locs = arange( 36, 40.2, 0.2 )
elif 'z05' in case_file and 'Sr' in case_file:
x_locs = arange( 16, 20.2, 0.2 )
elif 'z10' in case_file or 'STE' in case_file:
x_locs = arange( -5, -0.8, 0.2 )
trr.wall_normal_data_to_reserved_pickles_from_pandas_hdf(
join(root, case_file), x_locs , overwrite = False, append = True
)
def get_available_cases_df():
from os import listdir
from re import findall
import pandas as pd
available_reserved_files = [
f for f in listdir(root) if f.endswith(".p")
]
cases_df = pd.DataFrame( columns = ['file','x','y'] )
for res_file in available_reserved_files:
cases_df = cases_df.append(
pd.DataFrame(
data = {
'x' : float(findall(
'x[-0-9][0-9]?.[0-9]', res_file
)[0].replace('x','')),
'y' : float(findall(
'y[-0-9][0-9]?.?[0-9]?', res_file
)[0].replace('y','')),
'file' : findall(
'[A-Za-z0-9_]+_x', res_file
)[0]\
.replace('_x','')\
.replace('5','')\
.replace('_AirfoilNormal','') ,
},
index = [0]
),
ignore_index = True)
return cases_df
def get_df_cases_from_pickle_names(cases_df):
from os import listdir
from os.path import join
from pandas import read_pickle
all_pickles = [f for f in listdir(root) if f.endswith('.p')]
case_time_series_dfs = []
for case in cases_df.iterrows():
for pickle in [p for p in all_pickles\
if case[1].file in p\
and "x{0:.0f}".format(case[1].x) in p\
and "y{0:.0f}".format(case[1].y) in p]:
df = read_pickle( join( root, pickle ) )
df['case_name'] = case[1].file
case_time_series_dfs.append( df )
return case_time_series_dfs
#def correct_heights(df):
# from numpy import round as np_round
#
# def round_of_rating(number):
# """Round a number to the closest half integer.
# """
# return round(number * 20) / 2 / 10.
#
# height_correction = {
# 'Sr20R21_a0_p0_U20_z00_tr': -1.0,
# 'Sr20R21_a0_p0_U20_z05_tr_New': 0.0,
# 'Sr20R21_a0_p0_U20_z10_tr': 1.0,
# }
#
# for key in height_correction.keys():
#
# df.loc[ df.case_name == key , 'y'] = \
# df[ df.case_name == key ].y + height_correction[key]
#
# df.loc[ df.case_name == key , 'near_y'] = \
# df[ df.case_name == key ].near_y \
# + height_correction[key]
#
# df.loc[ df.case_name == key , 'near_y_delta'] = \
# df[ df.case_name == key ].near_y \
# / df[ df.case_name == key ].delta_99
#
# df.near_y_delta = np_round(df.near_y_delta,1)
# df.near_y = np_round(df.near_y ,1)
#
# print sorted(df.near_y_delta.unique())
# return df
def do_the_time_resolved_analysis():
import pandas as pd
from os.path import join
import article2_data_analysis_routines as dar
def do_the_frequency_plot(df,plot_name, schematic = ''):
for y in df.near_y_delta.unique():
df_y_cases = df[ df.near_y_delta == y ]
dar.do_the_frequency_analysis(
df_y_cases,
y = y,
plot_name = plot_name,
schematic = schematic
)
def do_the_Reynolds_quadrant_analysis(df, plot_name):
for y in df.near_y_delta.unique():
if round( y, 2 ) in [0.9]:#, 0.3, 0.6, 0.9]:
df_y_cases = df[ df.near_y_delta == y ]
dar.do_the_reynolds_stress_quadrant_analysis(
df_y_cases,
y_delta = y,
plot_name = plot_name,
)
def do_the_coherence_analysis(df_upstream, df_downstream
,plot_name,schematic = ''):
coherence_df = pd.DataFrame()
for y_up, y_down in zip(
sorted(df_upstream.near_y_delta.unique()),
sorted(df_downstream.near_y_delta.unique())
):
partial_coherence_df = dar.do_the_coherence_analysis(
df_upstream[ df_upstream.near_y_delta == y_up ],
df_downstream[ df_downstream.near_y_delta == y_down ],
)
if not partial_coherence_df.empty:
coherence_df = coherence_df.append(
partial_coherence_df, ignore_index = True
)
dar.plot_coherence_Uc_phi( coherence_df ,
plot_name = plot_name,
schematic = schematic)
all_cases_pickle = pd.read_pickle( join( root, 'AllPointPickle.p' ) )
#x0_cases = all_cases_pickle[
# all_cases_pickle.near_x == -1
#]
#x0_coherence_cases = all_cases_pickle[
# (all_cases_pickle.near_x == -3) | (all_cases_pickle.near_x == -1)
#]
#x0_coherence_cases = x0_coherence_cases[
# x0_coherence_cases.case_name != "STE_a0_p0_U20_z00_tr"
#]
# TE locations # ###########################################################
#TE_cases = all_cases_pickle[
# (all_cases_pickle.near_x == -1) & \
# (all_cases_pickle.case_name == 'STE_a0_p0_U20_z00_tr')
#]
TE_cases = \
all_cases_pickle[
#(all_cases_pickle.near_x == -1) & \
(all_cases_pickle.case_name == \
'Sr20R21_a0_p0_U20_z10_tr')
]
TE_cases = TE_cases.append(
all_cases_pickle[
#(all_cases_pickle.near_x == 20) & \
(all_cases_pickle.case_name == \
'Sr20R21_a0_p0_U20_z05_tr_New')
], ignore_index = True
)
TE_cases = TE_cases.append(
all_cases_pickle[
#(all_cases_pickle.near_x == 40) & \
(all_cases_pickle.case_name == \
'Sr20R21_a0_p0_U20_z00_tr')
], ignore_index = True
)
TE_cases = TE_cases.append(
all_cases_pickle[
#(all_cases_pickle.near_x == -1) & \
(all_cases_pickle.case_name == \
'STE_a0_p0_U20_z00_tr')
], ignore_index = True
)
## upstream locations ######################################################
##TE_cases_upstream = all_cases_pickle[
## (all_cases_pickle.near_x == -3) & \
## (all_cases_pickle.case_name == 'STE_a0_p0_U20_z00_tr')
##]
##up_shift = -4
#up_shift = -2
#TE_cases_upstream = \
# all_cases_pickle[
# (all_cases_pickle.near_x == -1 + up_shift) & \
# (all_cases_pickle.case_name == \
# 'Sr20R21_a0_p0_U20_z10_tr')
# ]
#TE_cases_upstream = TE_cases_upstream.append(
# all_cases_pickle[
# (all_cases_pickle.near_x == 20 + up_shift) & \
# (all_cases_pickle.case_name == \
# 'Sr20R21_a0_p0_U20_z05_tr_New')
# ], ignore_index = True
#)
#TE_cases_upstream = TE_cases_upstream.append(
# all_cases_pickle[
# (all_cases_pickle.near_x == 40 + up_shift) & \
# (all_cases_pickle.case_name == \
# 'Sr20R21_a0_p0_U20_z00_tr')
# ], ignore_index = True
#)
#TE_cases_upstream = TE_cases_upstream.append(
# all_cases_pickle[
# (all_cases_pickle.near_x == -1 + up_shift) & \
# (all_cases_pickle.case_name == \
# 'STE_a0_p0_U20_z00_tr')
# ], ignore_index = True
#)
#TE_cases = correct_heights( TE_cases )
#TE_cases_upstream = correct_heights( TE_cases_upstream )
schematic_TE = '/home/carlos/Documents/PhD/Articles/Article_2/'+\
'Figures/measurement_locations_TE_m2_with_edge_normal.png'
#do_the_frequency_plot( TE_cases, 'TE', schematic = schematic_TE)
schematic_x0 = '/home/carlos/Documents/PhD/Articles/Article_2/'+\
'Figures/measurement_locations_x0_m2.png'
schematic_TE = '/home/carlos/Documents/PhD/Articles/Article_2/'+\
'Figures/measurement_locations_TE_m2_noSTE.png'
#TE_cases = TE_cases[ TE_cases.case_name != 'STE_a0_p0_U20_z00_tr' ]
do_the_Reynolds_quadrant_analysis( TE_cases, 'TE' )
#do_the_coherence_analysis( TE_cases_upstream, TE_cases, 'TE' ,
# schematic = schematic_TE)
#dar.plot_mean_and_std( TE_cases )
#do_the_frequency_plot( x0_cases, 'x0', schematic = schematic_x0 )
#do_the_Reynolds_quadrant_analysis( x0_cases, 'x0' )
#do_the_coherence_analysis( x0_coherence_cases , "x0",
# schematic = schematic_x0)
def correlation_coherence_and_length_scale_analysis():
import article2_data_analysis_routines as dar
from os.path import join
root = '/home/carlos/Documents/PhD/Articles/Article_2/' + \
'Article2_Scripts/time_resolved_scripts/Results_v2'
source_root = '/home/carlos/Documents/PhD/Articles/Article_2/' + \
'Article2_Scripts/time_resolved_scripts/ReservedData'
def do_the_vertical_coherence_analysis(
hdfs ,
plot_individual = False,
overwrite = False
):
#dar.get_vertical_correlation(
# [ join( source_root, h ) for h in hdfs ],
# root = root,
# plot_individual = plot_individual ,
# overwrite = overwrite
#)
#for hdf in hdfs:
# dar.plot_vertical_correlation_from_pickle(
# join(
# root,
# 'WallNormalCorrelation_Values_' + hdf.replace(
# '.hdf5', '.p'
# )
# ),
# root = root
# )
#dar.get_vertical_length_scale( root = root )
dar.print_vertical_length_scale_bl_integration( )
def do_the_streamwise_coherence_analysis( hdfs , overwrite = False ):
#for hdf in hdfs:
#dar.get_streamwise_coherence_and_correlation(
# join( source_root, hdf ),
# overwrite = overwrite
#)
#dar.plot_streamwise_correlation_from_pickle(
# 'StreamwiseCorrelation_Values_' + hdf.replace( '.hdf5', '.p' )
#)
#dar.do_the_streamwise_coherence_analysis(
# 'StreamwiseCoherence_Values_' + hdf.replace( '.hdf5', '.p' ),
# overwrite = overwrite
#)
#dar.get_streamwise_length_scale_and_ke()
#dar.plot_pickled_Uc(
# [ 'Uc_data_Values_' + f.replace('.hdf5','.p') for f in hdfs ],
# print_integration = True
#)
dar.plot_wavenumber_spectra(
[ join( source_root, h ) for h in hdfs ],
var = 'u'
)
#dar.plot_phi()
hdf_list_to_process = [
'STE_a0_p0_U20_z00_tr.hdf5',
'Sr20R21_a0_p0_U20_z10_tr.hdf5',
'Sr20R21_a0_p0_U20_z05_tr.hdf5',
'Sr20R21_a0_p0_U20_z00_tr.hdf5',
]
do_the_streamwise_coherence_analysis(
hdf_list_to_process,
overwrite = True
)
#do_the_vertical_coherence_analysis(
# hdf_list_to_process,
# plot_individual = False,
# overwrite = True
# )
from os.path import join
import publish
root = join('/home/carlos/Documents/PhD/Articles/Article_2',
'Article2_Scripts/time_resolved_scripts/LineReservedData/')
#get_relevant_wall_normal_data_from_pandas_hdf(exceptions = ['STE'])
#get_relevant_wall_normal_data_from_pandas_hdf()
#get_relevant_wall_normal_data_from_pandas_hdf(exceptions = ['z05','STE','z00'])
#do_the_time_resolved_analysis()
correlation_coherence_and_length_scale_analysis()
publish.publish()