py4py.reverb.timeseries.process =============================== .. py:module:: py4py.reverb.timeseries.process .. autoapi-nested-parse:: Timeseries internal processing module .. autoapisummary:: py4py.reverb.timeseries.process.interpolation_across_range py4py.reverb.timeseries.process.generate_spectrum_bounds py4py.reverb.timeseries.process.generate_tf py4py.reverb.timeseries.process.generate_spectra_base py4py.reverb.timeseries.process.generate_times_and_delta_continuum py4py.reverb.timeseries.process.generate_spectra_min_max py4py.reverb.timeseries.process.generate_spectra_details py4py.reverb.timeseries.process.generate_times_line_emission py4py.reverb.timeseries.process.generate_spectra_error py4py.reverb.timeseries.process.copy_spectra_error py4py.reverb.timeseries.process.apply_spectra_error Module Contents --------------- .. py:function:: interpolation_across_range(x: numpy.typing.NDArray[numpy.floating], y: numpy.typing.NDArray[numpy.floating], x_int: float) -> float Simple linear interpolation function :param x: X values :param y: Y values :param x_int: X to find Y for :returns: Linear interpolation of Y for x_int .. py:function:: 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. :param spectrum: The table in Python output format :returns: The bounds .. py:function:: 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: Optional[int] = None, velocity: Optional[bool] = False) -> py4py.reverb.TransferFunction Generates the response function for a system. :param databases: 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) :type databases: dict :param spectrum: Spectrum to template the wavelength bins off of :type spectrum: Table :param delay_bins: Number of bins to bin delays by :type delay_bins: int :param line: Python line number to select :type line: int :param dynamic_range: 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. :type dynamic_range: float :param wave: Frequency of the line selected (in A) :type wave: float :param name: Name of the output files. :type name: str :param limit: Number of photons to limit the DB query to. Set low for testing. :type limit: int :param observer: Which observer (if several) to use. :type observer: int :param velocity: Whether to plot in velocity space or not. :type velocity: bool :returns: The response-mapped transfer function. :rtype: TransferFunction 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 .. py:function:: generate_spectra_base(spectrum: astropy.table.Table, spectra_times: astropy.table.Table) -> astropy.table.Table Generates the base spectra for each timestep. :param spectrum: The base, unmodified spectrum used for the output time series :type spectrum: Table :param spectra_times: Times to produce a spectrum for :type spectra_times: Table :returns: With one spectrum per target spectra time, keyed by the times :rtype: Table .. py:function:: generate_times_and_delta_continuum(transfer_function: py4py.reverb.TransferFunction, lightcurve: astropy.table.Table, delay_max: Optional[float] = None) -> astropy.table.Table Generates the timesteps to evaluate the TF at and the change in continuum at each :param transfer_function: The TF :type transfer_function: TransferFunction :param lightcurve: The lightcurve base used for this. :type lightcurve: Table :param delay_max: The maximum delay to generate the delta continuum for :type delay_max: float :returns: Time domain broken down into small steps :rtype: times (np.array) .. py:function:: generate_spectra_min_max(times: astropy.table.Table, transfer_function: py4py.reverb.TransferFunction, spectra: astropy.table.Table, spectrum: astropy.table.Table, continuum_fit: Optional[numpy.poly1d] = 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. :param times: The list of times to take spectra and the associated delta continuum for that time :type times: Table :param transfer_function: The response function of the system :type transfer_function: TransferFunction :param spectra: The base spectrum in Python format :type spectra: Table :param spectrum: The time series of spectra :type spectrum: Table :param continuum_fit: A function that describes the background continuum as a function of wavelength :type continuum_fit: Optional[poly1d] :returns: None .. py:function:: generate_spectra_details(times: astropy.table.Table, transfer_function: py4py.reverb.TransferFunction, spectra: astropy.table.Table, spectrum: astropy.table.Table, continuum_fit: Optional[numpy.poly1d] = None, calculate_error: Optional[bool] = False, error_over_variation: Optional[float] = 0.01, verbose: Optional[bool] = True) Generates synthetic spectra from a base spectrum, transfer function, and varying continuum. :param times: A table containing the timesteps the time-series should be evaluated over :type times: Table :param transfer_function: The TF containing the response function to use :type transfer_function: TransferFunction :param spectra: The output table for the finished timeseries :type spectra: Table :param spectrum: A table containing the spectrum to use as the base for the time-series :type spectrum: Table :param continuum_fit: If this is a continuuum-subtracted timeseries, the function that describes the continuum :type continuum_fit: poly1d :param calculate_error: Whether or not we should calculate the error on the timeseries steps :type calculate_error: Optional[bool] :param error_over_variation: If calculating error, what should be the target integrated line error over the line variation range :type error_over_variation: Optional[float] :param verbose: Whether or not to print out info messages :type verbose: Optional[bool] :returns: None. .. py:function:: 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 :param spectra: The time-series of spectra :type spectra: Table :param spectra_times: The times at which the spectra are taken (i.e. the fake observations) :type spectra_times: Table :param verbose: Whether or not to report on the total line variation :type verbose: bool :returns: A table with the line emission for each timestep :rtype: Table .. py:function:: 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. :param spectra: A timeseries of spectra. :type spectra: Table :param error: The ratio of error on the spectrum to the variation in luminosity within it. :type error: float :param fudge_factor: A scaling factor. :type fudge_factor: float :returns: A copy of the spectra table with errors applied. .. py:function:: 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. :param origin: The timeseries of spectra with errors. :type origin: Table :param target: The timeseries of spectra that we want to copy the errors to :type target: Table :param rescale: Optionally, whether to rescale the errors to be proportionally the same, rather than absolutely the same. :type rescale: bool :returns: Copy of the 'target' timeseries with errors applied .. py:function:: 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. :param spectra: A timeseries of spectra, with timesteps as columns 5+. :type spectra: Table :returns: A copy of the input spectra with the errors applied :rtype: Table