The stringlength method

The stringlength method is a technique to search for potentially nonsinusoidal, periodic variation in a data set. The idea consists to fold the data with a number of trial periods. Consecutive points in the phased data set are connected by hypothetical lines and the total length (the string length) is calculated. The strong length statistic assumes a minimum, when the folding produces a well ordered set. The stringlength method is described by in detail by Dworetsky 1983, MNRAS 203, 917-924.

Example: A string length analysis

import numpy as np
import matplotlib.pylab as plt
from PyAstronomy import pyTiming as pyt

period = 1.75

x = np.linspace(0, 10, 100)
y = 20 * np.sin(2*np.pi*x/period)
y += np.random.normal(0, 1, len(x))

# Trial periods to be tested (200 trial periods between 0.5 and 4.5;
# same units as x-axis)
tps = (0.5, 4.5, 200)

# Calculate string length
p, sl = pyt.stringlength_dat(x, y, tps)

# Show the string length. An alias at the double period
# (half frequency) is obvious.
plt.plot(p, sl, 'b.-')
plt.ylabel("String length")
plt.xlabel("Trial period")
plt.show()

Function documentation

PyAstronomy.pyTiming.stringlength_dat(x, m, tps, norm='default', isFreq=False, closed=True)

Compute string length for data set.

Parameters
x, marrays

x and y coordinates of data points.

tpstuple or array

The trial periods (or frequencies): Either a three-tuple specifying (pmin, pmax, nperiods) used by numpy’s linspace or an array of trial periods. If isFreq is True, tps is interpreted as frequencies.

isFreqboolean, optional

If True, the input tps will be assumed to refer to frequencies instead of periods.

normstring, {default, no}

If ‘default’ (default), the data points (mi) will be renormalized according to Eq. 3 in Dworetsky 1983, i.e., using mnew = (mi - min(m)) / (2*(max(m) - min(m))). If ‘no’ is specified, the data will not be changed.

closedboolean, optional

If True (default), first and last point on the phase axis will be connected (close the loop).

Returns
Trial periods/frequenciesarray

The tested periods (or frequencies if isFreq is True).

String lengtharray

Associated string lengths

PyAstronomy.pyTiming.stringlength_pm(p, m, norm='default', closed=True)

Compute the string length for phased data set.

Parameters
parray

The phase array (0-1). Sorted in ascending order.

marray

Data array

normstring, {default, no}

If ‘default’ (default), the data points (mi) will be renormalized according to Eq. 3 in Dworetsky 1983, i.e., using mnew = (mi - min(m)) / (2*(max(m) - min(m))). If ‘no’ is specified, the data will not be changed.

closedboolean, optional

If True (default), first and last point on the phase axis will be connected (close the loop).

Returns
slfloat

The string length

PyAstronomy.pyTiming.stringlength_norm(m, norm)

Normalize string length data set.

Parameters
marray

Data array

normstring, {default, no}

If ‘default’ (default), the data points (mi) will be renormalized according to Eq. 3 in Dworetsky 1983, i.e., using mnew = (mi - min(m)) / (2*(max(m) - min(m))). If ‘no’ is specified, the data will not be changed.

Returns
msarray

The normalized data