abs_user
User class is a parent class of all child classes specified in user module gps_synth/user.
User class has a combination of concrete and abstract methods:
- concrete methods are meant to be called in child classes with super() function.
- abstract methods are meant to show what methods should be in a child class, but their implementation is a subject of this child class.
User
Bases: ABC
Source code in gps_synth/common/abs_user.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
create_list_of_locations(gdf_hw, gdf_event, home_id, work_id, regular_location_ids, day_of_week)
Based on day of week define type and number of locations to visit for a user within a day and derive information about them
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf_hw
|
GeoDataFrame
|
Set of locations (and their features) of a network to use from for home and work anchors |
required |
gdf_event
|
GeoDataFrame
|
Set of locations (and their features) of a network to use for regular and random event anchors |
required |
home_id
|
int
|
Id of home anchor |
required |
work_id
|
int
|
Id of work anchor |
required |
regular_location_ids
|
List[int]
|
List of regular event locations' ids |
required |
day_of_week
|
int
|
description |
required |
Returns:
| Type | Description |
|---|---|
List[List[Union[int, float]]]
|
List[List[Union[int, float]]]: List of lists, each element has three items: nearest node id and lat and lon coordinates of location's centroid |
Source code in gps_synth/common/abs_user.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
get_chaotic_point(point_start, point_end, radius_of_buffer, proximity_to_road)
Produce one chaotic point between two points meaning that with very high likelihood it will not be located on the path but near to it. Applied to make a movement look more humanlike
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point_start
|
Point
|
description |
required |
point_end
|
Point
|
description |
required |
radius_of_buffer
|
int
|
A radius to define a potential space for a chaotic point |
required |
proximity_to_road
|
int
|
A distance to define how a chaotic point should be from a path |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Point |
Point
|
A chaotic point |
Source code in gps_synth/common/abs_user.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
get_info_about_loc(df_loc, list_of_ids)
Based on id of a location find some information about it and store in a list
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_loc
|
DataFrame
|
Set of locations of a network and their features to search in based on id |
required |
list_of_ids
|
List[int]
|
List of locations' ids to derive some information about |
required |
Returns:
| Type | Description |
|---|---|
List[List[Union[int, float]]]
|
List[List[Union[int, float]]]: List of lists, each element has three items: nearest node id and lat and lon coordinates of location's centroid |
Source code in gps_synth/common/abs_user.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
get_meaningful_locations(gdf_hw, gdf_event)
Create meaningful locations for a user: one home, one work, several regular events, the radius between home and work and home and regular locations are defined in the config The distribution of meaningful locations should follow some distance conditions. Store computed anchors in correponding instance attributes
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf_hw
|
GeoDataFrame
|
Set of locations of a network to choose from for home and work anchors |
required |
gdf_event
|
GeoDataFrame
|
Set of locations of a network to choose from for regular event anchors |
required |
Source code in gps_synth/common/abs_user.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
get_moving_points(user_id, data_array, graph_proj, nodes, transformer_to_WGS, start_node, end_node, start_coords, end_coords, mean_move_speed_ms, proximity_to_road, time_start)
First create route between origin and destination locations, interpolate this path with points, and create GPS data while moving from point to point
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
Id of a user |
required |
data_array
|
List[List[Union[int, float, Timestamp]]]
|
List to store user's GPS data (user_id, lon, lat, timestamp) |
required |
graph_proj
|
MultiDiGraph
|
Projected graph of a network |
required |
nodes
|
GeoDataFrame
|
Nodes of netwrok's projected graph |
required |
start_node
|
int
|
Id of the nearest node to a start location |
required |
end_node
|
int
|
Id of the nearest node to an end location |
required |
start_coords
|
Tuple[float, float]
|
Lon and lat of start location |
required |
end_coords
|
Tuple[float, float]
|
Lon and lat of end location |
required |
mean_move_speed_ms
|
Union[int, float]
|
description |
required |
proximity_to_road
|
int
|
A distance to define how a chaotic point should be from a path |
required |
time_start
|
Timestamp
|
Timestamp from which to start generating moving points |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Timestamp |
Timestamp
|
Time from which to start generating GPS data for another activity |
Source code in gps_synth/common/abs_user.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | |
get_points_on_path(path, number_of_points)
Generate mostly equally distanced points along path between its start and end point
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
LineString
|
A line along which to generate points |
required |
number_of_points
|
int
|
Number of points to generate along the path (it includes the start and end point) |
required |
Returns:
| Type | Description |
|---|---|
List[Point]
|
List[Point]: List of points placed on the path |
Source code in gps_synth/common/abs_user.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
get_random_id_within_buffer(center_point, radius_buffer, gdf_locations)
Find a random id of a location which is within a buffer, created around center point with specified distance. A center point should be surronded with some amount of needed locations, otherwise None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_point
|
Point
|
A point around which create a buffer |
required |
radius_buffer
|
int
|
A radius of a buffer |
required |
gdf_locations
|
GeoDataFrame
|
Locations to filter with condition "within a buffer" |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
Union[int, None]
|
Random id among filtered loctions or None if home anchor is too near to border of a place |
Source code in gps_synth/common/abs_user.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
get_regular_or_random_loc(gdf_event, regular_location_ids, number_of_events)
Randomly create a list with specified number of event ids, which could be either from regular event locations or completely accidental
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf_event
|
GeoDataFrame
|
Set of locations of a network to choose from for regular event anchors |
required |
regular_location_ids
|
List[int]
|
List of regular event locations' ids |
required |
number_of_events
|
int
|
A number of event ids tom create |
required |
Returns:
| Type | Description |
|---|---|
List[int]
|
List[int]: List of event ids for a userto visit within a day |
Source code in gps_synth/common/abs_user.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
get_static_points(user_id, data_array, transformer_to_WGS, startlon, startlat, time_start, time_end)
Generate the nearby points around some coordinates (the centroid point of a user’s location)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
Id of a user |
required |
data_array
|
List[List[Union[int, float, Timestamp]]]
|
List to store user's GPS data (user_id, lon, lat, timestamp) |
required |
startlon
|
float
|
Longitude of a point where to start generating nearby points (more precisely their coordinates) |
required |
startlat
|
float
|
Latitude of a point where to start generating nearby points (more precisely their coordinates) |
required |
time_start
|
Timestamp
|
Timestamp from which to start generating static points |
required |
time_end
|
Timestamp
|
Upper timestamp limit of genaration |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Timestamp |
Timestamp
|
Time from which to start generating GPS data for another activity |
Source code in gps_synth/common/abs_user.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |