Coding a GMPE- Using Coordinates in Calculations

64 views
Skip to first unread message

May Lim

unread,
Sep 23, 2014, 2:53:19 AM9/23/14
to openqua...@googlegroups.com
From what I understood, in file oq-hazardlib/openquake/hazardlib/gsim/base.py,

    def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):

is the method we have to implement if we wish to translate a GMPE into python code. 

However, we only have access to limited attributes (only those defined in classes SitesContext, RuptureContext, and DistancesContext). We need the azimuth in our calculation, which is not made available.
(We thought of using the coordinates for source and site to calculate azimuth directly in our method, but there doesn't seem to be a way to call the coordinates attributes directly either)

 Any advice? Thanks!

Damiano Monelli

unread,
Sep 23, 2014, 3:04:21 AM9/23/14
to openqua...@googlegroups.com
Hi,

you can extract site coordinates from the sites context object (for an example see: https://github.com/gem/oq-hazardlib/blob/master/openquake/hazardlib/gsim/si_midorikawa_1999.py#L327).
That is just call the attributes 'lons' and 'lats' from 'sites'. You can then compute the azimuth using the 'azimuth' method in the 'geodetic' module

Hope it helps,

Damiano
--
You received this message because you are subscribed to the Google Groups "OpenQuake Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openquake-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

May Lim

unread,
Sep 23, 2014, 11:10:59 PM9/23/14
to openqua...@googlegroups.com
Hi Damiano, 

Thanks for your help!
How about source coordinates? Do rup.lats and rup.lons work?

- May

Damiano Monelli

unread,
Sep 24, 2014, 10:07:20 AM9/24/14
to openqua...@googlegroups.com
Dear May,

we just added in the OpenQuake-hazard library (see pull request: https://github.com/gem/oq-hazardlib/pull/233) the possibility to
extract the rupture hypocenter longitude and latitude values as well as the rupture strike angle.

So from the 'rup' object, you can just extract 'hypo_lon', 'hypo_lat', and 'strike'.

Please note that this will be available with the OpenQuake-engine nightly-build from tomorrow.

Best,

Damiano

May Lim

unread,
Oct 31, 2014, 12:38:13 AM10/31/14
to openqua...@googlegroups.com
Hi Damiano, 

"Please note that this will be available with the OpenQuake-engine nightly-build from tomorrow."

Does this mean that we need the latest version of OQ to use 'hypo_lon' and 'hypo_lat'? We haven't updated our OQ engine source code since installation earlier this April. Would we be able to use hypo attributes still?

Thanks!

Daniele Viganò

unread,
Oct 31, 2014, 4:50:15 AM10/31/14
to openqua...@googlegroups.com
Dear May,


On Friday, October 31, 2014 5:38:13 AM UTC+1, May Lim wrote:

Does this mean that we need the latest version of OQ to use 'hypo_lon' and 'hypo_lat'? We haven't updated our OQ engine source code since installation earlier this April. Would we be able to use hypo attributes still?

no, you have to update the OQ Engine to get that feature.

If you are running OQ from git sources you need to:
  • Pull the code from each OQ repo (engine, hazardlib, commonlib, risklib) with git pull
  • Install the new DB with cd /path/to/oq-engine && sudo -u postgres ./bin/oq_create_db --db-name=openquake2 && ./bin/oq-engine --upgrade-db
If you are running OQ from Ubuntu packages please follow this link:
If you are still running version 1.0 you need to install a nightly build (see the link above).

The current nightly build contains the pre-1.2 release of the engine, so please have a look also to these links:
Regards,
Daniele
Reply all
Reply to author
Forward
0 new messages