@@ -325,14 +325,21 @@ def radial_profiles(
325
325
326
326
_df .index = pd .to_datetime (_df .index )
327
327
rs = f'{ resample_bin_size_dist } ns'
328
- resampled = _df .resample (rs , label = 'right' ).mean ().dropna ()
329
- dist_perc = resampled .index .astype (np .int64 )
328
+ bin_place = 'left' if concatenate_profiles else 'right'
329
+ resampled = _df .resample (rs , label = bin_place ).mean ().dropna ()
330
+ resampled ['dist_perc' ] = resampled .index .astype (np .int64 )
331
+ if not use_absolute_dist and resampled ['dist_perc' ].max () > 100 :
332
+ outer_mean_val = resampled [resampled ['dist_perc' ]>= 100 ].mean ()
333
+ outer_mean_val ['dist_perc' ] = 100
334
+ resampled = resampled [resampled ['dist_perc' ]<= 100 ]
335
+ resampled .iloc [- 1 ] = outer_mean_val
336
+ vals = resampled ['value' ].values
337
+ dist_perc = resampled ['dist_perc' ].values
330
338
obj .resampled_radial_profiles .append ({
331
- 'values' : resampled [ 'value' ]. values ,
339
+ 'values' : vals ,
332
340
'norm_dist' : dist_perc ,
333
341
'angle' : angle
334
342
})
335
- vals = resampled ['value' ].values
336
343
337
344
all_dist .update (dist_perc )
338
345
all_angles .add (angle )
@@ -355,11 +362,11 @@ def radial_profiles(
355
362
if not resample_bin_size_dist > 0 :
356
363
obj .resampled_radial_profiles = obj .radial_profiles
357
364
358
-
359
365
cols = [f'value_{ r } ' for r in range (len (obj .resampled_radial_profiles ))]
360
366
361
367
if concatenate_profiles :
362
368
all_dist = [* [- d for d in all_dist ], * [d for d in all_dist ]]
369
+ all_dist = list (set (all_dist ))
363
370
else :
364
371
all_dist = list (all_dist )
365
372
@@ -374,15 +381,18 @@ def radial_profiles(
374
381
375
382
idx = profile ['norm_dist' ]
376
383
# obj.radial_df[f'value_{r}'] = np.nan
377
- obj .radial_df .loc [idx , f'value_{ r } ' ] = profile ['values' ]
384
+ try :
385
+ obj .radial_df .loc [idx , f'value_{ r } ' ] = profile ['values' ]
386
+ except Exception as err :
387
+ import pdb ; pdb .set_trace ()
378
388
is_saturated = np .max (profile ['values' ]) == max_dtype
379
389
obj .radial_df ['is_saturated' ] = is_saturated
380
390
if not concatenate_profiles :
381
391
continue
382
392
383
393
# Find the closest -180 profile
384
394
angle = profile ['angle' ]
385
- opposite_angle = - angle
395
+ opposite_angle = angle - np . sign ( angle ) * np . pi
386
396
closest_angle_idx = np .argmin (np .abs (all_angles - opposite_angle ))
387
397
closest_angle = all_angles [closest_angle_idx ]
388
398
for ro , other_profile in enumerate (obj .resampled_radial_profiles ):
@@ -391,11 +401,13 @@ def radial_profiles(
391
401
392
402
other_idx = other_profile ['norm_dist' ]
393
403
obj .radial_df .loc [- other_idx , f'value_{ r } ' ] = other_profile ['values' ]
394
- profiles_conctenated_idx .add (ro )
395
-
404
+ profiles_conctenated_idx .add (ro )
405
+ profiles_conctenated_idx . add ( r )
396
406
397
- obj .radial_df .sort_index (inplace = True )
398
- obj .radial_df = obj .radial_df .astype (float )
407
+ obj .radial_df = (
408
+ obj .radial_df .dropna (axis = 1 , how = 'all' ).sort_index ().astype (float )
409
+ )
410
+ cols = obj .radial_df .columns .intersection (cols )
399
411
400
412
radial_df = obj .radial_df [cols ]
401
413
obj .mean_radial_profile = radial_df .mean (axis = 1 )
0 commit comments