Phot

Phot#

This is the API for the Phot module.

Module to read in and manipulate photometric data.

class coPsi.Phot.Data(file=None, x=array([], dtype=float64), y=array([], dtype=float64), dy=None, cadence=None, figsize=(10, 6))#

Photometric data.

Read and prepare photometric data for which to calculate the stellar rotation period.

Data constructor initialized with either filename for data in a .txt file, or by setting x (time) and y (flux) directly (and dy, error).

Parameters:
  • file (str) – Filename. Optional, default None.

  • x (array) – Time.

  • y (array) – Flux.

  • dy (array) – Flux error.

  • cadence – Cadence for observations. Optional, default None. If None calculated from getCadence()

  • cadence – float

appendData(x, y, dy=None, atzero=True)#

Append data

Append data to the existing data.

Parameters:
  • x (array) – Time.

  • y (array) – Flux.

  • dy (array) – Flux error. Optional, default None.

bin2cadence(cadence)#

Bin to cadence

Bin the data to a given cadence.

Parameters:

cadence (float) – Cadence for observations. Unit same as self.x.

fillGaps(gap=0.5, yfill=None, cadence=None)#

Fill gaps

Fill the gaps in the data by simply putting in the median of the observations by default.

Parameters:
  • gap (float) – Value to consider a gap in days. Optional, default 0.5.

  • yfill (float) – Values to put in gaps. Optional, default None. If None median is used.

  • cadence – Cadence for observations. Optional, default None. If None calculated from getCadence()

  • cadence – float

filterData(window=5001, poly=3)#

Savitsky-Golay filter

Using scipy.signal.savgol_filter().

Parameters:
  • window (int) – Length of window for filter. Optional, default 5001.

  • poly (int) – Degree for polynomial. Optional, default 3.

getCadence()#

Calculate cadence

Calculated as the median of the difference between timestamps.

maxTime(tolGap=5)#

Maximum timeseries length

Find the maximum timeseries length between gaps exceeding tolGap days.

Parameters:

tolGap (float) – Value to consider a gap in days. Optional, default 5.

plotData(ax=None, dots=1, return_ax=0, font=12, usetex=False)#

Plot the data

Parameters:
  • ax (matplotlib.axes._subplots.AxesSubplot) – Axis in which to plot the KDE. Optional, default None, figure and axis will be created.

  • dots (bool) – Whether to use dots instead of lines in plot. Optional, default 1.

  • return_ax (bool) – Whether to return ax. Optional, default 0.

  • font (float) – Fontsize for labels. Optional, default 12.

  • usetex (bool) – Whether to use LaTeX in plots. Optional, default False.

prepData(file=None, window=8001, poly=3, gap=0.5, yfill=None, cadence=None)#

Prepare data.

Collection of calls to readData(), filterData(), and fillGaps()

readData(file, atzero=True)#

Data from .txt file

# time

flux

error

t1

fl1

efl1

t2

fl2

efl2

tn

fln

efln

Parameters:
  • file (str) – Filename.

  • atzero (bool) – Whether to set the first time stamp to zero. Optional, default True.