Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ repos:
hooks:
- id: nbstripout
exclude: ^docs/
args: [ '--extra-keys=metadata.kernelspec metadata.language_info' ]
args: [
'--extra-keys=metadata.kernelspec metadata.language_info',
'--keep-metadata-keys=cell.metadata.tags cell.metadata.jupyter',
'--keep-id',
]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
Expand Down
80 changes: 22 additions & 58 deletions notebooks/user_guide.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3499,25 +3499,12 @@
"metadata": {},
"outputs": [],
"source": [
"from pedpy import (\n",
" compute_grid_cell_polygon_intersection_area,\n",
" get_grid_cells,\n",
")\n",
"\n",
"grid_size = 0.4\n",
"grid_cells, _, _ = get_grid_cells(walkable_area=walkable_area, grid_size=grid_size)\n",
"\n",
"min_frame_profiles = 250 # We use here just an excerpt of the\n",
"max_frame_profiles = 400 # trajectory data to reduce compute time\n",
"min_frame_profiles = 500 # We use here just an excerpt of the\n",
"max_frame_profiles = 1000 # trajectory data to reduce compute time\n",
"\n",
"profile_data = profile_data[profile_data.frame.between(min_frame_profiles, max_frame_profiles)]\n",
"\n",
"# Compute the grid intersection area for the resorted profile data (they have the same sorting)\n",
"# for usage in multiple calls to not run the compute heavy operation multiple times\n",
"(\n",
" grid_cell_intersection_area,\n",
" resorted_profile_data,\n",
") = compute_grid_cell_polygon_intersection_area(data=profile_data, grid_cells=grid_cells)"
"profile_data = profile_data[profile_data.frame.between(min_frame_profiles, max_frame_profiles)]"
Comment thread
schroedtert marked this conversation as resolved.
]
},
{
Expand Down Expand Up @@ -3567,44 +3554,31 @@
},
"outputs": [],
"source": [
"from pedpy import plot_measurement_setup\n",
"from pedpy import PEDPY_ORANGE, get_grid_cells, plot_measurement_setup\n",
"\n",
"plot_measurement_setup(\n",
"ax = plot_measurement_setup(\n",
" walkable_area=walkable_area,\n",
" measurement_areas=[profile_measurement_area],\n",
" ma_line_width=2,\n",
" ma_alpha=0.2,\n",
").set_aspect(\"equal\")\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pedpy import (\n",
" compute_grid_cell_polygon_intersection_area,\n",
" get_grid_cells,\n",
")\n",
"\n",
"grid_size = 0.4\n",
"grid_cells_measurement_area, _, _ = get_grid_cells(\n",
" axis_aligned_measurement_area=profile_measurement_area,\n",
" grid_size=grid_size,\n",
")\n",
"grid_cells = [MeasurementArea(cell) for cell in grid_cells_measurement_area]\n",
"plot_measurement_setup(\n",
" measurement_areas=grid_cells,\n",
" ma_line_color=PEDPY_ORANGE,\n",
" ma_line_width=0.3,\n",
" ma_alpha=0,\n",
" axes=ax,\n",
")\n",
"ax.set_aspect(\"equal\")\n",
"\n",
"min_frame_profiles = 250 # We use here just an excerpt of the\n",
"max_frame_profiles = 400 # trajectory data to reduce compute time\n",
"\n",
"profile_data = profile_data[profile_data.frame.between(min_frame_profiles, max_frame_profiles)]\n",
"\n",
"# Compute the grid intersection area for the resorted profile data (they have the same sorting)\n",
"# for usage in multiple calls to not run the compute heavy operation multiple times\n",
"(\n",
" grid_cell_intersection_area_measurement_area,\n",
" resorted_profile_data_measurement_area,\n",
") = compute_grid_cell_polygon_intersection_area(data=profile_data, grid_cells=grid_cells_measurement_area)"
"plt.show()"
]
},
{
Expand Down Expand Up @@ -3667,17 +3641,15 @@
"from pedpy import SpeedMethod, compute_speed_profile\n",
"\n",
"voronoi_speed_profile = compute_speed_profile(\n",
" data=resorted_profile_data,\n",
" data=profile_data,\n",
" walkable_area=walkable_area,\n",
" grid_intersections_area=grid_cell_intersection_area,\n",
" grid_size=grid_size,\n",
" speed_method=SpeedMethod.VORONOI,\n",
")\n",
Comment thread
schroedtert marked this conversation as resolved.
"\n",
"arithmetic_speed_profile = compute_speed_profile(\n",
" data=resorted_profile_data,\n",
" data=profile_data,\n",
" walkable_area=walkable_area,\n",
" grid_intersections_area=grid_cell_intersection_area,\n",
" grid_size=grid_size,\n",
" speed_method=SpeedMethod.ARITHMETIC,\n",
")\n",
Expand Down Expand Up @@ -3770,19 +3742,17 @@
"from pedpy import AxisAlignedMeasurementArea, SpeedMethod, compute_speed_profile\n",
"\n",
"voronoi_speed_profile = compute_speed_profile(\n",
" data=resorted_profile_data_measurement_area,\n",
" data=profile_data,\n",
" walkable_area=walkable_area,\n",
" axis_aligned_measurement_area=profile_measurement_area,\n",
" grid_intersections_area=grid_cell_intersection_area_measurement_area,\n",
" grid_size=grid_size,\n",
" speed_method=SpeedMethod.VORONOI,\n",
")\n",
"\n",
"arithmetic_speed_profile = compute_speed_profile(\n",
" data=resorted_profile_data_measurement_area,\n",
" data=profile_data,\n",
" walkable_area=walkable_area,\n",
" axis_aligned_measurement_area=profile_measurement_area,\n",
" grid_intersections_area=grid_cell_intersection_area_measurement_area,\n",
" grid_size=grid_size,\n",
" speed_method=SpeedMethod.ARITHMETIC,\n",
")\n",
Expand Down Expand Up @@ -3916,16 +3886,13 @@
"source": [
"from pedpy import DensityMethod, compute_density_profile\n",
"\n",
"# here it is important to use the resorted data, as it needs to be in the same ordering as \"grid_cell_intersection_area\"\n",
"voronoi_density_profile = compute_density_profile(\n",
" data=resorted_profile_data,\n",
" data=profile_data,\n",
" walkable_area=walkable_area,\n",
" grid_intersections_area=grid_cell_intersection_area,\n",
" grid_size=grid_size,\n",
" density_method=DensityMethod.VORONOI,\n",
")\n",
"\n",
"# here the unsorted data can be used\n",
"classic_density_profile = compute_density_profile(\n",
" data=profile_data,\n",
" walkable_area=walkable_area,\n",
Expand Down Expand Up @@ -4005,17 +3972,14 @@
"source": [
"from pedpy import DensityMethod, compute_density_profile\n",
"\n",
"# here it is important to use the resorted data, as it needs to be in the same ordering as \"grid_cell_intersection_area\"\n",
"voronoi_density_profile = compute_density_profile(\n",
" data=resorted_profile_data_measurement_area,\n",
" data=profile_data,\n",
" walkable_area=walkable_area,\n",
" axis_aligned_measurement_area=profile_measurement_area,\n",
" grid_intersections_area=grid_cell_intersection_area_measurement_area,\n",
" grid_size=grid_size,\n",
" density_method=DensityMethod.VORONOI,\n",
")\n",
"\n",
"# here the unsorted data can be used\n",
"classic_density_profile = compute_density_profile(\n",
" data=profile_data,\n",
" walkable_area=walkable_area,\n",
Expand Down
Loading
Loading