Metrics Analyzer

class ptp.metrics.Analyser(data, file=None, prefix=None, usetex=False, save_format='png', dpi=300, cache=None, skip=0.2)[source]

PTP metrics analyser

Parameters
  • data – Array of objects with simulation data

  • file – Path of the file

  • prefix – Prefix to include on filenames when saving

  • usetex – Whether to use latex interpreter

  • save_format – Select image format: ‘png’ or ‘eps’

  • dpi – Image resolution in dots per inch

  • skip – Fraction of the dataset to skip on the analysis.

analysis_plot()[source]

Decorator factory for analysis plots

Runs some common processing for plots and returns a decorator.

calc_expected_delays(metadata, save=False)[source]

Calculate the expected range of PTP delays in the given FH setup

Takes queueing, processing, and transmission delays into account.

Parameters
  • metadata – Metadata dictionary containing FH setup information

  • save – whether to write results into info.txt

Returns

Dictionary containing (best DL, worst DL, best UL, worst UL) theoretical delays including processing and queueing delays.

check_seq_id_gaps(verbose=True, save=False)[source]

Check whether there are gaps on sequenceIds

delay_asymmetry(verbose=True, save=False)[source]

Analyze the delay asymmetry

Compute and print some relevant asymmetry metrics.

Parameters
  • verbose – whether to print results (otherwise just return it)

  • save – whether to write results into info.txt

Returns

Average delay asymmetry

foffset_err_stats(save=False)[source]

Print the frequency offset estimation error statistics

Parameters

save – whether to write results into info.txt

load_maxte_and_mtie_cache()[source]

Load cached max|TE| and MTIE results

max_te(te, window_len)[source]

Maximum absolute time error (max|TE|)

Computes the max|TE| based on time error (TE) samples. The max|TE| metric compute the maximum among the absolute time error sample over a sliding non-overlapping window.

Parameters
  • window_len – Window length

  • te – Vector of time error (TE) values

Returns

The calculated Max|TE| over a sliding window

Return type

max_te

mtie(te, window_step=2, starting_window=16)[source]

Maximum time interval error (MTIE)

Computes the MTIE based on time error (TE) samples. The MTIE computes the peak-to-peak time interval error (TIE) over windows of increasing duration.

Parameters
  • te – Vector of TE values

  • window_step – Enlarge window by this step on every iteration

  • starting_window – Starting window size

Returns

MTIE observation intervals mtie_array : The calculated MTIE for each observation interval

Return type

tau_array

ptp_exchanges_per_sec(save=False)[source]

Compute average number of PTP exchanges per second

Parameters

save – whether to write results into info.txt

Returns

The computed average

rank_algorithms(metric, max_te_win_len=1000, save=False)[source]

Rank algorithms based on a chosen performance metric

Parameters
  • metric – Metric used for ranking: max-te, mtie, rms or std

  • max_te_win_len – Window length used for the max|TE| computation

rolling_window_mtx(x, window_size, shift=1)[source]

Compute all overlapping (rolling) observation windows in a matrix

Parameters
  • x – observation vector that is supposed to be split into overlapping windows

  • shift – Controls the shift between consecutive windows or, equivalently, the overlap. For instance, if shift=1, each window overlaps with N-1 samples of the previous window. If shift=window_size, the windows are completely disjoint.

  • window_size – the target window size

Returns

Window matrix with all windows as rows. That is, if n_windows is the number of windows, the result has dimensions:

(n_windows, window_size)

save_maxte_and_mtie_cache()[source]

Save cached max|TE| and MTIE results

save_metadata(metadata, save=False)[source]

Save metadata info on the path where plots are saved

Note this method will overwrite the info.txt file. Hence, it should be called before all other methods that print to info.txt.

toffset_drift_err_stats(save=False)[source]

Print the time offset drift estimation error statistics

Parameters

save – whether to write results into info.txt

toffset_err_stats(save=False)[source]

Print the time offset estimation error statistics

Parameters

save – whether to write results into info.txt

window_optimizer_results(save=False)[source]

Print window optimizer results from cache file