|
3499 | 3499 | "metadata": {}, |
3500 | 3500 | "outputs": [], |
3501 | 3501 | "source": [ |
3502 | | - "from pedpy import (\n", |
3503 | | - " compute_grid_cell_polygon_intersection_area,\n", |
3504 | | - " get_grid_cells,\n", |
3505 | | - ")\n", |
3506 | | - "\n", |
3507 | 3502 | "grid_size = 0.4\n", |
3508 | | - "grid_cells, _, _ = get_grid_cells(walkable_area=walkable_area, grid_size=grid_size)\n", |
3509 | 3503 | "\n", |
3510 | | - "min_frame_profiles = 250 # We use here just an excerpt of the\n", |
3511 | | - "max_frame_profiles = 400 # trajectory data to reduce compute time\n", |
| 3504 | + "min_frame_profiles = 500 # We use here just an excerpt of the\n", |
| 3505 | + "max_frame_profiles = 1000 # trajectory data to reduce compute time\n", |
3512 | 3506 | "\n", |
3513 | | - "profile_data = profile_data[profile_data.frame.between(min_frame_profiles, max_frame_profiles)]\n", |
3514 | | - "\n", |
3515 | | - "# Compute the grid intersection area for the resorted profile data (they have the same sorting)\n", |
3516 | | - "# for usage in multiple calls to not run the compute heavy operation multiple times\n", |
3517 | | - "(\n", |
3518 | | - " grid_cell_intersection_area,\n", |
3519 | | - " resorted_profile_data,\n", |
3520 | | - ") = compute_grid_cell_polygon_intersection_area(data=profile_data, grid_cells=grid_cells)" |
| 3507 | + "profile_data = profile_data[profile_data.frame.between(min_frame_profiles, max_frame_profiles)]" |
3521 | 3508 | ] |
3522 | 3509 | }, |
3523 | 3510 | { |
|
3567 | 3554 | }, |
3568 | 3555 | "outputs": [], |
3569 | 3556 | "source": [ |
3570 | | - "from pedpy import plot_measurement_setup\n", |
| 3557 | + "from pedpy import PEDPY_ORANGE, get_grid_cells, plot_measurement_setup\n", |
3571 | 3558 | "\n", |
3572 | | - "plot_measurement_setup(\n", |
| 3559 | + "ax = plot_measurement_setup(\n", |
3573 | 3560 | " walkable_area=walkable_area,\n", |
3574 | 3561 | " measurement_areas=[profile_measurement_area],\n", |
3575 | 3562 | " ma_line_width=2,\n", |
3576 | 3563 | " ma_alpha=0.2,\n", |
3577 | | - ").set_aspect(\"equal\")\n", |
3578 | | - "plt.show()" |
3579 | | - ] |
3580 | | - }, |
3581 | | - { |
3582 | | - "cell_type": "code", |
3583 | | - "execution_count": null, |
3584 | | - "metadata": {}, |
3585 | | - "outputs": [], |
3586 | | - "source": [ |
3587 | | - "from pedpy import (\n", |
3588 | | - " compute_grid_cell_polygon_intersection_area,\n", |
3589 | | - " get_grid_cells,\n", |
3590 | 3564 | ")\n", |
3591 | 3565 | "\n", |
| 3566 | + "grid_size = 0.4\n", |
3592 | 3567 | "grid_cells_measurement_area, _, _ = get_grid_cells(\n", |
3593 | 3568 | " axis_aligned_measurement_area=profile_measurement_area,\n", |
3594 | 3569 | " grid_size=grid_size,\n", |
3595 | 3570 | ")\n", |
| 3571 | + "grid_cells = [MeasurementArea(cell) for cell in grid_cells_measurement_area]\n", |
| 3572 | + "plot_measurement_setup(\n", |
| 3573 | + " measurement_areas=grid_cells,\n", |
| 3574 | + " ma_line_color=PEDPY_ORANGE,\n", |
| 3575 | + " ma_line_width=0.3,\n", |
| 3576 | + " ma_alpha=0,\n", |
| 3577 | + " axes=ax,\n", |
| 3578 | + ")\n", |
| 3579 | + "ax.set_aspect(\"equal\")\n", |
3596 | 3580 | "\n", |
3597 | | - "min_frame_profiles = 250 # We use here just an excerpt of the\n", |
3598 | | - "max_frame_profiles = 400 # trajectory data to reduce compute time\n", |
3599 | | - "\n", |
3600 | | - "profile_data = profile_data[profile_data.frame.between(min_frame_profiles, max_frame_profiles)]\n", |
3601 | | - "\n", |
3602 | | - "# Compute the grid intersection area for the resorted profile data (they have the same sorting)\n", |
3603 | | - "# for usage in multiple calls to not run the compute heavy operation multiple times\n", |
3604 | | - "(\n", |
3605 | | - " grid_cell_intersection_area_measurement_area,\n", |
3606 | | - " resorted_profile_data_measurement_area,\n", |
3607 | | - ") = compute_grid_cell_polygon_intersection_area(data=profile_data, grid_cells=grid_cells_measurement_area)" |
| 3581 | + "plt.show()" |
3608 | 3582 | ] |
3609 | 3583 | }, |
3610 | 3584 | { |
|
3667 | 3641 | "from pedpy import SpeedMethod, compute_speed_profile\n", |
3668 | 3642 | "\n", |
3669 | 3643 | "voronoi_speed_profile = compute_speed_profile(\n", |
3670 | | - " data=resorted_profile_data,\n", |
| 3644 | + " data=profile_data,\n", |
3671 | 3645 | " walkable_area=walkable_area,\n", |
3672 | | - " grid_intersections_area=grid_cell_intersection_area,\n", |
3673 | 3646 | " grid_size=grid_size,\n", |
3674 | 3647 | " speed_method=SpeedMethod.VORONOI,\n", |
3675 | 3648 | ")\n", |
3676 | 3649 | "\n", |
3677 | 3650 | "arithmetic_speed_profile = compute_speed_profile(\n", |
3678 | | - " data=resorted_profile_data,\n", |
| 3651 | + " data=profile_data,\n", |
3679 | 3652 | " walkable_area=walkable_area,\n", |
3680 | | - " grid_intersections_area=grid_cell_intersection_area,\n", |
3681 | 3653 | " grid_size=grid_size,\n", |
3682 | 3654 | " speed_method=SpeedMethod.ARITHMETIC,\n", |
3683 | 3655 | ")\n", |
|
3770 | 3742 | "from pedpy import AxisAlignedMeasurementArea, SpeedMethod, compute_speed_profile\n", |
3771 | 3743 | "\n", |
3772 | 3744 | "voronoi_speed_profile = compute_speed_profile(\n", |
3773 | | - " data=resorted_profile_data_measurement_area,\n", |
| 3745 | + " data=profile_data,\n", |
3774 | 3746 | " walkable_area=walkable_area,\n", |
3775 | 3747 | " axis_aligned_measurement_area=profile_measurement_area,\n", |
3776 | | - " grid_intersections_area=grid_cell_intersection_area_measurement_area,\n", |
3777 | 3748 | " grid_size=grid_size,\n", |
3778 | 3749 | " speed_method=SpeedMethod.VORONOI,\n", |
3779 | 3750 | ")\n", |
3780 | 3751 | "\n", |
3781 | 3752 | "arithmetic_speed_profile = compute_speed_profile(\n", |
3782 | | - " data=resorted_profile_data_measurement_area,\n", |
| 3753 | + " data=profile_data,\n", |
3783 | 3754 | " walkable_area=walkable_area,\n", |
3784 | 3755 | " axis_aligned_measurement_area=profile_measurement_area,\n", |
3785 | | - " grid_intersections_area=grid_cell_intersection_area_measurement_area,\n", |
3786 | 3756 | " grid_size=grid_size,\n", |
3787 | 3757 | " speed_method=SpeedMethod.ARITHMETIC,\n", |
3788 | 3758 | ")\n", |
|
3916 | 3886 | "source": [ |
3917 | 3887 | "from pedpy import DensityMethod, compute_density_profile\n", |
3918 | 3888 | "\n", |
3919 | | - "# here it is important to use the resorted data, as it needs to be in the same ordering as \"grid_cell_intersection_area\"\n", |
3920 | 3889 | "voronoi_density_profile = compute_density_profile(\n", |
3921 | | - " data=resorted_profile_data,\n", |
| 3890 | + " data=profile_data,\n", |
3922 | 3891 | " walkable_area=walkable_area,\n", |
3923 | | - " grid_intersections_area=grid_cell_intersection_area,\n", |
3924 | 3892 | " grid_size=grid_size,\n", |
3925 | 3893 | " density_method=DensityMethod.VORONOI,\n", |
3926 | 3894 | ")\n", |
3927 | 3895 | "\n", |
3928 | | - "# here the unsorted data can be used\n", |
3929 | 3896 | "classic_density_profile = compute_density_profile(\n", |
3930 | 3897 | " data=profile_data,\n", |
3931 | 3898 | " walkable_area=walkable_area,\n", |
|
4005 | 3972 | "source": [ |
4006 | 3973 | "from pedpy import DensityMethod, compute_density_profile\n", |
4007 | 3974 | "\n", |
4008 | | - "# here it is important to use the resorted data, as it needs to be in the same ordering as \"grid_cell_intersection_area\"\n", |
4009 | 3975 | "voronoi_density_profile = compute_density_profile(\n", |
4010 | | - " data=resorted_profile_data_measurement_area,\n", |
| 3976 | + " data=profile_data,\n", |
4011 | 3977 | " walkable_area=walkable_area,\n", |
4012 | 3978 | " axis_aligned_measurement_area=profile_measurement_area,\n", |
4013 | | - " grid_intersections_area=grid_cell_intersection_area_measurement_area,\n", |
4014 | 3979 | " grid_size=grid_size,\n", |
4015 | 3980 | " density_method=DensityMethod.VORONOI,\n", |
4016 | 3981 | ")\n", |
4017 | 3982 | "\n", |
4018 | | - "# here the unsorted data can be used\n", |
4019 | 3983 | "classic_density_profile = compute_density_profile(\n", |
4020 | 3984 | " data=profile_data,\n", |
4021 | 3985 | " walkable_area=walkable_area,\n", |
|
0 commit comments