Skip to content

Commit 9d06733

Browse files
Fix docstrings [docs only]
1 parent e867a1c commit 9d06733

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

stingray/crossspectrum.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2381,7 +2381,7 @@ def trace_maximum(self, min_freq=None, max_freq=None):
23812381
return np.array(max_positions)
23822382

23832383
def shift_and_add(self, f0_list, nbins=100, output_obj_type=AveragedCrossspectrum, rebin=None):
2384-
"""Shift and add the dynamical power spectrum.
2384+
"""Shift and add the dynamical cross spectrum.
23852385
23862386
This is the basic operation for the shift-and-add operation used to track
23872387
kHz QPOs in X-ray binaries (e.g. Méndez et al. 1998, ApJ, 494, 65).
@@ -2404,6 +2404,10 @@ def shift_and_add(self, f0_list, nbins=100, output_obj_type=AveragedCrossspectru
24042404
rebin : int, default None
24052405
Rebin the final spectrum by this factor. At the moment, the rebinning
24062406
is linear.
2407+
output_obj_type : class, default :class:`AveragedCrossspectrum`
2408+
The type of the output object. Can be, e.g. :class:`AveragedCrossspectrum` or
2409+
:class:`AveragedPowerspectrum`.
2410+
24072411
Returns
24082412
-------
24092413
output: :class:`AveragedPowerspectrum` or :class:`AveragedCrossspectrum`

stingray/powerspectrum.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,52 @@ def __init__(self, lc=None, segment_size=None, norm="frac", gti=None, sample_tim
10491049
self._make_matrix(lc)
10501050

10511051
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+
"""
10521098
return super().shift_and_add(
10531099
f0_list, nbins=nbins, output_obj_type=AveragedPowerspectrum, rebin=rebin
10541100
)

0 commit comments

Comments
 (0)