pybacktrack.interpolate_file

pybacktrack.interpolate_file(curve_function, input_filename, output_filename, input_x_column_index=0, *, reverse_output_columns=False)

Interpolate curve_function at x positions, read from input file, and store both x and interpolated y values to output file.

Parameters:
  • curve_function (function) – A callable function y=f(x) accepting a single x argument and returning a y value (or None to exclude from output).

  • input_filename (string) – Name of input text file containing the x positions at which to sample curve_function. A single x value is obtained from each row by indexing the input_x_column_index column (zero-based index).

  • output_filename (string) – Name of output text file containing x and y values. Each row of output file contains an x value and its associated y value (with order depending on reverse_output_columns).

  • input_x_column_index (int, optional) – Determines which column of input file to read x values from.

  • reverse_output_columns (bool, optional) – Determines order of x and y columns in output file. If True then output y x, otherwise output x y.

Raises:

ValueError – If cannot read an x value, as a floating-point number, from input file at column index input_x_column_index.

Notes

Changed in version 1.5: The following changes were made:

  • curve_function can return None, in which case there is no output row for the input x.

  • Some arguments (after *) are now keyword-only (ie, can no longer be specified as positional arguments).