pNeuma_simulator.results module

pNeuma_simulator.results.aggregate(l_agents, n_cars: int, n_moto: int)[source]

Calculate various aggregate metrics based on the given list of agents.

Parameters:
  • l_agents (list[Particle]) – A list of agents. (#list(list(Particles))?)

  • n_cars (int) – The number of cars.

  • n_moto (int) – The number of motorcycles.

Returns:

Vehicle Kilometers Traveled by cars. VHT_cars (float): Vehicle Hours Traveled by cars. VKT_moto (float): Vehicle Kilometers Traveled by motorcycles. VHT_moto (float): Vehicle Hours Traveled by motorcycles.

Return type:

VKT_cars (float)

pNeuma_simulator.results.confidence_interval(data, rng, setting='sem')[source]

Calculate the confidence interval or standard error of the mean (SEM) for a given dataset.

Parameters:
  • data (array-like) – The dataset for which the confidence interval or SEM is to be calculated.

  • rng (numpy.random.Generator) – A random number generator instance for reproducibility.

  • setting (str, optional) – The type of result to return. Options are: - “low”: Return the lower bound of the confidence interval. - “high”: Return the upper bound of the confidence interval. - “sem”: Return the standard error of the mean (default).

Returns:

The requested confidence interval bound or SEM if the dataset has more than one element, otherwise None.

Return type:

float or None

pNeuma_simulator.results.intersect(p1, p2, p3, p4)[source]

Calculates the intersection point of two line segments.

This function calculates the intersection point of the line segment defined by points p1 and p2 with the line segment defined by points p3 and p4. If the line segments are parallel or do not intersect within their lengths, the function returns None.

Parameters:
  • p1 (tuple) – The first point of the first line segment, as a tuple (x1, y1).

  • p2 (tuple) – The second point of the first line segment, as a tuple (x2, y2).

  • p3 (tuple) – The first point of the second line segment, as a tuple (x3, y3).

  • p4 (tuple) – The second point of the second line segment, as a tuple (x4, y4).

Returns:

The intersection point as a tuple (x, y) if the line segments intersect within their lengths, otherwise None.

Return type:

tuple or None

pNeuma_simulator.results.loader(permutation, path: str, verbose: bool = True)[source]

Loads and returns the items from a JSON file within a zip archive.

Parameters:
  • permutation – The permutation to be used in the zip file name.

  • path (str) – The path to the directory containing the zip file.

  • verbose (bool) – Specify whether to print the file name

Returns:

The items loaded from the JSON file.

Return type:

list

pNeuma_simulator.results.normalized(surface, section)[source]

Calculate normalized intersection points and values between surface curves and section diagonals.

Calculate the normalized intersection points and their corresponding values between the curves of a surface and the diagonals of a section.

Parameters:
  • surface (object) – An object representing the surface, which contains collections of curves and an array of data values.

  • section (object) – An object representing the section, which contains collections of diagonals.

Returns:

A tuple containing two lists:
  • l_points (list): A list of lists, where each sublist contains the intersection points for each diagonal.

  • l_response (list): A list of lists, where each sublist contains the corresponding values at the

    intersection points for each diagonal.

Return type:

tuple

pNeuma_simulator.results.percolate(items, n_cars, n_moto, rng, start: int = 1)[source]

Analyzes the percolation of vehicles and motorcycles in a given dataset.

Parameters:
  • items (list) – A list of items where each item is a list of frames. Each frame is a dictionary containing vehicle data.

  • n_cars (int) – The number of cars in the dataset.

  • n_moto (int) – The number of motorcycles in the dataset.

  • rng (numpy.random.Generator) – A random number generator instance for reproducibility.

  • start (int, optional) – The starting frame index to consider for analysis. Defaults to 1.

Returns:

A tuple containing four lists:
  • x (list): The bin centers for the binned data.

  • y (list): The mean difference in velocity between motorcycles and cars for each bin.

  • l_T (list): Control data (T).

  • l_DPhi (list): Response data (Dphi).

  • binder (list): The binder cumulant for each bin.

Return type:

tuple

pNeuma_simulator.results.polarize(items, n_cars, n_moto, rng, start: int = 1)[source]

Analyzes the polarization of motorcycles in a given dataset.

Parameters:
  • items (list) – A list of items where each item is a list of frames. Each frame is a dictionary containing vehicle data.

  • n_cars (int) – The number of cars in the dataset.

  • n_moto (int) – The number of motorcycles in the dataset.

  • rng (numpy.random.Generator) – A random number generator instance for reproducibility.

  • start (int, optional) – The starting frame index to consider for analysis. Defaults to 1.

Returns:

A tuple containing four lists:
  • x (list): The bin centers for the binned data.

  • y (list): The mean difference in velocity between motorcycles and cars for each bin.

  • low (list): The lower bound of the confidence interval for each bin.

  • high (list): The upper bound of the confidence interval for each bin.

Return type:

tuple

pNeuma_simulator.results.zipdir(path: str, permutation, ziph) None[source]

Zip the directory at the given path.

Parameters:
  • path (str) – The path of the directory to be zipped.

  • permutation (tuple) – The permutation considered.

  • ziph – The zipfile handle.