@@ -325,14 +325,21 @@ def radial_profiles(
325325
326326 _df .index = pd .to_datetime (_df .index )
327327 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
330338 obj .resampled_radial_profiles .append ({
331- 'values' : resampled [ 'value' ]. values ,
339+ 'values' : vals ,
332340 'norm_dist' : dist_perc ,
333341 'angle' : angle
334342 })
335- vals = resampled ['value' ].values
336343
337344 all_dist .update (dist_perc )
338345 all_angles .add (angle )
@@ -355,11 +362,11 @@ def radial_profiles(
355362 if not resample_bin_size_dist > 0 :
356363 obj .resampled_radial_profiles = obj .radial_profiles
357364
358-
359365 cols = [f'value_{ r } ' for r in range (len (obj .resampled_radial_profiles ))]
360366
361367 if concatenate_profiles :
362368 all_dist = [* [- d for d in all_dist ], * [d for d in all_dist ]]
369+ all_dist = list (set (all_dist ))
363370 else :
364371 all_dist = list (all_dist )
365372
@@ -374,15 +381,18 @@ def radial_profiles(
374381
375382 idx = profile ['norm_dist' ]
376383 # 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 ()
378388 is_saturated = np .max (profile ['values' ]) == max_dtype
379389 obj .radial_df ['is_saturated' ] = is_saturated
380390 if not concatenate_profiles :
381391 continue
382392
383393 # Find the closest -180 profile
384394 angle = profile ['angle' ]
385- opposite_angle = - angle
395+ opposite_angle = angle - np . sign ( angle ) * np . pi
386396 closest_angle_idx = np .argmin (np .abs (all_angles - opposite_angle ))
387397 closest_angle = all_angles [closest_angle_idx ]
388398 for ro , other_profile in enumerate (obj .resampled_radial_profiles ):
@@ -391,11 +401,13 @@ def radial_profiles(
391401
392402 other_idx = other_profile ['norm_dist' ]
393403 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 )
396406
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 )
399411
400412 radial_df = obj .radial_df [cols ]
401413 obj .mean_radial_profile = radial_df .mean (axis = 1 )
0 commit comments