-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurban_sarca_lib.py
166 lines (134 loc) · 5.18 KB
/
urban_sarca_lib.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env python
# -*- coding: cp1250 -*-
# ------------------------------------------------------------------------------
# Urban Green SARCA Library
# ------------------------------------------------------------------------------
# Author: Jakub Brom
# Date: 2020 - 10 - 07
#
# Copyright (c) Jakub Brom, 2020 - 2023.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------------
import numpy as np
def interceptFactor(LAI, precip, fresh_biomass, k=1.0, S=0.2):
"""
Interception factor for both dry and wet deposition of
radionuclides.
:param LAI: Leaf Area Index (unitless)
:param k: Constant of radionuclide: I = 0.5, Sr and Ba = 2.0, Cs and \
another radionuclides = 1.0
:param precip: Precipitation amount (mm) for period of deposition \
(ca 24 hours after radiation accident).
:param fresh_biomass: Amount of fresh biomass :math:`(t.ha^{-1})`
:param S: Mean thickness of water film at plant leaves (mm). \
Default S = 0.2 mm
:return: Interception Factor (rel.)
"""
try:
IF = LAI * k * S * (1.0 - np.exp((-np.log(2.0))/(3.0 * S) * (
precip + 0.0001))) / (precip + 0.0001)
IF[IF > 1.0] = 1.0
IF[fresh_biomass < 0.5] = 0.0
except ArithmeticError:
raise ArithmeticError("Interception factor has not been "
"calculated")
return IF
def contBiomass(depo, IF):
"""
Radiaoctive contamination of biomass :math:`(Bq.m^{-2})`
:param depo: Total radioactive deposition :math:`(Bq.m^{-2})`
:param IF: Interception Factor (rel.)
:return: Radioactive contamination of biomass :math:`(Bq.m^{-2})`
"""
try:
cont_biomass = depo * IF
cont_biomass[cont_biomass < 0.0] = 0.0
except ArithmeticError:
raise ArithmeticError("Vegetation biomass radioactive "
"contamination has not been calculated")
return cont_biomass
def contSoil(depo, IF):
"""
Radiaoctive contamination of soil :math:`(Bq.m^{-2})`
:param depo: Total radioactive deposition :math:`(Bq.m^{-2})`
:param IF: Interception Factor (rel.)
:return: Radioactive contamination of soil :math:`(Bq.m^{-2})`
"""
try:
cont_soil = depo * (1 - IF)
cont_soil[cont_soil < 0.0] = 0.0
except ArithmeticError:
raise ArithmeticError("Soil radioactive "
"contamination has not been calculated")
return cont_soil
def contMass(cont_biomass, fresh_biomass):
"""
Calculation radioactive contamination of fresh vegetation mass \
:math:`(Bq.kg^{-1})`
:param cont_biomass: Radioactive deposition on biomass \
:math:`(Bq.m^{-2})`
:param fresh_biomass: Amount of fresh biomass of vegetation \
:math:`(t.ha^{-1})`
:return: Fresh vegetation mass radioactive contamination \
:math:`(Bq.kg^{-1})`
"""
ignore_zero = np.seterr(all="ignore")
try:
cont_mass = cont_biomass/(fresh_biomass * 0.1)
cont_mass[cont_mass < 0.0] = 0.0
except ArithmeticError:
raise ArithmeticError("Mass Radioactive "
"contamination of fresh biomass has not "
"been calculated")
return cont_mass
def referLevel(depo, rl_dict):
"""
Mask of radioactive deposition for reference levels (categories) defined by tresholds.
:param depo: Total radioactive deposition :math:`(Bq.m^{-2})`
:param rl_dict: Dictionary with reference level tresholds :math:`(Bq.m^{-2})` and their keys (RL 1, RL 2, ...).
:return: Mask of radioactive deposition for reference levels.
"""
try:
# Sort dict according to values and extract RL values for categories
rl_dict_sort = {k: v for k, v in sorted(rl_dict.items(), key=lambda item: item[1])}
rl_keys = [int(i.split(' ')[1]) for i in list(rl_dict_sort.keys())]
rl_values = list(rl_dict_sort.values())
# Make ref_levels array
reference_groups = np.where(depo < rl_values[0], 0.0, depo)
for i in range(0,len(rl_keys)):
reference_groups = np.where(depo >= rl_values[i], rl_keys[i], reference_groups)
except ArithmeticError:
raise ArithmeticError("Mask for reference levels has not been"
" calculated")
return reference_groups
def hygLimit(cont_mass, hyg_lim=1000):
"""
Mask for hygienic limit of biomass radioactive contamination
exceeding.
:param cont_mass: Fresh vegetation mass radioactive contamination \
:math:`(Bq.kg^{-1})`
:param hyg_lim: Hygienic limit of mass radioactive contamination \
:math:`(Bq.kg^{-1})`. Default value is 1000 :math:`(Bq.kg^{-1})` \
according to Czech law.
:return: Mask for hygienic limit of biomass radioactive \
contamination exceeding.
"""
try:
hyg_lim_mask = np.where(cont_mass >= hyg_lim, 1.0, 0.0)
except ArithmeticError:
raise ArithmeticError("Mask for hygienic limit of mass "
"radioactive contamination has not been "
"calculated")
return hyg_lim_mask