Risk Assessment API¶
Toolkit for hazard modeling, agent effects, and protection policy evaluation.
RiskToolkit¶
hera.riskassessment.riskToolkit.RiskToolkit
¶
Bases: abstractToolkit
Toolkit for agent-based risk assessment.
Manages hazardous agents (chemical, thermal, blast), their injury effect models, protection policies, and casualty estimation. Agents are stored as versioned data sources and can be loaded from JSON descriptors or from the database.
Source code in hera/riskassessment/riskToolkit.py
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
analysis
property
¶
Access the risk analysis layer.
Returns:
| Type | Description |
|---|---|
analysis
|
Object providing risk area calculation and LSM integration. |
ProtectionPolicy
property
¶
Access the ProtectionPolicy class for building protection action pipelines.
Returns:
| Type | Description |
|---|---|
type
|
The ProtectionPolicy class (not an instance). |
presentation
property
¶
Access the presentation layer for casualty visualizations.
Returns:
| Type | Description |
|---|---|
casualtiesPlot
|
|
__init__(projectName, filesDirectory=None, connectionName=None)
¶
Initialize the RiskToolkit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectName
|
str
|
The project name. |
required |
filesDirectory
|
str
|
Directory for file outputs. |
None
|
connectionName
|
str
|
The DB connection name. |
None
|
Source code in hera/riskassessment/riskToolkit.py
getAgent(nameOrDesc, version=None)
¶
Initialize the agents.
:param nameOrDesc: str or JSON. Can be either the name of the agent (str) or the descriptor
{
"name" : [the name of the agent],
"effectParameters" : {
TenBergeCoefficient and ect.
},
"effects": {
"effect name" : { effect data (+ injury levels) }
}
}
:param projectName: str The name of the project in the local DB that will be searched for the agent. :return:
Source code in hera/riskassessment/riskToolkit.py
listAgentsNames()
¶
Lists the agents that are currently loaded in the DB (both local and public).
:return: list A list of agent names.
Source code in hera/riskassessment/riskToolkit.py
loadAgent(name, agentDescription, version, saveMode=TOOLKIT_SAVEMODE_FILEANDDB)
¶
Adds the agent to the DB. Either to the public or to the local DB.
Equivalent to loadData
:param name: str Agent name :param agentDescription: dict The agent description
:return: None
Source code in hera/riskassessment/riskToolkit.py
loadData(fileNameOrData, saveMode=TOOLKIT_SAVEMODE_FILEANDDB, **kwargs)
¶
Abstract loading a data from file. Manages the parsing of the
datafile.
Equivalent to loadData
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fileNameOrData
|
|
required | |
parser
|
|
required |
Source code in hera/riskassessment/riskToolkit.py
Agent¶
hera.riskassessment.agents.Agents.Agent
¶
Represents a hazardous agent with its associated injury effect models.
An agent is initialized from a JSON descriptor that defines its name,
effect parameters (e.g. Ten Berge coefficient), and one or more injury
effects (e.g. inhalation, thermal). Each effect is accessible by name
via dictionary-style access (agent["inhalation"]).
Source code in hera/riskassessment/agents/Agents.py
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 167 168 169 170 | |
effectNames
property
¶
List of effect names defined for this agent.
Returns:
| Type | Description |
|---|---|
list of str
|
|
physicalproperties
property
¶
Physical properties of the agent (molecular weight, density, vapor pressure, etc.).
Returns:
| Type | Description |
|---|---|
PhysicalPropeties
|
|
fullDescription
property
¶
The full JSON descriptor used to initialize this agent.
Returns:
| Type | Description |
|---|---|
dict
|
|
effectproperties
property
¶
The effect parameters dictionary (e.g. tenbergeCoefficient).
Returns:
| Type | Description |
|---|---|
dict
|
|
tenbergeCoefficient
property
writable
¶
The Ten Berge coefficient for dose-response calculations.
Returns:
| Type | Description |
|---|---|
float
|
|
name
property
¶
The name of the agent.
Returns:
| Type | Description |
|---|---|
str
|
|
__getitem__(name)
¶
Access an effect by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
|
required |
Returns:
| Type | Description |
|---|---|
Injury
|
The injury effect object. |
__init__(descriptor)
¶
Constructor of the Agent project.
Initializes an agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
descriptor
|
|
required |
Source code in hera/riskassessment/agents/Agents.py
toJSON()
¶
Serialize the agent to a JSON-compatible dictionary.
Returns:
| Type | Description |
|---|---|
dict
|
|
Source code in hera/riskassessment/agents/Agents.py
ProtectionPolicy¶
hera.riskassessment.protectionpolicy.ProtectionPolicy.ProtectionPolicy
¶
Bases: object
Calculates the expected concentration of the defined protection policy. The policy should include: - indoor time. - masking. - evacuation.
So a policy is a list of actions that take place: each action modifies the concentration field and is defined by a begining and end. The end can be infite (=None), like in evacuation.
The object should support chaining of actions:
ProtectionPolicy.indoor(alpha=0.2,begin=0,end=10).masking(factor=1000,begin=0,end=1000).compute(C,concentrationField="C") .masking(distribution="beta",mean=1000,sigma=10,begin=0,end=1000,bins=100).compute(C,concentrationField="C")
This will create attributes with the details of the execution pipeline. in each attribute we will have: actionID (sequential number) => { "params" : { paramname => value } "outputfields" : ["field"] }
outputfields is used for the subsequent protection (if there is multiple output).
Currently, only a single indoor time is defined (without exit time)
In the future, we should calculate the concentrations field for each action imposed on the concentrations of the previous one (i.e add a field).
Source code in hera/riskassessment/protectionpolicy/ProtectionPolicy.py
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
params
property
¶
dict The parameters associated with this protection policy.
finalname
property
¶
str The name of the final concentration field in the dataset after all protection actions have been applied.
xname
property
¶
str The name of the x-coordinate dimension in the dataset.
yname
property
¶
str The name of the y-coordinate dimension in the dataset.
datetimename
property
¶
str The name of the datetime dimension in the dataset.
data
property
¶
xarray.Dataset or None
The concentration dataset produced after calling compute.
None before computation.
hdfkey
property
¶
Combined HDF key for all actions in this policy.
Returns:
| Type | Description |
|---|---|
str
|
|
__init__(actionList=None, x='x', y='y', datetime='datetime')
¶
A basic action list.
[ { name: "indoor|masking|evacuation", params: { action params } } ]
Source code in hera/riskassessment/protectionpolicy/ProtectionPolicy.py
addActions(jsonStrOrFile)
¶
add actions from a file.
The actions are under the "actions" key.
Source code in hera/riskassessment/protectionpolicy/ProtectionPolicy.py
addAction(name, params)
¶
Adds json with the params
indoor(**kwargs)
¶
Adds an indoor protection to the list of actions.
Must supply alpha or turnover. If indoor is restricted by time, then must supply (begin,end) or (enter,stay).
:params: kwargs:
- alpha (1/[time]) - room alpha = 1/[turn over rate].
- turnover ([time]) - room turn over rate.
- begin - the time in which the population enters indoor
- end - the time in which the population leaves indoor.
- enter - timedelta str after the begining of the simulation that the population enters indoor
- stay - timedelta str for staying indoor.
Source code in hera/riskassessment/protectionpolicy/ProtectionPolicy.py
masks(**kwargs)
¶
Adds a masking protection.
:params: kwargs:
- protectionFactor - The protectionFactor of the masks.
- begin - the time in which the population enters indoor.
- end - the time in which the population leaves indoor.
- enter - timedelta str after the begining of the simulation that the population enters indoor.
- stay - timedelta str for staying indoor.
Source code in hera/riskassessment/protectionpolicy/ProtectionPolicy.py
compute(data, C='C', lazy=False)
¶
Executes the pipeline.
Source code in hera/riskassessment/protectionpolicy/ProtectionPolicy.py
Effects¶
Injury models and calculators. Subclass names follow the Calculator<Name>, InjuryLevel<Name>, Injury<Name> convention because the factories resolve them with pydoc.locate.
Calculator¶
hera.riskassessment.agents.effects.Calculator
¶
AbstractCalculator
¶
Bases: object
Holds the abstract calculator.
Source code in hera/riskassessment/agents/effects/Calculator.py
injuryBreathingRate
property
¶
Breathing rate used when the injury level was determined.
Returns:
| Type | Description |
|---|---|
Quantity
|
|
__init__(breathingRate=10 * ureg.L / ureg.min)
¶
Initialize with the reference breathing rate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
breathingRate
|
Quantity
|
|
10 * L / min
|
Source code in hera/riskassessment/agents/effects/Calculator.py
toJSON()
¶
CalculatorHaber
¶
Bases: AbstractCalculator
Implements the haber law (simple integral) on the concentrations.
Source code in hera/riskassessment/agents/effects/Calculator.py
__init__(breathingRate=10 * ureg.L / ureg.min, **kwargs)
¶
Calculates the Haber dosage. The integration is performed on the time axis.
:param: time: a string with the name of the axis to perform the integration on.
Source code in hera/riskassessment/agents/effects/Calculator.py
calculate(concentrationField, breathingRate=10 * ureg.L / ureg.min, time='datetime', field=None, inUnits=None)
¶
Calculates the dosage from a concentration field.
Concentration field can be pandas.DataFrame or xarray.Dataset. If it is xarray.Dataset, then use the field parameter to calculate the toxic from the requested field.
Return
An xarray or pandas (depend on the input) with the toxic loads
in each time step.
Source code in hera/riskassessment/agents/effects/Calculator.py
toJSON()
¶
CalculatorTenBerge
¶
Bases: AbstractCalculator
Implements the ten=berge law (int C^n dt) on the concentrations.
Source code in hera/riskassessment/agents/effects/Calculator.py
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
__init__(tenbergeCoefficient, breathingRate=10 * ureg.L / ureg.min, **kwargs)
¶
:param: n: the ten-berge coefficient. :param: time: the time variable.
Source code in hera/riskassessment/agents/effects/Calculator.py
calculate(concentrationField, field, breathingRate=10 * ureg.L / ureg.min, time='datetime', inUnits=None)
¶
Calculates the toxic load from a concentration field. \begin{equation} D(T) = \int_0^T C^n dt \end{equation}
Concentration field can be pandas.DataFrame or xarray.Dataset. If it is xarray.Dataset, then use the field parameter to calculate the toxic from the requested field.
Source code in hera/riskassessment/agents/effects/Calculator.py
toJSON()
¶
Serialize the Ten Berge calculator to a JSON-compatible dictionary.
CalculatorMaxConcentration
¶
Bases: AbstractCalculator
Calculator using the maximum rolling-average concentration.
Source code in hera/riskassessment/agents/effects/Calculator.py
__init__(sampling, breathingRate=10 * ureg.L / ureg.min, **kwargs)
¶
Implements the maximal concentration on the time axis.
calculate(concentrationField, field, breathingRate=10 * ureg.L / ureg.min, time='datetime', inUnits=None)
¶
Calculate the maximal concentrations
Concentration field can be pandas.DataFrame or xarray.Dataset. If it is xarray.Dataset, then use the field parameter to calculate the toxic from the requested field.
Source code in hera/riskassessment/agents/effects/Calculator.py
toJSON()
¶
Serialize the max-concentration calculator to a JSON-compatible dictionary.
InjuryLevel¶
hera.riskassessment.agents.effects.InjuryLevel
¶
InjuryLevel
¶
Bases: object
Represents an injury level
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
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 167 168 169 170 171 172 | |
name
property
¶
Name of this injury level.
Returns:
| Type | Description |
|---|---|
str
|
|
units
property
¶
Units associated with this injury level.
Returns:
| Type | Description |
|---|---|
Unit or None
|
|
__init__(name, units=None, **parameters)
¶
Initialize the injury level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
|
required |
units
|
Unit or None
|
|
None
|
**parameters
|
|
{}
|
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
calculateContours(toxicLoads, time='datetime', x='x', y='y')
¶
Calculates the contours of the current injury from the toxic loads.
Return
GeoPandas.GeoDataFrame with the fields:
time | injury name | total polygon | diff polygon | percentInjury
| | the total area | a differance from the level above. | if necessary.
The data returns in km because itm is in km.
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
toJSON()
¶
InjuryLevelLognormal10DoseResponse
¶
Bases: InjuryLevel
Calculates the % of the population that will be affected at a given ToxicLoad
This class also return the toxic load of a requested fraction.
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
TL_50
property
¶
Toxic load at which 50% of the population is affected.
Returns:
| Type | Description |
|---|---|
Quantity
|
|
sigma
property
¶
Probit inverse (log-normal standard deviation).
Returns:
| Type | Description |
|---|---|
float
|
|
__init__(name, **parameters)
¶
Initiates the injury level.
parameters are - TL_50: The ToxicLoad in which 50% are effected. - sigma: The probit inverse.
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
getPercent(ToxicLoad)
¶
Using lognormal distribution with base 10.
In that case define a new probable variable:
Y such that Y = X/a. (X is the original dose in base 10, Y is in natural base). Then, X_avg/a = Y_avg and Sig_x/a = Sig_y.
Where a is the transformation between the bases: 10^(x) = exp(y) --> x = log10(e)*y --> a = log10(e).
Therefore, in order to use the lognormal with the natural base we divide all the data (and the mean,std) with the 'a' coefficient.
Important Notes:
- See that the a factor in v/a and Effect[0]/a actually cancel.
- lognorm calculates log(x/scale)/sigma --> log(x/scale)= log10(x/scale)/a But we use sigma/a ==> and we get that lognorm.cdf(x/a,sigma/a,scale/a) = lognorm.cdf(x,sigma/a,scale) = Phi(log10(x/scale)/a / (sigma/a) ) = Phi(log10(x/scale)/sigma ) which is what we got from the manuals (and see Ziv).
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
getToxicLoad(Percent)
¶
Return the toxic load corresponding to a given injury fraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Percent
|
float or array_like
|
|
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
|
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
toJSON()
¶
Serialize the lognormal dose-response level to a JSON-compatible dictionary.
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
InjuryLevelThreshold
¶
Bases: InjuryLevel
Injury level defined by a single concentration threshold.
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
threshold
property
¶
Concentration threshold value.
Returns:
| Type | Description |
|---|---|
Quantity
|
|
__init__(name, units=None, **parameters)
¶
Initialize a threshold-based injury level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
|
required |
units
|
Unit or None
|
|
None
|
**parameters
|
|
{}
|
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
getPercent(ToxicLoad)
¶
Return 1 if toxic load exceeds threshold, else 0.
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
toJSON()
¶
Serialize the threshold injury level to a JSON-compatible dictionary.
InjuryLevelExponential
¶
Bases: InjuryLevel
Injury level using an exponential dose-response model.
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
k
property
¶
Exponential rate constant.
Returns:
| Type | Description |
|---|---|
float
|
|
__init__(name, **parameters)
¶
Initialize an exponential injury level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
|
required |
**parameters
|
|
{}
|
Source code in hera/riskassessment/agents/effects/InjuryLevel.py
getPercent(ToxicLoad)
¶
Return the fraction affected using 1 - exp(-k * ToxicLoad).
toJSON()
¶
Serialize the exponential injury level to a JSON-compatible dictionary.
Injury¶
hera.riskassessment.agents.effects.Injury
¶
InjuryFactory
¶
Bases: object
Factory for creating Injury instances from JSON configuration.
Resolves the injury type and calculator classes by name, instantiates
them with the supplied parameters, and returns a fully configured
Injury object.
Source code in hera/riskassessment/agents/effects/Injury.py
name
property
¶
Name of this injury factory.
Returns:
| Type | Description |
|---|---|
str
|
|
getInjury(name, cfgJSON, **additionalparameters)
¶
Creates the appropriate injury
Structure:
{
"type" :
additionalparameters:¶
These are parameters that might be used by the calculator
For example the tenberge coefficient.
Source code in hera/riskassessment/agents/effects/Injury.py
Injury
¶
Bases: object
Holds a list of injury levels
Source code in hera/riskassessment/agents/effects/Injury.py
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
calculator
property
¶
The calculator used for toxic load computation.
Returns:
| Type | Description |
|---|---|
AbstractCalculator
|
|
levels
property
¶
Ordered list of injury levels.
Returns:
| Type | Description |
|---|---|
list of InjuryLevel
|
|
levelNames
property
¶
Names of all injury levels.
Returns:
| Type | Description |
|---|---|
list of str
|
|
__getitem__(name)
¶
__init__(name, cfgJSON, calculator, units=None)
¶
Loads the relevant injury levels from the JSONcfg
{
"type" : <injuryLevel type>. Appends 'pyriskassessment.casualties.InjuryLevel.InjuryLevel' to the name.
"levels" : [....],
parameters: {
"InjuryName" : { injury parameters },
.
.
}
Source code in hera/riskassessment/agents/effects/Injury.py
getPercent(level, ToxicLoad)
¶
calculate the toxic load and subtract the percent from the percent above.
Source code in hera/riskassessment/agents/effects/Injury.py
calculate(concentrationField, field, time='datetime', x='x', y='y', breathingRate=10 * ureg.L / ureg.min, sel={}, isel={})
¶
Deprecated. Use calculateRegionOfInjured instead.
Source code in hera/riskassessment/agents/effects/Injury.py
calculateRegionOfInjured(concentrationField, field, time='datetime', x='x', y='y', breathingRate=10 * ureg.L / ureg.min, sel={}, isel={})
¶
Calculates the fraction of the population that was effected in each point, and returns its contour.
The levels are determined by the injury type.
Parameters
Parameters
concentrationField:
an xarray with the concentrations at each time.
time: str
The name time dimension. if None then don't look up for time (assume it is without time).
x: str
The name x dimension.
y: str
The name of the y dimension.
breathingRate:
The breathing rate used. The default is man at Rest.
parameters: kwargs
Additional parameters that are needed for the calculations.
Returns
Returns
A thresholdGeoDataFrame with the columns:
time | injury name | total polygon | diff polygon | addtional fields
| | the total area | a differance from the level above. | if necessary.
Source code in hera/riskassessment/agents/effects/Injury.py
calculateToxicLoads(concentrationField, time='datetime', breathingRate=10 * ureg.L / ureg.min, field=None)
¶
Calculates the toxic loads of the concetration field.
Paramters
concentrationField : pandas or xarray.
The concentrations to calculate.
If xarray, then we assume that it is a 2D map with an additional 'time' coordinate.
If pandas, then we assume that it is a 'time' in the index and each other column is a point to calculate.
time : str
The name of the time column (or the name of the index column if it is pandas).
breathingRate: unum [L/min].
The breathing rate used. The default is man at Rest is 10L/min.
field : str
If xarray, the name of the field to use.
ignored if pandas
Source code in hera/riskassessment/agents/effects/Injury.py
calculatePointWiseFractionInjured(timeConcentration, time='datetime', breathingRate=10 * ureg.L / ureg.min, field=None)
¶
Calculates the fraction of injury over time in each point.
Can be used with pandas.DataFrame or xarray.Dataset [not implemented yet].
Parameters
Parameters
timeConcentration : pandas.DataFrame, or xarray.DataFrame.
Holds the concentration in time.
If xarray, also has a 'time' coordinate that will be calculated. [not implemented yet]
If DataFrame:
Each point is represeneted by a column, and the time is an index (with the name 'datetime').
So the structure of the input is :
P1 P2 P3
time
00:00 0 0 0
00:01 0.1 0.1 0.01
00:02 0.4 0.1 0.01
00:05 0.5 0.1 0.01
time : str The name of the time column (or the name of the index).
breathingRate : unum, L/min The breathing rate of the population.
parameters: kwargs. Additional parameter to the calculator (for example ten-berge coefficient).
selection parameters (xarray only):
sel - select according to the coordinates (see sel funcion of the xarray).
isel - select according to the coordinate index (see isel function of the xarray).
Source code in hera/riskassessment/agents/effects/Injury.py
calculateThresholdPolygon(data, time)
¶
Calculates the diff of the polygon based on the toxic load.
Source code in hera/riskassessment/agents/effects/Injury.py
toJSON()
¶
Serialize the injury to a JSON-compatible dictionary.
Source code in hera/riskassessment/agents/effects/Injury.py
InjuryLognormal10
¶
Bases: Injury
Injury using base-10 lognormal dose-response levels.
Source code in hera/riskassessment/agents/effects/Injury.py
InjuryThreshold
¶
Bases: Injury
Injury using threshold-based levels.
Source code in hera/riskassessment/agents/effects/Injury.py
InjuryExponential
¶
Bases: Injury
Injury using exponential dose-response levels.