710 durations = [dt.seconds for dt in time_diff] |
710 durations = [dt.seconds for dt in time_diff] |
711 # Assume the last two profiles have the same duration |
711 # Assume the last two profiles have the same duration |
712 duration = np.array(durations) |
712 duration = np.array(durations) |
713 return duration |
713 return duration |
714 |
714 |
715 def calculate_rc(self, idx_min=4000, idx_max=5000): |
715 def calculate_rc(self, idx_min=-2000, idx_max=-500): |
716 """ Calculate range corrected signal. |
716 """ Calculate range corrected signal. |
717 |
717 |
718 The background signal is estimated as the mean signal between idx_min and idx_max. |
718 The background signal is estimated as the mean signal between idx_min and idx_max. |
719 |
719 |
720 The calculations is stored in the self.rc parameters. |
720 The calculations is stored in the self.rc parameters. |
724 idx_min : int |
724 idx_min : int |
725 Minimum index to calculate background signal. |
725 Minimum index to calculate background signal. |
726 idx_max : int |
726 idx_max : int |
727 Maximum index to calculate background signal. |
727 Maximum index to calculate background signal. |
728 """ |
728 """ |
729 background = np.mean(self.matrix[:, idx_min:idx_max], axis=1) # Calculate the background from 30000m and above |
729 background = np.mean(self.matrix[:, idx_min:idx_max], axis=1) |
730 self.rc = (self.matrix.transpose() - background).transpose() * (self.z ** 2) |
730 self.rc = (self.matrix.transpose() - background).transpose() * (self.z ** 2) |
|
731 |
|
732 def noise_mask(self, idx_min=-2000, idx_max=-500, threshold=1.): |
|
733 """ Calculate points that are probably noise. |
|
734 |
|
735 To calculate this, we find the max value of the background region. Then we reject all points that |
|
736 are less than `threshold` times this value. |
|
737 Parameters |
|
738 ---------- |
|
739 idx_min : int |
|
740 Minimum index to calculate background signal. |
|
741 idx_max : int |
|
742 Maximum index to calculate background signal. |
|
743 threshold : float |
|
744 Threshold value. |
|
745 """ |
|
746 background_max = np.max(self.matrix[:, idx_min:idx_max], axis=1) |
|
747 background_mean = np.mean(self.matrix[:, idx_min:idx_max], axis=1) |
|
748 mean_to_max = background_max - background_mean |
|
749 |
|
750 noise_limit = background_mean + mean_to_max * threshold |
|
751 |
|
752 mask = self.matrix <= noise_limit[:, np.newaxis] |
|
753 |
|
754 return mask |
731 |
755 |
732 def update(self): |
756 def update(self): |
733 """ |
757 """ |
734 Update the time parameters and data according to the raw input data. |
758 Update the time parameters and data according to the raw input data. |
735 """ |
759 """ |