Lightspeedpy API

class lightspeedpy.DataSet(filenames, **kwargs)

Bases: object

Contains metadata relating to one contiguous LightSpeed observation. The data set is never loaded into memory, so many-GB observations can be treated.

There are three ways to initialize a DataSet:

  1. Use DataSet.from_first() to create a data set of all files in the capture

  2. Use DataSet.from_dir() to create a data set out of all the files in a directory

  3. Use the constructor and pass all the files you want to be in the data set as a parameter.

Parameters:
  • filenames (list of str) – List of files to include

  • cut_cr (bool, optional) – Set to False to no longer cut CRs.

apply_timing_offset(timing_offset=0)

Apply a timing offset to the data set. Now, a frame read at timing_offset will be treated as having time 0.

Parameters:

timing_offset (float) – Time offset, in seconds

bootstrap()

Resamples the file names for use in bootstrapping. If you want to estimate uncertainties, redo your analysis with many DataSet.bootstrap()’ed data sets and calculate the standard deviation of your results.

Notes

You should never bootstrap a data set twice. Instead, you should always create a copy of the original data set with copy.deepcopy and then bootstrap the copy.

display_filenames()

Print all the filenames in the data set

from_dir(**kwargs)

Create a DataSet for all files in a directory

Parameters:

directory (str) – name of the directory

:keyword See DataSet:

from_first(min_index=None, max_index=None, **kwargs)

Create a DataSet for all files in a capture

Parameters:
  • filename (str) – name of a file in the capture

  • min_index (int, optional) – Minimum cube index to use. Default: the lowest that was downloaded

  • max_index (int, optional) – Maximum cube index to use. Default: the highest that was downloaded

:param See DataSet:

iterator(**kwargs)

Create an iterator for iterating through all frames in a DataSet.

:keyword The default keyword arguments are the ones you passed when you created the DataSet.: :keyword You can override the defaults by passing new arguments here. You can also pass the following: :keyword max_frames: Maximum number of frames to iterate through. Default: all the frames :kwtype max_frames: int, optional :keyword use_bar: Show a progress bar. Default: True. :kwtype use_bar: bool, optional

Notes

for frame in data_set.iterator() is equivalent to for frame in data_set.

num_frames()

Counts the number of frames in the data set

Returns:

The number of frames in the data set

Return type:

int

property pixel_properties

PixelProperties Pixel properties of the data set

set_bias(bias)

Set the bias

Parameters:

bias (DataSet or PixelProperties) – A DataSet containing the bias observation, or the PixelProperties of the observation

set_dark(dark_data_set)

Set the dark

Parameters:

dark_data_set (DataSet) – A DataSet containing the dark observation

set_flat(flat_data_set)

Set the flat

Parameters:

flat_data_set (DataSet) – A DataSet containing the flat observation

set_self_bias()

Estimate an observation from these data. This can only be done accurately for very fast readout of a faint source, where most of the pixels detect zero photons.

stack(**kwargs)

Obtain the average image of the data cube.

Returns:

The average image of the cube, in electrons.

Return type:

array-like

Notes

Same keyword arguments as DataSet. For keyword arguments you do not provide, the values you passed to the data set constructor will be used.

class lightspeedpy.Ephemeris(parfile, data_set, observatory='LCO')

Bases: object

Class to contain a PINT ephemeris and assign phases to lightspeed data. Ephemerides are saved in the lightspeedpy/tmp directory so that they don’t have to be recomputed.

Parameters:
  • parfile (str) – File name of the PINT ephemeris file

  • data_set (DataSet) – The data set to create timestamps for

  • observatory (str, optional) – Observatory where Lightspeed was. Default: LCO

get_phase(time)

Returns the phase (0 to 1) corresponding to a specific time

class lightspeedpy.Frame(image, timestamp, duration)

Bases: object

image

Contains the frame image in units of electrons. If darks and biases were set, they are already subtracted. The flat was not included, nor the QE

Type:

array-like

timestamp

Time in seconds after camera start

Type:

float

duration

Frame time in seconds

Type:

float

class lightspeedpy.PixelProperties(bias, widths, skew, source_data_set, dest_data_set)

Bases: object

Biases and noise of each pixel in the data set. Use PixelProperties.from_data() or PixelProperties.from_bias() to create it.

bias

Image of biases of each pixel

Type:

array-like

widths

Noises in each pixel, defined as the standard deviation of the Gaussian error approximation.

Type:

array-like

default()

Get the default pixel properties for a data set with no bias and not self-biased.

from_bias(dest_data_set)

Get the pixel properties of a bias data set

from_data(dest_data_set)

Get the pixel properties of a faint, rapid readout data set

get_prob(image, true_n, mask=None)

Get the probability for the observed counts to have been produced given a true source count.

Parameters:
  • image (array-like) – Detected image (e.g. from frame.image)

  • true_n (int) – True number of counts

  • mask (array of bool, optional) – If you only wish to get probabilities for a subset of the full image, provide that subset as the iamge argument and supply the pixel mask here.

Return type:

array-like

The probability for each pixel to have originated from the given true source count.

load()
save(filename, clobber)

Save the pixel properties to a file

Parameters:

filename (str) – Name of the output file

class lightspeedpy.Region(filename)

Bases: object

Class to store DS9 regions.

Notes

  • All regions are assumed to be stored in ciao format.

  • All coordinates must be physical

check_inside_absolute(x, y)

Return True if (x, y) is inside the region

load()

Load a region from a region file

Parameters:

filename (str) – File name of the region

Returns:

Region object

Return type:

Region

lightspeedpy.add_dataset_args(parser)

Add the standard lightspeedpy arguments to an argparse parser. These include input, output, bias, self-bias, flat, flat, frames, timing-offset, and clobber.

Parameters:

parser (argparse parser) – Parser to which to add arguments

lightspeedpy.get_dataset(args)

Get the DataSet from an argparse parser, assuming the arguments correspond to those created by cli.add_dataset_args().

Parameters:

args (argparse args) – Command line arguments

lc subpackage

image subpackage