scripts.synthetic_data_generation.main package

Submodules

scripts.synthetic_data_generation.main.transform_test_data_set module

class scripts.synthetic_data_generation.main.transform_test_data_set.CoordinateSystem(origin_with_respect_to_ref_sys_x, origin_with_respect_to_ref_sys_y, origin_with_respect_to_ref_sys_z, yaw_xy_with_respect_to_ref_sys, pitch_yz_with_respect_to_ref_sys, roll_xz_with_respect_to_ref_sys)

Bases: object

This class represents a coordinate system/orientation of an object in the real world. It is seen relative to a arbitrary frame of reference, which could be e.g. a location that is analyzed.

Parameters
  • origin_with_respect_to_ref_sys_x (numeric) – x-translation parameter of coordinate system in relation to frame of refrence

  • origin_with_respect_to_ref_sys_y (numeric) – y-translation parameter of coordinate system in relation to frame of refrence

  • origin_with_respect_to_ref_sys_z (numeric) – z-translation parameter of coordinate system in relation to frame of refrence

  • yaw_xy_with_respect_to_ref_sys (numeric) – xy-rotational parameter (counterclockwise) of coordinate system in relation to frame of refrence, see https://bit.ly/3AZM5iP for graphical representation

  • pitch_yz_with_respect_to_ref_sys (numeric) – yz-rotational parameter (counterclockwise) of coordinate system in relation to frame of refrence, see https://bit.ly/3AZM5iP for graphical representation

  • roll_xz_with_respect_to_ref_sys (numeric) – xz-rotational parameter (counterclockwise) of coordinate system in relation to frame of refrence, see https://bit.ly/3AZM5iP for graphical representation

get_pitch_yz()

Getter function for pitch (yz-rotational) parameter of coordinate system in relation to frame of reference

Returns

Returns pitch (yz-rotational) parameter of coordinate system in relation to frame of reference

Return type

numeric

get_roll_xz()

Getter function for roll (xz-rotational) parameter of coordinate system in relation to frame of reference

Returns

Returns roll (xz-rotational)) parameter of coordinate system in relation to frame of reference

Return type

numeric

get_translation_x()

Getter function for x-translation parameter of coordinate system in relation to frame of reference

Returns

Returns x-translation parameter of coordinate system in relation to frame of reference

Return type

numeric

get_translation_y()

Getter function for y-translation parameter of coordinate system in relation to frame of reference

Returns

Returns y-translation parameter of coordinate system in relation to frame of reference

Return type

numeric

get_translation_z()

Getter function for z-translation parameter of coordinate system in relation to frame of reference

Returns

Returns z-translation parameter of coordinate system in relation to frame of reference

Return type

numeric

get_yaw_xy()

Getter function for yaw (xy-rotational) parameter of coordinate system in relation to frame of reference

Returns

Returns yaw (xy-rotational) parameter of coordinate system in relation to frame of reference

Return type

numeric

class scripts.synthetic_data_generation.main.transform_test_data_set.Location(name, external_identifier, sensors)

Bases: object

This class represents a real world measurement location.

Parameters
  • name (string) – Name of the location or venue

  • external_identifier (string) – Code / ID of room in external system

  • sensors (Array of Sensor) – Sensors placed inside the location for measurement purposes

construct_json_payload()

Constructs the json payload of a location

Returns

Returns constructed json payload for a location

Return type

dict(json)

get_location_external_id()

Getter function for the location external id

Returns

Returns location external id

Return type

string

get_location_name()

Getter function for the location name

Returns

Returns location name

Return type

string

class scripts.synthetic_data_generation.main.transform_test_data_set.Sensor(sensor_type, coordinate_system, sensor_precision, sensor_pollingrate, measurement_reach, sensor_temporal_measurement_unit='ms', sensor_spatial_measurement_unit='cm', sensor_identifier='', stability_function_type='linear')

Bases: object

This class represents a synthetic sensor that emulates the measurement of datapoints based on the (virtual) sensor’s parameters and the true position of the object to measure

Parameters
  • sensor_type (string) – Description of the sensor type, e.g. RFID, camera or NFC

  • coordinate_system (CoordinateSystem) – Coordinate system that describes the position and rotation of the sensor inside the frame of reference (e.g. of the location)

  • sensor_precision (numeric) – Precision of the sensor, i.e. minimal spatial resolution of the sensor in the measurement unit defined in parameter “sensor_spatial_measurement_unit”

  • sensor_pollingrate (numeric) – Pollingrate of the sensor, i.e. maximal temporal resolution of the sensor in the measurement unit defined in parameter “sensor_temporal_measurement_unit”

  • measurement_reach (numeric) – Maximum measurement reach of the sensor, past this distance the sensor is not able to measure anything, measurement unit defined in parameter “sensor_spatial_measurement_unit”

  • sensor_spatial_measurement_unit (String) – Measurement unit of the sensor in a temporal dimension, allowed are the SI unit “s” (including all prefixes) and the non-SI units “min” (minutes), “h”(hours) and “d”(days) TODO: NOT YET CONSIDERED

  • sensor_temporal_measurement_unit (String) – Measurement unit of the sensor in a spatial dimension, allowed are all available SI prefixes for meters TODO: NOT YET CONSIDERED

  • sensor_identifier (string) – Unique identifier of the sensor, defaults to automatically generated uuid4

  • stability_function_type (string) – Defines type of the stability function of the measurement of the sensor, i.e. how large the signal degradation is based on distance between object to be measured and the sensor. Covered are ‘linear’ and ‘static’, default ‘linear’

calculate_distance_to_point(point_abs_x, point_abs_y, point_abs_z)

Calculate distance between sensor and point

Parameters
  • self (Sensor) – self

  • point_abs_x (integer) – x coordinate of point

  • point_abs_y (integer) – y coordinate of point

  • point_abs_z (integer) – z coordinate of point

Returns

Returns the distance from sensor to point

Return type

integer

check_sensor_measurement_distance(distance_to_point)
generate_random_point_in_sphere(point_x, point_y, point_z)

Simualtes measurement of a sensor. Given a random true position as x,y,z coordinates the function creates a random point around the true position given based on the precision of the sensor. This is done via rejection sampling (https://en.wikipedia.org/wiki/Rejection_sampling) to generate a uniform distribution.

Parameters
  • point_x (numeric) – x-Coordinate of the true position (as relative coordinate) of object for which a measurement should be simulated

  • point_y (numeric) – y-Coordinate of the true position (as relative coordinate) of object for which a measurement should be simulated

  • point_z (numeric) – z-Coordinate of the true position (as relative coordinate) of object for which a measurement should be simulated

Returns

Returns positional parameters (x,y,z) for synthetically generated measurement point. Returned parameters are in coordinate system of sensor for which the measurement was simulated.

Return type

3-tuple (numeric,numeric,numeric)

get_sensor_coordinate_system()

Getter function for the sensor coordinate system

Returns

Returns sensor coordinate system

Return type

CoordinateSystem

get_sensor_id()

Getter function for the sensor id

Returns

Returns x,y,z-coordinate of the sensor in the frame of reference

Return type

string

get_sensor_orientation()

Getter function for orientation parameters (yaw [xy], pitch [yz], roll [xz]) of sensors in the frame of reference

Returns

Returns orientation parameters of the sensor in the frame of reference

Return type

tuple(numeric)

get_sensor_pollingrate()

Getter function for the sensor pollingrate

Returns

Returns sensor pollingrate in ms

Return type

numerical

get_sensor_position()

Getter function for positional parameters (x,y,z) of sensors in the frame of reference

Returns

Returns x,y,z-coordinate of the sensor in the frame of reference

Return type

tuple(numeric)

get_sensor_precision()

Getter function for the sensor precision

Returns

Returns sensor precision

Return type

numeric

get_sensor_reach()

Getter function for the sensor reach

Returns

Returns sensor reach

Return type

numeric

get_sensor_spatial_measurement_unit()

Getter function for spatial measurement unit of the sensor

Returns

Returns spatial measurent unit of the sensor

Return type

string

get_sensor_temporal_measurement_unit()

Getter function for temporal measurement unit of the sensor

Returns

Returns temporal measurent unit of the sensor

Return type

string

get_sensor_type()

Getter function for the sensor type

Returns

Returns sensor type

Return type

string

scripts.synthetic_data_generation.main.transform_test_data_set.function_wrapper_data_ingestion(path, import_rows, measurement_sensor, identifier_randomization_method='random', identifier_type='mac-address', transform_to_3D_data=False)

Wrapper function to facilitate generation of simulation dataframe

Parameters
  • path (string) – File path to movement data file

  • import_rows (integer) – Number of rows that should be sourced

  • measurement_sensor (Sensor) – Sensor for which the measurements should be simulated

  • identifier_randomization_method (string) – randomization method for identifier, default ‘random’

  • identifier_type (string) – Identifier type used for object id randomization, default ‘mac-address’

  • transform_to_3D_data (Boolean) – Flag if data should be 3D (True) or 2D (False), default ‘False’

Returns

Returns the simulation dataframe containing all simulated measurements

Return type

pandas dataframe

scripts.synthetic_data_generation.main.transform_test_data_set.function_wrapper_example_plots(example_sensor, point_x, point_y, point_z, repeated_steps)

Wrapper function to facilitate generation of rejection sampling and coordinate system plots (frame of reference in sensor frame and vice versa)

Parameters
  • example_sensor (Sensor) – Sensor for which measurements and coordinate systems should be simulated

  • point_x (integer) – x coordinate of center of sphere for rejection sampling

  • point_y (integer) – y coordinate of center of sphere for rejection sampling

  • point_z (integer) – z coordinate of center of sphere for rejection sampling

  • repeated_steps (integer) – Number of measurements that should be generated via rejection sampling

Returns

None

Return type

None

scripts.synthetic_data_generation.main.transform_test_data_set.generate_random_object_id(randomization_type='mac-address')

Function that generates random object id based on randomization type

Parameters

randomization_type (string) – Type of randomization, default ‘mac-address’

Returns

Returns a randomized 12-byte MAC Address divided by semicolons

Return type

string

scripts.synthetic_data_generation.main.transform_test_data_set.import_occupancy_presence_dataset(filepath, import_rows_count, drop_irrelevant_columns=True, transform_to_3D_data=False, starting_date='01.06.2019', date_format='%d.%m.%Y')

Imports the true position dataset of the given format from source: https://www.kaggle.com/claytonmiller/occupancy-presencetrajectory-data-from-a-building/version/1

Parameters
  • filepath (raw string literal) – filepath of trueposition dataset

  • import_rows_count (integer) – Max. number of rows that should be imported from dataset

  • drop_irrelevant_columns (boolean) – Specifies if (for this analysis) irrelevant columns should be dropped, default is True

  • transform_to_3D_data (boolean) – Specifies if data should either consider the true position coordinate as 0 (if == False) or set the z-coordinate of the true positions as ‘height’ (if == True), default is True

  • starting_date (string) – As dataset only provides date ids, they need to be transformed into actual dates. starting_date specifies actual date for day_id == 0. Uses date_format for date parsing, default is ‘01.06.2019’

  • date_format (string) – Specifies format of starting_date, default is ‘%d.%m.%Y’

Raises

ValueError – ValueError risen if not expected columns are present

Returns

Returns the imported file as dataframe

Return type

dataframe

scripts.synthetic_data_generation.main.transform_test_data_set.plot_point_in_two_coordinate_systems(point_x, point_y, point_z, point_coord_sys, plot_system_indicators=True)

Plots two coordinate systems (frame of reference and point coordinate system that contain the same point transformed). Upper plot is in frame of reference, Lower plot in point coordinate system

Parameters
  • point_x (numeric) – x-coordinate of point in point coordinate system

  • point_y (numeric) – y-coordinate of point in point coordinate system

  • point_z (numeric) – z-coordinate of point in point coordinate system

  • point_coord_sys (CoordinateSystem) – Coordinate system of the point to be plotted

  • plot_system_indicators (boolean) – Speficies wheter or not system indicators (x,y,z and identity vector for coordinate systems incl. labels) should be plotted or not, default is True

Returns

Returns nothing

Return type

None

scripts.synthetic_data_generation.main.transform_test_data_set.plot_randomized_sphere(sensor, randomization_steps)

Plots (in 3D) x randomized measurements and sphere of precision based on sensor parameters around origin, where x = randomization_steps

Parameters
  • sensor (Sensor) – Sensor for which the measurements should be simulated

  • randomization_steps (integer) – Amount of measurements that should be simulated

Returns

Returns nothing

Return type

None

scripts.synthetic_data_generation.main.transform_test_data_set.simulate_measure_data_from_true_positions(true_position_dataframe, sensor, identifier_randomization_method='random', identifier_type='mac-address')

Simulates measurement of one sensor

Parameters
  • true_position_dataframe (dataframe) – Dataframe that contains true positions

  • sensor (Sensor) – Sensor for which the measurements should be simulated

  • identifier_randomization_type (string) – Specifies the randomization approach for object identifiers, default: ‘none’

  • identifier_type (string) – Specifies type of identifier that should be used if randomization takes place, default: mac-address

Returns

Returns the simulated measurement output of the sensor as dataframe

Return type

dataframe

scripts.synthetic_data_generation.main.transform_test_data_set.simulate_sensor_measurement_for_multiple_sensors(sensors, number_of_true_positions_to_consider, identifier_randomization_method='random', identifier_type='mac-address', transform_to_3D_data=False)

Wrapper that facilitates the simulation for multiple sensors

Parameters
  • sensors (list of Sensor) – List of all sensors for which the measurements should be simulated

  • number_of_true_positions_to_consider (integer) – Number of rows that should be sourced

  • measurement_sensor (Sensor) – Sensor for which the measurements should be simulated

  • identifier_randomization_method (string) – randomization method for identifier, default ‘random’

  • identifier_type (string) – Identifier type used for object id randomization, default ‘mac-address’

  • transform_to_3D_data (Boolean) – Flag if data should be 3D (True) or 2D (False), default ‘False’

Returns

Returns the simulation dataframe containing all simulated measurements for all sensors

Return type

pandas dataframe

scripts.synthetic_data_generation.main.transform_test_data_set.transform_cartesian_coordinate_system(point_x, point_y, point_z, coordinate_system, inverse_transformation=False, output_transformation_matrix=False)

Transforms positional coordinates of a point in a specific coordinate system into its frame of reference (f.o.r)

Parameters
  • point_x (numeric) – x-Coordinate of the true position (as relative coordinate) of object for which the coordinates should be transformed into the frame of reference

  • point_y (numeric) – y-Coordinate of the true position (as relative coordinate) of object for which a measurement should be transformed into the frame of reference

  • point_z (numeric) – z-Coordinate of the true position (as relative coordinate) of object for which a measurement should be transformed into the frame of reference

  • coordinate_system (CoordinateSystem) – Coordinate system of the object (point_x,y,z) for which the coordinate transformation should be performed

  • inverse_transformation (boolean) – Parameter that specifies wheter the coordinate transformation should be performed from “Point coordinate system” -> “Frame of reference” (if == False) or from “Frame of reference” -> “Point coordinate system” (if == True), default is False

  • output_transformation_matrix (boolean) – Specifies if output should contain the output transformation matrix (== True) or not (== False), default is False

Returns

Return dependent on output_transformation_matrix parameter. If set to false function outputs transformed coordinates of point. If set to true, function outputs the transformation matrix and the transformed points coordinates.

Return type

point coordinate tuple (x,y,z) or transformation_matrix and point coordinate tuple (x,y,z)

Module contents