- Notifications
You must be signed in to change notification settings - Fork0
python wrapper for opensha using py4j
License
NotificationsYou must be signed in to change notification settings
GNS-Science/opensha-py
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
README.md
A python bridge for opensha based onpy4j.org
Taking the example fromhttps://github.com/opensha/opensha-core/blob/master/src/org/opensha/sha/examples/HazardCurveCalcExample.javaand wrapping it with a py4j gateway.
Now, we can do this in python...
#!pythonfrompy4j.java_gatewayimportJavaGatewaygateway=JavaGateway()hazard_calc_app=gateway.entry_pointprint('HazardCurve calculation with default timespan = 30 years')hazard_calc_app.execute(34.2,-118.344)print('HazardCurve calculation with timespan = 50 years')hazard_calc_app.setTimeSpan(50)hazard_calc_app.execute(34.2,-118.344)
prerequisites:
- python3
- py4j
Note the opensha-py project is cloned into a folder containing the main opensha repos - seehttps://github.com/opensha/opensha-commons/blob/master/README.md)
The class path includes:
- the 'fat' opensha Jar file
- the py4j Jar
- opensha-py/src/java
export OPENSHA_PY_CLASSPATH=opensha-core/build/libs/opensha-core-all.jar:opensha-py/share/py4j/py4j0.10.9.jar:opensha-py/src/java:.javac -cp$OPENSHA_PY_CLASSPATH opensha-py/src/java/org/opensha/py/HazardCurveCalcGateway.java
java -cp$OPENSHA_PY_CLASSPATH org.opensha.py.HazardCurveCalcGateway
python opensha-py/src/test_gateway.py
About
python wrapper for opensha using py4j
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published