Settings¶
settings ¶
Settings
dataclass
¶
Bases: ABC
Base class for all settings dataclasses.
Provides serialization/deserialization functionality to and from dictionaries, JSON strings, and files.
to_dict ¶
Converts settings to a dictionary.
Returns:
-
dict(dict) –Dictionary representation of the settings
Source code in trajectopy\core\settings.py
encoder
staticmethod
¶
Encodes values for JSON serialization.
Parameters:
-
name(str) –Name of the attribute being encoded
-
value(Any) –Value to encode
Returns:
-
Any(Any) –Encoded value suitable for JSON serialization
Source code in trajectopy\core\settings.py
decoder
staticmethod
¶
Decodes values from JSON deserialization.
Parameters:
-
name(str) –Name of the attribute being decoded
-
value(Any) –Value to decode
Returns:
-
Any(Any) –Decoded value
to_json ¶
Converts settings to a JSON string.
Returns:
-
str(str) –JSON string representation of the settings
to_file ¶
Writes settings to a JSON file.
Parameters:
-
path(str) –Path to the output file
from_dict
classmethod
¶
Creates settings instance from a dictionary.
Missing attributes keep their default value so that settings files written by older versions can still be read. Unknown attributes are ignored with a warning.
Parameters:
-
dct(dict) –Dictionary containing settings data
Returns:
-
Settings(_SettingsT) –New settings instance
Raises:
-
TypeError–If a value does not match the declared attribute type
Source code in trajectopy\core\settings.py
from_file
classmethod
¶
Loads settings from a JSON file.
Parameters:
-
path(str) –Path to the JSON file
Returns:
-
Settings(_SettingsT) –Settings instance loaded from file
Source code in trajectopy\core\settings.py
update_from_dict ¶
Updates settings from a dictionary.
Attributes missing from the dictionary keep their current value. Unknown attributes are ignored with a warning. The update is atomic: if any value is invalid, the settings remain unchanged.
Parameters:
-
dct(dict) –Dictionary containing updated settings data
Raises:
-
TypeError–If a value does not match the declared attribute type
Source code in trajectopy\core\settings.py
AlignmentPreprocessing
dataclass
¶
AlignmentPreprocessing(
min_speed: float = 0.0,
time_start: float = 0.0,
time_end: float = 0.0,
max_samples: int = 5000,
)
Bases: Settings
Configuration for alignment preprocessing filters.
Attributes:
-
min_speed(float) –Only poses with speed above this threshold are considered for alignment (meters/second). Defaults to 0.0.
-
time_start(float) –Only poses with timestamp above this threshold are considered. Timestamp is in seconds relative to first common timestamp. Defaults to 0.0.
-
time_end(float) –Only poses with timestamp below this threshold are considered. Timestamp is in seconds relative to first common timestamp. Defaults to 0.0.
-
max_samples(int) –Maximum number of matched poses used for the alignment. If more poses are available, a new random subset of this size is drawn on each run. Set to 0 to use all poses. Defaults to 5000.
AlignmentEstimationSettings
dataclass
¶
AlignmentEstimationSettings(
translation_x: bool = True,
translation_y: bool = True,
translation_z: bool = True,
rotation_x: bool = True,
rotation_y: bool = True,
rotation_z: bool = True,
scale: bool = False,
time_shift: bool = False,
leverarm_x: bool = False,
leverarm_y: bool = False,
leverarm_z: bool = False,
sensor_rotation: bool = False,
)
Bases: Settings
Configuration for parameters to estimate during trajectory alignment.
Attributes:
-
translation_x(bool) –Enable x-translation of similarity transformation
-
translation_y(bool) –Enable y-translation of similarity transformation
-
translation_z(bool) –Enable z-translation of similarity transformation
-
rotation_x(bool) –Enable rotation around X-axis of similarity transformation
-
rotation_y(bool) –Enable rotation around Y-axis of similarity transformation
-
rotation_z(bool) –Enable rotation around Z-axis of similarity transformation
-
scale(bool) –Enable scaling of similarity transformation
-
time_shift(bool) –Enable estimation of time shift between trajectories
-
leverarm_x(bool) –Enable estimation of lever arm in X-direction
-
leverarm_y(bool) –Enable estimation of lever arm in Y-direction
-
leverarm_z(bool) –Enable estimation of lever arm in Z-direction
-
sensor_rotation(bool) –Enable computation of sensor rotation offsets (independent of least squares, computes constant offsets between roll, pitch, yaw)
all_disabled
property
¶
Checks if all alignment parameters are disabled.
Returns:
-
bool(bool) –True if all parameters (Helmert, time shift, leverarm, sensor rotation) are disabled
all_lq_disabled
property
¶
Checks if all least-squares parameters are disabled.
Returns:
-
bool(bool) –True if all parameters estimated with least-squares are disabled
helmert_enabled
property
¶
Checks if any Helmert transformation parameter is enabled.
Returns:
-
bool(bool) –True if any translation, rotation, or scale parameter is enabled
leverarm_enabled
property
¶
Checks if any leverarm parameter is enabled.
Returns:
-
bool(bool) –True if any leverarm component (x, y, z) is enabled
time_shift_enabled
property
¶
Checks if time shift estimation is enabled.
Returns:
-
bool(bool) –True if time shift is enabled
short_mode_str
property
¶
Gets a short string describing enabled parameter groups.
Returns:
-
str(str) –Space-separated string of enabled parameter groups (e.g., "Helmert Time-Shift Leverarm")
time_shift_filter
property
¶
Gets time shift parameter filter.
Returns:
-
list[bool]–List[bool]: List of 3 bools, all True if time shift enabled, else all False
helmert_filter
property
¶
Gets Helmert parameter filter.
Returns:
-
list[bool]–List[bool]: List of 7 bools indicating which Helmert parameters are enabled
leverarm_filter
property
¶
Gets leverarm parameter filter.
Returns:
-
list[bool]–List[bool]: List of 3 bools indicating which leverarm components are enabled
enabled_lq_parameter_filter
property
¶
Gets filter for enabled least-squares parameters only.
Returns:
-
list[bool]–List[bool]: List of bools for only the enabled parameter groups
lq_parameter_filter
property
¶
Gets complete least-squares parameter filter.
Returns:
-
list[bool]–List[bool]: List of 11 bools for all LQ parameters (7 Helmert + 1 time shift + 3 leverarm)
__bool__ ¶
Returns True if any least-squares parameter is enabled.
Returns:
-
bool(bool) –True if at least one least-squares parameter is enabled
from_components
classmethod
¶
from_components(
similarity: bool = False,
time_shift: bool = False,
leverarm: bool = False,
sensor_rotation: bool = False,
) -> AlignmentEstimationSettings
Creates settings from high-level component flags.
Parameters:
-
similarity(bool, default:False) –Enable all similarity transformation parameters. Defaults to False.
-
time_shift(bool, default:False) –Enable time shift estimation. Defaults to False.
-
leverarm(bool, default:False) –Enable all leverarm parameters. Defaults to False.
-
sensor_rotation(bool, default:False) –Enable sensor rotation estimation. Defaults to False.
Returns:
-
AlignmentEstimationSettings(AlignmentEstimationSettings) –New settings instance
Source code in trajectopy\core\settings.py
all
classmethod
¶
all(
sensor_rotation: bool = True,
) -> AlignmentEstimationSettings
Creates settings with all parameters enabled.
Parameters:
-
sensor_rotation(bool, default:True) –Enable sensor rotation. Defaults to True.
Returns:
-
AlignmentEstimationSettings(AlignmentEstimationSettings) –Settings with all parameters enabled
Source code in trajectopy\core\settings.py
from_bool_list
classmethod
¶
from_bool_list(
bool_list: list[bool],
) -> AlignmentEstimationSettings
Creates settings from a list of boolean values.
Parameters:
-
bool_list(list[bool]) –List of 14 booleans corresponding to parameter enable flags
Returns:
-
AlignmentEstimationSettings(AlignmentEstimationSettings) –New settings instance
Raises:
-
ValueError–If bool_list length is not 14
Source code in trajectopy\core\settings.py
AlignmentStochastics
dataclass
¶
AlignmentStochastics(
std_xy_from: float = 1.0,
std_z_from: float = 1.0,
std_xy_to: float = 1.0,
std_z_to: float = 1.0,
std_roll_pitch: float = float(deg2rad(1.0)),
std_yaw: float = float(deg2rad(1.0)),
std_speed: float = 1.0,
error_probability: float = 0.05,
variance_estimation: bool = False,
robust_estimation: bool = True,
)
Bases: Settings
Configuration for alignment stochastic model (observation uncertainties).
Attributes:
-
std_xy_from(float) –Standard deviation of XY source position components in meters. Defaults to 1.0.
-
std_z_from(float) –Standard deviation of Z source position component in meters. Defaults to 1.0.
-
std_xy_to(float) –Standard deviation of XY target position components in meters. Defaults to 1.0.
-
std_z_to(float) –Standard deviation of Z target position component in meters. Defaults to 1.0.
-
std_roll_pitch(float) –Standard deviation of roll and pitch angles in radians. Defaults to ~0.017 rad (1°).
-
std_yaw(float) –Standard deviation of yaw angle in radians. Defaults to ~0.017 rad (1°).
-
std_speed(float) –Standard deviation of platform speed in meters per second. Defaults to 1.0.
-
error_probability(float) –Probability of error for stochastic testing. Defaults to 0.05.
-
variance_estimation(bool) –Enable a-posteriori variance factor estimation. Defaults to False.
-
robust_estimation(bool) –Down-weight epochs with large residuals (iteratively reweighted least squares with Huber weights), so that outliers, e.g. from wrong matches or GNSS multipath, hardly affect the estimated parameters. Defaults to True.
var_xy_from
property
¶
Gets variance of XY source position components.
Returns:
-
float(float) –Variance (squared standard deviation)
var_z_from
property
¶
Gets variance of Z source position component.
Returns:
-
float(float) –Variance (squared standard deviation)
var_xy_to
property
¶
Gets variance of XY target position components.
Returns:
-
float(float) –Variance (squared standard deviation)
var_z_to
property
¶
Gets variance of Z target position component.
Returns:
-
float(float) –Variance (squared standard deviation)
var_roll_pitch
property
¶
Gets variance of roll and pitch angles.
Returns:
-
float(float) –Variance (squared standard deviation)
var_yaw
property
¶
Gets variance of yaw angle.
Returns:
-
float(float) –Variance (squared standard deviation)
var_speed_to
property
¶
Gets variance of platform speed.
Returns:
-
float(float) –Variance (squared standard deviation)
AlignmentSettings
dataclass
¶
AlignmentSettings(
preprocessing: AlignmentPreprocessing = AlignmentPreprocessing(),
estimation_settings: AlignmentEstimationSettings = AlignmentEstimationSettings(),
stochastics: AlignmentStochastics = AlignmentStochastics(),
metric_threshold: float = METRIC_THRESHOLD,
time_threshold: float = TIME_THRESHOLD,
)
Bases: Settings
Complete configuration for trajectory alignment.
Combines preprocessing, estimation, and stochastic settings for trajectory alignment.
Attributes:
-
preprocessing(AlignmentPreprocessing) –Preprocessing filter settings
-
estimation_settings(AlignmentEstimationSettings) –Parameter estimation settings
-
stochastics(AlignmentStochastics) –Stochastic model (observation uncertainty) settings
-
metric_threshold(float) –Iteration threshold for metric parameters in least squares. Defaults to 1e-4.
-
time_threshold(float) –Iteration threshold for time shift parameter in least squares (seconds). Defaults to 1e-4.
__str__ ¶
Returns string representation of all settings.
Returns:
-
str(str) –Concatenated string of preprocessing, estimation, and stochastics settings
Source code in trajectopy\core\settings.py
RotationApproximationMethod ¶
Bases: Enum
Method for rotation approximation.
PositionApproximationMethod ¶
Bases: Enum
Method for position approximation.
ApproximationSettings
dataclass
¶
ApproximationSettings(
position_interval_size: float = 0.15,
position_min_observations: int = 25,
rotation_window_size: float = 0.15,
max_path_length_gap: float = 0.15,
position_approximation_method: PositionApproximationMethod = CUBIC,
rotation_approximation_method: RotationApproximationMethod = AVERAGE_IN_WINDOW,
)
Bases: Settings
Configuration for trajectory approximation and smoothing.
Attributes:
-
position_interval_size(float) –Size of position intervals in meters for cubic approximation. Defaults to 0.15.
-
position_min_observations(int) –Minimum number of observations required in each interval for cubic approximation. Defaults to 25.
-
rotation_window_size(float) –Size of rotation smoothing window in meters (not cubic). Defaults to 0.15.
-
max_path_length_gap(float) –Maximum gap size in path length for interpolation. Defaults to 0.15.
encoder
staticmethod
¶
Encodes position_approximation_method and rotation_approximation_method enums to string values.
Parameters:
-
name(str) –Attribute name
-
value(Any) –Value to encode
Returns:
-
Any(Any) –Encoded value
Source code in trajectopy\core\settings.py
decoder
staticmethod
¶
Decodes position_approximation_method and rotation_approximation_method strings to enums. Args: name: Attribute name value: Value to decode
Returns:
-
Any(Any) –Decoded value
Source code in trajectopy\core\settings.py
PairDistanceUnit ¶
Bases: Enum
Unit of measurement for pose pair distances in relative comparison.
from_str
classmethod
¶
from_str(unit_str: str) -> PairDistanceUnit
Converts a string to a PairDistanceUnit.
Parameters:
-
unit_str(str) –String to convert ("m", "meter", "s", "sec", "second")
Returns:
-
PairDistanceUnit(PairDistanceUnit) –Converted unit
Raises:
-
ValueError–If unit string is not recognized
Source code in trajectopy\core\settings.py
ComparisonMethod ¶
Bases: Enum
Method for trajectory comparison.
from_string
classmethod
¶
from_string(string: str) -> ComparisonMethod
Converts string to ComparisonMethod.
Parameters:
-
string(str) –String containing "absolute" or "relative"
Returns:
-
ComparisonMethod(ComparisonMethod) –Parsed comparison method
Source code in trajectopy\core\settings.py
RelativeComparisonSettings
dataclass
¶
RelativeComparisonSettings(
pair_min_distance: float = 100.0,
pair_max_distance: float = 800.0,
pair_distance_step: float = 100.0,
pair_distance_unit: PairDistanceUnit = METER,
use_all_pose_pairs: bool = True,
)
Bases: Settings
Configuration for relative trajectory comparison (RPE - Relative Pose Error).
Relative comparison involves finding pose pairs separated by specific distances or time intervals and computing relative translation/rotation differences.
Attributes:
-
pair_min_distance(float) –Minimum pose pair distance to consider during RPE computation. Defaults to 100.0.
-
pair_max_distance(float) –Maximum pose pair distance to consider during RPE computation. Defaults to 800.0.
-
pair_distance_step(float) –Step size for increasing pose pair distance. Defaults to 100.0.
-
pair_distance_unit(PairDistanceUnit) –Unit of pose pair distance (METER or SECOND). Defaults to METER.
-
use_all_pose_pairs(bool) –If True, use overlapping pose pairs; if False, use only consecutive (non-overlapping) pairs. Defaults to True.
encoder
staticmethod
¶
Encodes pair_distance_unit enum to string value.
Parameters:
-
name(str) –Attribute name
-
value(Any) –Value to encode
Returns:
-
Any(Any) –Encoded value
Source code in trajectopy\core\settings.py
decoder
staticmethod
¶
Decodes pair_distance_unit string to enum.
Parameters:
-
name(str) –Attribute name
-
value(Any) –Value to decode
Returns:
-
Any(Any) –Decoded value
Source code in trajectopy\core\settings.py
MatchingMethod ¶
Bases: Enum
Method for matching poses between two trajectories.
Attributes:
-
NEAREST_SPATIAL–Match by nearest Euclidean distance
-
NEAREST_TEMPORAL–Match by nearest timestamp
-
INTERPOLATION–Match using linear interpolation (SLERP for rotations)
-
NEAREST_SPATIAL_INTERPOLATED–Match spatially using k-nearest and 3D line fit
-
UNKNOWN–Unknown matching method
InterpolationMethod ¶
Bases: Enum
Method for interpolation.
MatchingSettings
dataclass
¶
MatchingSettings(
method: MatchingMethod = INTERPOLATION,
max_time_diff: float = 0.01,
max_distance: float = 0.0,
max_gap_size: float = 10.0,
k_nearest: int = 2,
)
Bases: Settings
Configuration for trajectory matching.
Attributes:
-
method(MatchingMethod) –Matching method to use. Defaults to INTERPOLATION.
-
max_time_diff(float) –Maximum allowed time difference in seconds for temporal matching. Defaults to 0.01.
-
max_distance(float) –Maximum allowed distance in meters for spatial matching. Defaults to 0.0.
-
max_gap_size(float) –Maximum allowed gap size in seconds within trajectories. Defaults to 10.0.
-
k_nearest(int) –Number of nearest neighbors for spatial interpolation matching. Defaults to 2.
encoder
staticmethod
¶
Encodes method enum to string value.
Parameters:
-
name(str) –Attribute name
-
value(Any) –Value to encode
Returns:
-
Any(Any) –Encoded value
Source code in trajectopy\core\settings.py
decoder
staticmethod
¶
Decodes method string to enum.
Parameters:
-
name(str) –Attribute name
-
value(Any) –Value to decode
Returns:
-
Any(Any) –Decoded value
Source code in trajectopy\core\settings.py
PlotSettings
dataclass
¶
PlotSettings(
ate_unit_is_mm: bool = False,
directed_ate: bool = False,
ate_remove_above: float = 0.0,
hist_percentile: float = 1.0,
colorbar_max_std: float = 3.0,
smoothing_window: int = 1,
use_relative_timestamps: bool = False,
line_width: float = 5,
marker_size: float = 5.0,
font_size: int = 10,
export_format: str = "png",
export_width: int = 1600,
use_opengl: bool = True,
)
Bases: Settings
Configuration of all plots (GUI and :mod:trajectopy.visualization).
The along-track direction is positive in travel direction, horizontal cross-track is positive to the right, and vertical cross-track is positive upwards.
Attributes:
-
ate_unit_is_mm(bool) –Show position deviations in millimeters instead of meters. Defaults to False.
-
directed_ate(bool) –Show position deviations split into along-track, horizontal cross-track and vertical cross-track instead of x, y and z. Defaults to False.
-
ate_remove_above(float) –Exclude position deviations above this value in meters (0.0 = keep all). Defaults to 0.0.
-
hist_percentile(float) –Show histogram data up to this percentile of the absolute values. Defaults to 1.0.
-
colorbar_max_std(float) –Clip color-coded values to mean ± this many standard deviations, so that outliers don't dominate the color scale (0.0 = no clipping). Defaults to 3.0.
-
smoothing_window(int) –Moving-average window applied to color-coded values (1 = no smoothing). Defaults to 1.
-
use_relative_timestamps(bool) –Show time axes in seconds relative to the first timestamp instead of absolute (UTC) time. Defaults to False.
-
line_width(float) –Line width in pixels. Defaults to 1.5.
-
marker_size(float) –Marker size in pixels of color-coded trajectory maps. Defaults to 4.
-
font_size(int) –Font size in points of axis labels and titles. Defaults to 10.
-
export_format(str) –File format for exported plots ("png", "jpg" or "svg"). Defaults to "png".
-
export_width(int) –Width in pixels of exported raster images. Defaults to 1600.
-
use_opengl(bool) –Draw plot windows with OpenGL, which keeps panning and zooming fluid for large data sets. Falls back to software rendering if OpenGL is not available. Exports are not affected. Defaults to True.
SortingSettings
dataclass
¶
Bases: Settings
Configuration for trajectory sorting and downsampling using Moving Least Squares.
Attributes:
-
voxel_size(float) –Size of voxel grid for downsampling (meters). Voxel centroids are used for nearest neighbor searches instead of raw points. Defaults to 0.05.
-
movement_threshold(float) –Maximum allowed point movement between MLS iterations (meters). Algorithm terminates when all points move less than this. Defaults to 0.005.
-
k_nearest(int) –Number of nearest voxels to consider during MLS smoothing. Defaults to 4.
ProcessingSettings
dataclass
¶
ProcessingSettings(
alignment: AlignmentSettings = AlignmentSettings(),
matching: MatchingSettings = MatchingSettings(),
relative_comparison: RelativeComparisonSettings = RelativeComparisonSettings(),
approximation: ApproximationSettings = ApproximationSettings(),
sorting: SortingSettings = SortingSettings(),
)
Bases: Settings
Complete configuration for trajectory processing.
Combines all processing-related settings including alignment, matching, relative comparison, approximation, and sorting.
Attributes:
-
alignment(AlignmentSettings) –Alignment configuration
-
matching(MatchingSettings) –Matching configuration
-
relative_comparison(RelativeComparisonSettings) –Relative comparison (RPE) configuration
-
approximation(ApproximationSettings) –Approximation and smoothing configuration
-
sorting(SortingSettings) –Sorting and downsampling configuration