Comments (4)
Using a GSIM is non-obvious. First of all, it should not be instantiated directly, but through the valid.gsim function
. Secondly, contexts objects should be instantiated by using a ContextMaker instance, which has to be instantiated carefully. Thirdly, the .compute
method should not be called directly. In short, here is how to do what you want:
import numpy as np
from openquake.hazardlib import valid
from openquake.hazardlib.contexts import simple_cmaker
gsim = valid.gsim('''[NGAEastGMPE]
gmpe_table="NGAEast_PEER_EX.hdf5"''')
n = 10
mags = np.linspace(5, 7, n)
cmaker = simple_cmaker([gsim], ['PGA'], mags=['%.2f' % mag for mag in mags])
ctx = cmaker.new_ctx(n)
ctx["mag"] = mags
ctx["vs30"] = np.linspace(200, 300, n)
ctx["rrup"] = np.linspace(1, 100, n)
mean, sigma, tau, phi = cmaker.get_mean_stds([ctx])
from oq-engine.
Thank you, I adapted your example and it passed the test. Note that I didn't need to instantiate the GMM using valid.gsim
(although I can and it is what you recommend). If you don't mind explaining why using valid.gsim
is a good practice, I would appreciate that. Either way, I think this issue can be closed now.
from oq-engine.
Using valid.gsim
is a good practice because it is the official way the engine convert strings into GMPEs, so it is guaranteed to work forever, while manual instantiation changed in the past and could potentially change again in the future.
from oq-engine.
Thanks @micheles, we weren't aware of this. Good to know.
from oq-engine.
Related Issues (20)
- get_convex_hull failing when getting polygons of some mosaic sources
- AAL Statistics output for classical_risk/case_2 not exportable
- NGAEastUSGSGMPE not working outside of unit tests HOT 3
- Fixing warnings in the documentation
- when a required site parameter is not provided, OQ is running full calculation but giving NAN results HOT 2
- Raise error for missing `residents` at the beginning of the calculation
- Stations still appear to be plotted in Avg GMF
- Implementation of post-loss amplification (PLA) HOT 3
- Document `oq show delta_loss`
- Add check in job.ini for scenario calculations
- Investigations for conditioned scenarios (needed for the Aristotle project)
- individual_rlzs is not honored with --hc HOT 1
- Add an early check for mixed sources
- Think about OQ_APPLICATION_MODE
- Move checks from settings.py to a function called when the webui is started
- Think about disabling numba in same places
- Calculate consequences from multiple perils (ground shaking and sep) for each asset
- openquake Hazard run job.ini crash Memory Error!!! HOT 7
- Improve error handling
- use of region_grid_spacing in a conditioned gmf produces a key error now HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oq-engine.