moncenterlib.gnss.postprocessing module

The module for standard and precise positioning with GNSS (global navigation satellite system).

  • Post‐Processing Analysis;

  • Soon.

The module has the following classes: - RtkLibPost; - Soon.

Learn more about the specific class.

class moncenterlib.gnss.postprocessing.RtkLibPost(logger: bool | Logger | None = None)

Bases: object

This class is based on the RTKLib software package.

RTKLIB contains the post-processing analysis application RTKPOST. RTKPOST accepts standard RINEX 2.10, 2.11, 2.12, 3.00, 3.01, and 3.02 (draft) observation data and navigation message files for GPS, GLONASS, Galileo, QZSS, BeiDou, and SBAS. It can compute positioning solutions in various modes including single-point, DGPS/DGNSS, kinematic, static, PPP-kinematic, and PPP-static.

See more about RTKLIB here: https://rtklib.com/

This class can post-process one or more files. See code usage examples in the examples folder.

Available file types:

{
    "rover": "",
    "base": "",
    "nav": "",
    "sp3": "",
    "clk": "",
    "ionex": "",
    "erp": "",
    "dcb": "",
    "fcb": "",
    "sbas": "",
    "otl": "",
    "satant": "",
    "rcvant": ""
}
__init__(logger: bool | Logger | None = None)
Parameters:

logger (bool | Logger, optional) – if the logger is None, a logger will be created inside the default class. If the logger is False, then no information will be output. If you pass an instance of your logger, the information output will be implemented according to your logger. Defaults to None.

config2dict(path2conf: str) dict[str, str]

This method is used to convert file configuration to dictionary.

Parameters:

path2conf (str) – The path to the file configuration

Raises:

ValueError – Path to path2conf is strange.

Returns:

Return dictionary of configuration.

Return type:

dict

Examples

>>> from moncenterlib.gnss.postprocessing import RtkLibPost
>>> rtk_post = RtkLibPost()
>>> config = rtk_post.config2dict('/path/to/config.conf')
{
    "param1": "val1",
    "param2": "val2"
}
dict2config(config: dict[str, str], path_file: str | _TemporaryFileWrapper, input_rnx: dict[str, str] = {'': ''})

Saves the dictionary with the RtkLibPost configuration to a file. The file can be used in rnx2rtkp CLI or rtkpost GUI.

Parameters:
  • config (dict[str, str]) – Config for rnx2rtkp of RTKLibPost.

  • path_file (str | tempfile._TemporaryFileWrapper) – The path where the configuration file will be created. You can use it in rnx2rtkp CLI or rtkpost GUI.

  • input_rnx (dict[str, str | list], optional) – The dictionary where keys are a type of file and values are a path to one file. Defaults to {}.

Exaples:
>>> from moncenterlib.gnss.postprocessing import RtkLibPost
>>> rtk_post = RtkLibPost()
>>> paths = {"rover": "path/to/rover_file", "satant": "path/to/satant_file"}
>>> config = rtk_post.get_default_config()
>>> rtk_post.dict2config(config, "path/to/config.conf", input_rnx=paths)
get_default_config() dict

Return variable __default_config. __default_config isn’t editable. In the future, you will manually configure this config and send it to the start method. See documentation RTKLIB (manual_2.4.2, page 34-49), how to configuration. Also you can see in example code how to configure.

Returns:

default config for rnx2rtkp of RTKLib

Return type:

dict

Examples

>>> from moncenterlib.gnss.postprocessing import RtkLibPost
>>> rtk_post = RtkLibPost()
>>> rtk_post.get_default_config()
{
    'pos1-posmode': '0',
    'pos1-frequency':  '2',
    'pos1-soltype':  '0',
    'pos1-elmask':  '15',
    'pos1-snrmask_r':  'off',
    'pos1-snrmask_b':  'off',
    ...
}
get_full_status() dict[str, dict[str, list]]

Returns the full lines of processing status information.

Returns:

The dictionary contains 2 keys. stderr, stdout. The stderr key stores the list lines of error information. The stdout key stores the list lines of information.

Return type:

dict[str, dict[str, list]]

Examples

>>> post = RtkLibConvib()
>>> post.start_single_processing(...)
>>> print(post.get_full_status())
{
    "/home/file1": {
        "stdout": ["Status: Running", "bla bla"],
        "stderr": ["Error: File not found", "bum bum"]
    }
    "/home/file2": {
        "stdout": ["ok"],
        "stderr": []
    }
}
get_last_status() dict[str, dict]

Returns the last line of processing status information.

Returns:

The dictionary contains 3 keys. stderr, stdout, isStop. The stderr key stores the last line of error information. The stdout key stores the last line of information. The isStop key stores a boolean value. True if the process has stopped, False otherwise.

Return type:

dict[str, str | bool]

Examples

>>> post = RtkLibPost()
>>> post.start_single_processing(...)
>>> While True:
>>>     status = post.get_last_status()
>>>     if status["isStop"]:
>>>         break
>>>     time.sleep(1)
>>>     print(status)
{
    "isStop": True,
    "stdout": "some info",
    "stderr": ""
}
match_files(input_rnx: dict[str, str], recursion: bool = True) tuple[dict, dict]
This method allows you to automatically match the input files. The input is provided with data types and

paths to the directory where these files are stored. Each file is scanned and the measurement start date is read. By this date, the files are being compared. This allows you to automate further post-processing of a large number of files.

Parameters:
  • input_rnx (dict[str, str]) – The dictionary where keys are a type of file and values are a path to the directory where files are stored.

  • recursion (bool, optional) – Recursively search for files. Defaults to True.

Raises:
  • ValueError – Does not support a type of file

  • ValueError – Invalid file path

Returns:

A tuple has two elements.

The first is the matched files, the second is the files for which the files could not be matched.

Return type:

tuple[dict, dict]

Examples

>>> from moncenterlib.gnss.postprocessing import RtkLibPost
>>> rtk_post = RtkLibPost()
>>> paths = {"rover": "path/to/rover_directory", "nav": "path/to/nav_directory", "satant": "path/to/satant_directory"}
>>> match_files, no_match = rtk_post.match_files(paths, True)
start_multi_processing(match_list: dict[str, dict[str, str | list]], output_dir: str, config: dict[str, str], timeint: int = 0, workers: int = 1)

The method starts the postprocessing. The method allows you to postprocess a large number of files. The generated dictionary with the matched files is taken from the ‘match_files’ method. This method is non-blocking. You can use an endless loop to wait for the process to complete. See the usage example.

Parameters:
  • match_list (dict[str, dict[str, str | list]]) – Match files from the ‘match_files’ method.

  • output_dir (str) – The path to the directory where the files will be saved.

  • config (dict[str, str]) – Config for rnx2rtkp of RTKLibPost.

  • timeint (int, optional) – Time interval. Defaults to 0.

  • workers (int, optional) – The number of parallel processes. It reduces the processing time for multiple files. Defaults to 1.

Examples

>>> from moncenterlib.gnss.postprocessing import RtkLibPost
>>> rtk_post = RtkLibPost()
>>> paths = {"rover": "path/to/rover_directory", "nav": "path/to/nav_directory", "satant": "path/to/satant_file"}
>>> match_files, no_match = rtk_post.match_files(paths, True)
>>> config = rtk_post.get_default_config()
>>> rtk_post.start_multi_processing(match_files, "path/to/output_directory", config, timeint=1, workers=2)
>>> # wait process and get status
>>> while True:
...     time.sleep(1)
...     status = rtk_post.get_last_status()
...     print(status)
...     states = [s['isStop'] for s in status.values()]
...     if all(states):
...         break
>>> print(rtk_post.output_files)
start_single_processing(input_rnx: dict[str, str], output_dir: str, config: dict[str, str], timeint: int = 0, wait_process: bool = True)

The method starts the postprocessing. This method can process single files. This method is non-blocking. You can use an endless loop to wait for the process to complete. See the usage example.

Parameters:
  • input_rnx (dict[str, str]) – The dictionary where keys are a type of file and values are a path to the file.

  • output_dir (str) – The path to the directory where the files will be saved.

  • config (dict[str, str]) – Config for rnx2rtkp of RTKLibPost.

  • timeint (int, optional) – Time interval. Defaults to 0.

  • wait_process (bool, optional) – Wait for the method to be rejected. Or run it as a parallel process. Defaults to False.

Raises:
  • ValueError – Output directory does not exist.

  • ValueError – Rover path is not set.

  • ValueError – Path to file ‘path/to/file’ does not exist.

Examples

>>> from moncenterlib.gnss.postprocessing import RtkLibPost
>>> rtk_post = RtkLibPost()
>>> paths = {"rover": "path/to/rover_file", "nav": "path/to/nav_file", "satant": "path/to/satant_file"}
>>> config = rtk_post.get_default_config()
>>> rtk_post.start_single_processing(paths, "path/to/output_directory", config, timeint=1, wait_process=True)
>>> print(rtk_post.output_files)