Skip to content

Integrating weather events into TLO #1604

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

Draft
wants to merge 89 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
3c404d1
Experiments
RachelMurray-Watson Mar 3, 2025
5a07093
File for formatting the projected precipitation-mediated disruptions …
RachelMurray-Watson Mar 3, 2025
56153df
Reformatted to allow for other services
RachelMurray-Watson Mar 3, 2025
6b13b8d
Building class that caculates the service availability for each facil…
RachelMurray-Watson Mar 3, 2025
62cce7c
Fixed typo
RachelMurray-Watson Mar 3, 2025
b001afb
Started adding ewe
RachelMurray-Watson Mar 3, 2025
6137251
Added but not set 'facility_used_level_1': Property(Types.CATEG…
RachelMurray-Watson Mar 4, 2025
4efe1f8
Assigned the closest facility based on distance... but could be very …
RachelMurray-Watson Mar 5, 2025
54b95e6
Unsure if it is needed?
RachelMurray-Watson Mar 5, 2025
290f5a3
Typo in function
RachelMurray-Watson Mar 5, 2025
b6a021b
Also fixed accessing dataframe and the column names in the data
RachelMurray-Watson Mar 5, 2025
2e7d5f3
Also fixed accessing dataframe and the column names in the data
RachelMurray-Watson Mar 5, 2025
e907118
Dropping coordinates as causing tests to fail (point not json seriali…
RachelMurray-Watson Mar 5, 2025
8c330a5
renamed mislabelled property
RachelMurray-Watson Mar 5, 2025
e46e556
Removed print
RachelMurray-Watson Mar 7, 2025
d7211d7
Still needs the properties of services disrupted/projected disruption…
RachelMurray-Watson Mar 7, 2025
559077b
Read in the projected precipitation-mediated disruptions for ANC.
RachelMurray-Watson Mar 7, 2025
8bc31ed
Resource files for precipitation-mediated disruptions
RachelMurray-Watson Mar 7, 2025
1c73859
test
RachelMurray-Watson Mar 7, 2025
9b0dc6c
changed path to save files
RachelMurray-Watson Mar 7, 2025
19b3dd8
removed the masterfacility check as thse are aggregated facilities
RachelMurray-Watson Mar 7, 2025
8b43cfc
updated to include the facility name
RachelMurray-Watson Mar 7, 2025
ae88c36
changed default to none
RachelMurray-Watson Mar 7, 2025
812fd51
Added assertion checks for type of model and scenario
RachelMurray-Watson Mar 7, 2025
104e238
Initial test of climate inclusion.
RachelMurray-Watson Mar 7, 2025
22ba45a
Only have data for year > 2025.
RachelMurray-Watson Mar 7, 2025
efbbdef
Fixed typo (omitting module when calling services affected)
RachelMurray-Watson Mar 7, 2025
73fd950
test
RachelMurray-Watson Mar 7, 2025
602de5c
Changed to allow tests to run... was getting error with M
RachelMurray-Watson Mar 10, 2025
a72670b
probabilities not percentages
RachelMurray-Watson Mar 10, 2025
aaceab7
Was accidentally using the property of services affected instead of t…
RachelMurray-Watson Mar 10, 2025
818bede
Now made abs value, which makes sampling easier
RachelMurray-Watson Mar 10, 2025
5f58e62
Now made abs value, which makes sampling easier
RachelMurray-Watson Mar 10, 2025
61428ec
Now made abs value, which makes sampling easier
RachelMurray-Watson Mar 10, 2025
7eca435
Was assigning the incorrect lost as possible categories for level_1a
RachelMurray-Watson Mar 10, 2025
3d9ec35
Added binomial trial
RachelMurray-Watson Mar 10, 2025
f6d40a2
Added file of lat/long facilities included
RachelMurray-Watson Mar 10, 2025
9a64821
Extra assertions
RachelMurray-Watson Mar 10, 2025
0224a46
edited params
RachelMurray-Watson Mar 10, 2025
bc66b55
Update file paths
RachelMurray-Watson Mar 26, 2025
793325c
Moved to resource file
RachelMurray-Watson Mar 26, 2025
e4f6d61
Dropped coordinates of residence after assigning facilities
RachelMurray-Watson Mar 26, 2025
e55fdb2
Renamed folders
RachelMurray-Watson Mar 26, 2025
6f2fc00
Ensures that facility type for disruption matches the facility assign…
RachelMurray-Watson Mar 28, 2025
ee364f0
Checked to ensure the disruption parameter is not None
RachelMurray-Watson Mar 28, 2025
29bbbfd
Reordered to check both if there was equipment, then if there was a d…
RachelMurray-Watson Mar 28, 2025
6695a7d
Need to import shapely
RachelMurray-Watson Mar 28, 2025
69a5699
Scenario file for climate disruptions
RachelMurray-Watson Mar 28, 2025
2d86ab8
The climate disruption parameters are now parameters, not properties
RachelMurray-Watson Apr 1, 2025
24e8317
ensured climate change params were actually set as parameters... unsu…
RachelMurray-Watson Apr 1, 2025
c6467bc
Merge branch 'refs/heads/master' into rmw/climate_change_switch
RachelMurray-Watson Apr 1, 2025
a36fa74
Added shapley to requirements, needed to assign individual locations.
RachelMurray-Watson Apr 3, 2025
54e0104
Tidied
RachelMurray-Watson Apr 3, 2025
ed8e24b
Changed order to fix CMD issue?
RachelMurray-Watson Apr 3, 2025
8d73871
Rename scenario file
RachelMurray-Watson Apr 3, 2025
bfa24cd
rolls back files and lines touched unintentionally (?)
tbhallett Apr 4, 2025
002b87f
Using WorldPop population density data on a 1km grid square. Matched …
RachelMurray-Watson Apr 9, 2025
c7fe8d4
Saved file
RachelMurray-Watson Apr 9, 2025
0fb14e2
fixed file path
RachelMurray-Watson Apr 9, 2025
940378e
Title was being cut off
RachelMurray-Watson Apr 9, 2025
ef182f4
Changed the assignation of random coordinates to ones based on the re…
RachelMurray-Watson Apr 9, 2025
71c1540
World pop density data with relative proportions
RachelMurray-Watson Apr 9, 2025
760bf86
Added both shapley and geopandas to base text
RachelMurray-Watson Apr 9, 2025
41f4b1f
made briefer
RachelMurray-Watson Apr 9, 2025
afbc113
Updated based on new package requirements
RachelMurray-Watson Apr 9, 2025
88c1ced
changed services to all as presume same effect across all
RachelMurray-Watson Apr 10, 2025
094f9ab
renamed column
RachelMurray-Watson Apr 10, 2025
2166d56
Tests. See now climate model results were incorrectly saved
RachelMurray-Watson Apr 10, 2025
66076cd
Redid facility level precipitation
RachelMurray-Watson Apr 10, 2025
b6dad27
Updated resource files based on correct labelling of months
RachelMurray-Watson Apr 10, 2025
b50b478
Fixed up dates
RachelMurray-Watson Apr 10, 2025
67e0b34
Reassigned defaults
RachelMurray-Watson Apr 10, 2025
d9545f1
extra check
RachelMurray-Watson Apr 10, 2025
40e7f6b
Changed type for services
RachelMurray-Watson Apr 10, 2025
8706f0a
Changing parameter still not working...
RachelMurray-Watson Apr 11, 2025
eb37004
Added climate parameters to Healthsystem resource file
RachelMurray-Watson Apr 11, 2025
891ddd5
Moved around reading in of files... For some reason, the parameters a…
RachelMurray-Watson Apr 11, 2025
c2cd786
Fixed high to highest
RachelMurray-Watson Apr 11, 2025
d7176ea
Fixed high to highest and low to lowest
RachelMurray-Watson Apr 11, 2025
48daf02
Fixed error of attribute vs parameter
RachelMurray-Watson Apr 11, 2025
7e70bcc
Fixed indenting issue that meant that no climate events were being di…
RachelMurray-Watson Apr 23, 2025
bd7ff57
Shorten for sample run
RachelMurray-Watson Apr 23, 2025
a52e515
Reverted changes made to test if it's working
RachelMurray-Watson Apr 23, 2025
6e0ad54
Reverted changes made to test if it's working
RachelMurray-Watson Apr 23, 2025
3887887
This now isn't working to assign parameters... but works in scropt?
RachelMurray-Watson Apr 23, 2025
7d65c9c
Get average days
RachelMurray-Watson Apr 23, 2025
5411b71
Get average days
RachelMurray-Watson Apr 23, 2025
f55156e
Set up for runs
RachelMurray-Watson Apr 23, 2025
84b3f86
Smaller, faster
RachelMurray-Watson Apr 24, 2025
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
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ dev = [
"pyinstrument>=4.3",
# Building requirements files
"pip-tools",
"shapely",
"geopandas"
]

[project.scripts]
Expand Down
6 changes: 6 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ et-xmlfile==1.1.0
# via openpyxl
fonttools==4.42.1
# via matplotlib
geopandas==1.0.1
# via tlo (pyproject.toml)
gitdb==4.0.10
# via gitpython
gitpython==3.1.36
Expand Down Expand Up @@ -137,6 +139,10 @@ requests-oauthlib==1.3.1
# via msrest
scipy==1.10.1
# via tlo (pyproject.toml)
shapely==2.1.0
# via
# geopandas
# tlo (pyproject.toml)
six==1.16.0
# via
# azure-core
Expand Down
21 changes: 20 additions & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ cachetools==5.3.1
certifi==2023.7.22
# via
# msrest
# pyogrio
# pyproj
# requests
cffi==1.15.1
# via cryptography
Expand Down Expand Up @@ -90,6 +92,8 @@ filelock==3.12.4
# virtualenv
fonttools==4.42.1
# via matplotlib
geopandas==1.0.1
# via tlo (pyproject.toml)
gitdb==4.0.10
# via gitpython
gitpython==3.1.36
Expand Down Expand Up @@ -128,9 +132,12 @@ msrestazure==0.6.4
numpy==1.24.4
# via
# contourpy
# geopandas
# matplotlib
# pandas
# pyogrio
# scipy
# shapely
# tlo (pyproject.toml)
oauthlib==3.2.2
# via requests-oauthlib
Expand All @@ -139,12 +146,16 @@ openpyxl==3.1.0
packaging==23.1
# via
# build
# geopandas
# matplotlib
# pyogrio
# pyproject-api
# pytest
# tox
pandas==2.0.3
# via tlo (pyproject.toml)
# via
# geopandas
# tlo (pyproject.toml)
pillow==10.0.1
# via matplotlib
pip-tools==7.3.0
Expand Down Expand Up @@ -173,8 +184,12 @@ pyjwt[crypto]==2.8.0
# pyjwt
pylint==3.0.1
# via tlo (pyproject.toml)
pyogrio==0.10.0
# via geopandas
pyparsing==3.1.1
# via matplotlib
pyproj==3.7.1
# via geopandas
pyproject-api==1.6.1
# via tox
pyproject-hooks==1.0.0
Expand Down Expand Up @@ -210,6 +225,10 @@ ruff==0.0.292
# via tlo (pyproject.toml)
scipy==1.10.1
# via tlo (pyproject.toml)
shapely==2.1.0
# via
# geopandas
# tlo (pyproject.toml)
six==1.16.0
# via
# azure-core
Expand Down
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point
from pathlib import Path
import os


resourcefilepath = '/Users/rem76/PycharmProjects/TLOmodel/resources'


worldpop_density_data = pd.read_csv(
Path(resourcefilepath) /'climate_change_impacts' / 'mwi_pd_2020_1km_ASCII_XYZ_worldpop.csv',
)

print(worldpop_density_data.head())

worldpop_density_data['Z'] = pd.to_numeric(worldpop_density_data['X'], errors='coerce')
worldpop_density_data['Y'] = pd.to_numeric(worldpop_density_data['Y'], errors='coerce')
worldpop_density_data['Z'] = pd.to_numeric(worldpop_density_data['Z'], errors='coerce')

geometry = [Point(xy) for xy in zip(worldpop_density_data['X'], worldpop_density_data['Y'])]
worldpop_gdf = gpd.GeoDataFrame(worldpop_density_data, geometry=geometry, crs="EPSG:4326")

malawi_admin2 = gpd.read_file(
Path(resourcefilepath) / 'mapping' / 'ResourceFile_mwi_admbnda_adm2_nso_20181016.shp')

worldpop_gdf.set_crs("EPSG:4326", inplace=True)
malawi_admin2.set_crs("EPSG:4326", inplace=True)

print(worldpop_gdf.crs)
print(malawi_admin2.crs)
worldpop_gdf = worldpop_gdf.to_crs(malawi_admin2.crs)

joined = gpd.sjoin(worldpop_gdf, malawi_admin2[['ADM2_EN', 'geometry']], how='left', predicate='within')

joined['Z_prop'] = joined.groupby('ADM2_EN')['Z'].transform(lambda x: x / x.sum())

print(joined)

joined.to_file(
Path(resourcefilepath) / 'climate_change_impacts'/'worldpop_density_with_districts.shp',
driver='ESRI Shapefile'
)
Loading
Loading