py4py.reverb.timeseries.process
Timeseries internal processing module
|
Simple linear interpolation function |
Given a spectrum table with 'wave_min' and 'wave_max' columns, |
|
|
Generates the response function for a system. |
|
Generates the base spectra for each timestep. |
|
Generates the timesteps to evaluate the TF at and the change in continuum at each |
|
When passed a timeseries of spectra, finds the outermost extent of the flux envelope (minimum and maximum values), |
|
Generates synthetic spectra from a base spectrum, transfer function, and varying continuum. |
|
Given a finished timeseries of spectra, produce the total line emission at each observation |
|
Given a timeseries of spectra, generates random errors of magnitude dependent on the luminosity variation within it. |
|
Spectra error are calculated from minimum to maximum line variation. |
|
Given a timeseries of spectra with an 'error' column, creates a copy and |
Module Contents
- py4py.reverb.timeseries.process.interpolation_across_range(x: numpy.typing.NDArray[numpy.floating], y: numpy.typing.NDArray[numpy.floating], x_int: float) float
Simple linear interpolation function
- Parameters:
x (numpy.typing.NDArray[numpy.floating]) – X values
y (numpy.typing.NDArray[numpy.floating]) – Y values
x_int (float) – X to find Y for
- Returns:
Linear interpolation of Y for x_int
- Return type:
float
- py4py.reverb.timeseries.process.generate_spectrum_bounds(spectrum: astropy.table.Table) numpy.typing.NDArray[numpy.floating]
Given a spectrum table with ‘wave_min’ and ‘wave_max’ columns, returns the full list of bins.
- Parameters:
spectrum (astropy.table.Table) – The table in Python output format
- Returns:
The bounds
- Return type:
numpy.typing.NDArray[numpy.floating]
- py4py.reverb.timeseries.process.generate_tf(databases: dict, spectrum: astropy.table.Table, delay_bins: int, line: int, wave: float, name: str, limit: int = 999999999, dynamic_range: float = 2, observer: int | None = None, velocity: bool | None = False) py4py.reverb.TransferFunction
Generates the response function for a system.
- Parameters:
databases (dict) – Dictionary of ‘min’, ‘mid’ and ‘max’ data, each containing a dictionary with ‘path’ (to the file), ‘continuum’ (the continuum used in creation) and ‘scale’ (number of spectral cycles used)
spectrum (Table) – Spectrum to template the wavelength bins off of
delay_bins (int) – Number of bins to bin delays by
line (int) – Python line number to select
dynamic_range (float) – Truncates the time axis to include 100 - 10^(-dynamic range)`% of the photons. E.g. dynamic_range=2 includes 99% of photons. Used as some models have very long tails.
wave (float) – Frequency of the line selected (in A)
name (str) – Name of the output files.
limit (int) – Number of photons to limit the DB query to. Set low for testing.
observer (int) – Which observer (if several) to use.
velocity (bool) – Whether to plot in velocity space or not.
- Returns:
The response-mapped transfer function.
- Return type:
- Outputs:
{name}_min.eps: Transfer function plot for minimum {name}.eps: Transfer function plot for midpoint {name}_max.eps: Transfer function plot for maximum {name}_resp.eps: Response function for minimum
- py4py.reverb.timeseries.process.generate_spectra_base(spectrum: astropy.table.Table, spectra_times: astropy.table.Table) astropy.table.Table
Generates the base spectra for each timestep.
- Parameters:
spectrum (Table) – The base, unmodified spectrum used for the output time series
spectra_times (Table) – Times to produce a spectrum for
- Returns:
With one spectrum per target spectra time, keyed by the times
- Return type:
Table
- py4py.reverb.timeseries.process.generate_times_and_delta_continuum(transfer_function: py4py.reverb.TransferFunction, lightcurve: astropy.table.Table, delay_max: float | None = None) astropy.table.Table
Generates the timesteps to evaluate the TF at and the change in continuum at each
- Parameters:
transfer_function (TransferFunction) – The TF
lightcurve (Table) – The lightcurve base used for this.
delay_max (float) – The maximum delay to generate the delta continuum for
- Returns:
Time domain broken down into small steps
- Return type:
times (np.array)
- py4py.reverb.timeseries.process.generate_spectra_min_max(times: astropy.table.Table, transfer_function: py4py.reverb.TransferFunction, spectra: astropy.table.Table, spectrum: astropy.table.Table, continuum_fit: numpy.poly1d | None = None)
When passed a timeseries of spectra, finds the outermost extent of the flux envelope (minimum and maximum values), and modifies the timeseries of spectra to add that as columns.
- Parameters:
times (Table) – The list of times to take spectra and the associated delta continuum for that time
transfer_function (TransferFunction) – The response function of the system
spectra (Table) – The base spectrum in Python format
spectrum (Table) – The time series of spectra
continuum_fit (Optional[poly1d]) – A function that describes the background continuum as a function of wavelength
- Returns:
None
- py4py.reverb.timeseries.process.generate_spectra_details(times: astropy.table.Table, transfer_function: py4py.reverb.TransferFunction, spectra: astropy.table.Table, spectrum: astropy.table.Table, continuum_fit: numpy.poly1d | None = None, calculate_error: bool | None = False, error_over_variation: float | None = 0.01, verbose: bool | None = True)
Generates synthetic spectra from a base spectrum, transfer function, and varying continuum.
- Parameters:
times (Table) – A table containing the timesteps the time-series should be evaluated over
transfer_function (TransferFunction) – The TF containing the response function to use
spectra (Table) – The output table for the finished timeseries
spectrum (Table) – A table containing the spectrum to use as the base for the time-series
continuum_fit (poly1d) – If this is a continuuum-subtracted timeseries, the function that describes the continuum
calculate_error (Optional[bool]) – Whether or not we should calculate the error on the timeseries steps
error_over_variation (Optional[float]) – If calculating error, what should be the target integrated line error over the line variation range
verbose (Optional[bool]) – Whether or not to print out info messages
- Returns:
None.
- py4py.reverb.timeseries.process.generate_times_line_emission(spectra: astropy.table.Table, spectra_times: astropy.table.Table, verbose: bool = False)
Given a finished timeseries of spectra, produce the total line emission at each observation
- Parameters:
spectra (Table) – The time-series of spectra
spectra_times (Table) – The times at which the spectra are taken (i.e. the fake observations)
verbose (bool) – Whether or not to report on the total line variation
- Returns:
A table with the line emission for each timestep
- Return type:
Table
- py4py.reverb.timeseries.process.generate_spectra_error(spectra: astropy.table.Table, error: float = 0.01, fudge_factor: float = 1.0)
Given a timeseries of spectra, generates random errors of magnitude dependent on the luminosity variation within it.
- Parameters:
spectra (Table) – A timeseries of spectra.
error (float) – The ratio of error on the spectrum to the variation in luminosity within it.
fudge_factor (float) – A scaling factor.
- Returns:
A copy of the spectra table with errors applied.
- py4py.reverb.timeseries.process.copy_spectra_error(origin: astropy.table.Table, target: astropy.table.Table, rescale: bool = False)
Spectra error are calculated from minimum to maximum line variation. This doesn’t really work well in situations where the variation is low due to a mixed positive-negative response function. So we instead copy across the errors from another timeseries, rescaling if necessary.
- Parameters:
origin (Table) – The timeseries of spectra with errors.
target (Table) – The timeseries of spectra that we want to copy the errors to
rescale (bool) – Optionally, whether to rescale the errors to be proportionally the same, rather than absolutely the same.
- Returns:
Copy of the ‘target’ timeseries with errors applied
- py4py.reverb.timeseries.process.apply_spectra_error(spectra: astropy.table.Table)
Given a timeseries of spectra with an ‘error’ column, creates a copy and applies random normally-distributed errors to the values at each timestep.
- Parameters:
spectra (Table) – A timeseries of spectra, with timesteps as columns 5+.
- Returns:
A copy of the input spectra with the errors applied
- Return type:
Table