polyfemos.scripts.check_output_files — polyfemos 0.3.29 documentation

# polyfemos.scripts.check_output_files

A command line script to check polyfemos output files.

copyright

  2019, University of Oulu, Sodankyla Geophysical Observatory

license

  GNU Lesser General Public License v3.0 or later (https://spdx.org/licenses/LGPL-3.0-or-later.html)

Public Functions

`polyfemos.scripts.check_output_files.` `check_csv_file`(filename, value_checks=[], valid_header=[])

  Function to verify the ‘*.alert’ and ‘*.csv’ files. The format of such files is described in Alert file Format and State of health CSV Format.

  Parameters

    - filename (str) – path to a file to be checked

    - value_checks (list, optional) – a list passed to `check_row()`

    - valid_header (list, optional) – a reference header used to verify the file header. See `check_header()` for more info.

`polyfemos.scripts.check_output_files.` `check_header`(header, valid_header)

  Checks if two lists of strings are identical using using `re.compile()` and `re.match()` functions. Asterisk (‘*’) can be used to match any number of any characters.

  Parameters

    - header (list[str]) – The header which is tried to verify.

    - valid_header (list[str]) – A header which the given `header` is compared to.

  Return type

    str

  Returns

    Error message if given headers does not match. If an empty string is returned, the `header` is ok.

`polyfemos.scripts.check_output_files.` `check_row`(row, value_checks)
  Parameters

    - row (list) – a list of values

    - value_checks (list) – a list of list, each nested list should consist of integer, function and a message string. The integer describes if the value in `row` is optional. The function is used to verify the value. If the function returns `None`, the value had some problems and the message is used to describe the problem.

  Return type

    str

  Returns

    Error message if the given row does not match the criteria. If an empty string is returned, the `row` is ok.

`polyfemos.scripts.check_output_files.` `check_stf_file`(filename)

  Function to verify the ‘*.stf’ files. The format of such files is described in Sohtextfile Format.

  Parameters

    filename (str) – path to ‘*.stf’ file to be checked

`polyfemos.scripts.check_output_files.` `main`(argv=None)

  Recursively checks folders for polyfemos output files and check the validity of the files. If the exact file is given, only the given file is checked.

  If a single path to a directory is given, the directory is recursively checked for files with given extension.

  Wild cards in path can be used to give a list of paths.

  Printed row/line and column indices start at 0.

  Parameters

    argv (list) – command line arguments

`polyfemos.scripts.check_output_files.` `print_warning`(filename, msg)
  Parameters

    - filename (str) – path to a file where the error was encountered

    - msg (str) – Message to be printed, if empty, nothing is printed.