Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Degurba Example #29

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8734791
update docs
elbeejay Feb 28, 2024
0bcd030
Merge branch 'main' of github.com:worldbank/GOSTurban into update-docs
elbeejay Feb 29, 2024
2eb4db3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 29, 2024
9f660ff
remove docs/notebooks
elbeejay Feb 29, 2024
c6ce3ca
Merge branch 'update-docs' of github.com:worldbank/GOSTurban into upd…
elbeejay Feb 29, 2024
be10311
Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
elbeejay Feb 29, 2024
9420f8d
Revert "remove docs/notebooks"
elbeejay Feb 29, 2024
545ab38
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 29, 2024
5a8a7fa
modify toc to only include notebook tutorials, clear notebook outputs
elbeejay Feb 29, 2024
ebeb0bb
Merge branch 'update-docs' of github.com:worldbank/GOSTurban into upd…
elbeejay Feb 29, 2024
ed08bff
fix deps, imports, and ci
elbeejay Feb 29, 2024
c9f852f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 29, 2024
419648a
generate conf.py as part of docs build workflow
elbeejay Feb 29, 2024
5e3578d
Merge branch 'update-docs' of github.com:worldbank/GOSTurban into upd…
elbeejay Feb 29, 2024
555845a
have workflow clean notebooks
elbeejay Feb 29, 2024
861c786
add extensions, options etc to _config.yml
elbeejay Feb 29, 2024
7c60f12
cleaned notebooks
elbeejay Feb 29, 2024
7ec9b65
remove non-functional exclusions
elbeejay Feb 29, 2024
4ebf1f5
build docs on prs, only deploy on main
elbeejay Feb 29, 2024
081bf9a
require nbconvert for docs
elbeejay Mar 1, 2024
a66f8c5
doc-strings for urbanraster.py
elbeejay Mar 12, 2024
0306d5e
doc-strings for step2
elbeejay Mar 12, 2024
3ec3ebd
lei.py docstrings
elbeejay Mar 12, 2024
522c775
urb doc-strings
elbeejay Mar 12, 2024
594004e
country_helper.py docstrings
elbeejay Mar 12, 2024
9f2f8ad
ignore words
elbeejay Mar 12, 2024
f5fa9c0
ignore more words
elbeejay Mar 12, 2024
88872dd
fix spellings
elbeejay Mar 12, 2024
8a66c39
fix spellings
elbeejay Mar 12, 2024
41ec26b
ignore another word
elbeejay Mar 12, 2024
66eb8cf
tomli to codepsell
elbeejay Mar 12, 2024
8773323
clean up doc-strings
elbeejay Mar 13, 2024
29bc9c8
clean up notebooks
elbeejay Mar 13, 2024
4bfd5f3
exclude implementation notebooks from ruff
elbeejay Mar 16, 2024
8b7c61f
finish cleaning up doc-strings
elbeejay Mar 16, 2024
9590759
new degurba example
elbeejay Mar 23, 2024
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
9 changes: 6 additions & 3 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: docs
on:
push:
branches:
- main
pull_request:

jobs:
build:
Expand All @@ -17,12 +16,16 @@ jobs:
- name: Dependencies
run: |
if [ -f pyproject.toml ]; then pip install ".[docs]"; fi
- name: Clear notebooks and create conf.py file
run: |
jupyter-book config sphinx docs/
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --ClearMetadataPreprocessor.enabled=True --clear-output --inplace $(find . -type f -name '*.ipynb')
- name: Build Sphinx Documentation
run: |
sphinx-build docs _build/html -b html
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: job.status == 'success'
if: github.ref == 'refs/heads/main' && job.status == 'success'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_build/html
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,11 @@ dmypy.json
_build/
docs/api/
src/GOSTurban/_version.py
docs/notebooks/

# ignore the generated sphinx conf.py file
# we generate it during the doc build using jupyter-book from _conf.py
docs/conf.py

# ignore any notebooks/implementations/output
notebooks/Implementations/output
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ repos:
- id: codespell
name: codespell
description: Checks for common misspellings in text files
additional_dependencies:
- tomli
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ pip install GOSTurban
pip install .
```

Install the package **in editable** mode with dependencies:
### Developer Installation

```shell
pip install -e .
```
Install the package **in editable** mode with all of the dependencies needed to run the tests and build the documentation locally:

```shell
pip install -e .[dev]
```

The `-e` flag stands for "editable," meaning changes to the source code will immediately affect the installed package.
The `-e` flag stands for "editable," meaning changes to the source code will immediately affect the installed package.

## License

Expand Down
14 changes: 13 additions & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ logo: images/logo.png
# Force re-execution of notebooks on each build.
# See https://jupyterbook.org/content/execute.html
execute:
execute_notebooks: off
execute_notebooks: force
allow_errors: true

# only build files in toc
only_build_toc: true

# Add a bibtex file so that we can create citations
bibtex_bibfiles:
Expand All @@ -25,3 +29,11 @@ repository:
html:
use_issues_button: false
use_repository_button: true

# specify sphinx extensions
sphinx:
extra_extensions:
- sphinx.ext.napoleon
- sphinxcontrib.apidoc
config:
apidoc_module_dir: ../src
37 changes: 36 additions & 1 deletion docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,39 @@ parts:
chapters:
- file: notebooks/Tutorials/UrbanAreas_tutorials.ipynb
- file: notebooks/Tutorials/LEI_Example.ipynb

# - caption: Implementations
# chapters:
# - file: notebooks/Implementations/JUP_SURGP_GLO_B_D__LEI_Evaluation.ipynb
# - file: notebooks/Implementations/URB_DECAT_B_ExploringGHSSMODcode.ipynb
# - file: notebooks/Implementations/URB_SEAU1_B_A_Ka_ExtractDataUrban.ipynb
# - file: notebooks/Implementations/WSF_DECAT_B_ExploringIDCerrors.ipynb
# - caption: KAZ_SCADR_UrbanizationReview
# chapters:
# - file: notebooks/Implementations/KAZ_SCADR_UrbanizationReview/ECA_Urban_Extents.ipynb
# - file: notebooks/Implementations/KAZ_SCADR_UrbanizationReview/Urban_metrics_Combine_All.ipynb
# - file: notebooks/Implementations/KAZ_SCADR_UrbanizationReview/Urban_metrics_Shape.ipynb
# - file: notebooks/Implementations/KAZ_SCADR_UrbanizationReview/Urban_metrics_Structure.ipynb
# - file: notebooks/Implementations/KAZ_SCADR_UrbanizationReview/KAZ_Urbanization_Review.ipynb
# - file: notebooks/Implementations/KAZ_SCADR_UrbanizationReview/Urban_metrics_Fullness.ipynb
# - file: notebooks/Implementations/KAZ_SCADR_UrbanizationReview/Urban_metrics_Sprawl.ipynb
# - caption: POV_EEAPV_COG_urban_assessment
# chapters:
# - file: notebooks/Implementations/POV_EEAPV_COG_urban_assessment/Summarize_Urban.ipynb
# - caption: Slum_Mapping
# chapters:
# - file: notebooks/Implementations/Slum_Mapping/Imagery_Search.ipynb
# - caption: URB_SCAUR_UKR_B_I_urbanizationReview
# chapters:
# - file: notebooks/Implementations/URB_SCAUR_UKR_B_I_urbanizationReview/URB_SCAUR_UKR_B_I_urbanizationReview.ipynb
# - caption: URB_SEAU1_NovelUrbanization
# chapters:
# - file: notebooks/Implementations/URB_SEAU1_NovelUrbanization/Create_Mosaick_Datasets.ipynb
# - file: notebooks/Implementations/URB_SEAU1_NovelUrbanization/GHSL_Standardize_To_Country.ipynb
# - file: notebooks/Implementations/URB_SEAU1_NovelUrbanization/MAP_Urbanization.ipynb
# - file: notebooks/Implementations/URB_SEAU1_NovelUrbanization/NGA_specific_results.ipynb
# - file: notebooks/Implementations/URB_SEAU1_NovelUrbanization/URB_SEAU1_B_A_Ka_NovelUrbanizaton.ipynb
# - file: notebooks/Implementations/URB_SEAU1_NovelUrbanization/WBGAPI_Extract_urbanization_GDP.ipynb
# - caption: URB_SURDR_ZAF_Energy_Transition
# chapters:
# - file: notebooks/Implementations/URB_SURDR_ZAF_Energy_Transition/Data Preparation.ipynb
# - file: notebooks/Implementations/URB_SURDR_ZAF_Energy_Transition/Zonal_statistics.ipynb
79 changes: 0 additions & 79 deletions docs/conf.py

This file was deleted.

52 changes: 10 additions & 42 deletions notebooks/Implementations/JUP_SURGP_GLO_B_D__LEI_Evaluation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,11 @@
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'src.LEI'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/tmp/ipykernel_81457/3673388608.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;31m#Import GOST urban functions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0msys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"../../\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 16\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0msrc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mLEI\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'src.LEI'"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"\n",
"import rasterio\n",
"import rasterio.features\n",
Expand All @@ -41,16 +28,13 @@
"from rasterio.plot import show\n",
"\n",
"# Import GOST urban functions\n",
"sys.path.append(\"../../\")\n",
"from src.LEI import *"
"from GOSTurban.LEI import calculate_LEI, summarize_LEI"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"LEI_folder = \"/home/wb411133/data/Projects/LEI\"\n",
Expand All @@ -72,7 +56,7 @@
" os.stat(os.path.join(root, \"GHSL.tif\")).st_size,\n",
" )\n",
" )\n",
" except:\n",
" except Exception:\n",
" pass"
]
},
Expand All @@ -81,7 +65,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Vizualize raster data - GHSL"
"# Visualize raster data - GHSL"
]
},
{
Expand Down Expand Up @@ -118,7 +102,7 @@
"source": [
"# write out raster to file\n",
"outProperties = inRaster.profile\n",
"outRaster = outRaster.astype(\"int32\")\n",
"outRaster = inRaster.astype(\"int32\")\n",
"outProperties[\"dtype\"] = \"int32\"\n",
"with rasterio.open(inputGHSL.replace(\".tif\", \"_LEI.tif\"), \"w\", **outProperties) as out:\n",
" out.write(outRaster)"
Expand All @@ -135,9 +119,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"for ghsl_file in GHSL_files:\n",
Expand Down Expand Up @@ -412,22 +394,8 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (geog)",
"language": "python",
"name": "geog"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"name": "python"
}
},
"nbformat": 4,
Expand Down
Loading
Loading