-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Hi @GeorgeEfstathiadis @hackdna,
I followed the code below to simulate GPS data.
import datetime
from forest.bonsai.simulate_gps_data import gps_to_csv, sim_gps_data
from forest.bonsai.simulate_log_data import sim_log_data
from forest.jasmine.traj2stats import Frequency, gps_stats_main
from forest.willow.log_stats import log_stats_main
# 1. If you don't have any smartphone data (yet), you can generate fake data
path_to_synthetic_gps_data = "/home/ubuntu/projects/gps/forest/tutorials/simu_gps_data"
path_to_synthetic_log_data = "/home/ubuntu/projects/gps/forest/tutorials/simu_log_data"
path_to_gps_summary = "/home/ubuntu/projects/gps/forest/tutorials/simu_gps_output"
path_to_log_summary = "/home/ubuntu/projects/gps/forest/tutorials/simu_log_output"
# Generate synthetic GPS data and communication log data as CSV files
# Define parameters for generating the data
# To conserve smartphone battery power, we typically collect location data intermittently: e.g., an on-cycle of 3 minutes followed by an off-cycle of 12 minutes. We'll generate data in this way.
# Number of persons to generate
n_persons = 1
# Location of persons to generate, format: Country_2_letter_ISO_code/City_Name
location = "GB/Bristol"
# Start date for generated trajectories
start_date = datetime.date(2021, 10, 1)
# End date for trajectories
end_date = datetime.date(2021, 10, 5)
# API key for OpenRouteService, generated from https://openrouteservice.org/
#api_key = "5b3ce3597851110001cf6248359f91eec01b4e09ae4ceced5a7d04d1"
api_key = "mock_key"
# Length of off-cycle + length of on-cycle in minutes
cycle = 15
# Length off-cycle / (length off-cycle + length on-cycle)
percentage = 0.8
# Dictionary of personal attributes for each user, set to None if random; check Attributes class for usage in simulate_gps_data module
personal_attributes = {
"User 1": {
"main_employment": "none",
"vehicle": "car",
"travelling_status": 10,
"active_status": 7,
},
"Users 2-4": {
"main_employment": "university",
"vehicle": "bicycle",
"travelling_status": 8,
"active_status": 8,
"active_status-16": 2,
},
"User 5": {
"main_employment": "office",
"vehicle": "foot",
"travelling_status": 9,
"travelling_status-20": 1,
"preferred_exits": ["cafe", "bar", "cinema"],
},
}
sample_gps_data = sim_gps_data(
n_persons,
location,
start_date,
end_date,
cycle,
percentage,
api_key,
personal_attributes,
)However, I encountered the following error, which seems like a bug in the code.
File [~/miniconda3/envs/gps/lib/python3.11/site-packages/forest/bonsai/simulate_gps_data.py:895](http://localhost:8888/lab/tree/Desktop/GPS_forest/~/miniconda3/envs/gps/lib/python3.11/site-packages/forest/bonsai/simulate_gps_data.py#line=894), in gen_all_traj(person, switches, start_date, end_date, api_key)
870 """Generates trajectories for a single person.
871
872 Args:
(...)
891 ValueError: if no offices around person's house address
892 """
894 if len(person.possible_destinations) < 4:
--> 895 raise ValueError("Not enough possible destinations")
896 if (
897 person.attributes.main_occupation != Occupation.NONE
898 and person.office_coordinates == (0, 0)
899 ):
900 raise ValueError("No office coordinates")
ValueError: Not enough possible destinations
Do you have any suggestions on how I might resolve this error? Thanks for your help!
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working