Skip to content

Commit

Permalink
Merge pull request #2 from mindearth/dev
Browse files Browse the repository at this point in the history
Included urban spatial structure indicators and analyses.
  • Loading branch information
MindEarth authored Nov 22, 2022
2 parents 26a426f + cebc809 commit c8c7f21
Show file tree
Hide file tree
Showing 15 changed files with 14,463 additions and 232 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
docs/_build
dist
build
mobilkit.egg-info
*.pyc
*.gz
*.pyo
.ipynb_checkpoints
dist/
docs/_build/
docs/mobilkit.*.rst
8,383 changes: 8,383 additions & 0 deletions docs/examples/USS01_Mumbai.ipynb

Large diffs are not rendered by default.

3,704 changes: 3,704 additions & 0 deletions docs/examples/USS02_CityComparison.ipynb

Large diffs are not rendered by default.

Binary file added docs/examples/figures/pings_stops_locs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,16 @@ If you use `mobilkit` please cite us:
2021, KDD 2021 Humanitarian Mapping Workshop, https://arxiv.org/abs/2107.14297

Bibtex:

@misc{ubaldi2021mobilkit,
title={Mobilkit: A Python Toolkit for Urban Resilience and Disaster Risk Management Analytics using High Frequency Human Mobility Data},
author={Enrico Ubaldi and Takahiro Yabe and Nicholas K. W. Jones and Maham Faisal Khan and Satish V. Ukkusuri and Riccardo Di Clemente and Emanuele Strano},
year={2021},
eprint={2107.14297},
primaryClass={cs.CY}
archivePrefix={arXiv},
}
primaryClass={cs.CY},
archivePrefix={arXiv}}





Credits and contacts
Expand All @@ -145,6 +146,8 @@ This code has been developed by `Mindearth <https://mindearth.ch>`_, the `Global

Funding was provided by the Spanish Fund for Latin America and the Caribbean (SFLAC) under the Disruptive Technologies for Development (DT4D) program.

The findings, interpretations, and conclusions expressed in this repository and in the example notebooks are entirely those of the authors. They do not necessarily represent the views of the International Bank for Reconstruction and Development/World Bank and its affiliated organizations, or those of the Executive Directors of the World Bank or the governments they represent.

The code is released under the MIT license (see the LICENSE file for details).


Expand All @@ -157,6 +160,8 @@ The code is released under the MIT license (see the LICENSE file for details).
examples/M4R_02_DisplacementAnalysis.ipynb
examples/M4R_03_POI_visit_analysis.ipynb
examples/M4R_04_Population_Density_Analysis.ipynb
examples/USS01_Mumbai.ipynb
examples/USS02_CityComparison.ipynb
reference/Loading_data.rst
mobilkit

Expand Down
7 changes: 7 additions & 0 deletions docs/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mobilkit
========

.. toctree::
:maxdepth: 4

mobilkit
2 changes: 1 addition & 1 deletion mobilkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
The `mobilkit` module documentation.
'''

__version__ = "0.1.7"
__version__ = "0.2.4.b"
16 changes: 16 additions & 0 deletions mobilkit/dask_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,29 @@
finalize=lambda s1: s1.apply(lambda final: len(set(final))),
)

sets2nunique = dd.Aggregation(
name="sets2nunique",
chunk=lambda s: s.apply(lambda x: list(set([e for es in x for e in es]))),
agg=lambda s0: s0.obj.groupby(level=list(range(s0.obj.index.nlevels))).sum(),
finalize=lambda s1: s1.apply(lambda final: len(set(final))),
)

# Constant column names
accColName = "acc"
lonColName = "lng"
latColName = "lat"
uidColName = "uid"
utcColName = "UTC"
dttColName = "datetime"
zidColName = "tile_ID"
stpColName = 'stops'
ldtColName = 'leaving_datetime'
durColName = 'duration'
medLatColName = latColName + '_medoid'
medLonColName = lonColName + '_medoid'
radLonColName = lonColName + '_RAD_'
radLatColName = latColName + '_RAD_'
locColName = "loc_ID"


eventLineRAW = [
Expand Down
3 changes: 2 additions & 1 deletion mobilkit/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,13 @@ def loaddata_takeapeek(dirpath, sep, ext):

def compute_datetime_col(df, selected_tz):
if dttColName in df.columns:
print("Warning, %s column already present, not computing it...")
print("Warning, '%s' column already present, not computing it..." % dttColName)
else:
df[dttColName] = dd.to_datetime(df[utcColName]*1e9, utc=False, unit="ns")\
.dt.tz_localize("UTC")\
.dt.tz_convert(selected_tz)\
.dt.tz_localize(None)
df[dttColName] = df[dttColName].astype('datetime64[s]')

return df

Expand Down
Loading

0 comments on commit c8c7f21

Please sign in to comment.