/
dim_medamb.py
139 lines (108 loc) · 4.42 KB
/
dim_medamb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Dimensión Medio Ambiente
# Documentos de referencia
# https://docs.google.com/spreadsheets/d/11sXtbYPi6ebDXrvFoHpA3qKGjS_OI4naNa0M4sXuFDY/edit#gid=1671296316
# https://kf.kobotoolbox.org/#/forms/aMbrw7VQcoKiZeRuEoJfCe/edit
import utils
from statistics import mean
# ------------------------------------------------------------
# Categoría: Waste / Residuos
# Subcategoría: Waste Generation
# Total solid waste generated by the population and economic activities
# ------------------------------------------------------------
def b1(datos):
respuestas = datos['group_consented/group_medamb/medamb_1'].split()
if "0" in respuestas: # No hay problema
return 100
return 0
# ------------------------------------------------------------
# Categoría: Waste / Residuos
# Subcategoría: Waste Sorting
# Segregation of materials with high value from the materials with low value, for the purpose of potential recovery
# ------------------------------------------------------------
def b2(datos):
respuestas = datos['group_consented/group_medamb/medamb_3'].split()
if len(respuestas) > 0: # Seleccionaron al menos una opción
return 100
return 0 # No seleccionaron ninguna opción
# ------------------------------------------------------------
# Categoría: Waste / Residuos
# Subcategoría: Waste Collection & Disposal
# Available disposal options and community behaviour to discard and/or recycle the volume of waste generated
# ------------------------------------------------------------
def b3(datos):
return mean([_b3a(datos), _b3b(datos)])
def _b3a(datos):
respuestas = datos['group_consented/group_medamb/medamb_4'].split()
# 0 No hay 0%
# 1 Malo 33%
# 2 Regular 66%
# 3 Bueno 100%
return utils.remap(int(respuestas[0]), 0, 3, 0, 100)
def _b3b(datos):
respuestas = datos['group_consented/group_medamb/medamb_5'].split()
if "3" in respuestas: # Vertederos informales
return 0
if "4" in respuestas: # Quema al aire libre
return 0
return 100
# ------------------------------------------------------------
# Categoría: Air quality
# Subcategoría: Air pollution
# Identification of areas with particularly severe air pollution (“hotspots”)
# ------------------------------------------------------------
def b4(datos):
respuestas = datos['group_consented/group_medamb/medamb_6'].split()
# Muy mala 0%
# Mala 25%
# Regular 50%
# Buena 75%
# Excelente 100%
return utils.remap(int(respuestas[0]), 5, 1, 0, 100)
# ------------------------------------------------------------
# Categoría: Climate
# Subcategoría: GHG emissions
# Greenhouse gas emissions per sector and respective local targets
# ------------------------------------------------------------
def b5(datos):
respuestas_a = datos['group_consented/group_medamb/medamb_7'].split()
respuestas_b = datos['group_consented/group_medamb/medamb_8'].split()
return mean([utils.remap(int(respuestas_a[0]), 3, 1, 0, 100),
utils.remap(int(respuestas_b[0]), 3, 1, 0, 100)])
# ------------------------------------------------------------
# Categoría: Water
# Subcategoría: Availability
# Variability of available water-related services, considering drinking water and water ecosystems services
# ------------------------------------------------------------
def b6(datos):
b6a = _b6a(datos)
b6b = _b6b(datos)
if b6a is not None:
if b6b is not None:
return mean([b6a, b6b])
return b6a
def _b6a(datos):
respuestas = datos['group_consented/group_medamb/medamb_9'].split()
if "0" in respuestas: # Nunca hay cortes de agua
return 100
return 0
def _b6b(datos):
if 'group_consented/group_medamb/medamb_10' not in datos:
return
respuestas = datos['group_consented/group_medamb/medamb_10'].split()
if "0" in respuestas:
return 100
if "1" in respuestas:
return 100
if "2" in respuestas:
return 100
return 0
# ------------------------------------------------------------
# Categoría: Water
# Subcategoría: Sanitation & Hygiene
# Availability of safely managed, sustainable sanitation services
# ------------------------------------------------------------
def b7(datos):
respuestas = datos['group_consented/group_medamb/medamb_11'].split()
if "0" in respuestas: # En caso de que no tengan drenaje 0%
return 0
return 100