@@ -1049,6 +1049,52 @@ def __init__(self, lc=None, segment_size=None, norm="frac", gti=None, sample_tim
1049
1049
self ._make_matrix (lc )
1050
1050
1051
1051
def shift_and_add (self , f0_list , nbins = 100 , rebin = None ):
1052
+ """Shift-and-add the dynamical power spectrum.
1053
+
1054
+ This is the basic operation for the shift-and-add operation used to track
1055
+ kHz QPOs in X-ray binaries (e.g. Méndez et al. 1998, ApJ, 494, 65).
1056
+
1057
+ Parameters
1058
+ ----------
1059
+ freqs : np.array
1060
+ Array of frequencies, the same for all powers. Must be sorted and on a uniform
1061
+ grid.
1062
+ power_list : list of np.array
1063
+ List of power spectra. Each power spectrum must have the same length
1064
+ as the frequency array.
1065
+ f0_list : list of float
1066
+ List of central frequencies
1067
+
1068
+ Other parameters
1069
+ ----------------
1070
+ nbins : int, default 100
1071
+ Number of bins to extract
1072
+ rebin : int, default None
1073
+ Rebin the final spectrum by this factor. At the moment, the rebinning
1074
+ is linear.
1075
+
1076
+ Returns
1077
+ -------
1078
+ output: :class:`AveragedPowerspectrum`
1079
+ The final averaged power spectrum.
1080
+
1081
+ Examples
1082
+ --------
1083
+ >>> power_list = [[2, 5, 2, 2, 2], [1, 1, 5, 1, 1], [3, 3, 3, 5, 3]]
1084
+ >>> power_list = np.array(power_list).T
1085
+ >>> freqs = np.arange(5) * 0.1
1086
+ >>> f0_list = [0.1, 0.2, 0.3, 0.4]
1087
+ >>> dps = DynamicalPowerspectrum()
1088
+ >>> dps.dyn_ps = power_list
1089
+ >>> dps.freq = freqs
1090
+ >>> dps.df = 0.1
1091
+ >>> dps.m = 1
1092
+ >>> output = dps.shift_and_add(f0_list, nbins=5)
1093
+ >>> assert isinstance(output, AveragedPowerspectrum)
1094
+ >>> assert np.array_equal(output.m, [2, 3, 3, 3, 2])
1095
+ >>> assert np.array_equal(output.power, [2. , 2. , 5. , 2. , 1.5])
1096
+ >>> assert np.allclose(output.freq, [0.05, 0.15, 0.25, 0.35, 0.45])
1097
+ """
1052
1098
return super ().shift_and_add (
1053
1099
f0_list , nbins = nbins , output_obj_type = AveragedPowerspectrum , rebin = rebin
1054
1100
)
0 commit comments