Skip to content

Commit

Permalink
Formatting (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
g4brielvs committed Apr 11, 2024
1 parent e7cebe7 commit a9471cd
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 138 deletions.
12 changes: 6 additions & 6 deletions notebooks/mobility/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Gaza Mobility Analysis

This notebook aims to analyze mobility data from Mapbox in Gaza after the attacks on October 7th. The analysis is exploratory in nature and has not been validated with other data sources primarily due to the lack of availability of similar datasets for the time period in consideration.
This notebook aims to analyze mobility data from Mapbox in Gaza after the attacks on October 7th. The analysis is exploratory in nature and has not been validated with other data sources primarily due to the lack of availability of similar datasets for the time period in consideration.

Mobility data has often been used as a proxy for economic activity. In this case, it could shed light on
Mobility data has often been used as a proxy for economic activity. In this case, it could shed light on
* The regions that saw activity in peacetime (Jan-June 2023) but no activity after October 7th, 2023.
* The regions that saw activity in the time of conflict. This could potentially indicate the congregation of people

The analysis is conducted at two types of aggregation - H3 grids at 0.73 sq. km and admin 2 regions at a weekly level. The temporal and spatial aggregation allows for comparison with Night Time Lights and damage indicators in the other notebooks.
The analysis is conducted at two types of aggregation - H3 grids at 0.73 sq. km and admin 2 regions at a weekly level. The temporal and spatial aggregation allows for comparison with Night Time Lights and damage indicators in the other notebooks.

## Data Description

### Mapbox Movement

Mapbox Movement is a global dataset of de-identified and aggregated mobile device activity. The dataset captures significant driving and non-driving mobile device activity aggregated into geographic tiles of 100-meter resolution (approximately one city block) and select Mapbox boundaries. Mapbox Movement typically relies on location data such as GPS coordinates, timestamps, and possibly other metadata attributes like speed, heading, and altitude. This data is typically collected from devices or sources that track location information over time.

The Mapbox Movement data used in this analysis is aggregated at a daily level and is represented in the form of an activity index.
The Mapbox Movement data used in this analysis is aggregated at a daily level and is represented in the form of an activity index.


#### Activity Levels
Expand All @@ -33,6 +33,6 @@ Because the raw activity counts in a later time span may be greater than activit

The Mapbox Movement data set is based on de-identified underlying mobile device activity that grows and changes every day. Any mobility data set is inherently skewed between highly populated regions (urban and metro areas) and sparsely populated regions (rural areas). So instead of providing "raw counts" of measurements, a custom normalization process is applied. This process measures and smooths out the impact of otherwise unpredictable changes in mobile device usage and calculates an activity index, which is more appropriate for comparison across time spans.

#### Baselining
#### Baselining

When activity levels are calculated in the context of Mapbox Movement, the baseline typically refers to the normal or expected levels of activity for a given area, time of day, day of the week, or other relevant factors. This baseline serves as a reference point for detecting deviations and anomalies in movement patterns or activity levels.
When activity levels are calculated in the context of Mapbox Movement, the baseline typically refers to the normal or expected levels of activity for a given area, time of day, day of the week, or other relevant factors. This baseline serves as a reference point for detecting deviations and anomalies in movement patterns or activity levels.
26 changes: 12 additions & 14 deletions notebooks/mobility/mapbox.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"import geopandas\n",
"import pandas as pd\n",
"\n",
"from gaza_israel_conflict_analysis.movement_analysis import h3_functions\n",
"from gaza_israel_conflict_analysis.movement_analysis import visuals"
"from gaza_israel_conflict_impact_analysis.movement_analysis import h3_functions\n",
"from gaza_israel_conflict_impact_analysis.movement_analysis import visuals"
]
},
{
Expand Down Expand Up @@ -670,22 +670,20 @@
" legend_bool = False\n",
" gaza_h3.merge(\n",
" movement_day[movement_day[\"agg_day_period\"] == date], on=\"h3_index\"\n",
" ).plot(\n",
" column=\"activity_index_total\", legend=False, ax=ax[idx], vmin=0, vmax=1.5\n",
" )\n",
" ).plot(column=\"activity_index_total\", legend=False, ax=ax[idx], vmin=0, vmax=1.5)\n",
" ax[idx].axis(\"off\")\n",
" ax[idx].set_title(date)\n",
" #ax[0].text(x=0, y=0, s='Source: Mapbox Movement')\n",
" # ax[0].text(x=0, y=0, s='Source: Mapbox Movement')\n",
"\n",
"norm = mcolors.Normalize(vmin=0, vmax=1.5)\n",
"sm = plt.cm.ScalarMappable(cmap='viridis', norm=norm)\n",
"sm = plt.cm.ScalarMappable(cmap=\"viridis\", norm=norm)\n",
"sm.set_array([]) # You have to set an empty array to avoid an error\n",
"\n",
"# Create a colorbar as a continuous legend\n",
"cbar = plt.colorbar(sm, ax=ax, orientation='vertical', fraction=0.046, pad=0.04)\n",
"cbar = plt.colorbar(sm, ax=ax, orientation=\"vertical\", fraction=0.046, pad=0.04)\n",
"\n",
"fig.text(s='Source: Mapbox Movement', x=0.1, y=0, fontsize=11)\n",
"plt.suptitle('Comparing Daily Activity in Gaza', fontsize=16, x=0.3, y=0.99);"
"fig.text(s=\"Source: Mapbox Movement\", x=0.1, y=0, fontsize=11)\n",
"plt.suptitle(\"Comparing Daily Activity in Gaza\", fontsize=16, x=0.3, y=0.99);"
]
},
{
Expand Down Expand Up @@ -734,14 +732,14 @@
" ax[idx].set_title(date)\n",
"\n",
"norm = mcolors.Normalize(vmin=0, vmax=1.5)\n",
"sm = plt.cm.ScalarMappable(cmap='viridis', norm=norm)\n",
"sm = plt.cm.ScalarMappable(cmap=\"viridis\", norm=norm)\n",
"sm.set_array([]) # You have to set an empty array to avoid an error\n",
"\n",
"# Create a colorbar as a continuous legend\n",
"cbar = plt.colorbar(sm, ax=ax[3], orientation='vertical', fraction=0.046, pad=0.04)\n",
"cbar = plt.colorbar(sm, ax=ax[3], orientation=\"vertical\", fraction=0.046, pad=0.04)\n",
"\n",
"fig.text(s='Source: Mapbox Movement', x=0.2, y=0, fontsize=11)\n",
"plt.suptitle('Comparing Weekly Activity in Gaza', fontsize=16, x=0.3, y=0.95);"
"fig.text(s=\"Source: Mapbox Movement\", x=0.2, y=0, fontsize=11)\n",
"plt.suptitle(\"Comparing Weekly Activity in Gaza\", fontsize=16, x=0.3, y=0.95);"
]
},
{
Expand Down
17 changes: 9 additions & 8 deletions notebooks/sample-indicators/health.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
"source": [
"import geopandas\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from matplotlib.ticker import FuncFormatter\n",
"from palettable.cartocolors.qualitative import Prism_10, Vivid_10\n",
"from palettable.tableau import ColorBlind_10, TableauMedium_10\n",
"from palettable.tableau import TableauMedium_10\n",
"\n",
"%config InlineBackend.figure_formats = ['svg']\n",
"%matplotlib inline"
Expand Down Expand Up @@ -2032,10 +2030,12 @@
],
"source": [
"fig, ax = plt.subplots(figsize=(10, 6))\n",
"plt.suptitle(\"Gaza: Percentage of Damaged Healthcare Locations\", y=1.01, fontsize=20, x=0.47)\n",
"plt.suptitle(\n",
" \"Gaza: Percentage of Damaged Healthcare Locations\", y=1.01, fontsize=20, x=0.47\n",
")\n",
"\n",
"df.pivot_table(\"perc\", \"ADM2_EN\", \"type\")[['Health']].plot(\n",
" ax=ax, kind=\"barh\", color=TableauMedium_10.mpl_colors, legend = False\n",
"df.pivot_table(\"perc\", \"ADM2_EN\", \"type\")[[\"Health\"]].plot(\n",
" ax=ax, kind=\"barh\", color=TableauMedium_10.mpl_colors, legend=False\n",
")\n",
"\n",
"# Add labels and customization\n",
Expand All @@ -2050,11 +2050,12 @@
"ax.yaxis.set_ticks_position(\"left\")\n",
"ax.xaxis.set_ticks_position(\"bottom\")\n",
"ax.grid(which=\"both\", linestyle=\"--\", linewidth=0.25, color=\"gray\", alpha=0.5)\n",
"#ax.legend(bbox_to_anchor=(1.01, 0.9))\n",
"# ax.legend(bbox_to_anchor=(1.01, 0.9))\n",
"\n",
"ax.set_title(\n",
" \"Estimated percentage of damaged healthcare locations for each second-level administrative division\",\n",
" fontsize=14,loc='left'\n",
" fontsize=14,\n",
" loc=\"left\",\n",
")\n",
"ax.text(\n",
" 0,\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/sample-indicators/sample-indicators.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Combining insights from multiple data sources for Gaza
# Combining insights from multiple data sources for Gaza
47 changes: 30 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,47 +1,60 @@
[build-system]
requires = ["setuptools>=61.0.0"]
build-backend = "setuptools.build_meta"
requires = ["hatchling>=1.21.0", "hatch-vcs>=0.3.0"]
build-backend = "hatchling.build"

[project]
name = "gaza_israel_conflict_analysis"
dynamic = ["version"]
description = "An Python package to support the Gaza Israel Conflict Impact Analysis"
name = "gaza-israel-conflict-impact-analysis"
description = "A Python package to support the Gaza Israel Conflict Impact Analysis"
readme = { file = "README.md", content-type = "text/markdown" }
license = { file = "LICENSE" }
keywords = [
"world bank",
"reproducible research",
"conflict monitor",
"gaza",
"reproducible research",
"world bank",
]
authors = [
{ name = "World Bank Development Data Group", email = "[email protected]" },
{ name = "World Bank Data Lab", email = "[email protected]" },
]
maintainers = [
{ name = "Gabriel Stefanini Vicente", email = "[email protected]" },
{ name = "Sahiti Sarva", email = "[email protected]" },
]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Topic :: Scientific/Engineering",
]
requires-python = ">=3.7"
dynamic = ["version"]

requires-python = ">=3.10"
dependencies = ["pandas>=2"]
[project.optional-dependencies]
notebook = ["notebook>=6.5.2"]
docs = [
"docutils==0.17.1", # https://jupyterbook.org/en/stable/content/citations.html?highlight=docutils#citations-and-bibliographies
"jupyter-book>=1,<2",
]

[project.urls]
"Homepage" = "https://github.com/datapartnership/gaza-israel-conflict-impact-analysis"
"Bug Reports" = "https://github.com/datapartnership/gaza-israel-conflict-impact-analysis/issues"
"Source" = "https://github.com/datapartnership/gaza-israel-conflict-impact-analysis"

[tool.setuptools.dynamic]
version = { attr = "gaza_israel_conflict_analysis.__version__" }
[tool.codespell]
skip = 'docs/_build,docs/references.bib,*.png,*.gz,*.whl'
ignore-regex = '^\s*"image\/png":\s.*'
ignore-words-list = "gost,"

[tool.hatch.build.targets.wheel]
packages = ["src/gaza_israel_conflict_impact_analysis"]

[tool.hatch.version]
source = "vcs"

[tool.ruff.lint.pydocstyle]
convention = "numpy"
2 changes: 1 addition & 1 deletion reports/20240317/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ The following is a comparative visualization that contrasts the overall estimate
|- | -|
|![buildings-20231025_dark](../20240202/buildings-20231025_dark.png) | ![buildings-20240317](buildings-20230317_dark.png)|

> Estimated damage inflicted to buildings in the Gaza Strip utilizing SAR imagery to evaluate the extent and geographical distribution of estimated destruction. Each bar represents a region, with height indicating the number of affected buildings and color denoting the intensity of estimated damage on scale from 0 to 1, from yellow to red, where 1 signifies total damage.
> Estimated damage inflicted to buildings in the Gaza Strip utilizing SAR imagery to evaluate the extent and geographical distribution of estimated destruction. Each bar represents a region, with height indicating the number of affected buildings and color denoting the intensity of estimated damage on scale from 0 to 1, from yellow to red, where 1 signifies total damage.
Empty file.
2 changes: 0 additions & 2 deletions src/gaza_israel_conflict_analysis/__init__.py

This file was deleted.

This file was deleted.

7 changes: 7 additions & 0 deletions src/gaza_israel_conflict_impact_analysis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version("gaza-israel-conflict-impact-analysis")
except PackageNotFoundError:
# package is not installed
pass
Loading

0 comments on commit a9471cd

Please sign in to comment.