-
Notifications
You must be signed in to change notification settings - Fork 3
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
Exposure + Vulnerability + Exposure Change #1
Conversation
LaurensLeunge
commented
May 19, 2021
•
edited
Loading
edited
- Added buildings.py workflow
- Added setup_exposure_buildings()
- Added _get_vulnerability()
- Added scale_exposure()
- Added _get_population_correction_factor()
- Added _get_gdp_correction_factor()
- Updated _set_root()
- Updated _configread()
- Updated _configwrite()
- Updated read_staticmaps()
- Updated write_staticmaps()
- Updated test_model_class.py test accordingly to the wflow test
Codecov Report
@@ Coverage Diff @@
## main #1 +/- ##
=======================================
Coverage ? 74.77%
=======================================
Files ? 4
Lines ? 440
Branches ? 0
=======================================
Hits ? 329
Misses ? 111
Partials ? 0 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @LaurensLeunge. Made some changes and create one issue for next release, see review.
@@ -155,231 +160,607 @@ def setup_hazard( | |||
) | |||
if self.staticmaps and not self.staticmaps.raster.identical_grid(ds): | |||
raise ValueError("The hazard maps should have identical grids.") | |||
# rename and add to staticmaps | |||
|
|||
if ds.raster.res[1] > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added: make sure all maps have N->S orientation
) | ||
|
||
# Determine the indexes of the reference year (GHS 2015) and the forecast year. | ||
ref_year_idx = list(annual_pop_data).index(2015) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These reference years should be settings of the setup methods. If users use different datasets these values might be different! made a new issue: #4
if not self._write: | ||
# start fresh in read-only mode | ||
self._staticgeoms = dict() | ||
region_fn = join(self.root, "region.GeoJSON") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added: reading region.geosjon which is used in "hydromt update fiat"
hydromt_fiat/workflows/buildings.py
Outdated
|
||
# downscaling exposure maps | ||
if da_bld_res > ds_like_res or da_pop_res > ds_like_res: | ||
logger.debug("Downscaling exposure maps to hazard resolution.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added: some logging
da_high_res = da_pop | ||
|
||
# get area map | ||
da_bld_area = get_area_grid(da_bld).rename("bld_area") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved inside if-statement - only required when downscaling
|
||
# # Create a population per buildings density map. | ||
# use pandas as xarray groupby sum is slow, see https://github.com/pydata/xarray/issues/4473 | ||
df_sum = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix speed: pandas based seems faster compared to xarray, see issue pydata/xarray#4473
da_pop.raster.set_nodata(nodata=0) | ||
|
||
# Get area and density grids. | ||
da_like_area = get_area_grid(ds_like) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed: defined once istead of multiple calls to get_area_grid
import pytest | ||
|
||
from hydromt.cli.cli_utils import parse_config | ||
from hydromt_fiat import FiatModel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed: import FiatModel directly instead of from hydromt.MODELS