wiver.wiver_python module¶
- exception wiver.wiver_python.InvalidWiverInputData¶
Bases:
ValueError
Invalid input data for Wiver model
- class wiver.wiver_python.WIVER(n_groups, n_zones, n_time_slices=5, n_time_series=1, n_modes=4, n_sectors=2, n_threads=None, logger=None)¶
Bases:
_WIVER
,_ArrayProperties
WIVER Business Trip Model
- Parameters:
n_groups (int) –
n_zones (int) –
n_time_slices (int) –
n_time_series (int) –
n_modes (int) –
n_sectors (int) –
n_threads (int) –
logger (Logger) –
- __init__(n_groups, n_zones, n_time_slices=5, n_time_series=1, n_modes=4, n_sectors=2, n_threads=None, logger=None)¶
- Parameters:
n_groups (
int
) – the number of groupsn_zones (
int
) – the number of zonesn_time_slices (
int
) – the number of time slicesn_time_series (
int
) – the number of time seriesn_modes (
int
) – the number of transport modesn_sectors (
int
) – the number of economic sectorsn_threads (
int
) – the maximum number of threads to use for calculationlogger (
Logger
) – an optional logger to use from within wiver. If not provided, a logger is created
- adjust_balancing_factor(iteration, threshold=0.1)¶
adjust the balancing factor for the destination choice model
- Parameters:
threshold (
float
) – if the difference between the modelled and the target trips is < threshold, the model convergesiteration (int) –
- assign_coordinates()¶
set the coordinates from self._coordinates to self.data
- calc()¶
calc the daily trips and the trips by time slice
- calc_starting_and_ending_trips()¶
calculate the starting trips per zone and group and return them as Dataframe
- Return type:
DataFrame
- calc_with_balancing(max_iterations=10, threshold=0.1)¶
calculate with balancing the destination choice model
- Parameters:
max_iterations (
int
) – the maximum number of iterationsthreshold (
float
) – if the difference between the modelled and the target trips is < threshold, the model converges
- define_arrays()¶
Define the arrays
- define_balancing()¶
Define the balancing factors and return them as dataset
- Return type:
Dataset
- define_matrices()¶
Define the matrices and return them as dataset
- Return type:
Dataset
- define_params()¶
Define the params and return them as dataset
- Return type:
Dataset
- define_results()¶
Define the results and return them as dataset
- Return type:
Dataset
- define_zonal_data()¶
Define the zonal data and return them as dataset
- Return type:
Dataset
- merge_datasets()¶
Merge the datasets
- read_all_data(datasets)¶
Read Datasets from netcdf-file
- Parameters:
datasets (
Dict
[str
,str
]) – dict with the filenames of the input and output data
- read_data(dataset_name, fn)¶
read single dataset from file
- Parameters:
dataset_name (
str
) – the dataset that should be readfn (
str
) – filename to read from
- classmethod read_from_netcdf(files, n_threads=None)¶
Read a Wiver Model from a set of netcdf-Filename defined in files
- Parameters:
files (
Dict
[str
,str
]) – dict with the file names of the input datan_threads (
int
) – the maximum number of threads to use for calculation
- Return type:
- save_all_data(wiver_files)¶
Save Dataset to netcdf-files
- Parameters:
wiver_files (
Dict
[str
,str
]) – dict with the input and output filenames
- save_data(dataset_name, fn)¶
Save Dataset to netcdf-file
- Parameters:
dataset_name (
str
) – the dataset that should be savedfn (
str
) – filename to write to
- save_detailed_results_to_visum(folder, visum_format='BK')¶
Save the detailed results to VISUM-Format including the matrices for each group
- Parameters:
folder (
str
) – the folder where the Visum-Matrices will be writtenvisum_format (
str
) – the Visum-Matrix format (Default=Binary Compressed (BK))
- save_results(wiver_files)¶
Save results except trips_gsij to folder
- Parameters:
wiver_files (
Dict
[str
,str
]) – dict with the filenames of the input and output data
- save_results_to_visum(folder, visum_format='BK')¶
Save the results to VISUM-Format
- Parameters:
folder (
str
) – the folder where the Visum-Matrices will be writtenvisum_format (
str
) – the Visum-Matrix format (Default=Binary Compressed (BK))
- set_arrays_from_balancing_ds(ds)¶
Set arrays from balancing dataset
- Parameters:
ds (
Dataset
) – Dataset with the balancing factors
- set_arrays_from_dataset()¶
Sets the arrays with values from the dataset
- set_n_threads(n_threads=None)¶
Set the number of threads
- Parameters:
n_threads (
int
) – the maximum number of threads to use for calculation
- validate_input_data()¶
make checks on the input data
- _coordinates = {'groups': 'group_names', 'modes': 'modes', 'sectors': 'sector_short', 'time_series': 'lbl_time_series', 'time_slices': 'lbl_time_slices', 'zone_no': 'zone_no'}¶
- property balancing: Dataset¶
return the balancing-Dataset and define it, if not yet done
- property base_trips_g: DataArray¶
the total trips from and to the home base per group
- property base_trips_km_g: DataArray¶
the total vehicle km of trips from and to the home base per group
- property linking_trips_g: DataArray¶
the total linking trips per group
- property linking_trips_km_g: DataArray¶
the total vehicle km of linking trips per group
- property matrices: Dataset¶
return the matrices-Dataset and define it, if not yet done
- property params: Dataset¶
return the results-Dataset and define it, if not yet done
- property results: Dataset¶
return the results-Dataset and define it, if not yet done
- property trips_g: DataArray¶
the total trips per group
- property vehicle_km_g: DataArray¶
the total vehicle kilometers per group
- property zonal_data: Dataset¶
return the zonal_data-Dataset and define it, if not yet done