Implementing sums across pop groups.

RE:#1512
This commit is contained in:
James Douglass 2024-01-25 13:56:55 -08:00
parent 9e50106f64
commit 18c06468c8
2 changed files with 20 additions and 8 deletions

View File

@ -360,7 +360,11 @@ MODEL_SPEC = {
"about": (
"The total population within the "
"administrative unit that is undersupplied "
"with urban nature.")
"with urban nature. If aggregating by "
"population groups, this will be the sum "
"of undersupplied populations across all "
"population groups within this administrative "
"unit.")
},
"Povr_adm": {
"type": "number",
@ -368,7 +372,11 @@ MODEL_SPEC = {
"about": (
"The total population within the "
"administrative unit that is oversupplied "
"with urban nature.")
"with urban nature. If aggregating by "
"population groups, this will be the sum "
"of oversupplied populations across all "
"population groups within this administrative "
"unit.")
},
"SUP_DEMadm_cap_[POP_GROUP]": {
"type": "number",
@ -1978,14 +1986,18 @@ def _supply_demand_vector_for_pop_groups(
feature_id]['sum']
group_sup_dem_in_region = urban_nature_sup_dem_stats[
feature_id]['sum']
group_oversupply_in_region = oversupply_stats[feature_id]['sum']
group_undersupply_in_region = undersupply_stats[feature_id]['sum']
stats_by_feature[feature_id][f'SUP_DEMadm_cap_{groupname}'] = (
group_sup_dem_in_region / group_population_in_region)
stats_by_feature[feature_id][f'Pund_adm_{groupname}'] = (
undersupply_stats[feature_id]['sum'])
group_undersupply_in_region)
stats_by_feature[feature_id][f'Povr_adm_{groupname}'] = (
oversupply_stats[feature_id]['sum'])
group_oversupply_in_region)
sums['supply-demand'][feature_id] += group_sup_dem_in_region
sums['population'][feature_id] += group_population_in_region
sums['oversupply'][feature_id] += group_oversupply_in_region
sums['undersupply'][feature_id] += group_undersupply_in_region
for feature_id in feature_ids:
stats_by_feature[feature_id]['SUP_DEMadm_cap'] = (

View File

@ -569,10 +569,10 @@ class UNATests(unittest.TestCase):
'pop_female': attributes[0]['pop_female'],
'pop_male': attributes[0]['pop_male'],
'adm_unit_id': 0,
'Pund_adm': 0,
'Pund_adm': 3991.8271484375,
'Pund_adm_female': 2235.423095703125,
'Pund_adm_male': 1756.404052734375,
'Povr_adm': 0,
'Povr_adm': 1084.1727294921875,
'Povr_adm_female': 607.13671875,
'Povr_adm_male': 477.0360107421875,
'SUP_DEMadm_cap': -17.907799109781322,
@ -645,10 +645,10 @@ class UNATests(unittest.TestCase):
'pop_female': attributes[0]['pop_female'],
'pop_male': attributes[0]['pop_male'],
'adm_unit_id': 0,
'Pund_adm': 0,
'Pund_adm': 4801.7900390625,
'Pund_adm_female': 2689.00244140625,
'Pund_adm_male': 2112.78759765625,
'Povr_adm': 0,
'Povr_adm': 274.2098693847656,
'Povr_adm_female': 153.55752563476562,
'Povr_adm_male': 120.65234375,
'SUP_DEMadm_cap': -17.907799109781322,