@@ -16,10 +16,10 @@ def generate_structure_functions( # noqa: C901, D417
16
16
y ,
17
17
skip_velocity_sf = False ,
18
18
scalar = None ,
19
- traditional_order = 0 ,
19
+ traditional_type = None ,
20
20
dx = None ,
21
21
dy = None ,
22
- boundary = "Periodic " ,
22
+ boundary = "periodic-all " ,
23
23
even = "True" ,
24
24
grid_type = "uniform" ,
25
25
nbins = 10 ,
@@ -47,15 +47,17 @@ def generate_structure_functions( # noqa: C901, D417
47
47
Defaults to False.
48
48
scalar: ndarray, optional
49
49
2D array of scalar values. Defaults to None.
50
- traditional_order: int, optional
51
- Order for calculating traditional non-advective structure functions.
52
- If 0, no traditional structure functions are calculated. Defaults to 0.
50
+ traditional_type: list, optional
51
+ List of traditional structure function types to calculate.
52
+ Accepted types are: "LL", "LLL", "LTT", "LSS". If None,
53
+ no traditional structure functions are calculated. Defaults to None.
53
54
dx: float, optional
54
55
Grid spacing in the x-direction. Defaults to None.
55
56
dy: float, optional
56
57
Grid spacing in the y-direction. Defaults to None.
57
58
boundary: str, optional
58
- Boundary condition of the data. Defaults to "Periodic".
59
+ Boundary condition of the data. Accepted strings are "periodic-x",
60
+ "periodic-y", and "periodic-all". Defaults to "periodic-all".
59
61
even: bool, optional
60
62
Flag indicating if the grid is evenly spaced. Defaults to True.
61
63
grid_type:str, optional
@@ -75,20 +77,30 @@ def generate_structure_functions( # noqa: C901, D417
75
77
SF_m = None
76
78
SF_z_scalar = None
77
79
SF_m_scalar = None
78
- SF_z_trad_velocity = None
79
- SF_m_trad_velocity = None
80
- SF_z_trad_scalar = None
81
- SF_m_trad_scalar = None
82
80
adv_E = None
83
81
adv_N = None
84
82
adv_scalar = None
83
+ SF_z_LL = None
84
+ SF_m_LL = None
85
+ SF_z_LLL = None
86
+ SF_m_LLL = None
87
+ SF_z_LTT = None
88
+ SF_m_LTT = None
89
+ SF_z_LSS = None
90
+ SF_m_LSS = None
85
91
86
92
# Define a list of separation distances to iterate over.
87
93
# Periodic is half the length since the calculation will wrap the data.
88
- if boundary == "Periodic " :
94
+ if boundary == "periodic-all " :
89
95
sep_z = range (1 , int (len (x ) / 2 ))
90
96
sep_m = range (1 , int (len (y ) / 2 ))
91
- else :
97
+ elif boundary == "periodic-x" :
98
+ sep_z = range (1 , int (len (x ) / 2 ))
99
+ sep_m = range (1 , int (len (y ) - 1 ))
100
+ elif boundary == "periodic-y" :
101
+ sep_z = range (1 , int (len (x ) - 1 ))
102
+ sep_m = range (1 , int (len (y ) / 2 ))
103
+ elif boundary is None :
92
104
sep_z = range (1 , int (len (x ) - 1 ))
93
105
sep_m = range (1 , int (len (y ) - 1 ))
94
106
@@ -101,22 +113,33 @@ def generate_structure_functions( # noqa: C901, D417
101
113
SF_z = np .zeros (len (sep_z ) + 1 )
102
114
SF_m = np .zeros (len (sep_m ) + 1 )
103
115
adv_E , adv_N = calculate_advection (u , v , x , y , dx , dy , grid_type )
104
- if traditional_order > 0 :
105
- SF_z_trad_velocity = np .zeros (len (sep_z ) + 1 )
106
- SF_m_trad_velocity = np .zeros (len (sep_m ) + 1 )
116
+ if traditional_type is not None :
117
+ if any ("LL" in t for t in traditional_type ):
118
+ SF_z_LL = np .zeros (len (sep_z ) + 1 )
119
+ SF_m_LL = np .zeros (len (sep_m ) + 1 )
120
+ if any ("LLL" in t for t in traditional_type ):
121
+ SF_z_LLL = np .zeros (len (sep_z ) + 1 )
122
+ SF_m_LLL = np .zeros (len (sep_m ) + 1 )
123
+ if any ("LTT" in t for t in traditional_type ):
124
+ SF_z_LTT = np .zeros (len (sep_z ) + 1 )
125
+ SF_m_LTT = np .zeros (len (sep_m ) + 1 )
107
126
108
127
if scalar is not None :
109
128
SF_z_scalar = np .zeros (len (sep_z ) + 1 )
110
129
SF_m_scalar = np .zeros (len (sep_m ) + 1 )
111
130
adv_scalar = calculate_advection (u , v , x , y , dx , dy , grid_type , scalar )
112
- if traditional_order > 0 :
113
- SF_z_trad_scalar = np .zeros (len (sep_z ) + 1 )
114
- SF_m_trad_scalar = np .zeros (len (sep_m ) + 1 )
131
+ if traditional_type is not None :
132
+ if any ("LSS" in t for t in traditional_type ):
133
+ SF_z_LSS = np .zeros (len (sep_z ) + 1 )
134
+ SF_m_LSS = np .zeros (len (sep_m ) + 1 )
115
135
116
136
# Iterate over separations right and down
117
137
for down in sep_m :
118
138
right = 1
119
- yroll = shift_array1d (y , shift_by = down , boundary = boundary )
139
+ if boundary == "periodic-all" or boundary == "periodic-y" :
140
+ yroll = shift_array1d (y , shift_by = down , boundary = "Periodic" )
141
+ else :
142
+ yroll = shift_array1d (y , shift_by = down , boundary = None )
120
143
121
144
SF_dicts = calculate_structure_function (
122
145
u ,
@@ -128,18 +151,24 @@ def generate_structure_functions( # noqa: C901, D417
128
151
skip_velocity_sf ,
129
152
scalar ,
130
153
adv_scalar ,
131
- traditional_order ,
154
+ traditional_type ,
132
155
boundary ,
133
156
)
134
157
135
158
if skip_velocity_sf is False :
136
159
SF_m [down ] = SF_dicts ["SF_velocity_down" ]
137
- if traditional_order > 0 :
138
- SF_m_trad_velocity [down ] = SF_dicts ["SF_trad_velocity_down" ]
160
+ if traditional_type is not None :
161
+ if any ("LL" in t for t in traditional_type ):
162
+ SF_m_LL [down ] = SF_dicts ["SF_LL_down" ]
163
+ if any ("LLL" in t for t in traditional_type ):
164
+ SF_m_LLL [down ] = SF_dicts ["SF_LLL_down" ]
165
+ if any ("LTT" in t for t in traditional_type ):
166
+ SF_m_LTT [down ] = SF_dicts ["SF_LTT_down" ]
139
167
if scalar is not None :
140
168
SF_m_scalar [down ] = SF_dicts ["SF_scalar_down" ]
141
- if traditional_order > 0 :
142
- SF_m_trad_scalar [down ] = SF_dicts ["SF_trad_scalar_down" ]
169
+ if traditional_type is not None :
170
+ if any ("LSS" in t for t in traditional_type ):
171
+ SF_m_LSS [down ] = SF_dicts ["SF_LSS_down" ]
143
172
144
173
# Calculate separation distances in y
145
174
tmp , yd [down ] = calculate_separation_distances (
@@ -148,7 +177,10 @@ def generate_structure_functions( # noqa: C901, D417
148
177
149
178
for right in sep_z :
150
179
down = 1
151
- xroll = shift_array1d (x , shift_by = right , boundary = boundary )
180
+ if boundary == "periodic-all" or boundary == "periodic-x" :
181
+ xroll = shift_array1d (x , shift_by = right , boundary = "Periodic" )
182
+ else :
183
+ xroll = shift_array1d (x , shift_by = right , boundary = None )
152
184
153
185
SF_dicts = calculate_structure_function (
154
186
u ,
@@ -160,18 +192,24 @@ def generate_structure_functions( # noqa: C901, D417
160
192
skip_velocity_sf ,
161
193
scalar ,
162
194
adv_scalar ,
163
- traditional_order ,
195
+ traditional_type ,
164
196
boundary ,
165
197
)
166
198
167
199
if skip_velocity_sf is False :
168
200
SF_z [right ] = SF_dicts ["SF_velocity_right" ]
169
- if traditional_order > 0 :
170
- SF_z_trad_velocity [right ] = SF_dicts ["SF_trad_velocity_right" ]
201
+ if traditional_type is not None :
202
+ if any ("LL" in t for t in traditional_type ):
203
+ SF_z_LL [right ] = SF_dicts ["SF_LL_right" ]
204
+ if any ("LLL" in t for t in traditional_type ):
205
+ SF_z_LLL [right ] = SF_dicts ["SF_LLL_right" ]
206
+ if any ("LTT" in t for t in traditional_type ):
207
+ SF_z_LTT [right ] = SF_dicts ["SF_LTT_right" ]
171
208
if scalar is not None :
172
209
SF_z_scalar [right ] = SF_dicts ["SF_scalar_right" ]
173
- if traditional_order > 0 :
174
- SF_z_trad_scalar [right ] = SF_dicts ["SF_trad_scalar_right" ]
210
+ if traditional_type is not None :
211
+ if any ("LSS" in t for t in traditional_type ):
212
+ SF_z_LSS [right ] = SF_dicts ["SF_LSS_right" ]
175
213
176
214
# Calculate separation distances in x
177
215
xd [right ], tmp = calculate_separation_distances (
@@ -183,15 +221,23 @@ def generate_structure_functions( # noqa: C901, D417
183
221
if skip_velocity_sf is False :
184
222
xd_bin , SF_z = bin_data (xd , SF_z , nbins )
185
223
yd_bin , SF_m = bin_data (yd , SF_m , nbins )
186
- if traditional_order > 0 :
187
- xd_bin , SF_z_trad_velocity = bin_data (xd , SF_z_trad_velocity , nbins )
188
- yd_bin , SF_m_trad_velocity = bin_data (yd , SF_m_trad_velocity , nbins )
224
+ if traditional_type is not None :
225
+ if any ("LL" in t for t in traditional_type ):
226
+ xd_bin , SF_z_LL = bin_data (xd , SF_z_LL , nbins )
227
+ yd_bin , SF_m_LL = bin_data (yd , SF_m_LL , nbins )
228
+ if any ("LLL" in t for t in traditional_type ):
229
+ xd_bin , SF_z_LLL = bin_data (xd , SF_z_LLL , nbins )
230
+ yd_bin , SF_m_LLL = bin_data (yd , SF_m_LLL , nbins )
231
+ if any ("LTT" in t for t in traditional_type ):
232
+ xd_bin , SF_z_LTT = bin_data (xd , SF_z_LTT , nbins )
233
+ yd_bin , SF_m_LTT = bin_data (yd , SF_m_LTT , nbins )
189
234
if scalar is not None :
190
235
xd_bin , SF_z_scalar = bin_data (xd , SF_z_scalar , nbins )
191
236
yd_bin , SF_m_scalar = bin_data (yd , SF_m_scalar , nbins )
192
- if traditional_order > 0 :
193
- xd_bin , SF_z_trad_scalar = bin_data (xd , SF_z_trad_scalar , nbins )
194
- yd_bin , SF_m_trad_scalar = bin_data (yd , SF_m_trad_scalar , nbins )
237
+ if traditional_type is not None :
238
+ if any ("LSS" in t for t in traditional_type ):
239
+ xd_bin , SF_z_LSS = bin_data (xd , SF_z_LSS , nbins )
240
+ yd_bin , SF_m_LSS = bin_data (yd , SF_m_LSS , nbins )
195
241
xd = xd_bin
196
242
yd = yd_bin
197
243
@@ -200,10 +246,14 @@ def generate_structure_functions( # noqa: C901, D417
200
246
"SF_advection_velocity_meridional" : SF_m ,
201
247
"SF_advection_scalar_zonal" : SF_z_scalar ,
202
248
"SF_advection_scalar_meridional" : SF_m_scalar ,
203
- "SF_traditional_velocity_zonal" : SF_z_trad_velocity ,
204
- "SF_traditional_velocity_meridional" : SF_m_trad_velocity ,
205
- "SF_traditional_scalar_zonal" : SF_z_trad_scalar ,
206
- "SF_traditional_scalar_meridional" : SF_m_trad_scalar ,
249
+ "SF_LL_zonal" : SF_z_LL ,
250
+ "SF_LL_meridional" : SF_m_LL ,
251
+ "SF_LLL_zonal" : SF_z_LLL ,
252
+ "SF_LLL_meridional" : SF_m_LLL ,
253
+ "SF_LTT_zonal" : SF_z_LTT ,
254
+ "SF_LTT_meridional" : SF_m_LTT ,
255
+ "SF_LSS_zonal" : SF_z_LSS ,
256
+ "SF_LSS_meridional" : SF_m_LSS ,
207
257
"x-diffs" : xd ,
208
258
"y-diffs" : yd ,
209
259
}
0 commit comments