autorino.common package

Submodules

autorino.common.decompress module

Created on Mon Jan 29 11:53:09 2024

@author: psakic

This module, decompress.py, provides functions for decompressing files, specifically those that are gzipped or in Hatanaka-compressed RINEX format.

autorino.common.decompress.decomp_gzip(gzip_file_inp, out_dir_inp=None, force=False)[source]

Decompresses a gzipped file.

Parameters:
  • gzip_file_inp (str) – The input gzipped file to decompress.

  • out_dir_inp (str, optional) – The output directory where the decompressed file will be stored. If not provided, the decompressed file will be stored in the same directory as the input file.

  • force (bool, optional) – If True, the file will be decompressed even if a decompressed file already exists.

Returns:

The path to the decompressed file.

Return type:

str

autorino.common.decompress.decomp_hatanaka(crx_file_inp, out_dir_inp=None, force=False)[source]

Decompresses a Hatanaka-compressed RINEX file.

Parameters:
  • crx_file_inp (str) – The input Hatanaka-compressed RINEX file to decompress.

  • out_dir_inp (str, optional) – The output directory where the decompressed file will be stored. If not provided, the decompressed file will be stored in the same directory as the input file.

  • force (bool, optional) – If True, the file will be decompressed even if a decompressed file already exists.

Returns:

The path to the decompressed file.

Return type:

str

autorino.common.decompress.decompress_file(file_inp, out_dir_inp=None, force=False)[source]

Decompresses a file. The file can be gzipped or in Hatanaka-compressed RINEX format.

Parameters:
  • file_inp (str) – The input file to decompress.

  • out_dir_inp (str, optional) – The output directory where the decompressed file will be stored. If not provided, the decompressed file will be stored in the same directory as the input file.

  • force (bool, optional) – If True, the file will be decompressed even if a decompressed file already exists.

Returns:

  • str – The path to the decompressed file.

  • bool – True if the file was decompressed, False otherwise.

autorino.common.decompress.is_compressed(file_inp)[source]

Checks if a file is compressed based on its extension.

Parameters:

file_inp (str) – The input file to check.

Returns:

True if the file is compressed, False otherwise.

Return type:

bool

autorino.common.eporng_cls module

Created on Mon Jan 8 15:47:58 2024

@author: psakic

This module, eporng_cls.py, provides a class for handling ranges of epochs.

class autorino.common.eporng_cls.EpochRange(epoch1, epoch2=None, period='1d', round_method='floor', tz='UTC')[source]

Bases: object

A class used to represent a range of epochs.

period

the rounding period. Use the pandas’ frequency aliases convention.

Type:

str

round_method

the method used for rounding the epochs.

Type:

str

tz

the timezone used for the epochs.

Type:

str

_epoch1_raw

the raw start of the epoch range.

Type:

datetime

_epoch2_raw

the raw end of the epoch range.

Type:

datetime

eporng_list(end_bound=False):

Computes the list of epochs corresponding to the EpochRange.

is_valid():

Checks if the epoch range is valid.

__init__(epoch1, epoch2=None, period='1d', round_method='floor', tz='UTC')[source]

Constructs all the necessary attributes for the epoch range object.

Parameters:
  • epoch1 (str, datetime, pd.Timestamp, pd.NaT, list) – the start of the epoch range.

  • epoch2 (str, datetime, pd.Timestamp, pd.NaT) – the end of the epoch range.

  • period (str, optional) – the rounding period. Use the pandas’ frequency aliases convention.

  • round_method (str, optional) – the method used for rounding the epochs.

  • tz (str, optional) – the timezone used for the epochs.

property epoch_end

Gets the end of the epoch range.

property epoch_start

Gets the start of the epoch range.

eporng_list(end_bound=False)[source]

Compute the list of epochs corresponding to the EpochRange.

Parameters:

end_bound (bool, optional) – If True, gives the end bound of the range. Default is False.

Returns:

List of epochs.

Return type:

list

eporng_list_manual(end_bound=False)[source]

Compute the list of epochs for a forced range.

Parameters:

end_bound (bool, optional) – If True, gives the end bound of the range. Default is False.

Returns:

List of epochs.

Return type:

list

eporng_list_regular(end_bound=False)[source]

Compute the list of epochs corresponding to the EpochRange if end_bound = True, give the end bound of the range (start bound is generated per default)

Parameters:

end_bound (bool, optional) – If True, gives the end bound of the range.

Returns:

List of epochs.

Return type:

list

extra_margin_splice()[source]

Returns the extra margin for splicing operations.

Leica raw files can be a bit over their nominal end, so we need to add a margin to the splicing operation.

is_valid()[source]

Checks if the epoch range is valid.

Returns:

True if the epoch range is valid, False otherwise.

Return type:

bool

property period_as_timedelta

For a period, e.g. 15min, 1H… return in as a pandas Timedelta

property period_values

For a period, e.g. 15min, 1H… Returns the value (e.g. 15, 1) and the unit (e.g. min, H)

autorino.common.eporng_fcts module

Created on Mon Jan 8 15:47:58 2024

@author: psakic

autorino.common.eporng_fcts.create_dummy_epochrange()[source]

Create a fake/dummy EpochRange object for test/development purpose

Returns:

ses – dummy EpochRange object.

Return type:

EpochRange object

autorino.common.eporng_fcts.datepars_intrpt(date_inp, tz=None, tz_if_naive='UTC')[source]

This function interprets a string or datetime-like object to a Pandas Timestamp. It also applies a timezone (UTC by default). Note that rounding does not take place here as rounding is not a parsing operation.

Parameters:
  • date_inp (str or datetime-like) – The input date to be interpreted.

  • tz (str, optional) – The timezone to be applied. The default is None.

  • tz_if_naive (str, optional) – The timezone to be applied if the input date is timezone-naive. The default is “UTC”.

Returns:

date_out – The interpreted date as a python native datetime.

Return type:

datetime

Note

If the input date is a string, it is parsed using the dateparser library. If the input date is a datetime-like object, it is converted first to a Pandas Timestamp. If the resulting date is a NaT (Not a Time) type, it is returned as is. If the resulting date does not have a timezone, the specified timezone is applied.

autorino.common.eporng_fcts.dates_list2epoch_range(dates_list_inp, period=None, round_method='floor')[source]

Converts a list of dates to an EpochRange.

Parameters:
  • dates_list_inp (iterable) – The input list of dates.

  • period (str, optional) –

    The rounding period. If not provided, the period is determined as the unique difference

    between consecutive dates in the input list. The default is None.

  • round_method (str, optional) – The method used for rounding the epochs. The default is ‘floor’.

Returns:

The converted EpochRange.

Return type:

EpochRange

Note

The current method for determining the period when not provided is a simple calculation of the unique difference between consecutive dates. This may not be the most accurate or desired method and should be improved in future iterations of this function.

autorino.common.eporng_fcts.epoch_range_intrpt(epo_inp)[source]

This function interprets an input to get an output EpochRange object. The input can either be a tuple, typically in the form of (epo1, epo2, period), or an instance of the EpochRange class. If the input is an EpochRange object, it is returned as is. If the input is a tuple, a new EpochRange object is created using the elements of the tuple.

Parameters:

epo_inp (tuple or EpochRange) – The input to be interpreted. If it’s a tuple, it should be in the form of (epo1, epo2, period).

Returns:

epo_range_out – The interpreted EpochRange object.

Return type:

EpochRange

autorino.common.eporng_fcts.iso_zulu_epoch(epo_in)[source]

Convert an input epoch to ISO 8601 format with Zulu time (UTC).

Parameters:

epo_in (datetime-like) – The input epoch to be converted.

Returns:

The epoch in ISO 8601 format with Zulu time (UTC).

Return type:

str

autorino.common.eporng_fcts.round_date(date_in, period, round_method='floor')[source]

low-level function to round a Pandas Serie or a datetime-like object according to the “ceil”, “floor”, “round”, “none” approach

Parameters:
  • date_in (Pandas Serie or a datetime-like object) – Input date .

  • period (str, optional) – the rounding period. Use the pandas’ frequency aliases convention (see bellow for details).

  • round_method (str, optional) – round method: ‘ceil’, ‘floor’, ‘round’, ‘none’. The default is “floor”.

Returns:

date_out – rounded date.

Return type:

Pandas Serie or datetime-like object (same as input)

autorino.common.eporng_fcts.round_date_legacy(date_in, period, round_method='floor')[source]

low-level function to round a Pandas Serie or a datetime-like object according to the “ceil”, “floor”, “round”, “none” approach

Parameters:
  • date_in (Pandas Serie or a datetime-like object) – Input date .

  • period (str, optional) – the rounding period. Use the pandas’ frequency aliases convention (see bellow for details).

  • round_method (str, optional) – round method: ‘ceil’, ‘floor’, ‘round’, ‘none’. The default is “floor”.

Returns:

date_out – rounded date.

Return type:

Pandas Serie or datetime-like object (same as input)

autorino.common.eporng_fcts.round_epochs(epochs_inp, period='1d', rolling_period=False, rolling_ref=-1, round_method='floor')[source]

High-level function to round several epochs to a common one. Useful to group and then splice RINEX

Use it with pandas .groupby in a further step

Parameters:
  • epochs_inp (iterable) – The input epochs expected to be rounded.

  • period (str, optional) – the rounding period. Use the pandas’ frequency aliases convention (see bellow for details). The default is ‘1d’.

  • rolling_period (bool, optional) – Whether to use a rolling period for splicing the RINEX files. If False, the spliced files will be based only on the “full” period provided, i.e. Day1 00h-24h, Day2 00h-24h, etc. If True, the spliced files will be based on the rolling period. i.e. Day1 00h-Day2 00h, Day1 01h-Day2 01h, Day1 02h-Day2 02h etc. Defaults to False.

  • rolling_ref (datetime-like or int, optional) – The reference for the rolling period. If datetime-like object, use this epoch as reference. If integer, use the epoch of the corresponding index Use -1 for the last epoch for instance. The default is -1.

  • round_method (str, optional) – round method: ‘ceil’, ‘floor’, ‘round’. The default is “floor”.

Returns:

Pandas Series of Timestamp or Timedelta

Return type:

epochs_rnd

autorino.common.eporng_fcts.timedelta2freq_alias(timedelta_in)[source]

Time representation conversion

Timedelta (from datetime, numpy or pandas) => Pandas’ Frequency alias

Parameters:

timedelta_in (timedelta-like) – POSIX Time. Can NOT YET handle several timedelta in a list.

Returns:

offset – Converted pandas’ frequency alias

Return type:

string

autorino.common.step_cls module

Created on Mon Jan 8 16:53:51 2024

@author: psakic

class autorino.common.step_cls.StepGnss(out_dir=None, tmp_dir=None, log_dir=None, inp_dir=None, inp_file_regex=None, epoch_range=None, site=None, session=None, options=None, metadata=None)[source]

Bases: object

The StepGnss class represents a step in a GNSS processing chain. It contains methods for initializing and managing various aspects of a processing step, including epoch ranges, sites, sessions, options, and metadata. It also provides methods for handling temporary directories, logging, and table management.

out_dir

The output directory for the step.

Type:

str

tmp_dir

The temporary directory for the step.

Type:

str

log_dir

The log directory for the step.

Type:

str

epoch_range

The epoch range for the step.

Type:

EpochRange

site

The site information for the step.

Type:

dict

session

The session information for the step.

Type:

dict

options

The options for the step.

Type:

dict

metadata
The metadata to be included in the converted RINEX files. Possible inputs are:
  • list of string (sitelog file paths),

  • single string (single sitelog file path)

  • single string (directory containing the sitelogs)

  • list of MetaData objects

  • single MetaData object.

Defaults to None.

Type:

str or list, optional

__init__(out_dir=None, tmp_dir=None, log_dir=None, inp_dir=None, inp_file_regex=None, epoch_range=None, site=None, session=None, options=None, metadata=None)[source]

Initializes a new instance of the StepGnss class.

Parameters:
  • out_dir (str) – The output directory for the step.

  • tmp_dir (str) – The temporary directory for the step.

  • log_dir (str) – The log directory for the step.

  • inp_dir (str) – The input directory for the step.

  • inp_file_regex (str) – The regular expression pattern for the input files. Default is ‘.*’ (everything).

  • epoch_range (EpochRange, optional) – The epoch range for the step. If not provided, a dummy epoch range is created.

  • site (dict, optional) – The site information for the step. If not provided, a dummy site is created.

  • session (dict, optional) – The session information for the step. If not provided, a dummy session is created.

  • options (dict, optional) – The options for the step. If not provided, an empty options dictionary is created.

  • metadata (str or list, optional) –

    The metadata to be included in the converted RINEX files. Possible inputs are:
    • list of string (sitelog file paths),

    • single string (single sitelog file path)

    • single string (directory containing the sitelogs)

    • list of MetaData objects

    • single MetaData object.

    Defaults to None.

_init_epoch_range(epoch_range)[source]

Initializes the epoch range of the StepGnss object.

This method sets the epoch range of the StepGnss object. If an epoch range is provided, it interprets the epoch range using the epoch_range_intrpt function from the arocmn module. If an epoch range is not provided, it creates a dummy epoch range between ‘NaT’ (not a time) using the EpochRange function from the arocmn module.

Parameters:

epoch_range (str, optional) – The epoch range for the step. If not provided, a dummy epoch range is created.

Return type:

None

_init_metadata(metadata)[source]

Initializes the metadata attribute of the StepGnss object.

This method checks if a ‘metadata’ is provided. If it is, it translates the path of the metadata, manages the site log input using the metadata_input_manage function from the rinexmod_api module, and sets the ‘metadata’ attribute of the StepGnss object to the managed site log input. If a ‘metadata’ is not provided, it sets the ‘metadata’ attribute to None.

Parameters:

metadata (str, optional) – The metadata for the step. If not provided, the ‘metadata’ attribute is set to None.

Return type:

None

_init_options(options)[source]

Initializes the options attribute of the StepGnss object.

This method sets the options attribute of the StepGnss object. If an options dictionary is not provided, it creates an empty dictionary and sets it as the options attribute.

Parameters:

options (dict, optional) – The options for the step. If not provided, an empty dictionary is created.

Return type:

None

_init_session(session)[source]

Initializes the session attribute of the StepGnss object.

If a session dictionary is not provided, a warning is logged and a dummy session dictionary is created and set as the session attribute. If a session dictionary is provided, it is set as the session attribute.

Parameters:

session (dict, optional) – The session information for the step. If not provided, a dummy session is created.

Return type:

None

_init_site(site)[source]

Initializes the site attribute of the StepGnss object.

If a site dictionary is not provided, a warning is logged and a dummy site dictionary is created and set as the site attribute. If a site dictionary is provided, it is set as the site attribute.

Parameters:

site (dict, optional) – The site information for the step. If not provided, a dummy site is created.

Return type:

None

_init_site_id()[source]

Initializes the site_id attribute of the StepGnss object.

This method checks if a ‘site_id’ is provided in the site dictionary. If it is, it sets the ‘site_id’ attribute of the StepGnss object to the provided ‘site_id’. If a ‘site_id’ is not provided, it sets the ‘site_id’ attribute to ‘XXXX00XX00XXXX’ as a default value.

Return type:

None

_init_table(table_cols: list = None, init_epoch: bool = True)[source]

Initializes the table of a StepGnss object.

This method creates a new pandas DataFrame with specified columns. If no columns are provided, it creates a DataFrame with default columns. If init_epoch is True, it also initializes the ‘epoch_srt’ and ‘epoch_end’ columns with the epoch range of the StepGnss object and the ‘site’ column with the site ID of the StepGnss object.

Parameters:
  • table_cols (list of str, optional) – The columns to include in the table. If not provided, default columns are used.

  • init_epoch (bool, optional) – If True, initializes the ‘epoch_srt’ and ‘epoch_end’ columns with the epoch range of the StepGnss object and the ‘site’ column with the site ID of the StepGnss object. Default is True.

Return type:

None

_init_tmp_dirs_paths(tmp_subdir_dwnld='010_downloaded', tmp_subdir_unzip='020_unzipped', tmp_subdir_conv='030_converted', tmp_subdir_rnxmod='040_rinexmoded', tmp_subdir_tables='090_tables')[source]

Initializes the temporary directories paths as attribute for the StepGnss object.

This method is internal only, for the initialisation of the StepGnss object.

See set_tmp_dirs for the actual creation of the directories.

This method sets the paths for the temporary directories of the StepGnss object. It creates the paths in a generic form, with placeholders and without creating the actual directories. The directories include logs, unzipped, converted, rinexmoded, and downloaded directories.

Parameters:
  • tmp_subdir_dwnld (str, optional) – The subdirectory for downloaded files. Default is ‘downloaded’.

  • tmp_subdir_unzip (str, optional) – The subdirectory for unzipped files. Default is ‘unzipped’.

  • tmp_subdir_conv (str, optional) – The subdirectory for converted files. Default is ‘converted’.

  • tmp_subdir_rnxmod (str, optional) – The subdirectory for rinexmoded files. Default is ‘rinexmoded’.

  • tmp_subdir_tables (str, optional) – The subdirectory for logs. Default is ‘logs’.

Return type:

None

check_local_files(io='out')[source]

Checks the existence of the output (‘out’) or input (‘inp’) local files (for non download cases) and updates the corresponding booleans in the ‘ok_out’ or ‘ok_inp’ column of the table.

This method iterates over each row in the table. For each row, it checks if the local file specified in the ‘fpath_out’ entry exists and is not empty. If the file exists and is not empty, the method sets the ‘ok_out’ entry for the file in the table to True and updates the ‘size_out’ entry with the size of the file. If the file does not exist or is empty, the method sets the ‘ok_out’ entry for the file in the table to False.

The method returns a list of the paths of the existing and non-empty local files.

Parameters:

io (str, optional) – The input/output direction to check. Default is ‘out’.

Returns:

The list of paths of the existing and non-empty local files.

Return type:

list

clean_tmp_dirs(days=7, keep_table_logs=True)[source]

Cleans the temporary directories of the StepGnss object.

This method removes all files older than a specified number of days in the temporary directories of the StepGnss object. The directories include logs, unzipped, converted, rinexmoded, and downloaded directories.

See also

remov_tmp_files

Cleans the files in the temporary directories at the end of the processing based on ad hoc lists.

Parameters:
  • days (int, optional) – The number of days to use as the threshold for deleting old files. Default is 7 days.

  • keep_table_logs (bool, optional) – If True, keeps the table logs sotored in the tmp directories. Default is True.

Return type:

None

static close_logfile()[source]

close the file handler of the logger

copy()[source]

Creates a duplicate of the current StepGnss object.

This method uses the deepcopy function from the copy module to create a new instance of the StepGnss class that is a complete copy of the current instance. All attributes of the current instance are copied to the new instance.

Returns:

A new instance of the StepGnss class that is a copy of the current instance.

Return type:

StepGnss

create_lockfile(timeout=1800, prefix_lockfile=None)[source]

Creates a lock file for the specified file path.

This method attempts to acquire a lock on the specified file. If the lock is acquired, it prints a success message. If the lock is not acquired (i.e., the file is already locked), it prints a message indicating that the process is locked.

Parameters:
  • timeout (int, optional) – The timeout period in seconds to wait for acquiring the lock. Default is 1800 seconds.

  • prefix_lockfile (str, optional) – The prefix to use for the lock file name. If not provided, a random integer is used.

Returns:

The FileLock object representing the lock on the file.

Return type:

FileLock

decompress(table_col='fpath_inp', table_ok_col='ok_inp')[source]

decompress the potential compressed files in the table_col column and its corresponding table_ok_col boolean column (usually fpath_inp and ok_inp)

It will uncompress the file if it is a (gzip+)Hatanaka-compressed RINEX, or a generic-compressed file (gzip only for the moment)

It will create a new column fpath_ori (for original) to keep the trace of the original file

Returns:

  • files_decmp_list – the DEcompressed files i.e. the one which are temporary and must be removed

  • files_uncmp_list – the UNcompressed files i.e. ALL the usables ones

decompress_table_batch(table_col='fpath_inp', table_ok_col='ok_inp')[source]

Decompresses the potential compressed files in the specified column of the table.

This method checks if the files specified in the ‘table_col’ column of the table are compressed. If they are, the method decompresses the files and updates the ‘table_col’ column with the paths of the decompressed files. It also updates the ‘ok_inp’ column with the existence of the decompressed files and the ‘fname’ column with the basenames of the decompressed files. If the files are not compressed or the ‘ok_inp’ column is False, the method does nothing. The method processes a complete table at once, which is faster than row-iterative decompression done by decompress.

Parameters:
  • table_col (str, optional) – The column in the table where the paths of the files are stored. Default is ‘fpath_inp’.

  • table_ok_col (str, optional) – The column in the table where the boolean indicating the existence of the files is stored. Default is ‘ok_inp’.

Returns:

The list of paths of the decompressed files.

Return type:

list

property epoch_range
filter_bad_keywords(keywords_path_excl)[source]

Filters a list of raw files if the full path contains certain keywords.

This method checks if the full path of the raw files contains any of the provided keywords. If a keyword is found in the full path of a raw file, the file is filtered out. The method modifies the ‘ok_inp’ column of the object’s table to reflect the filtering. The method returns a list of filtered raw files.

Parameters:

keywords_path_excl (list) – The list of keywords to filter the raw files. For example, if keywords_path_excl is [‘badword1’, ‘badword2’], any file whose full path contains either ‘badword1’ or ‘badword2’ will be filtered out.

Returns:

The list of filtered raw files.

Return type:

list

filter_filelist(filelist_exclu_inp, message_manu_exclu=False)[source]

Filters a list of raw files based on their presence in a provided exclusion list.

This method checks if the raw files are present in the provided exclusion list. If a raw file is present in the exclusion list, it is filtered out. The method modifies the ‘ok_inp’ column of the object’s table to reflect the filtering. The method returns a list of filtered raw files.

Parameters:
  • filelist_exclu_inp (str or list) – The exclusion list. It can be a string representing a path to a text file containing the exclusion list, or a list of strings representing the exclusion list.

  • message_manu_exclu (bool, optional) – If True, a debug message is logged for each file that is manually filtered in the exclusion list.

Returns:

The list of filtered raw files.

Return type:

list

filter_na(cols=None)[source]

Filters the table to remove rows with NaN values in the specified columns, and prints the dropped rows.

Parameters:

cols (list, optional) – The list of columns to check for NaN values. If None, all columns are checked.

Returns:

The dropped rows.

Return type:

pandas.DataFrame

filter_ok_out()[source]

Filters the raw files based on the ‘ok_out’ boolean column of the object’s table.

This method checks if the raw files have a positive ‘ok_out’ boolean i.e., the converted file already exists. It modifies the ‘ok_inp’ boolean column of the object’s table i.e. the step action must be done (True) or not (False) and returns the filtered raw files in a list.

Returns:

The list of filtered raw files.

Return type:

list

filter_prev_tab(df_prev_tab)[source]

Filters the raw files based on their presence in previous conversion tables.

This method checks if the raw files are present in previous conversion tables that are stored as logs. If a raw file is present in the previous conversion tables, it is filtered out. The method modifies the ‘ok_inp’ column of the object’s table to reflect the filtering. The method returns a list of filtered raw files.

Parameters:

df_prev_tab (pandas.DataFrame) – The previous conversion tables concatenated and stored as a DataFrame.

Returns:

The list of filtered raw files.

Return type:

list

filter_purge(col='ok_inp', inplace=False)[source]

Filters the table based on the values in a specified column.

This method removes all rows in the table where the value in the specified column is False. The method can either return a new DataFrame with the filtered data or modify the existing DataFrame in place.

Parameters:
  • col (str, optional) – The name of the column to use for filtering. The column should contain boolean values. Defaults to ‘ok_inp’.

  • inplace (bool, optional) – If True, the method will modify the existing DataFrame in place. If False, the method will return a new DataFrame with the filtered data. Defaults to False.

Returns:

If inplace is False, returns a new DataFrame with the filtered data. If inplace is True, returns a list of values in the specified column after filtering.

Return type:

pandas.DataFrame or list

filter_year_min_max(year_min=1980, year_max=2099, year_in_inp_path=None)[source]

Filters a list of raw files based on their year range.

This method checks if the year in the file path is within a specified range. The year is determined either by its position in the absolute path (if provided) or by a regex search. The method modifies the ‘ok_inp’ column of the object’s table to reflect the filtering. The method returns a list of filtered raw files.

Parameters:
  • year_min (int, optional) – The minimum year for the range. Default is 1980.

  • year_max (int, optional) – The maximum year for the range. Default is 2099.

  • year_in_inp_path (int, optional) – The position of the year in the absolute path. If not provided, a regex search is performed. For example, if the absolute path is: /home/user/input_data/raw/2011/176/PSA1201106250000a.T00 year_in_inp_path is 4

Returns:

The list of filtered raw files.

Return type:

list

force(step_name='')[source]

Enables the force mode for the current step.

This method sets the ‘ok_inp’ column of the table to True and updates the ‘note’ column to indicate that the force mode is enabled for the specified step.

Parameters:

step_name (str, optional) – The name of the step for which the force mode is enabled. Default is an empty string.

Return type:

None

get_step_type(full_object_name=False)[source]

Returns the type of the step as a string.

This method is used to identify the type of the current step in the GNSS processing chain. It returns the name of the class to which the current instance belongs. If the ‘full_object_name’ parameter is False, it returns a shortened version of the class name, in lower case and without the ‘Gnss’ suffix.

Parameters:

full_object_name (bool, optional) – If True, the full name of the class is returned. If False, a shortened version of the class name, in lower case, and without the ‘Gnss’ suffix. Default is False.

Returns:

The name of the class to which the current instance belongs. If ‘full_object_name’ is False, the last 4 characters are removed from the class name.

Return type:

str

get_vals_prev_tab(df_prev_tab, col_ref='fpath_inp', get_cols=['site', 'epoch_srt', 'epoch_end'])[source]

Updates columns in self.table with values from df_prev_tab for matching col_ref entries.

Parameters:
  • df_prev_tab (pandas.DataFrame) – The previous table to update from.

  • col_ref (str, optional) – The column to match on. Default is ‘fpath_inp’.

  • get_cols (list, optional) – The columns to update. Default is [‘site’, ‘epoch_srt’, ‘epoch_end’].

Return type:

None

guess_local_rnx(io='out', shortname=False)[source]

For a given site name and date in a table, guess the potential local RINEX files and write it as ‘fpath_out’ value in the table

guess_out_files()[source]

Generates output file paths for each row in the table and updates the table.

This method iterates over the rows of the table, constructs the output file path for each input file, and updates the fpath_out column in the table. It also ensures that the output directory exists and checks the validity of the output files.

Returns:

A list of output file paths generated for the table rows.

Return type:

list

Notes

  • The output directory is created if it does not exist.

  • The check_local_files method is called to validate the output files.

property inp_dir
invalidate_small_local_files(threshold=0.8, abs_min=1000)[source]

Invalidates local files that are smaller than a certain threshold.

This method checks if the size of each local file is smaller than the threshold times the median size of all local files. If a file is smaller, the method sets the ‘ok_out’ entry for the file in the table to False, indicating that the file is invalid and needs to be redownloaded. The method returns a list of the paths of the invalidated files.

Note: The ‘check_local_files’ method must be called before this method to ensure that the ‘size_out’ and ‘ok_out’ entries in the table are up-to-date.

Parameters:
  • threshold (float, optional) – The threshold for the file size, as a fraction of the median file size. Default is 0.80.

  • abs_min (int, optional) – The absolute minimum file size in bytes. Default is 1000 bytes.

Returns:

The list of paths of the invalidated files.

Return type:

list

load_tab_datelist(dates_list, period='1D')[source]

Loads the table from a list of dates.

This method takes a list of dates and uses it to update the current step’s table. It sets the ‘epoch_srt’ and ‘epoch_end’ columns of the table based on the dates in the list.

Parameters:
  • dates_list (list) – The list of dates to be loaded into the table.

  • period (str, optional) –

    The period between “epoch_srt” and “epoch_end”.

    Default is “1D” which means 1 day.

Return type:

None

load_tab_filelist(input_files, reset_table=True)[source]

Loads the table from a list of input files.

This method takes a list of input files and uses it to update the current step’s table. It sets the ‘fpath_inp’, ‘fname’, and ‘ok_inp’ columns of the table based on the input files. If ‘reset_table’ is True, it resets the current table before loading the new data.

Parameters:
  • input_files (list) – The list of input files to be loaded into the table. The input can be: * a python list * a text file path containing a list of files * a tuple containing several text files path * a directory path.

  • reset_table (bool, optional) – If True, the current table is reset before loading the new data. Default is True.

Returns:

The list of input files that were loaded into the table.

Return type:

list

load_tab_inpdir(reset_table=True, update_epochs=False)[source]

Loads the table with input files from the input directory for each epoch.

This method iterates over the epochs in the epoch range, translates the input directory path for each epoch, and retrieves the list of input files. It then updates the table with the file paths, epochs, and other relevant information.

Parameters:
  • reset_table (bool, optional) – If True, the current table is reset before loading the new data. Default is True.

  • update_epochs (bool, optional) – If True, updates the ‘epoch_srt’ and ‘epoch_end’ columns of the table based on the RINEX files. Recommended for RINEX only. Default is False.

Return type:

None

load_tab_prev_tab(prev_table, reset_table=True, new_inp_is_prev='out')[source]

Loads the table from the previous step’s table.

This method takes the table from the previous step in the processing chain and uses it to update the current step’s table. It copies the ‘fpath_out’, ‘size_out’, ‘fname’, ‘site’, ‘epoch_srt’, ‘epoch_end’, and ‘ok_inp’ columns from the input table to the current table. If ‘reset_table’ is True, it resets the current table before loading the new data.

Parameters:
  • prev_table (pandas.DataFrame) – The table from the previous step in the processing chain. It should contain ‘fpath_out’, ‘size_out’, ‘fname’, ‘site’, ‘epoch_srt’, ‘epoch_end’, and ‘ok_inp’ columns.

  • reset_table (bool, optional) – If True, the current table is reset before loading the new data. Default is True.

  • new_inp_is_prev (str, optional) – Specifies whether the new input files are the previous output files (‘out’) or the previous input files (‘inp’). Default is ‘out’.

Return type:

None

property log_dir
mono_chk_local(irow, io='out')[source]

Checks the existence and validity of a local file for a specific row in the table.

This method verifies if the file specified in the fpath_<io> column of the table exists and is non-empty. It updates the corresponding ok_<io> and size_<io> columns in the table based on the file’s existence and size.

Parameters:
  • irow (int) – The index of the row in the table to check.

  • io (str, optional) – Specifies whether to check the input (inp) or output (out) file path. Default is out.

Returns:

The absolute path of the file if it exists and is valid, otherwise None.

Return type:

str or None

Notes

  • If the file path is not initialized (NaN), the method sets ok_<io> to False.

  • If the file exists and is non-empty, the method sets ok_<io> to True and updates size_<io> with the file size.

  • If the file does not exist or is empty, the method sets ok_<io> to False and size_<io> to NaN.

mono_decompress(irow, out_dir=None, table_col='fpath_inp', table_ok_col='ok_inp')[source]

“on row” method

Decompresses the file specified in the ‘table_col’ entry of a given row in the table.

This method checks if the file specified in the ‘table_col’ entry of the given row is compressed. If it is, the method decompresses the file and updates the ‘table_col’ entry with the path of the decompressed file. It also updates the ‘ok_inp’ entry with the existence of the decompressed file and the ‘fname’ entry with the basename of the decompressed file. If the file is not compressed or the ‘ok_inp’ entry is False, the method does nothing.

Parameters:
  • irow (int) – The index of the row in the table.

  • out_dir (str, optional) –

    The output directory where the decompressed file will be stored. If not provided, the method

    uses the ‘tmp_dir_unzipped’ attribute if it exists, otherwise it uses the ‘tmp_dir’ attribute.

  • table_col (str, optional) – The column in the table where the path of the file is stored. Default is ‘fpath_inp’.

  • table_ok_col (str, optional) – The column in the table where the boolean indicating the existence of the file is stored. Default is ‘ok_inp’.

Returns:

The path of the decompressed file and a boolean indicating whether the file was decompressed.

Return type:

str, bool

mono_guess_rnx(irow, io='out', shortname=False)[source]

Guesses the local RINEX file path for a given row in the table.

This method determines the local RINEX file path based on the epoch range and site information for a specific row in the table. It supports both input (inp) and output (out) modes.

Parameters:
  • irow (int) – The index of the row in the table for which the RINEX file path is to be guessed.

  • io (str, optional) – Specifies whether to guess the input (inp) or output (out) file path. Default is out.

  • shortname (bool, optional) – guess RINEX’s shortname if True Default is False.

Returns:

The guessed local RINEX file path.

Return type:

str

Raises:

Exception – If the io parameter is not inp or out.

Notes

  • The method ensures that the timezone information is removed from the epoch start and end times to avoid compatibility issues with rinexmod.

  • The guessed file path is stored in the fpath_<io> column of the table.

mono_mv_final(irow, out_dir=None, table_col='fpath_out', copy_only=False, force=False)[source]

“on row” method

Moves the ‘table_col’ entry to a final destination based on out_dir for each row of the table.

This method is applied on each row of the table. It checks if the ‘ok_out’ column is True for the row. If it is, it moves the file specified in the ‘table_col’ column to a final destination directory based on out_dir. The final destination directory is either provided as an argument or

it defaults to the ‘out_dir’ attribute of the object.

The method also updates the ‘ok_out’, ‘table_col’, and ‘size_out’ columns of the table for the row based on the success of the operation.

Parameters:
  • irow (int) – The index of the row in the table on which the method is applied.

  • out_dir (str, optional) –

    The directory to which the file is moved.

    If not provided, the ‘out_dir’ attribute of the object is used.

  • table_col (str, optional) – The column in the table which contains the file path to be moved. Defaults to ‘fpath_out’.

  • copy_only (bool, optional) – If True, the file is copied to the final destination instead of being moved. Default is False.

  • force (bool, optional) – Force the move/copy if the file already exists Default is False

  • mono_mv_inpout (See also)

Returns:

The final path of the moved file if the operation is successful, None otherwise.

Return type:

str or None

mono_mv_inpout(irow, copy_only=False, force=False)[source]

Moves or copies the input file to the output file.

This method checks if the input file (fpath_inp) is valid and then moves or copies it to the output file path (fpath_out). It validates the move or copy operation and updates the table accordingly.

See also mono_mv_final

Parameters:
  • irow (int) – The index of the row in the table to process.

  • copy_only (bool, optional) – If True, the file is copied instead of moved. Default is False.

  • force (bool, optional) – Force the move/copy if the file already exists Default is False

Returns:

The path of the moved or copied file if the operation is successful, None otherwise.

Return type:

str or None

mono_mv_validat(irow, file_moved, table_col='fpath_out')[source]

Validates the move operation for a file in the table.

This method updates the table based on the success of a file move operation. If the file was successfully moved, it updates the ‘ok_out’, ‘table_col’, and ‘size_out’ columns. If the file move failed, it sets ‘ok_out’ to False and logs the row in the table log.

Parameters:
  • irow (int) – The index of the row in the table to validate.

  • file_moved (str) – The path of the moved file. If the move failed, this should be None.

  • table_col (str, optional) – The column in the table which contains the file path to be moved. Defaults to ‘fpath_out’.

Returns:

The final path of the moved file if the operation is successful, None otherwise.

Return type:

str

mono_ok_check(irow, step_name, fname_custom='', force=False, switch_ok_out_false=False, mv_final_mode=False)[source]

Checks the status of the input and output files for a specific row in the table.

This method verifies if the input file is valid and if the output file already exists. It logs appropriate messages and determines if the current step should be skipped.

Parameters:
  • irow (int) – The index of the row in the table to check.

  • step_name (str, optional) – The name of the step being checked. Default is “splice”.

  • fname_custom (str, optional) – The custom filename to use for logging. If not provided, “fpath_inp” from the table is used.

  • force (bool, optional) – If True, the step is forced and the input file is processed regardless of its status. Default is False. Usage of this option is discouraged, and kept manily for legacy reasons. It is better to set all the ok_inp boolean in the table to True with the .force() method.

  • switch_ok_out_false (bool, optional) – If True, the ‘ok_out’ column of the table is set to False if the step should be skipped. Default is False.

  • mv_final_mode (bool, optional) – If True, the step is skipped if the output file does not exists. Designed for final move (mv_final) steps. Default is False.

Returns:

False if the step should be skipped, True otherwise.

Return type:

bool

mono_rinexmod(irow, out_dir=None, table_col='fpath_out', rinexmod_options=None)[source]

“on row” method

Applies the rinexmod function to the ‘table_col’ entry of a specific row in the table.

This method is applied on each row of the table. It checks if the ‘ok_inp’ column is True for the row. If it is, it applies the rinexmod function to the file specified in the ‘table_col’ column. The rinexmod function modifies the RINEX file according to the provided rinexmod_options. The modified file is then saved to the specified output directory. The method also updates the ‘ok_out’, ‘table_col’, and ‘size_out’ columns of the table for the row based on the success of the operation.

Parameters:
  • irow (int) – The index of the row in the table on which the method is applied.

  • out_dir (str, optional) – The directory to which the modified file is saved. If not provided, the ‘tmp_dir_rinexmoded’ attribute of the object is used.

  • table_col (str, optional) – The column in the table which contains the file path to be modified. Defaults to ‘fpath_out’.

  • rinexmod_options (dict, optional) – The options to be used by the rinexmod function. If not provided, default options are used.

Returns:

The path of the modified file if the operation is successful, None otherwise.

Return type:

str or None

move_files(mode='inpout', copy_only=False, force=False)[source]

Moves or copies files based on the specified mode.

This method iterates over the rows in the table and moves or copies files from the input path to the output path or to the final destination based on the mode. It validates the move or copy operation and updates the table accordingly.

Parameters:
  • mode (str, optional) – The mode of operation. Can be: ‘inpout’ to move/copy files from input to output path, ‘final’ to move/copy files to the final destination. Default is ‘inpout’.

  • copy_only (bool, optional) – If True, the files are copied instead of moved. Default is False.

  • force (bool, optional) – If True, forces the operation even if the input files are not valid. Default is False.

Returns:

A list of paths of the moved or copied files.

Return type:

list

property out_dir
print_table(no_print=False, no_return=True, max_colwidth=33)[source]

Prints the table of the StepGnss object with specified formatting.

This method formats and prints the table of the StepGnss object. It shrinks the strings in the ‘fraw’, ‘fpath_inp’, and ‘fpath_out’ columns to a specified maximum length and formats the ‘epoch_srt’ and ‘epoch_end’ columns as strings with a specific date-time format. The method then prints the formatted table to the logger.

Parameters:
  • no_print (bool, optional) – If True, the function does not print the table to the logger. Default is False.

  • no_return (bool, optional) – If True, the function does not return the formatted table. Default is True.

  • max_colwidth (int, optional) – The maximum length of the strings in the ‘fraw’, ‘fpath_inp’, and ‘fpath_out’ columns. Default is 33.

Returns:

The formatted table as a string if ‘no_return’ is False. Otherwise, None.

Return type:

str or None

remov_tmp_files()[source]

Removes the temporary files which have been stored in the two lists self.tmp_rnx_files and self.tmp_decmp_files.

This method iterates over the lists of temporary RINEX and decompressed files. If a file exists and is not an original file, it is removed and its path is removed from the list. If a file does not exist or is an original file, its path is kept in the list for future reference.

Note: This method modifies the ‘tmp_rnx_files’ and ‘tmp_decmp_files’ attributes of the object.

See Also clean_tmp_dirs(), which clean all the temporary files based on their creation date

Return type:

None

set_logfile(log_dir_inp=None, step_suffix='auto')[source]

set logging in a file

set_table_log(out_dir=None, step_suffix='')[source]
set_tmp_dirs()[source]

Translates and creates temporary directories.

This method translates the paths of the temporary directories and creates them if they do not exist. The directories include logs, unzipped, converted, rinexmoded, and downloaded directories. The paths are translated using the translate_path method of the StepGnss object, which replaces placeholders in the paths with actual values. The directories are created if the make_dir parameter of the translate_path method is set to True.

Note: This translation is also done in the _init_tmp_dirs_paths method, but it is redone here to ensure accuracy.

Returns:

A tuple containing the paths of the downloaded, unzipped, converted, rinexmoded, and logs directories, in that order.

Return type:

tuple

set_translate_dict()[source]

Generates the translation dictionary based on the site and session dictionaries, object attributes, and site id.

The translation dictionary is used to replace placeholders in the path strings with actual values. It includes keys for each attribute in the site and session dictionaries, as well as for the site id. The site id has three variations: ‘site_id’, ‘site_id4’, and ‘site_id9’, each in both lower and upper case.

The method does not take any parameters and does not return any value. It directly modifies the ‘translate_dict’ attribute of the object.

Return type:

None

property site_id
property site_id4
property site_id9
property table
table_ok_cols_bool()[source]

Converts the column of the table to boolean values.

This method converts the specified column of the table to boolean values. The column is converted to True if the value is ‘OK’ and False otherwise.

Wrapper for arocmn.is_ok()

Return type:

None

property tmp_dir
translate_core(path_inp, trslt_dic_use, epoch_use, make_dir=False, absolute=False)[source]
translate_path(path_inp: str, epoch_inp=None, make_dir: bool = False, absolute: bool = False) str[source]

Translates a given path using the object’s translation dictionary and optionally creates the directory.

This function is able to create a directory corresponding to the translated path if make_dir is True. Warning: it creates the directory as it is! (no dirname extraction) If the translated path is a full path with a filename, you will get nasty results!

Parameters:
  • path_inp (str) – The input path to be translated.

  • epoch_inp (datetime, optional) – The epoch input to be used in the translation. Default is None.

  • make_dir (bool, optional) – If True, the function will create the directory corresponding to the translated path. Default is False.

  • absolute (bool, optional) – If True, the function will return the absolute path. Default is False.

Returns:

The translated directory path.

Return type:

str

Notes

The function uses the translator function from the arocmn module to perform the translation.

for translation of attribute self.inp_file_rinex, use also this method (we decide to not create a dedicated method for this)

translate_path_row(path_inp: str, irow: int, make_dir: bool = False, absolute: bool = False) str[source]

Translates a given path using the object’s translation dictionary for a specific row in the table.

This function translates the input path using the translation dictionary specific to the site ID of the row indicated by irow. It optionally creates the directory and returns the absolute path.

Parameters:
  • path_inp (str) – The input path to be translated.

  • irow (int) – The index of the row in the table to use for translation. Will override the StepGnss translate_dict.

  • make_dir (bool, optional) – If True, the function will create the directory corresponding to the translated path. Default is False.

  • absolute (bool, optional) – If True, the function will return the absolute path. Default is False.

Returns:

The translated directory path.

Return type:

str

trslt_dic_siteid(site_id_inp)[source]

Returns an ad hoc translation dictionary with given site IDs.

This function returns an ad hoc translation dictionary with the site ID in different formats. It adds the site ID in 4-character and 9-character formats, both in upper and lower case. If the site ID ends with ‘XXX’, it uses the 4-character format for the ‘site_id’ key.

Parameters:

site_id_inp (str) – The site ID to be used for updating the translation dictionary.

Returns:

trsltdict_out – The updated translation dictionary.

Return type:

dict

updt_eporng_tab(column_srt='epoch_srt', column_end='epoch_end', round_method='none')[source]

Updates the EpochRange of the StepGnss object based on the min/max epochs in the object’s table.

This function calculates the minimum and maximum epochs from the specified columns in the table. It then calculates the most common period (time difference between start and end epochs) in the table. The function updates the EpochRange of the StepGnss object with these calculated values.

Parameters:
  • column_srt (str, optional) – The name of the column in the table that contains the start epochs. Default is ‘epoch_srt’.

  • column_end (str, optional) – The name of the column in the table that contains the end epochs. Default is ‘epoch_end’.

  • round_method (str, optional) – The method used for rounding the epochs. The default is ‘none’.

Notes

If the period spacing in the table is not uniform, the function will keep the most common period.

updt_epotab_rnx(use_rnx_filename_only=False, update_epoch_range=True)[source]

Updates the StepGnss table’s columns ‘epoch_srt’ and ‘epoch_end’ based on the RINEX files.

If the StepGnss object contains RINEX files, this function updates the ‘epoch_srt’ and ‘epoch_end’ columns of the StepGnss table based on the RINEX files. The start and end epochs and the period of the RINEX file can be determined based on its name only (if use_rnx_filename_only is True). This function is much faster but less reliable. At the end of the table update, it can also update the EpochRange object associated to the StepGnss object (if update_epoch_range is True).

Parameters:
  • use_rnx_filename_only (bool, optional) – If True, determines the start epoch, the end epoch and the period of the RINEX file based on its name only. The RINEX file is not read. This function is much faster but less reliable. Default is False.

  • update_epoch_range (bool, optional) – If True, at the end of the table update, also updates the EpochRange object associated to the StepGnss object. This is recommended. Default is True.

Return type:

None

updt_epotab_tz(tz='UTC')[source]

Updates the epoch table with the specified timezone.

This method updates the ‘epoch_srt’ and ‘epoch_end’ columns of the epoch table with the specified timezone. It uses the ‘tz’ parameter to set the timezone for the epoch table.

Parameters:

tz (str, optional) – The timezone to be applied to the epoch table. Default is ‘UTC’.

Return type:

None

updt_rnxmodopts(rinexmod_options_inp=None, irow=None, debug_print=False)[source]

Updates the rinexmod options dictionnary.

This method updates the rinexmod options based on the provided input options and the current state of the StepGnss object. It handles default options, merges them with input options, and sets specific options like metadata and site name/marker.

Parameters:
  • rinexmod_options_inp (dict, optional) – Input options for RINEX modification. Default is None.

  • irow (int, optional) – Row index for setting the site name/marker from the table. Default is None.

  • debug_print (bool, optional) – If True, prints the RINEX modification options for debugging purposes. Default is False.

Returns:

Updated RINEX modification options.

Return type:

dict

updt_site_w_rnx_fname()[source]

Updates the site information in the table and in the ‘site_id’ object based on the RINEX filenames.

This method iterates over each row in the table and updates the ‘site’ column with the first 9 characters of the ‘fname’ column if the filename matches the RINEX regex pattern. It then updates the ‘site_id’ attribute of the StepGnss object based on the unique site values in the table.

Return type:

None

write_in_table_log(row_in)[source]

autorino.common.step_fcts module

Created on Mon Jan 8 16:53:51 2024

@author: psakic

autorino.common.step_fcts.check_lockfile(lockfile_path)[source]

Checks the lock status of a specified file.

This function attempts to acquire a lock on the specified file. If the lock is acquired, it prints a success message and releases the lock. If the lock is not acquired (i.e., the file is already locked by a previous process), it prints a message indicating that the process is locked.

Parameters:

lockfile_path (str) – The path of the lock file to check the lock status for.

Return type:

None

autorino.common.step_fcts.dummy_sess_dic()[source]

Creates a dummy session dictionary.

This function creates and returns a dictionary with dummy session information. The dictionary contains the following keys: - name: The name of the session. - data_frequency: The data frequency of the session. - tmp_dir_parent: The parent directory for temporary files. - tmp_dir_structure: The directory structure for temporary files. - log_parent_dir: The parent directory for log files. - log_dir_structure: The directory structure for log files. - out_dir_parent: The parent directory for output files. - out_structure: The directory structure for output files.

Returns:

A dictionary containing dummy session information.

Return type:

dict

autorino.common.step_fcts.dummy_site_dic()[source]

Creates a dummy site dictionary.

This function creates and returns a dictionary with dummy site information. The dictionary contains the following keys: - name: The name of the site. - site_id: The site identifier. - domes: The DOMES number of the site. - sitelog_path: The path to the site log. - position_xyz: The XYZ coordinates of the site.

Returns:

A dictionary containing dummy site information.

Return type:

dict

autorino.common.step_fcts.guess_sites_list(inp_fil)[source]

Guess the list of sites from the input list.

This function guesses the list of sites from the input list.

It extracts the site identifier from the input list and returns a list of unique site identifiers.

Parameters:

inp_fil (list) – The input list to extract the site identifiers from. See import_files for details.

Returns:

A list of unique site identifiers extracted from the input list.

Return type:

list

autorino.common.step_fcts.import_files(inp_fil, inp_regex='.*')[source]

Handles multiple types of input lists and returns a python list of the input.

This function can handle various types of input lists and convert them into a python list. The input can be:

  • a python list

  • a text file path containing a list of files

  • a tuple containing several text files path

  • a directory path.

If the input is a directory path, all the files matching the regular expression specified by ‘inp_regex’ are read.

Parameters:
  • inp_fil (list or str or tuple) – The input list to be interpreted. It can be a python list, a text file path containing a list of files, a tuple containing several text files path, or a directory path.

  • inp_regex (str, optional) – The regular expression used to filter the files when ‘inp_fil’ is a directory path. Default is “.*” which matches any file.

Returns:

The interpreted list.

Return type:

list

autorino.common.step_fcts.is_ok(val_inp)[source]

Checks if the input value is OK or not.

This function takes an input value and checks if it is defined. It considers None, NaN, False and an empty string as not OK. If the input value is one of these, the function returns False. Otherwise, it returns True.

Parameters:

val_inp (any or iterable of any) – The input value to be checked. Can handle iterables.

Returns:

True if the input value is defined, False otherwise.

Return type:

bool

autorino.common.step_fcts.load_previous_tables(log_dir)[source]

Load all previous tables from the log directory.

This function searches for all files ending with “*table.log” in the log directory and concatenates them into a single pandas DataFrame. If no such files are found, it returns an empty DataFrame and logs a warning.

Parameters:

log_dir (str) – The directory where the log files are stored.

Returns:

A DataFrame containing the concatenated data from all found log files. If no files are found, an empty DataFrame is returned.

Return type:

pandas.DataFrame

autorino.common.step_fcts.log_tester()[source]

Tests if the logger is working.

This function checks if the logger is working by logging a test message. If the logger is not working, it raises an exception.

Raises:

Exception – If the logger is not working.

autorino.common.step_fcts.make_site_id9(site_id_inp)[source]

Converts a site ID to a 9-character format.

This function takes a site ID and converts it to a 9-character format. If the input site ID is already 9 characters long, it returns the uppercase version of the input. If the input site ID is 4 characters long, it appends ‘00XXX’ to the uppercase version of the input. Otherwise, it takes the first 4 characters of the input, converts them to uppercase, and appends ‘00XXX’.

Parameters:

site_id_inp (str) – The input site ID to be converted.

Returns:

The site ID in 9-character format.

Return type:

str

autorino.common.step_fcts.move_copy_core(src, dest, copy_only=False, force=False)[source]

Moves or copies a file from the source to the destination.

This function attempts to copy or move a file from the source path to the destination path. If the operation is successful, it logs the action and returns the path of the moved/copied file. If the operation fails, it logs the error and returns None.

Parameters:
  • src (str) – The source file path.

  • dest (str) – The destination file path.

  • copy_only (bool, optional) – If True, the file is copied instead of moved. Default is False.

  • force (bool, optional) – Force the move/copy if the file already exists Default is False

Returns:

The path of the moved/copied file if the operation is successful, None otherwise.

Return type:

str or None

autorino.common.step_fcts.print_tab_core(table_inp, max_colwidth=33)[source]

Prints the table of the StepGnss object with specified formatting.

This method formats and prints the table of the StepGnss object. It shrinks the strings in the ‘fraw’, ‘fpath_inp’, and ‘fpath_out’ columns to a specified maximum length and formats the ‘epoch_srt’ and ‘epoch_end’ columns as strings with a specific date-time format. The method then prints the formatted table to the logger.

Parameters:
  • table_inp (pd.DataFrame) – The input table to be formatted and printed.

  • max_colwidth (int, optional) – The maximum column width for the output table. Default is 33.

Returns:

The formatted table as a string.

Return type:

str

autorino.common.step_fcts.rnxs2step_obj(rnxs_lis_inp)[source]

Convert a list of RINEX files to a StepGnss object.

This function creates a StepGnss object and populates it with data from the provided list of RINEX files. It loads the table from the file list, updates the site information from the RINEX filenames, and updates the epoch table from the RINEX filenames.

Parameters:

rnxs_lis_inp (list) – A list of RINEX file paths to be converted into a StepGnss object.

Returns:

A StepGnss object populated with data from the provided RINEX files.

Return type:

StepGnss

autorino.common.translate module

Created on Thu Jan 25 19:20:22 2024

@author: psakic

autorino.common.translate._translator_env_variables(path_inp)[source]

Translates environment variables in the input path.

This function is used internally by the translator function to handle environment variables in the path. It replaces each environment variable enclosed in angle brackets and prefixed with a dollar sign (e.g., <$VAR>) with its corresponding value from the system’s environment variables.

Parameters:

path_inp (str) – The input path containing environment variables to be translated.

Returns:

The translated path with environment variables replaced with their corresponding values from the system’s environment variables.

Return type:

str

Notes

If an environment variable in the path does not exist in the system’s environment variables, it will remain unchanged in the translated path.

autorino.common.translate._translator_epoch(path_inp, epoch_inp)[source]

Translates strftime aliases in the input path using the provided epoch information.

This function is used internally by the translator function to handle strftime aliases in the path. It also handles the special aliases <HOURCHAR> and <hourchar>, which are replaced with the hour of the epoch in uppercase and lowercase letters, respectively.

Parameters:
  • path_inp (str) – The input path containing strftime aliases to be translated.

  • epoch_inp (datetime) – A datetime object containing the epoch information used for translation.

Returns:

The translated path with strftime aliases replaced with the corresponding epoch information.

Return type:

str

Notes

For more information on strftime and strptime behavior, see: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior

autorino.common.translate._translator_keywords(path_inp, translator_dict)[source]

Translates keywords in the input path using the provided dictionary.

This function is used internally by the translator function to handle keywords in the path. It replaces each keyword enclosed in angle brackets (e.g., <keyword>) with its corresponding value from the dictionary. Keywords are case-sensitive and must not be prefixed with a dollar sign ($).

Parameters:
  • path_inp (str) – The input path containing keywords to be translated.

  • translator_dict (dict) – A dictionary containing keywords and their corresponding values for translation.

Returns:

The translated path with keywords replaced with their corresponding values from the dictionary.

Return type:

str

Notes

If a keyword in the path does not exist in the dictionary, it will remain unchanged in the translated path.

autorino.common.translate.abs_path_wrt(relative_path, base_abs_path)[source]

Converts a relative path to an absolute path with respect to another absolute file path.

Parameters:
  • relative_path (str) – The relative path to be converted.

  • base_abs_path (str) – The absolute path of the base file or directory.

Returns:

The absolute path.

Return type:

str

autorino.common.translate.translator(path_inp, translator_dict=None, epoch_inp=None)[source]

Frontend function to translates a given path using environment variables, epoch information, and a provided dictionary.

Parameters:
  • path_inp (str) – The input path to be translated.

  • translator_dict (dict, optional) – A dictionary containing keywords and their corresponding values for translation. Default is None.

  • epoch_inp (datetime, optional) – A datetime object containing epoch information for translation. Default is None.

Returns:

The translated path.

Return type:

str

Notes

The function first translates any environment variables in the path. If epoch information is provided, it is used to translate any strftime aliases in the path. If a translator dictionary is provided, it is used to translate any keywords in the path.