Skip to content

Commit

Permalink
simplify irrigation
Browse files Browse the repository at this point in the history
  • Loading branch information
jensdebruijn committed Feb 21, 2024
1 parent 508107f commit 0d9f493
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions geb/agents/farmers.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ def initiate_agents(self) -> None:
np.array(
[
self.irrigation_source_key["well"],
self.irrigation_source_key["tubewell"],
]
),
)
Expand Down Expand Up @@ -989,9 +988,9 @@ def abstract_water_numba(
):
farmer_has_access_to_irrigation_water = True
break
has_access_to_irrigation_water[
activated_farmer_index
] = farmer_has_access_to_irrigation_water
has_access_to_irrigation_water[activated_farmer_index] = (
farmer_has_access_to_irrigation_water
)

# Actual irrigation from surface, reservoir and groundwater
if surface_irrigated[farmer] == 1 or well_irrigated[farmer] == 1:
Expand Down Expand Up @@ -1073,9 +1072,9 @@ def abstract_water_numba(
groundwater_abstraction_cell_m3 = (
groundwater_abstraction_cell_m * cell_area[field]
)
groundwater_abstraction_m3[
f_var
] = groundwater_abstraction_cell_m3
groundwater_abstraction_m3[f_var] = (
groundwater_abstraction_cell_m3
)
available_groundwater_m3[
f_var
] -= groundwater_abstraction_cell_m3
Expand Down Expand Up @@ -1167,8 +1166,7 @@ def abstract_water(
self.irrigation_source,
np.array(
[
self.irrigation_source_key["canals"],
self.irrigation_source_key["other"],
self.irrigation_source_key["canal"],
]
),
),
Expand All @@ -1177,7 +1175,6 @@ def abstract_water(
np.array(
[
self.irrigation_source_key["well"],
self.irrigation_source_key["tubewell"],
]
),
),
Expand Down Expand Up @@ -2007,9 +2004,9 @@ def set_yearly_yield_spei(self) -> None:
self.yearly_yield_ratio[:, 0] = self.calculate_yearly_mean(
self.per_harvest_yield_ratio
)
self.yearly_SPEI_probability[
:, 0
] = self.convert_seasonal_to_yearly_SPEI_probability()
self.yearly_SPEI_probability[:, 0] = (
self.convert_seasonal_to_yearly_SPEI_probability()
)
self.per_harvest_SPEI[:] = 0

# Step 2: Shift and reset matrices
Expand Down Expand Up @@ -2330,10 +2327,9 @@ def adapt_irrigation_well(self) -> None:
adaptation_mask = self.adapt_SEUT(
ADAPTATION_TYPE, annual_cost, loan_duration, extra_constraint, adapted
)
print("Adaptation mask:", adaptation_mask.sum())

# Update irrigation source for farmers who adapted
self.irrigation_source[adaptation_mask] = self.irrigation_source_key["tubewell"]
self.irrigation_source[adaptation_mask] = self.irrigation_source_key["well"]

# Set their well depth
self.well_depth[adaptation_mask] = well_depth[adaptation_mask]
Expand Down

0 comments on commit 0d9f493

Please sign in to comment.