src.superphot_plus.lightcurve
A data class for storing information for a single light curve.
Module Contents
Classes
A class for storing and manipulating a light curve. |
- class Lightcurve(times, fluxes, flux_errors, bands, name=None, sn_class=None, **kwargs)[source]
A class for storing and manipulating a light curve.
- _reindex(indices, in_place=True)[source]
Rearrange or subset the values in each array to match the ordering provided by indices.
- Parameters:
indices (array_like) – This can either be an array-like of integer indices to keep and the order in which to put them or an array-like of bools that indicate whether to keep each entry.
in_place (bool) – A Boolean indicating whether to modify the data in-place or make a new copy of the light curve.
- Returns:
result – The resulting Lightcurve. Returns self if in_place == True.
- Return type:
- obs_count(band=None)[source]
Return the count of observations (in a given band).
- Parameters:
band (str, optional) – The band to count. Use None to count all bands.
- Returns:
count – The observation count
- Return type:
int
- unique_bands()[source]
Return a list of unique bands in the data.
- Returns:
result – An array of the unique bands.
- Return type:
numpy array
- find_max_flux(error_coeff=-1.0, band=None)[source]
Find the value and timestamp of the maximum flux in a given band, accounting for the error estimate.
Uses value[t] = fluxes[t] + error_coeff * | flux_errors[t] |
- Parameters:
error_coeff (float) – The multiplicative constant to use when accounting for error. Default = -1.0 for flux - abs(error).
band (str, optional) – The band to check. Use None to find the maximum over all bands.
- Returns:
value, timestamp – Returns the maximum flux value and its corresponding time.
- Return type:
float, float
- Raises:
ValueError if the light curve is empty or there are no observations in the given band. –
- sort_by_time(in_place=True)[source]
Sort the data by timestamp.
- Parameters:
in_place (bool) – A Boolean indicating whether to modify the data in-place.
- Returns:
result – The padded lightcurve. Returns self if in_place == True.
- Return type:
- filter_by_band(keep_bands, in_place=True)[source]
Filter the light curve to keep only the specified bands.
- Parameters:
keep_bands (array-like) – An array of bands to include in the final data.
in_place (bool) – A Boolean indicating whether to modify the data in-place.
- Returns:
result – The filtered lightcurve. Returns self if in_place == True.
- Return type:
- band_as_int(ordered_bands, fail_on_missing=True)[source]
Returns the band array as integers corresponding to the band’s position in ordered_bands.
- Parameters:
ordered_bands (array_like) – The order in which to enumerate the bands.
fail_on_missing (bool) – Raise an exception if one of the bands is not included in the ordering.
- Returns:
result – The list of bands as integers. Uses -1 for unspecified bands.
- Return type:
array_like
- Raises:
ValueError if a band in the light curve is not included in ordered_bands –
and fail_on_missing is True. –
- pad_bands(bands, size, in_place=True)[source]
Truncate or pad the bands so that each band has exactly
sizeentries.- Parameters:
bands (array-like) – An array of bands to include in the final data.
size (int) – The required number of data points in each band.
in_place (bool) – A Boolean indicating whether to modify the data in-place.
- Returns:
result – The padded lightcurve. Returns self if in_place == True.
- Return type:
- save_to_file(filename, overwrite=False)[source]
Write the light curve to a file.
- Parameters:
filename (str) – The file name to use.
overwrite (bool, optional) – Overwrite existing files.
- Raises:
FileExistsError if the file exists and overwrite is False. –
- debug_string()[source]
Create and return a human readable debugging string.
- Returns:
res – The debugging string.
- Return type:
str
- classmethod from_file(filename, ref_band='r', t0_lim=None, shift_time=True)[source]
Create a Lightcurve object from a file.
- Parameters:
filename (str) – The name of the file to use.
ref_band (str) – The reference band to use. Default = ‘r’
t0_lim (float, optional) – Upper limit for t0. Defaults to None.
shift_time (bool) – Shift the time stamps so that the maximum flux in the reference band occurs at time = 0. Default = True.
- Return type:
A new Lightcurve object.
- Raises:
FileNotFoundError if the file does not exist. –