@@ -153,51 +153,51 @@ def test_bulk_statistics_missing_segments():
153
153
### Test 2D data with time dimension
154
154
test_data = tb_test .make_simple_sample_data_2D ().core_data ()
155
155
common_dset_opts = {
156
- "in_arr" : test_data ,
157
- "data_type" : "iris" ,}
158
-
156
+ "in_arr" : test_data ,
157
+ "data_type" : "iris" ,
158
+ }
159
+
159
160
test_data_iris = tb_test .make_dataset_from_arr (
160
- time_dim_num = 0 , y_dim_num = 1 , x_dim_num = 2 , ** common_dset_opts )
161
+ time_dim_num = 0 , y_dim_num = 1 , x_dim_num = 2 , ** common_dset_opts
162
+ )
161
163
162
164
# detect features
163
165
threshold = 7
164
166
# test_data_iris = testing.make_dataset_from_arr(test_data, data_type="iris")
165
167
fd_output = tobac .feature_detection .feature_detection_multithreshold (
166
- test_data_iris ,
167
- dxy = 1000 ,
168
- threshold = [threshold ],
169
- n_min_threshold = 100 ,
170
- target = "maximum" ,)
168
+ test_data_iris ,
169
+ dxy = 1000 ,
170
+ threshold = [threshold ],
171
+ n_min_threshold = 100 ,
172
+ target = "maximum" ,
173
+ )
171
174
172
175
# perform segmentation with bulk statistics
173
176
stats = {
174
- "segment_max" : np .max ,
175
- "segment_min" : min ,
176
- "percentiles" : (np .percentile , {"q" : 95 }),}
177
+ "segment_max" : np .max ,
178
+ "segment_min" : min ,
179
+ "percentiles" : (np .percentile , {"q" : 95 }),
180
+ }
177
181
178
182
out_seg_mask , out_df = tobac .segmentation .segmentation_2D (
179
- fd_output , test_data_iris , dxy = 1000 , threshold = threshold )
183
+ fd_output , test_data_iris , dxy = 1000 , threshold = threshold
184
+ )
180
185
181
- # specify some timesteps we set to zero
186
+ # specify some timesteps we set to zero
182
187
timesteps_to_zero = [1 , 3 , 10 ] # 0-based indexing
183
- modified_data = out_seg_mask .data .copy ()
188
+ modified_data = out_seg_mask .data .copy ()
184
189
# Set values to zero for the specified timesteps
185
190
for timestep in timesteps_to_zero :
186
191
modified_data [timestep , :, :] = 0 # Set all values for this timestep to zero
187
192
188
193
# assure that bulk statistics in postprocessing give same result
189
194
out_segmentation = tb_utils .get_statistics_from_mask (
190
- out_df , out_seg_mask , test_data_iris , statistic = stats )
195
+ out_df , out_seg_mask , test_data_iris , statistic = stats
196
+ )
191
197
192
198
assert out_df .time .unique ().size == out_segmentation .time .unique ().size
193
199
194
200
195
-
196
-
197
-
198
-
199
-
200
-
201
201
def test_bulk_statistics_multiple_fields ():
202
202
"""
203
203
Test that multiple field input to bulk_statistics works as intended
0 commit comments