Commit 75390e06 authored by Graeme Weatherill's avatar Graeme Weatherill
Browse files

Bug/oq change dec2021

parent c585c5a4
Pipeline #38066 failed with stage
in 14 minutes and 10 seconds
......@@ -26,5 +26,5 @@ repos:
name: pylint
entry: pylint
language: system
args: [ --disable=E0611, -E, -j4 ]
args: [ --disable=E0611, --disable=E1101, -E, -j4 ]
types: [ python ]
......@@ -11,7 +11,7 @@ setup(
license="AGPLv3+",
extras_require={"tests": test_requirements},
install_requires=[
"openquake.engine",
"openquake.engine>=3.13.0",
"geopandas",
"pyyaml",
"Rtree",
......
......@@ -107,9 +107,7 @@ class Shakemap(object):
else:
self.caching = False
self.cache_file = None
self.rctx = None
self.dctx = None
self.sctx = None
self.ctx = None
self.synth_rupture_max_site_dist = valid.positive_float(
synthetic_rupture_max_site_distance, "Max. Synthetic Rupture Site Distance"
)
......@@ -126,7 +124,7 @@ class Shakemap(object):
cmaker = ContextMaker(
self.tectonic_region,
[gmm[1] for gmm in self.ground_motion_model],
param={"imtls": {"PGA": []}}, # param is a dummy object to mock an OQ config
oq={"imtls": {"PGA": []}}, # param is a dummy object to mock an OQ config
)
# Always calculate rupture distance regardless of whether it is needed by the GMM
if "rrup" not in cmaker.REQUIRES_DISTANCES: # pylint: disable=no-member
......@@ -144,9 +142,9 @@ class Shakemap(object):
)[0]
# For the sites and rupture context we can use the context maker to get all of the
# source, site and rupture distances
self.rctx, self.sctx, self.dctx = cmaker.make_contexts(
self.site_model.get_site_collection(), self.earthquake.rupture
)
self.ctx = cmaker.get_ctxs(
[self.earthquake.rupture], self.site_model.get_site_collection()
)[0]
def _cache_contexts(self, grp: h5py.Group):
"""
......@@ -159,10 +157,10 @@ class Shakemap(object):
for gmm in [gmm[1] for gmm in self.ground_motion_model]:
for rup_attr in gmm.REQUIRES_RUPTURE_PARAMETERS:
if rup_attr not in rup_ctxt.attrs:
rup_ctxt.attrs[rup_attr] = getattr(self.rctx, rup_attr)
rup_ctxt.attrs[rup_attr] = getattr(self.ctx, rup_attr)
for attr in gmm.REQUIRES_DISTANCES:
if attr not in list(dist_ctxt):
distance = getattr(self.dctx, attr)
distance = getattr(self.ctx, attr)
dist_dset = dist_ctxt.create_dataset(attr, distance.shape, dtype="f")
dist_dset[:] = distance
site_ctxt = ctxt.create_dataset(
......@@ -234,7 +232,7 @@ class Shakemap(object):
input_imt = imt.from_string(intensity_measure_type)
try:
mean, [stddev] = gmm.get_mean_and_stddevs(
self.sctx, self.rctx, self.dctx, input_imt, [const.StdDev.TOTAL]
self.ctx, self.ctx, self.ctx, input_imt, [const.StdDev.TOTAL]
)
except KeyError:
warnings.warn(
......
......@@ -17,11 +17,11 @@ SITE_PROPERTIES = {
"lat": np.float64, # Latitudes (in decimal degrees)
"depth": np.float64, # Site depth (in km, negative indicates above ground)
"vs30": np.float64, # Vs30 of the sites (in m/s)
"vs30measured": np.bool, # Vs30 is measured (True) or inferred (False)
"vs30measured": bool, # Vs30 is measured (True) or inferred (False)
"z1pt0": np.float64, # Depth (m) to the Vs 1.0 km/s layer
"z2pt5": np.float64, # Depth (km) to the Vs 2.5 km/s layer
"xvf": np.float64, # Distance (km) to the volcanic front
"backarc": np.bool, # Site is in the subduction backarc (True) or else
"backarc": bool, # Site is in the subduction backarc (True) or else
"region": np.int32, # Region to which the site belongs
"geology": (np.string_, 20), # Geological classification for the site
}
......
......@@ -220,9 +220,9 @@ def shakemaps_from_quakeml(
results.tectonic_region,
mean_shakemaps,
stddev_shakemaps,
shakemap.sctx,
shakemap.rctx,
shakemap.dctx,
shakemap.ctx,
shakemap.ctx,
shakemap.ctx,
)
# MMIs are not in logarithmic domain, so setting is_stddev to True
results.shakemaps["mean"][imt] = shakemap.to_geotiff(mmi, imt, is_stddev=True)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment