Spectra Interpolation#

Utilities for interpolating spectra provided in .csv format.

drdmannturb.interpolation.extract_x_spectra(filepath: Path, abs: bool = False) tuple[ndarray, ndarray][source]#

Given a filepath to a csv with data in two cols; the first should be the x coordinates and the second should be the spectra value

Parameters:
  • filepath (Path) – Filepath to CSV

  • abs (bool) –

Returns:

tuple[np.ndarray, np.ndarray] – A tuple of the x-coords on log scale and the spectra data

Return type:

tuple[ndarray, ndarray]

drdmannturb.interpolation.interp_spectra(x_interp: ndarray, x_true: ndarray, spectra: ndarray) ndarray[source]#

Cubic spline interpolation of spectra over x_interp, given original x-coords x_true

Parameters:
  • x_interp (np.ndarray) – x-coords to evaluate the interpolation at

  • x_true (np.ndarray) – x-coords to use in reaching the interpolation

  • spectra (np.ndarray) – spectra date corresponding to the x-coords in x_true

Returns:

np.ndarray – The evaluation of the interpolation of the data spectra at the coords x_interp

Return type:

ndarray

drdmannturb.interpolation.interpolate(datapath: Path, num_k1_points: int, plot: bool = False) tuple[ndarray, ...][source]#

Calculates and returns the interpolations over a common set of x-coordinates.

Parameters:
  • datapath (Path) – Path to directory in which u_spectra.csv, v_spectra.csv, w_spectra.csv, uw_cospectra.csv are contained.

  • num_k1_points (int) – Number of points to use in interpolating given spectra.

  • plot (bool) – If True, will plot the interpolations after. Else just returns.

Returns:

tuple[np.ndarray, ] – Tuple of x_interp, interp_u, interp_v, interp_w, interp_uw. x_interp is given in normal space, under the assumption that the x data of the input spectra is in log-space.

Return type:

tuple[ndarray, …]