Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The consequence script does not work anymore #7162

Open
micheles opened this issue Sep 8, 2021 · 2 comments
Open

The consequence script does not work anymore #7162

micheles opened this issue Sep 8, 2021 · 2 comments
Assignees
Milestone

Comments

@micheles
Copy link
Contributor

micheles commented Sep 8, 2021

The script in oq-risk-tests by @raoanirudh does not work with engine 3.12+ for several reasons (changed sap, changed the datastore, moved modules around). A good idea would be to integrate it in the engine since now the event based damage calculator is a lot more powerful that it was in the past. This is a lot of work.

@micheles micheles added this to the Engine 3.13.0 milestone Sep 8, 2021
@micheles micheles modified the milestones: Engine 3.13.0, Engine 3.14.0 Jan 19, 2022
@micheles micheles modified the milestones: Engine 3.14.0, Engine 3.15.0 Apr 14, 2022
@micheles micheles modified the milestones: Engine 3.15.0, Engine 3.16.0 Sep 6, 2022
@micheles micheles modified the milestones: Engine 3.16.0, Engine 3.17.0 Jan 24, 2023
@micheles micheles modified the milestones: Engine 3.17.0, Engine 3.18.0 Jul 5, 2023
@ptormene ptormene self-assigned this Jul 14, 2023
@raoanirudh
Copy link
Member

For a generic and flexible consequence module, we would need to handle the following things cleanly and consistently:

  • Consequence name: What is the consequence called? Should we support a limited set of pre-defined consequence names or permit the user to define more? Where’s the best place to specify the name?
    Currently six consequence names are supported (loss, losses, collapsed, injured, fatalities, homeless) and these are hardcoded in risklib/scientific.py. In demos/risk/ScenarioDamage/consequences.csv, the consequence being calculated is losses.
  • Exposure tag(s): The field(s) from the exposure file that will be associated with the consequence function, akin to the taxonomy field used for the taxonomy mapping for fragility and vulnerability.
    In demos/risk/ScenarioDamage/consequences.csv, the exposure field associated with the consequence functions is taxonomy.
    This link is also currently explicitly declared in the job file demos/risk/ScenarioDamage/job_risk.ini
[consequence]
consequence_file = {'taxonomy': 'consequences.csv'}
  • Consequence ratios: The ratios that will get multiplied by the damage state probabilities, one set of ratios for each consequence function.
    The consequence ratios are currently provided by the user in the consequence CSV file, eg. demos/risk/ScenarioDamage/consequences.csv.
    The total number and names of the damage states in the consequences CSV file should match the number of limit states defined in the fragility model NRML file demos/risk/ScenarioDamage/structural_fragility_model.xml.
  • Damage type: Should the consequence ratios be multiplied by the structural damage state probabilities, nonstructural damage state probabilities, or contents damage state probabilities?
    This is currently controlled by the loss_type field in the consequences CSV file. In demos/risk/ScenarioDamage/consequences.csv the user indicates that the structural damage state probabilities are to be used.
  • Consequence multiplier: In most cases, this is a field in the exposure (eg. structural value, number of buildings, or number of occupants) that should be multiplied to the sumprod of the consequence ratios and damage state probabilities. In a few other cases, this field could be a function of one or more exposure fields (eg. debris).
    In the current implementation, this is the last term in the equations in https://github.com/gem/oq-engine/blob/engine-3.17/openquake/risklib/scientific.py#L1645-L1654
    elif consequence == 'losses':
        return dmgdist @ coeffs * asset['value-' + loss_type]
    elif consequence == 'collapsed':
        return dmgdist @ coeffs * asset['value-number']
    elif consequence == 'injured':
        return dmgdist @ coeffs * asset['occupants_night']
    elif consequence == 'fatalities':
        return dmgdist @ coeffs * asset['occupants_night']
    elif consequence == 'homeless':
        return dmgdist @ coeffs * asset['occupants_avg']
  • Aggregation of consequences: If the job file includes aggregate_by = .. the engine must perform the usual aggregation by tag(s) for each consequence, similar to what's done by the scenario risk and event based risk calculators for losses and the scenario damage and event based damage calculators for damage results.

@nicolepaul
Copy link
Contributor

Please note that the homeless calculations should be using residents (and not occupants_avg or occupants_night). More background here: #8788

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants