Skip to content

Commit

Permalink
add 6.3.1 and update progress statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
MaiaPelletier committed Apr 12, 2023
1 parent f1d1802 commit 96dd595
Show file tree
Hide file tree
Showing 13 changed files with 362 additions and 20 deletions.
14 changes: 7 additions & 7 deletions GIFProgressStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def update_progress_status(indicator_ids):
old_pm = None

# Run data + metadata through calculation to get progress
progress = pm.measure_indicator_progress(indicator)
progress = pm.measure_indicator_progress(indicator, False)
all_progress_statuses[ind_id] = progress

if progress is not None:
Expand All @@ -187,7 +187,7 @@ def update_progress_status(indicator_ids):
# Update progress status field in meta
progress_dict = {'progress_status': progress}
# Uncomment to update metadata files
update_progress_status_meta(progress_dict, ind_id)
# update_progress_status_meta(progress_dict, ind_id)
return progress_diff


Expand All @@ -203,11 +203,11 @@ def update_progress_status(indicator_ids):
# turn_on_progress_calc(ind_id)
# remove_progress_configs(ind_id)

# diffs = update_progress_status(indicator_ids)
diffs = update_progress_status(indicator_ids)
# update_progress_diff(diffs)

# individal calculations result ----
test_ind = merge_indicator('17-1-2')
test_data = pm.data_progress_measure(test_ind['data'])
print(test_data)
print(pm.measure_indicator_progress(test_ind))
# test_ind = merge_indicator('4-2-2')
# test_data = pm.data_progress_measure(test_ind['data'])
# print(test_data)
# print(pm.measure_indicator_progress(test_ind))
122 changes: 117 additions & 5 deletions ProgressMeasure.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
def measure_indicator_progress(indicator):
def measure_indicator_progress(indicator, all_calcs=False):
"""Sets up all needed parameters and data for progress calculation, determines methodology for calculation,
and returns progress measure as an output.
Args:
all_calcs: indicates if returning a dictionary of all calcs or just the progress status
indicator: Indicator for which the progress is being calculated for.
Returns:
output: str. A string indicating the progress measurement for the indicator.
Expand Down Expand Up @@ -65,14 +66,20 @@ def measure_indicator_progress(indicator):
if config['target'] is None:
# update progress thresholds for qualitative target
config = update_progress_thresholds(config, method=1)
# do progress calculation according to methodology for qualitative target
output = methodology_1(data=data, config=config)
if all_calcs:
output = get_all_progress_calculations(data=data, config=config, method=1)
else:
# do progress calculation according to methodology for qualitative target
output = methodology_1(data=data, config=config)

else:
# update progress thresholds for quantitative target
config = update_progress_thresholds(config, method=2)
# do progress calculation according to methodology for quantitative target
output = methodology_2(data=data, config=config)
if all_calcs:
output = get_all_progress_calculations(data=data, config=config, method=1)
else:
# do progress calculation according to methodology for quantitative target
output = methodology_2(data=data, config=config)

return output

Expand Down Expand Up @@ -283,3 +290,108 @@ def methodology_2(data, config):
else:
return None


def get_all_progress_calculations(data, config, method):

direction = str(config['direction'])
t = float(config['current_year'])
t_0 = float(config['base_year'])
t_tao = None
x = float(config['high'])
y = float(config['med'])
z = float(config['low'])
target = None
cagr_o = None
cagr_r = None
ratio = None
status = None

# get current value from data
current_value = data.Value[data.Year == t].values[0]
# get value from base year from data
base_value = data.Value[data.Year == t_0].values[0]

if method == 1:
direction = str(config['direction'])
t = float(config['current_year'])
t_0 = float(config['base_year'])
x = float(config['high'])
y = float(config['med'])
z = float(config['low'])

# get current value from data
current_value = data.Value[data.Year == t].values[0]
# get value from base year from data
base_value = data.Value[data.Year == t_0].values[0]
# calculate growth
cagr_o = growth_calculation(current_value, base_value, t, t_0)

# use negative growth value if desired direction of progress is negative
if direction == "negative":
cagr_o = -1 * cagr_o

# compare growth rate to progress thresholds to return progress measure
if cagr_o > x:
status = "substantial_progress"
elif y < cagr_o <= x:
status = "moderate_progress"
elif z <= cagr_o <= y:
status = "moderate_deterioration"
elif cagr_o < z:
status = "substantial_deterioration"
else:
status = None

else:
direction = str(config['direction'])
t = float(config['current_year'])
t_0 = float(config['base_year'])
target = float(config['target'])
t_tao = float(config['target_year'])
x = float(config['high'])
y = float(config['med'])
z = float(config['low'])

# get current value from data
current_value = data.Value[data.Year == t].values[0]
# get base value from data
base_value = data.Value[data.Year == t_0].values[0]

# check if the target is achieved
if (direction == "negative" and current_value <= target) or (
direction == "positive" and current_value >= target):
status = "target_achieved"
else:
# calculate observed growth
cagr_o = growth_calculation(current_value, base_value, t, t_0)
# calculate theoretical growth
cagr_r = growth_calculation(target, base_value, t_tao, t_0)
# calculating growth ratio
ratio = cagr_o / cagr_r

# compare growth ratio to progress thresholds to return progress measure
if ratio >= x:
status = "substantial_progress"
elif y <= ratio < x:
status = "moderate_progress"
elif z <= ratio < y:
status = "negligible_progress"
elif ratio < z:
status = "deterioration"
else:
status = None

calcs = {
'base_year': config['base_year'],
'current_year': config['current_year'],
'direction': direction,
'target': target,
'current_value': current_value,
'base_value': base_value,
'cagr_o': cagr_o,
'cagr_r': cagr_r,
'ratio': ratio,
"status": status
}

return calcs
65 changes: 65 additions & 0 deletions data/indicator_6-3-1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"Year","Series","Geography","GeoCode","Value"
"2013","Wastewater discharge from manufacturing industries","",,66.0313712261764
"2015","Wastewater discharge from manufacturing industries","",,63.1190926275992
"2017","Wastewater discharge from manufacturing industries","",,63.0986619982493
"2020","Wastewater discharge from manufacturing industries","",,64.3180083377371
"2013","Wastewater discharged from municipal sewage systems","Alberta",48,99.9531944769483
"2013","Wastewater discharged from municipal sewage systems","British Columbia",59,97.1544385893798
"2013","Wastewater discharged from municipal sewage systems","",,99.1087574270214
"2013","Wastewater discharged from municipal sewage systems","Manitoba",46,100
"2013","Wastewater discharged from municipal sewage systems","New Brunswick",13,100
"2013","Wastewater discharged from municipal sewage systems","Newfoundland and Labrador",10,76.5848086807539
"2013","Wastewater discharged from municipal sewage systems","Nova Scotia",12,93.6593059936909
"2013","Wastewater discharged from municipal sewage systems","Ontario",35,100
"2013","Wastewater discharged from municipal sewage systems","Prince Edward Island",11,99.6491228070175
"2013","Wastewater discharged from municipal sewage systems","Quebec",24,99.8414696694176
"2013","Wastewater discharged from municipal sewage systems","Saskatchewan",47,100
"2013","Wastewater discharged from municipal sewage systems","Yukon",60,100
"2014","Wastewater discharged from municipal sewage systems","Alberta",48,99.9768679157992
"2014","Wastewater discharged from municipal sewage systems","British Columbia",59,97.178731979538
"2014","Wastewater discharged from municipal sewage systems","",,99.1060842566767
"2014","Wastewater discharged from municipal sewage systems","Manitoba",46,100
"2014","Wastewater discharged from municipal sewage systems","New Brunswick",13,100
"2014","Wastewater discharged from municipal sewage systems","Newfoundland and Labrador",10,77.4407060121346
"2014","Wastewater discharged from municipal sewage systems","Nova Scotia",12,94.3673931502972
"2014","Wastewater discharged from municipal sewage systems","Ontario",35,100
"2014","Wastewater discharged from municipal sewage systems","Prince Edward Island",11,100
"2014","Wastewater discharged from municipal sewage systems","Quebec",24,99.8293116348672
"2014","Wastewater discharged from municipal sewage systems","Saskatchewan",47,99.8988877654196
"2014","Wastewater discharged from municipal sewage systems","Yukon",60,100
"2015","Wastewater discharged from municipal sewage systems","Alberta",48,100
"2015","Wastewater discharged from municipal sewage systems","British Columbia",59,97.0282559272491
"2015","Wastewater discharged from municipal sewage systems","",,99.1178495091113
"2015","Wastewater discharged from municipal sewage systems","Manitoba",46,100
"2015","Wastewater discharged from municipal sewage systems","New Brunswick",13,100
"2015","Wastewater discharged from municipal sewage systems","Newfoundland and Labrador",10,80.9788654060067
"2015","Wastewater discharged from municipal sewage systems","Nova Scotia",12,93.9718482252142
"2015","Wastewater discharged from municipal sewage systems","Ontario",35,100
"2015","Wastewater discharged from municipal sewage systems","Prince Edward Island",11,100
"2015","Wastewater discharged from municipal sewage systems","Quebec",24,99.8300743732453
"2015","Wastewater discharged from municipal sewage systems","Saskatchewan",47,100
"2015","Wastewater discharged from municipal sewage systems","Yukon",60,100
"2016","Wastewater discharged from municipal sewage systems","Alberta",48,100
"2016","Wastewater discharged from municipal sewage systems","British Columbia",59,97.2071373157486
"2016","Wastewater discharged from municipal sewage systems","",,99.1310401960007
"2016","Wastewater discharged from municipal sewage systems","Manitoba",46,99.9693815064299
"2016","Wastewater discharged from municipal sewage systems","New Brunswick",13,100
"2016","Wastewater discharged from municipal sewage systems","Newfoundland and Labrador",10,82.9757462686567
"2016","Wastewater discharged from municipal sewage systems","Nova Scotia",12,94.0736119775421
"2016","Wastewater discharged from municipal sewage systems","Ontario",35,100
"2016","Wastewater discharged from municipal sewage systems","Prince Edward Island",11,100
"2016","Wastewater discharged from municipal sewage systems","Quebec",24,99.8376394183256
"2016","Wastewater discharged from municipal sewage systems","Saskatchewan",47,100
"2016","Wastewater discharged from municipal sewage systems","Yukon",60,100
"2017","Wastewater discharged from municipal sewage systems","Alberta",48,100
"2017","Wastewater discharged from municipal sewage systems","British Columbia",59,97.1354956047287
"2017","Wastewater discharged from municipal sewage systems","",,99.1057680919104
"2017","Wastewater discharged from municipal sewage systems","Manitoba",46,99.9653619674402
"2017","Wastewater discharged from municipal sewage systems","New Brunswick",13,100
"2017","Wastewater discharged from municipal sewage systems","Newfoundland and Labrador",10,81.6827344434707
"2017","Wastewater discharged from municipal sewage systems","Nova Scotia",12,93.7376400791035
"2017","Wastewater discharged from municipal sewage systems","Ontario",35,100
"2017","Wastewater discharged from municipal sewage systems","Prince Edward Island",11,100
"2017","Wastewater discharged from municipal sewage systems","Quebec",24,99.8412150500518
"2017","Wastewater discharged from municipal sewage systems","Saskatchewan",47,99.9423298731257
"2017","Wastewater discharged from municipal sewage systems","Yukon",60,100
1 change: 1 addition & 0 deletions indicator-config/2-4-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ precision: []
progress_calculation_options:
- direction: positive
target_year: 2030
progress_status: moderate_progress
reporting_status: complete
sort: ''
standalone: false
Expand Down
3 changes: 2 additions & 1 deletion indicator-config/4-1-2.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
auto_progress_calculation: true
auto_progress_calculation: false
computation_units: Percentage
copyright: ''
data_footnote: ''
Expand Down Expand Up @@ -42,6 +42,7 @@ permalink: ''
precision: []
progress_calculation_options:
- direction: positive
progress_status: substantial_progress
reporting_status: complete
sort: ''
standalone: false
Expand Down
3 changes: 2 additions & 1 deletion indicator-config/4-3-1.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
auto_progress_calculation: true
auto_progress_calculation: false
computation_units: ''
copyright: ''
data_footnote: ''
Expand Down Expand Up @@ -38,6 +38,7 @@ national_geographical_coverage: Canada, Province or territory
page_content: ''
permalink: ''
precision: []
progress_status: moderate_progress
reporting_status: complete
sort: ''
standalone: false
Expand Down
3 changes: 2 additions & 1 deletion indicator-config/5-5-1.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
auto_progress_calculation: true
auto_progress_calculation: false
composite_breakdown_label: ''
computation_units: Percentage
copyright: ''
Expand Down Expand Up @@ -39,6 +39,7 @@ precision: []
progress_calculation_options:
- direction: positive
target_year: 2030
progress_status: substantial_progress
reporting_status: complete
sort: ''
standalone: false
Expand Down
6 changes: 3 additions & 3 deletions indicator-config/6-3-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ data_non_statistical: false
data_notice_class: ''
data_notice_heading: ''
data_notice_text: ''
data_show_map: false
data_show_map: true
data_start_values: []
embedded_feature_footer: ''
embedded_feature_html: ''
Expand All @@ -22,11 +22,11 @@ graph_titles: []
graph_type: line
indicator_name: global_indicators.6-3-1-title
indicator_number: '6.3.1'
national_geographical_coverage: ''
national_geographical_coverage: 'Canada, Province or territory'
page_content: ''
permalink: ''
precision: []
reporting_status: inprogress
reporting_status: complete
sort: ''
standalone: false
tags: []
2 changes: 1 addition & 1 deletion indicator-config/8-5-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ page_content: ''
permalink: ''
precision: []
progress_calculation_options:
- direction: down
- direction: negative
target_year: 2030
progress_status: substantial_deterioration
reporting_status: complete
Expand Down
2 changes: 1 addition & 1 deletion indicator-config/8-6-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ page_content: ''
permalink: ''
precision: []
progress_calculation_options:
- direction: down
- direction: negative
target_year: 2020
progress_status: substantial_progress
reporting_status: complete
Expand Down
37 changes: 37 additions & 0 deletions meta/6-3-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# NATIONAL
SDG_GOAL: |
Goal 6: Ensure availability and sustainable management of water and sanitation for all
SDG_TARGET: |
Target: 6.3: By 2030, improve water quality by reducing pollution, eliminating dumping and minimizing release of hazardous chemicals and materials, halving the proportion of untreated wastewater and substantially increasing recycling and safe reuse globally.
SDG_INDICATOR: |
Indicator: 6.3.1: Proportion of domestic and industrial wastewater flows safely treated
STAT_CONC_DEF: ' '
DATA_COMP: |
(Primary treatment + Secondary treatment + Tertiary treatment) / Total volumes
REC_USE_LIM: ' '

# GLOBAL
SDG_GOAL__GLOBAL: |
Goal 6: Ensure availability and sustainable management of water and sanitation for all
SDG_TARGET__GLOBAL: |
Target: 6.3: By 2030, improve water quality by reducing pollution, eliminating dumping and minimizing release of hazardous chemicals and materials, halving the proportion of untreated wastewater and substantially increasing recycling and safe reuse globally.
SDG_INDICATOR__GLOBAL: |
Indicator: 6.3.1: Proportion of domestic and industrial wastewater flows safely treated
un_designated_tier: Tier II
un_custodian_agency: United Nations Environment Programme (UNEP) (GEMS/Water)
goal_meta_link: https://unstats.un.org/sdgs/metadata/files/Metadata-06-03-02.pdf
goal_meta_link_text: United Nations Sustainable Development Goals Metadata (PDF 4.0
MB)

# SOURCE(S)
source_active_1: true
source_url_text_1: Statistics Canada. Table 38-10-0124-01 Wastewater volumes discharged from municipal sewage systems by treatment category (x 1,000,000)
source_url_1: https://www150.statcan.gc.ca/t1/tbl1/en/tv.action?pid=3810012401
source_organisation_1: Statistics Canada
source_geographical_coverage_1: Canada, Province or territory

source_active_2: true
source_url_text_2: Statistics Canada. Table 38-10-0060-01 Water discharge in manufacturing industries, by type of final treatment and industry (x 1,000,000)
source_url_2: https://doi.org/10.25318/3810006001-eng
source_organisation_2: Statistics Canada
source_geographical_coverage_2: Canada
Loading

0 comments on commit 96dd595

Please sign in to comment.