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

Adding with_betw_ratio in Aristotle mode #10127

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 43 additions & 31 deletions openquake/calculators/event_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
nofilter, getdefault, get_distances, SourceFilter)
from openquake.hazardlib.calc.gmf import GmfComputer
from openquake.hazardlib.calc.conditioned_gmfs import ConditionedGmfComputer
from openquake.hazardlib import logictree, InvalidFile
from openquake.hazardlib import valid, logictree, InvalidFile
from openquake.hazardlib.calc.stochastic import get_rup_array, rupture_dt
from openquake.hazardlib.source.rupture import (
RuptureProxy, EBRupture, get_ruptures)
Expand Down Expand Up @@ -428,6 +428,46 @@ def compute_avg_gmf(gmf_df, weights, min_iml):
return dic


def read_gsim_lt(oq):
# in aristotle mode the gsim_lt is read from the exposure.hdf5 file
gsim_lt = readinput.get_gsim_lt(oq)
if oq.aristotle:
if not oq.mosaic_model:
if oq.rupture_dict:
lon, lat = [oq.rupture_dict['lon'], oq.rupture_dict['lat']]
elif oq.rupture_xml:
hypo = readinput.get_rupture(oq).hypocenter
lon, lat = [hypo.x, hypo.y]
mosaic_models = get_close_mosaic_models(lon, lat, 5)
# NOTE: using the first mosaic model
oq.mosaic_model = mosaic_models[0]
if len(mosaic_models) > 1:
logging.info('Using the "%s" model' % oq.mosaic_model)
[expo_hdf5] = oq.inputs['exposure']
if oq.mosaic_model == '???':
raise ValueError(
'(%(lon)s, %(lat)s) is not covered by the mosaic!' %
oq.rupture_dict)
if oq.gsim != '[FromFile]':
raise ValueError(
'In Aristotle mode the gsim can not be specified in'
' the job.ini: %s' % oq.gsim)
if oq.tectonic_region_type == '*':
raise ValueError(
'The tectonic_region_type parameter must be specified')
gsim_lt = logictree.GsimLogicTree.from_hdf5(
expo_hdf5, oq.mosaic_model,
oq.tectonic_region_type.encode('utf8'))
# add with_betw_ratio when only the total stddev is defined
betw = {'with_betw_ratio': 1.7}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should try to avoid the hardcoding of the value for this parameter, especially because the ratio might be different for different tectonic region types. Can we surface this through the interface in some way so that the engine doesn't make an implicit decision on behalf of the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already done, since in the job.ini file it is possible to specify the parameter with_betw_ratio to any value (see #10128). The value 1.7 was chosen for consistency with GEESE. However, we do not have a WebUI interface to change the parameter. If you want that, I guess for the advanced interface i.e. for GEM people and not for Aristotle users, you should open a ticket.

for gsims in gsim_lt.values.values():
for g, gsim in enumerate(gsims):
if len(gsim.DEFINED_FOR_STANDARD_DEVIATION_TYPES) == 1:
gsims[g] = valid.modified_gsim(
gsim, add_between_within_stds=betw)
return gsim_lt


@base.calculators.add('event_based', 'scenario', 'ucerf_hazard')
class EventBasedCalculator(base.HazardCalculator):
"""
Expand Down Expand Up @@ -590,36 +630,8 @@ def agg_dicts(self, acc, result):

def _read_scenario_ruptures(self):
oq = self.oqparam
gsim_lt = readinput.get_gsim_lt(oq)
if oq.aristotle:
# the gsim_lt is read from the exposure.hdf5 file
if not oq.mosaic_model:
if oq.rupture_dict:
lon, lat = [oq.rupture_dict['lon'], oq.rupture_dict['lat']]
elif oq.rupture_xml:
hypo = readinput.get_rupture(oq).hypocenter
lon, lat = [hypo.x, hypo.y]
mosaic_models = get_close_mosaic_models(lon, lat, 5)
# NOTE: using the first mosaic model
oq.mosaic_model = mosaic_models[0]
if len(mosaic_models) > 1:
logging.info('Using the "%s" model' % oq.mosaic_model)
[expo_hdf5] = oq.inputs['exposure']
if oq.mosaic_model == '???':
raise ValueError(
'(%(lon)s, %(lat)s) is not covered by the mosaic!' %
oq.rupture_dict)
if oq.gsim != '[FromFile]':
raise ValueError(
'In Aristotle mode the gsim can not be specified in'
' the job.ini: %s' % oq.gsim)
if oq.tectonic_region_type == '*':
raise ValueError(
'The tectonic_region_type parameter must be specified')
gsim_lt = logictree.GsimLogicTree.from_hdf5(
expo_hdf5, oq.mosaic_model,
oq.tectonic_region_type.encode('utf8'))
elif (str(gsim_lt.branches[0].gsim) == '[FromFile]'
gsim_lt = read_gsim_lt(oq)
if (str(gsim_lt.branches[0].gsim) == '[FromFile]'
and 'gmfs' not in oq.inputs):
raise InvalidFile('%s: missing gsim or gsim_logic_tree_file' %
oq.inputs['job_ini'])
Expand Down
Loading