data_utils module

data_utils.activity_colors(list_act=None, palette='gist_earth')[source]

Match each activity from list to a color from the input palette. Useful to keep consistent colors across visualizations

data_utils.bootstrap_mean(data, num_samples, sample_size=None)[source]

Compute the bootstrap mean of an array.

Parameters: - data: Input array of data. - num_samples: Number of bootstrap samples to generate. - sample_size: Size of each bootstrap sample. If None, it will be set to the size of the input data.

Returns: - bootstrap_means: Array containing the bootstrap means.

data_utils.compute_distances_from_tmat(tmat)[source]

Computes a distance matrix using the locations of the provided travel time matrix

data_utils.cplex_to_df(w, x, d, tt, car_avail, mode_travel, keys, act_id, location, minutes=False)[source]

Stores a CPLEX solution into a Pandas dataframe.

data_utils.create_params(biogeme_pickle, desired_times=None)[source]
data_utils.create_pseudo_random_params(N, parameter_file, preference_file, error_var)[source]
data_utils.discretize_sched(schedule, block_size=0.5)[source]

Returns a 24h schedule discretized in blocks of size (duration) n Block size is expressed in hours

//If no schedule is passed, then a random discretized schedule is generated, otherwise, the passed schedule is discretized accordingly (existing activities are broken down into blocks)//

If a list of activities (list_act) is passed, then all the activities of the list are scheduled. Otherwise, schedules are generated randomly from the default list of activities.

data_utils.plot_mode(df, modes=None)[source]

Plots modes used in trip legs of a given schedule (df). modes = list of possible modes

data_utils.plot_schedule(df, axs, colors='colorblind')[source]

Plots given schedule. df = Pandas dataframe containing schedule. The dataframe must contain the columns ‘start_time’, ‘end_time’, ‘act_id’ and ‘label’

data_utils.print_time_format(time_in_seconds)[source]
data_utils.round_nearest(x, a)[source]