1313from .logging import setup_log
1414from .calibrations import Calibrations
1515import logging
16+
17+ from .plotting import plot_ts
18+
1619setup_log ()
1720
1821LOG = logging .getLogger ('study_lyte.profile' )
@@ -360,6 +363,9 @@ def acceleration(self):
360363 if self .motion_detect_name != Sensor .UNAVAILABLE :
361364 # Remove gravity
362365 self ._acceleration = get_neutral_bias_at_border (self .raw [self .motion_detect_name ])
366+ # from study_lyte.plotting import plot_ts
367+ # ax = plot_ts(self._acceleration, show=False)
368+ # ax = plot_ts(self.raw[self.motion_detect_name], ax=ax, show=True)
363369 else :
364370 self ._acceleration = Sensor .UNAVAILABLE
365371 return self ._acceleration
@@ -390,6 +396,7 @@ def barometer(self):
390396 baro = baro .set_index ('time' )['baro' ]
391397
392398 if self .accelerometer != Sensor .UNAVAILABLE :
399+ # TODO: WHATS GOING ON HERE?
393400 idx = abs (self .accelerometer .depth - - 1 ).argmin ()
394401 else :
395402 idx = self .start .index
@@ -405,6 +412,7 @@ def depth(self):
405412 if self .motion_detect_name != Sensor .UNAVAILABLE and self .depth_method != 'barometer' :
406413 # User requested fused
407414 if self .depth_method == 'fused' :
415+ LOG .info ("Using fused sensors to compute depth." )
408416 depth = self .fuse_depths (self .accelerometer .depth .values .copy (),
409417 self .barometer .depth .values .copy (),
410418 error = self .error .index )
@@ -419,11 +427,16 @@ def depth(self):
419427
420428 else :
421429 self ._depth = pd .Series (data = depth , index = self .raw ['time' ])
430+
422431 # User requested accelerometer
423432 elif self .depth_method == 'accelerometer' :
433+ LOG .info ("Using accelerometer alone to compute depth." )
424434 self ._depth = self .accelerometer .depth
425435 else :
436+ LOG .info ("Using barometer alone to compute depth." )
426437 self ._depth = self .barometer .depth
438+
439+ # Assign positions of each event detected
427440 self .assign_event_depths ()
428441
429442 return self ._depth
@@ -590,6 +603,8 @@ def report_card(self):
590603 profile_string += msg .format ('Snow Depth' , f'{ self .distance_through_snow :0.1f} cm' )
591604 profile_string += msg .format ('Ground Strike:' , 'True' if self .ground .time is not None else 'False' )
592605 profile_string += msg .format ('Upward Motion:' , "True" if self .has_upward_motion else "False" )
606+ if self .angle != Sensor .UNAVAILABLE :
607+ profile_string += msg .format ('Angle:' , int (self .angle ))
593608 profile_string += msg .format ('Errors:' , f'@ { self .error .time :0.1f} s' if self .error .time is not None else 'None' )
594609
595610 profile_string += '-' * (len (header )- 2 ) + '\n '
@@ -629,7 +644,10 @@ def fuse_depths(cls, acc_depth, baro_depth, error=None):
629644 sensor_diff = abs (acc_bottom ) - abs (baro_bottom )
630645 delta = 0.572 * abs (acc_bottom ) + 0.308 * abs (baro_bottom ) + 0.264 * sensor_diff + 8.916
631646 # delta = (acc_bottom * (5 - scale) + baro_bottom * scale) / 5
632- avg = (avg / avg_bottom ) * - 1 * delta
647+ avg = (avg / avg_bottom ) * - 1 * delta
648+ # from study_lyte.plotting import plot_ts
649+ # ax = plot_ts(avg, show=True)
650+
633651 return avg
634652
635653 @property
@@ -639,7 +657,7 @@ def angle(self):
639657 """
640658 if self ._angle is None and self .acceleration_names != Sensor .UNAVAILABLE :
641659 if 'Y-Axis' in self .acceleration_names :
642- data = self .raw [self .acceleration_names ].iloc [0 :self .start .index ].mean (axis = 0 )
660+ data = self .raw [self .acceleration_names ].iloc [0 :self .start .index + 1 ].mean (axis = 0 )
643661 magn = data .pow (2 ).sum ()** 0.5
644662 self ._angle = np .arccos (abs (data ['Y-Axis' ]) / magn ) * 180 / np .pi
645663 else :
0 commit comments