Skip to content
Snippets Groups Projects
user avatar
Brandon Clayton authored
0e0c7e9c
History

Python Source Code for USGS Risk-Targeted Ground Motion Calculator

The erp-rtgm-calculator is a Python-based library for the calculation of risk-targeted ground motion values, in accordance with the American Society of Civil Engineers 7 (ASCE 7) standard (Section 21.2.1.2 of ) ASCE, 2021) and the American Association of State Highway and Transportation Officials (2023 AASHTO) Guide Specifications for Load and Resistance Factor (LRFD) Seismic Bridge Design (AASHTO, 2023).

This library serves as the source code for the updated USGS Risk-Targeted Ground Motion Calculator web service. Updated functionality includes:

  • The ability for the user to input and retrieve risk-targeted ground motions for hazard curves for multiple intensity measures (IMs) simultaneously, using the iterative procedure of Luco et al. (2007).
  • The ability to obtain risk-targeted ground motions for multiple design standards (ASCE 7 and AASHTO)

Suggested citation: Makdisi, A.J., Clayton, B.S., Luco, N., and Kortum, Z.A. (2024). erp-rtgm-calculator: Python Source Code for USGS Risk-Targeted Ground Motion Calculator, U.S. Geological Survey software release, https://doi.org/10.5066/P9A2F2B8.

Prerequisites

Installation

To install the v1.0.0 release:

pip install rtgmpy --index-url https://code.usgs.gov/api/v4/projects/7255/packages/pypi/simple

Other tagged versions can be found at https://code.usgs.gov/ghsc/erp/erp-rtgm-calculator/-/packages

For running from the command line:

See Poetry installation instructions for more information.

You can clone this repository as follows:

$ git clone https://code.usgs.gov/ghsc/erp/erp-rtgm-calculator.git

Documentation

Scientific background and code usage documentation can be found in the documentation.

Example use cases can be found in the examples directory.

Basic Usage

Running from the command line

The risk-targeted ground motion calculation can be run from the command line by specifying the location of a .csv file containing the hazard curve information for the site of interest. An example template can be found in rtgmpy/example-haz-inputs/example-hazcurve-input.csv.

$ poetry run rtgm <BuildingCode> </path/to/hazard-curve.csv> </path/to/output.json>(optional)
  • <BuildingCode> designates the construction code document that the risk-targeted ground motion calculation is being performed in accordance with, either ASCE7 or AASHTO
  • </path/to/hazard-curve.csv> is the location of the .csv input file of hazard curve data
  • </path/to/output.json> (Optional) allows for a user-defined path to the output data. Default is json-output/output.json

For example:

$ poetry run rtgm ASCE7 rtgmpy/example-haz-inputs/example-hazcurve-input.csv json-output/PortlandASCE7.json

Which writes the output file in .json format in the appropriate path json-output/PortlandASCE7.json

Running in Python

from rtgmpy import GroundMotionHazard, BuildingCodeRTGMCalc
import json

Ground motion hazard data must be provided to the calculator functions using the GroundMotionHazard module.

# Defining hazard data from a csv file - must follow the same format as the example
csv_path = 'rtgmpy//example-haz-inputs//example-hazcurve-input.csv'
haz_data = GroundMotionHazard.from_csv(csv_path)

# Can also provide a path to a json file
# json_path = 'rtgmpy//example-haz-inputs//all-IMs//SeattleWA-example.json'
# haz_data = GroundMotionHazard.from_json(json_path)

# Or directly from a python dictionary (needs to have the correct structure)
# haz_dict = {'site':{'name':'Portland OR','lat':45.5,'lon':-122.6,'Vs30':760}}
# haz_dict['hazCurves'] = {'PGA':{
#                                 'iml':[0.0023,0.0035,0.0052,0.0079,0.0118,0.0177,0.0265,0.0398,
#                                        0.0597,0.0896,0.134,0.202,0.302,0.454,0.68,1.02,1.53],
#                                 'afe':[0.764,0.609,0.462,0.329,0.22,0.137,0.0808,0.0452,0.0247,0.0135,
#                                        0.00753,0.00426,0.00244,0.00129,0.000574,0.000195,4.68e-05]
#                                 }
#                         }            
# haz_data = GroundMotionHazard.from_dict(haz_dict)
haz_data
{
   "site": {
      "name": "Portland OR",
      "lat": 45.5,
      "lon": -122.6,
      "Vs30": 760
   },
   "hazCurves": {
      "PGA": {
         "iml": [
                 0.0023,0.0035,0.0052,0.0079,0.0118,0.0177,0.0265,0.0398,
                 0.0597,0.0896,0.134,0.202,0.302,0.454,0.68,1.02,1.53
         ],
         "afe": [
                 0.764,0.609,0.462,0.329,0.22,0.137,0.0808,0.0452,0.0247,0.0135,
                 0.00753,0.00426,0.00244,0.00129,0.000574,0.000195,4.68e-05
         ]
      },
      "SA0P05": {},
      "SA0P1": {},
      "SA0P5": {},
      "SA1P0": {},
      "SA5P0": {},
      "SA10P0": {}
   }
}

The risk-targeted ground motion calculation can be performed for a given building code guideline as follows:

# Example risk-targeted ground motion calculation 
# using ASCE 7 guidelines and a random set of hazard curves
rtgm_data = BuildingCodeRTGMCalc.calc_rtgm(haz_data,bldg_code='ASCE7')
# Summary plot of results
fig,axs = rtgm_data.plotFullRiskCalc('SA1P0');

png

# Dictionary structure of output data
rtgm_data['summary']
{
   "PGA": {
      "uhgm": 0.7758484,
      "rtgm": 0.6796348,
      "riskCoeff": 0.8759892,
      "colRisk_annual": 2.0105856E-4,
      "timePeriod": 50,
      "colRisk_T": 0.010003567
   },
   "SA0P1": {
      "uhgm": 1.3793267,
      "rtgm": 1.2090442,
      "riskCoeff": 0.8765467,
      "colRisk_annual": 2.029103E-4,
      "timePeriod": 50,
      "colRisk_T": 0.0100952415
   },
   "SA0P5": {
      "uhgm": 1.6055665,
      "rtgm": 1.4041245,
      "riskCoeff": 0.87453526,
      "colRisk_annual": 2.0237298E-4,
      "timePeriod": 50,
      "colRisk_T": 0.010068641
   },
   "SA1P0": {
      "uhgm": 0.9453363,
      "rtgm": 0.8281113,
      "riskCoeff": 0.87599653,
      "colRisk_annual": 2.0219407E-4,
      "timePeriod": 50,
      "colRisk_T": 0.010059785
   },
   "SA5P0": {
      "uhgm": 0.11586628,
      "rtgm": 0.104094446,
      "riskCoeff": 0.8984015,
      "colRisk_annual": 2.0166195E-4,
      "timePeriod": 50,
      "colRisk_T": 0.010033441
   },
   "SA10P0": {
      "uhgm": 0.04372669,
      "rtgm": 0.038819008,
      "riskCoeff": 0.88776463,
      "colRisk_annual": 2.0220556E-4,
      "timePeriod": 50,
      "colRisk_T": 0.010060353
   }
}

Web Services

Local Server

Development Server

The development server will look for any changes to the code and automatically restart. To start the development server:

poetry run start

Open browser to localhost:8080

Production Server

To start the production server:

poetry run start:prod

Open browser to localhost:8080

Docker

Build Docker Locally

docker build -t rtgm-ws .

Run Docker Locally

docker run -p 8080:8080 rtgm-ws

Open browser to localhost:8080

References

American Association of State Highway and Transportation Officials (AASHTO) (2023). AASHTO Guide Specifications for LRFD Seismic Bridge Design (3rd Edition), American Association of State Highway and Transportation Officials, 295 pp.

American Society of Civil Engineers (ASCE) (2021). Minimum Design Loads and Associated Criteria for Buildings and Other Structures (ASCE 7-22). American Society of Civil Engineers, 975 pp. https://doi.org/10.1061/9780784415788

Luco, N., B.R. Ellingwood, R.O. Hamburger, J.D. Hooper, J.K. Kimball, and & C.A. Kircher (2007), "Risk-Targeted versus Current Seismic Design Maps for the Conterminous United States," Proceedings of the 2007 Structural Engineers Association of California Convention, Lake Tahoe, CA, pp. 163-175.