flitsr.input.input_reader.Input

class flitsr.input.input_reader.Input

Bases: ABC

An abstract spectral input type

__init__()

Methods

__init__()

check_format(input_path)

Check whether the files from the specified input_path are of the concrete types format.

get_elem_separators()

Method to get the separators used for printing out elements when writing a spectrum in the format of this input type.

get_reader(input_path)

Static helper method that guesses the input type of the given input path out of all available input types.

get_run_file_name(input_path)

Return the name of the run file that this input type determines for the given input string.

get_type()

Return the InputType enum of this input type.

read_in(input_path, split_faults[, method_level])

Static helper method that guesses the input type of the given input path out of all available input types, and reads in the spectrum using that input type.

read_spectrum(input_path, split_faults[, ...])

Read in the spectrum from the given input file using this input type.

write_spectrum(spectrum, output_path)

Write the given spectrum in the format of this input type.

abstractmethod static check_format(input_path: str) bool

Check whether the files from the specified input_path are of the concrete types format. The implementation of this abstract method must return a boolean, where True indicates that the input is in the format recognized by the implementing class, and False otherwise

Parameters:

input_path – str: The input path to check for format.

Returns:

True if the input path refers to input in the format that this input type can read, or False otherwise.

classmethod get_elem_separators() List[str]

Method to get the separators used for printing out elements when writing a spectrum in the format of this input type. NOTE: this method does not need to be implemented by an input type unless it is used in the implemented write_spectrum method.

static get_reader(input_path: str) Input

Static helper method that guesses the input type of the given input path out of all available input types.

Parameters:

input_path – str: The input path string to guess the input type for.

Returns:

The concrete input type that can read in the given input path.

abstractmethod get_run_file_name(input_path: str)

Return the name of the run file that this input type determines for the given input string.

Parameters:

input_path – str: The name of the input file.

Returns:

The name of the run file.

classmethod get_type() InputType

Return the InputType enum of this input type.

static read_in(input_path: str, split_faults: bool, method_level=False) Spectrum

Static helper method that guesses the input type of the given input path out of all available input types, and reads in the spectrum using that input type.

Parameters:
  • input_path – str: The spectrum input path string to read in.

  • split_faults – bool: Whether to split faults using FLITSR’s split_faults functionality.

  • method_level – (Default value = False) Whether to read this spectrum in as a method level spectrum.

Returns:

The spectrum that was read in.

abstractmethod read_spectrum(input_path: str, split_faults: bool, method_level=False) Spectrum

Read in the spectrum from the given input file using this input type.

Parameters:
  • input_path – str: The path string of the input spectrum.

  • split_faults – bool: Whether to split faults using FLITSR’s split_faults functionality.

  • method_level – (Default value = False) Whether to read this spectrum in as a method level spectrum.

Returns:

The spectrum that was read in.

classmethod write_spectrum(spectrum: Spectrum, output_path: str)

Write the given spectrum in the format of this input type. NOTE: this method does not need to be implemented by an input type. If it is not implemented and this method is called, a NotImplementedError will be thrown.

Parameters:
  • spectrum – Spectrum: The spectrum to write.

  • output_path – str: The output path location string.