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

Exposure + Vulnerability + Exposure Change #1

Merged
merged 13 commits into from
May 20, 2021
Merged

Exposure + Vulnerability + Exposure Change #1

merged 13 commits into from
May 20, 2021

Conversation

LaurensLeunge
Copy link
Contributor

@LaurensLeunge LaurensLeunge commented May 19, 2021

  • 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

@LaurensLeunge LaurensLeunge changed the title Exposure + Vulnerability Exposure + Vulnerability + Exposure Change May 19, 2021
@LaurensLeunge LaurensLeunge marked this pull request as ready for review May 19, 2021 16:25
@codecov-commenter
Copy link

codecov-commenter commented May 20, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@84f4ab8). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84f4ab8...983c1cf. Read the comment docs.

Copy link
Contributor

@DirkEilander DirkEilander left a 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:
Copy link
Contributor

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)
Copy link
Contributor

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")
Copy link
Contributor

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"


# 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.")
Copy link
Contributor

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")
Copy link
Contributor

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 = (
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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

@DirkEilander DirkEilander merged commit 9eb12b0 into main May 20, 2021
@DirkEilander DirkEilander deleted the exposure branch May 20, 2021 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants