turbx 1.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- turbx/__init__.py +52 -0
- turbx/bl.py +620 -0
- turbx/blasius.py +64 -0
- turbx/cli.py +19 -0
- turbx/composite_profile.py +243 -0
- turbx/confidence_interval.py +64 -0
- turbx/eas3.py +420 -0
- turbx/eas4.py +567 -0
- turbx/fig_ax_constructor.py +52 -0
- turbx/freestream_parameters.py +268 -0
- turbx/gradient.py +391 -0
- turbx/grid_metric.py +272 -0
- turbx/h5.py +236 -0
- turbx/mvp.py +385 -0
- turbx/rgd.py +2693 -0
- turbx/rgd_mean.py +523 -0
- turbx/rgd_testing.py +354 -0
- turbx/rgd_xpln_ccor.py +701 -0
- turbx/rgd_xpln_coh.py +992 -0
- turbx/rgd_xpln_mean_dim.py +336 -0
- turbx/rgd_xpln_spectrum.py +940 -0
- turbx/rgd_xpln_stats.py +738 -0
- turbx/rgd_xpln_turb_budget.py +1193 -0
- turbx/set_mpl_env.py +85 -0
- turbx/signal.py +277 -0
- turbx/spd.py +1206 -0
- turbx/spd_wall_ccor.py +629 -0
- turbx/spd_wall_ci.py +406 -0
- turbx/spd_wall_import.py +676 -0
- turbx/spd_wall_spectrum.py +638 -0
- turbx/spd_wall_stats.py +618 -0
- turbx/utils.py +84 -0
- turbx/ztmd.py +2224 -0
- turbx/ztmd_analysis.py +2337 -0
- turbx/ztmd_loader.py +56 -0
- turbx-1.0.2.dist-info/LICENSE +21 -0
- turbx-1.0.2.dist-info/METADATA +120 -0
- turbx-1.0.2.dist-info/RECORD +41 -0
- turbx-1.0.2.dist-info/WHEEL +5 -0
- turbx-1.0.2.dist-info/entry_points.txt +2 -0
- turbx-1.0.2.dist-info/top_level.txt +1 -0
turbx/utils.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
'''
|
|
4
|
+
========================================================================
|
|
5
|
+
Utilities
|
|
6
|
+
========================================================================
|
|
7
|
+
'''
|
|
8
|
+
|
|
9
|
+
# ======================================================================
|
|
10
|
+
|
|
11
|
+
def even_print(label, output, **kwargs):
|
|
12
|
+
'''
|
|
13
|
+
print/return a fixed width message
|
|
14
|
+
'''
|
|
15
|
+
terminal_width = kwargs.get('terminal_width',72)
|
|
16
|
+
s = kwargs.get('s',False) ## return string
|
|
17
|
+
|
|
18
|
+
ndots = (terminal_width-2) - len(label) - len(output)
|
|
19
|
+
text = label+' '+ndots*'.'+' '+output
|
|
20
|
+
if s:
|
|
21
|
+
return text
|
|
22
|
+
else:
|
|
23
|
+
#sys.stdout.write(text)
|
|
24
|
+
print(text)
|
|
25
|
+
return
|
|
26
|
+
|
|
27
|
+
def format_time_string(tsec):
|
|
28
|
+
'''
|
|
29
|
+
format seconds as dd:hh:mm:ss
|
|
30
|
+
'''
|
|
31
|
+
m, s = divmod(abs(int(round(tsec))),60)
|
|
32
|
+
h, m = divmod(m,60)
|
|
33
|
+
d, h = divmod(h,24)
|
|
34
|
+
d = int(round(d))
|
|
35
|
+
h = int(round(h))
|
|
36
|
+
m = int(round(m))
|
|
37
|
+
s = int(round(s))
|
|
38
|
+
if (d==0) and (h==0) and (m==0):
|
|
39
|
+
s_out = f'{s:d}s'
|
|
40
|
+
elif (d==0) and (h==0):
|
|
41
|
+
s_out = f'{m:d}m:{s:02d}s'
|
|
42
|
+
elif (d==0):
|
|
43
|
+
s_out = f'{h:d}h:{m:02d}m:{s:02d}s'
|
|
44
|
+
else:
|
|
45
|
+
s_out = f'{d:d}d:{h:02d}h:{m:02d}m:{s:02d}s'
|
|
46
|
+
if (tsec >= 0):
|
|
47
|
+
return s_out
|
|
48
|
+
else:
|
|
49
|
+
return f'-{s_out}'
|
|
50
|
+
|
|
51
|
+
def format_nbytes(size):
|
|
52
|
+
'''
|
|
53
|
+
format a number of bytes to [B],[KB],[MB],[GB],[TB]
|
|
54
|
+
'''
|
|
55
|
+
if not isinstance(size,(int,float)):
|
|
56
|
+
raise ValueError('arg should be of type int or float')
|
|
57
|
+
if (size<1024):
|
|
58
|
+
size_fmt, size_unit = size, '[B]'
|
|
59
|
+
elif (size>1024) and (size<=1024**2):
|
|
60
|
+
size_fmt, size_unit = size/1024, '[KB]'
|
|
61
|
+
elif (size>1024**2) and (size<=1024**3):
|
|
62
|
+
size_fmt, size_unit = size/1024**2, '[MB]'
|
|
63
|
+
elif (size>1024**3) and (size<=1024**4):
|
|
64
|
+
size_fmt, size_unit = size/1024**3, '[GB]'
|
|
65
|
+
else:
|
|
66
|
+
size_fmt, size_unit = size/1024**4, '[TB]'
|
|
67
|
+
return size_fmt, size_unit
|
|
68
|
+
|
|
69
|
+
def step(a,b,x,order=3):
|
|
70
|
+
'''
|
|
71
|
+
Polynomial step function
|
|
72
|
+
https://en.wikipedia.org/wiki/Smoothstep
|
|
73
|
+
'''
|
|
74
|
+
x = (x-a)/(b-a)
|
|
75
|
+
if (order==1):
|
|
76
|
+
y = -2*x**3 + 3*x**2
|
|
77
|
+
elif (order==2):
|
|
78
|
+
y = 6*x**5 - 15*x**4 + 10*x**3
|
|
79
|
+
elif (order==3):
|
|
80
|
+
y = -20*x**7 + 70*x**6 - 84*x**5 + 35*x**4
|
|
81
|
+
else:
|
|
82
|
+
raise NotImplementedError
|
|
83
|
+
y = np.clip(y,0.,1.)
|
|
84
|
+
return y
|