Skip to content

Commit

Permalink
Default to using a worldpop dataset within 3 years of the final year …
Browse files Browse the repository at this point in the history
…of the productivity data
  • Loading branch information
azvoleff committed Jul 31, 2024
1 parent 4b74da6 commit f5a3a12
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions LDMP/calculate_ldn.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,38 @@ def btn_calculate(self):
), # TODO: Use SOC matrix for the above once defined
}

pop_dataset = conf.REMOTE_DATASETS["WorldPop"][
"Gridded Population Count (gender breakdown)"
]
pop_start_year = pop_dataset["Start year"]
pop_end_year = pop_dataset["End year"]
# Use a population dataset that is as close as possible to the
# chosen final year, but no more than three years earlier or later
# than that year
if year_final < (pop_start_year - 3) or year_final > (pop_end_year + 3):
log(
f"final year {year_final} is too far away from available worldpop data years"
)
QtWidgets.QMessageBox.information(
None,
self.tr("Error"),
self.tr(
f"Final year of the productivity data ({year_final}) must be "
"within three years of the years for which population data "
f"is available from the WorldPop dataset ({pop_start_year}-{pop_end_year})."
),
)
return
else:
if year_final < pop_start_year:
pop_year = pop_start_year
elif year_final > pop_end_year:
pop_year = pop_end_year
else:
pop_year = year_final
payload["population"] = {
"year": year_final,
"asset": "users/geflanddegradation/toolbox_datasets/worldpop_mf_v1_300m",
"year": pop_year,
"asset": pop_dataset["GEE Dataset"],
"source": "WorldPop (gender breakdown)",
}

Expand Down

0 comments on commit f5a3a12

Please sign in to comment.