Modules

The main file for the package

class private_swedish_mind.private_swedish_mind.AnalyseBasicJoinedData(point, n_layers)[source]

Class handles input files with the schema: [‘timestamp’, ‘geometry_gps_csv’, ‘geometry_mpn_csv’], where timestamp is a timestamp, geometry_gps_csv is string representation of a list of length one, which element is a position in a WGS84_EPSG projection. The geometry_mpn_csv is a string representation of a list which element is a position in a WGS84_EPSG projection.

add_distance_column()[source]

adding distance column.

Returns

list of distances between GPS and each of MPN positions

add_hist_column()[source]

adding histogram by looping through mnp-indexes and vc-indexes

Returns

column hist to self.df

add_hist_groups_column()[source]

adding histograms for different groups of VC sizes

Returns

add_hist_load_group_columns()[source]

adding columns for different load groups

Returns

add_rings_column()[source]

constructing rings column vc_gps_rings centered around vc_index_gps. The number of layers is given by self.n_layers.

Returns

vc_gps_rings column to self.df

add_vcs_indexes()[source]

Adding indexes of Voronoi cell from vcs for GPS and MPN points for given df

create_voronoi_polygons()[source]

creates Voronoi polygons with self.antennas_data as centers, bounded by self.contour

Returns

GeoPandas DF with VCs

get_objects_within_area(objects, geom='geometry')[source]

given objects and bounding geometry find which objects are within the geometry Returns a GeoPandas DF

make_plots()[source]

producing all the plots

Returns

process_antennas_load(coarse_grain_factor=100)[source]

processing coords and summing up load for each position

process_position_data()[source]
Returns

static read_antennas()[source]

reads and prepares antennas for whole Sweden. Returns a GeoPandas df with the antennas.

static read_antennas_load()[source]

reading data for given dates

static read_data()[source]

reading data from the folder DATA_DIR which start with result. Returns Pandas DF, as a concatenation of all files

Returns

Pandas DF with [‘timestamp’, ‘geometry_gps_csv’, ‘geometry_mpn_csv’] columns

remove_too_often_antennas()[source]
Returns

transform_df()[source]

transforms string representation of a list to a Shapely point, and groups the data for each timestamp.

Returns

GeoPandas DF with timestamp, Point(), [Point(), Point(), … Point()] schema

Utilities

Auxilliary routines for the main module

private_swedish_mind.utils.get_rings_around_cell(cell_idx, vcs, width)[source]

given the Voronoi cells vcs, the index of the cell cell_idx and the number of layers width creates a list of lists, where the first list contains indexes of vcs for the zero layer, the second – for the first layer etc.

private_swedish_mind.utils.get_splits(load, n_parts, make_int=True)[source]

given the Pandas Series with Voronoi cell areas, sorts the areas by accending order and splits into given number of parts.

Returns a list of tuples with splits borders, like [(0.01, 2.63), (2.71, 24.67), (25.16, 184.09)]

private_swedish_mind.utils.get_vcs_used_area(vcs, data, area_max)[source]

collecting Voronoi cells visited during all journeys and their area, if it below the given threshould

private_swedish_mind.utils.make_diffs_ring_histogram_sample_size(hist_data, series_length)[source]

we take samples of different size from hist column, make a histogram for each sample and observe how the difference between it and the histogram for full hist column. We learn how the difference evolves with sample size.

returns Pandas DF with the differences

private_swedish_mind.utils.make_hist_mpn_geoms(mpn_geoms, cell_rings)[source]

taking list of mpn_geoms and corresponding list of cell rings cell_rings. Makes histogram for population of cell rings based in mpn_geoms.

Module for plotting