Skip to content

Commit

Permalink
Merge pull request #131 from GEB-model/high-res
Browse files Browse the repository at this point in the history
Allow resolutions higher than 30 arcsec (at least up to 6 arcsec). 3'' remains to be tested
  • Loading branch information
jensdebruijn authored Nov 20, 2024
2 parents 9a4d2d7 + 98e13cc commit 6bd3b81
Show file tree
Hide file tree
Showing 9 changed files with 302 additions and 260 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
jobs:
build-docs:
name: Build Sphinx Documentation
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
# Check out the repository
- uses: actions/checkout@v4
Expand Down
34 changes: 32 additions & 2 deletions examples/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ setup_channel_depth:

setup_channel_ratio:

setup_elevation:

setup_soil_parameters:

setup_land_use_parameters:
Expand Down Expand Up @@ -353,3 +351,35 @@ setup_forcing:
setup_SPEI:
calibration_period_start: 2000-01-01
calibration_period_end: 2020-12-31

setup_well_prices_by_reference_year_global:
WHY_10: 82.0209974 # $/m
WHY_20: 164 # $/m
WHY_30: 50 # $/m
reference_year: 2017
start_year: 1960
end_year: 2020

setup_irrigation_sources:
irrigation_sources:
"no": -1
canal: 0
well: 1

setup_create_farms_simple:
data_source: lowder

setup_farmer_characteristics_simple:
risk_aversion_mean: 2
risk_aversion_standard_deviation: 1
discount_rate: 0.05
interest_rate: 0.05
reduce_crops: true

setup_population:

setup_assets:
feature_types:
- buildings
- roads
- rails
6 changes: 3 additions & 3 deletions geb/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,15 @@ def build(

region = config["general"]["region"]
if "basin" in region:
region_config = {
"basin": region["basin"],
}
region_config = {"basin": region["basin"], "max_bounds": region["max_bounds"]}
elif "pour_point" in region:
pour_point = region["pour_point"]
region_config = {
"subbasin": [[pour_point[0]], [pour_point[1]]],
"max_bounds": region["max_bounds"],
}
elif "geometry" in region:
raise NotImplementedError("Max bounds needs to be implemented")
region_config = {
"geom": region["geometry"],
}
Expand Down
4 changes: 2 additions & 2 deletions geb/data_catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ wb_inflation_rate:
source_license: CC-BY-4.0
source_url: https://data.worldbank.org/indicator/FP.CPI.TOTL.ZG
sorce_version: 5551656
path: economics/WB inflation rates/API_FP.CPI.TOTL.ZG_DS2_en_csv_v2_5551656.csv
path: economics/WB inflation rates/API_FP.CPI.TOTL.ZG_DS2_en_csv_v2_77.csv
driver: csv
data_type: DataFrame
kwargs:
Expand All @@ -311,7 +311,7 @@ wb_lending_rate:
source_license: CC-BY-4.0
source_url: https://data.worldbank.org/indicator/FR.INR.LEND
sorce_version: 5553913
path: economics/WB lending interest rates/API_FR.INR.LEND_DS2_en_csv_v2_5553913.csv
path: economics/WB lending interest rates/API_FR.INR.LEND_DS2_en_csv_v2_3789.csv
driver: csv
data_type: DataFrame
kwargs:
Expand Down
4 changes: 2 additions & 2 deletions geb/hydrology/landcover.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,9 @@ def step(self):
actual_bare_soil_evaporation,
open_water_evaporation,
],
prestorages=[w_pre, topwater_pre],
prestorages=[w_pre.sum(axis=0), topwater_pre],
poststorages=[
self.var.w,
self.var.w.sum(axis=0),
self.var.topwater,
],
tollerance=1e-6,
Expand Down
7 changes: 7 additions & 0 deletions geb/hydrology/routing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ def __init__(self, model):
self.model.files["grid"]["routing/kinematic/ldd"],
compress=False,
)
# in previous versions of GEB we followed the CWatM specification, where masked data
# was set at 0. We now use the official LDD specification where masked data is 255
# (max value of uint8). To still support old versions we set these values of 255 to
# 0 for now. When all models have been updated, this can be removed and the
# subroutines can be updated accordingly.
ldd[ldd == 255] = 0

(
self.var.lddCompress,
Expand Down Expand Up @@ -161,6 +167,7 @@ def __init__(self, model):
self.var.load(self.model.files["grid"]["routing/kinematic/mannings"])
* self.model.config["parameters"]["manningsN"]
)
assert (self.var.chanMan > 0).all()
# Channel gradient (fraction, dy/dx)
minimum_channel_gradient = 0.0001
self.var.chanGrad = np.maximum(
Expand Down
4 changes: 3 additions & 1 deletion geb/hydrology/routing/subroutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ def repairLdd1(ldd):

@njit(cache=True)
def dirID(lddorder, ldd):
out_array = np.full_like(ldd, -1) # Initialize out_array with -1, same shape as ldd
out_array = np.full_like(
ldd, -1, dtype=np.int32
) # Initialize out_array with -1, same shape as ldd
dirX = np.array([0, -1, 0, 1, -1, 0, 1, -1, 0, 1], dtype=np.int32)
dirY = np.array([0, 1, 1, 1, 0, 0, 0, -1, -1, -1], dtype=np.int32)

Expand Down
Loading

0 comments on commit 6bd3b81

Please sign in to comment.