IO¶
The IO module contains the primary methods for PBjam to process either a time series or power density spectrum from the user or an automatically downloaded data set from the Mikulski Archive for Spact Telescopes (https://archive.stsci.edu/home) via the Lightkurve package.
- class pbjam.IO.psd(ID, lk_kwargs={}, time=None, flux=None, flux_err=None, useWeighted=False, downloadDir=None, fit_mean=False, timeConversion=86400, badIdx=None, numax=None)[source]¶
Asteroseismology wrapper for Astropy Lomb-Scargle
Uses the Astropy.LombScargle class to compute the power spectrum of a given time series. A variety of choices for computing the spectrum are available. The recommended methods are either fast or Cython.
Notes
The Cython implementation is very slow for time series longer than about 1 month (array size of 1e5). The Fast implementation is similar to the an FFT, but at a very slight loss of accuracy. There appears to be a slight increasing slope with frequency toward the Nyquist frequency.
The adjustments to the frequency resolution, due to gaps, performed in the KASOC filter may not be beneficial the statistics we use in the detection algorithm. This has not been thuroughly tested yet though. So recommend leaving it in, but with a switch to turn it off for testing.
- Parameters:
time (array) – Time stamps of the time series.
flux (array) – Flux values of the time series.
flux_error (array) – Flux value errors of the time series.
fit_mean (bool, optional) – Keyword for Astropy.LombScargle. If True, uses the generalized Lomb-Scargle approach and fits with a floating mean. Default is False.
timeConversion (float) – Factor to convert the time series such that it is in seconds. Note, all stored time values, e.g. cadence or duration, are kept in the input units. Default is 86400 to convert from days to seconds.
- dt¶
Cadence of the time series.
- Type:
float
- dT¶
Total length of the time series.
- Type:
float
- NT¶
Number of data points in the time series.
- Type:
int
- dutyCycle¶
Duty cycle of the time series.
- Type:
float
- Nyquist¶
Nyquist frequency in Hz.
- Type:
float
- df¶
Fundamental frequency spacing in Hz.
- Type:
float
- ls¶
Astropy Lomb-Scargle class instance used in computing the power spectrum.
- Type:
astropy.timeseries.LombScargle object:
- indx¶
Mask array for removing nan and/or -inf values from the time series.
- Type:
array, bool
- freqHz¶
Frequency range in Hz.
- Type:
array, float
- freq¶
Freqeuency range in muHz.
- Type:
array, float
- normfactor¶
Normalization factor to ensure the power conforms with Parseval.
- Type:
float
- power¶
Power spectrum of the time series in ppm^2.
- Type:
array, float
- powerdensity¶
Power density spectrum of the time series in ppm^2/muHz
- Type:
array float
- amplitude¶
Amplitude spectrum of the time series in ppm.
- Type:
array, float
- __call__(oversampling=1, nyquist_factor=1.0, method='fast')[source]¶
Compute power spectrum
Computes the power spectrum and normalizes it to conform with Parseval’s theorem. The output is available as the power in ppm^2, powerdensity in ppm^2/muHz and the amplitude spectrum in ppm.
The frequency range is transformed to muHz as this is customarily used in asteroseismology of main sequence stars.
- Parameters:
oversampling (int) – The number of times the frequency range should be oversampled. This equates to zero-padding when using the FFT.
nyquist_factor (float) – Factor by which to extend the spectrum past the Nyquist frequency. The default is 10% greater than the true Nyquist frequency. We use this to get a better handle on the background level at high frequency.
method (str) – The recommended methods are either `fast’ or `Cython’. Cython is a bit more accurate, but significantly slower.
- getTSWindowFunction(tmin=None, tmax=None, cadenceMargin=1.01)[source]¶
Generates a time series window function.
- Parameters:
tmin (float, optional) – Minimum time value for padding. If None, uses the minimum of self.time. Default is None.
tmax (float, optional) – Maximum time value for padding. If None, uses the maximum of self.time. Default is None.
cadenceMargin (float, optional) – Margin factor to identify gaps in the time series. Default is 1.01.
- Returns:
A tuple containing the adjusted time array and the corresponding window function array.
- Return type:
tuple
Notes
The method first initializes the time (t) and window function (w) arrays.
It then identifies gaps in the time series larger than cadenceMargin * self.dt
and fills them with zeros in the window function. - The method ensures the length of the time series does not exceed a break counter of 100 to avoid infinite loops. - Padding is added at the start and end of the time series if tmin or tmax are specified and exceed the current bounds of t.