Create Earthquakes#
from pyincore import HazardService, IncoreClient
import json
client = IncoreClient()
Connection successful to IN-CORE services. pyIncore version detected: 1.15.1
hazardsvc = HazardService(client)
Create Model Based Earthquake#
Input: Json representing a model based earthquake.
Attenuation Models supported: AbrahamsonSilvaKamai2014, AtkinsonBoore1995, CampbellBozorgnia2014, ChiouYoungs2014,
and Toro1997
with open("files/eq-model.json", 'r') as file:
eq_model_json = file.read()
print(json.dumps(json.loads(eq_model_json), indent=4))
{
"name": "Memphis EQ Model",
"description": "Memphis model based hazard",
"eqType": "model",
"attenuations": {
"AtkinsonBoore1995": "1.0"
},
"eqParameters": {
"srcLatitude": "35.927",
"srcLongitude": "-89.919",
"magnitude": "7.9",
"depth": "10.0"
},
"visualizationParameters": {
"demandType": "PGA",
"demandUnits": "g",
"minX": "-90.3099",
"minY": "34.9942",
"maxX": "-89.6231",
"maxY": "35.4129",
"numPoints": "1025",
"amplifyHazard": "true"
}
}
model_response = hazardsvc.create_earthquake(eq_model_json)
print(json.dumps(model_response, indent=4))
{
"eqType": "model",
"id": "65ccf6f39acc0e6ae7e4aa64",
"name": "Memphis EQ Model",
"description": "Memphis model based hazard",
"date": "2024-02-14T17:22:59+0000",
"creator": "cwang138",
"owner": "cwang138",
"spaces": [
"cwang138"
],
"attenuations": {
"AtkinsonBoore1995": 1.0
},
"eqParameters": {
"srcLatitude": 35.927,
"srcLongitude": -89.919,
"magnitude": 7.9,
"coseismicRuptureDepth": 0.0,
"dipAngle": 0.0,
"azimuthAngle": 0.0,
"rakeAngle": 0.0,
"seismogenicDepth": 0.0,
"depth": 10.0,
"depth2p5KmPerSecShearWaveVelocity": 2.0,
"shearWaveDepth1p0": 0.0,
"faultTypeMap": {},
"region": "Global"
},
"visualizationParameters": {
"demandType": "PGA",
"demandUnits": "g",
"minX": -90.3099,
"minY": 34.9942,
"maxX": -89.6231,
"maxY": 35.4129,
"numPoints": 1025,
"amplifyHazard": true
},
"defaultSiteClass": "D",
"siteAmplification": "NEHRP",
"hazardDatasets": [
{
"hazardType": "deterministic",
"datasetId": "65ccf6f30fd17b2cf8511ff7",
"demandType": "PGA",
"demandUnits": "g",
"period": 0.0,
"threshold": null,
"eqParameters": {
"srcLatitude": 35.927,
"srcLongitude": -89.919,
"magnitude": 7.9,
"coseismicRuptureDepth": 0.0,
"dipAngle": 0.0,
"azimuthAngle": 0.0,
"rakeAngle": 0.0,
"seismogenicDepth": 0.0,
"depth": 10.0,
"depth2p5KmPerSecShearWaveVelocity": 2.0,
"shearWaveDepth1p0": 0.0,
"faultTypeMap": {},
"region": "Global"
}
}
]
}
Create Dataset(s) Based Earthquake (Probabilistic & Deterministic)#
Inputs: Json representing a the dataset based earthquake; Each available dataset in tif format
with open("files/eq-dataset.json", 'r') as file:
eq_dataset_json = file.read()
print(json.dumps(json.loads(eq_dataset_json), indent=4))
{
"name": "Memphis Deterministic EQ",
"description": "Memphis dataset based deterministic hazard",
"eqType": "dataset",
"hazardDatasets": [
{
"hazardType": "deterministic",
"demandType": "SA",
"demandUnits": "g",
"period": "0.2",
"eqParameters": {
"srcLatitude": "35.927",
"srcLongitude": "-89.919",
"magnitude": "7.9",
"depth": "10.0"
}
},
{
"hazardType": "deterministic",
"demandType": "PGA",
"demandUnits": "g",
"period": "0.0",
"eqParameters": {
"srcLatitude": "35.927",
"srcLongitude": "-89.919",
"magnitude": "7.9",
"depth": "10.0"
}
}
]
}
file_paths = ["files/eq-dataset-SA.tif", "files/eq-dataset-PGA.tif"]
# order should be same as the hazardDatasets from above json
# eq-dataset1.tif represents 0.2 SA & eq-dataset2.tif represents PGA
dataset_response = hazardsvc.create_earthquake(eq_dataset_json, file_paths)
print(json.dumps(dataset_response, indent=4))
{
"eqType": "dataset",
"id": "65ccf6f4d61b8f0bb597b151",
"name": "Memphis Deterministic EQ",
"description": "Memphis dataset based deterministic hazard",
"date": "2024-02-14T17:22:59+0000",
"creator": "cwang138",
"owner": "cwang138",
"spaces": [
"cwang138"
],
"hazardDatasets": [
{
"hazardType": "deterministic",
"datasetId": "65ccf6f35711307c3ca38d97",
"demandType": "SA",
"demandUnits": "g",
"period": 0.2,
"threshold": null,
"eqParameters": {
"srcLatitude": 35.927,
"srcLongitude": -89.919,
"magnitude": 7.9,
"coseismicRuptureDepth": 0.0,
"dipAngle": 0.0,
"azimuthAngle": 0.0,
"rakeAngle": 0.0,
"seismogenicDepth": 0.0,
"depth": 10.0,
"depth2p5KmPerSecShearWaveVelocity": 2.0,
"shearWaveDepth1p0": 0.0,
"faultTypeMap": {},
"region": "Global"
}
},
{
"hazardType": "deterministic",
"datasetId": "65ccf6f485da222307906276",
"demandType": "PGA",
"demandUnits": "g",
"period": 0.0,
"threshold": null,
"eqParameters": {
"srcLatitude": 35.927,
"srcLongitude": -89.919,
"magnitude": 7.9,
"coseismicRuptureDepth": 0.0,
"dipAngle": 0.0,
"azimuthAngle": 0.0,
"rakeAngle": 0.0,
"seismogenicDepth": 0.0,
"depth": 10.0,
"depth2p5KmPerSecShearWaveVelocity": 2.0,
"shearWaveDepth1p0": 0.0,
"faultTypeMap": {},
"region": "Global"
}
}
]
}
Get Earthquake Values#
eq_model_id = model_response['id']
points = [
{
"demands": ["0.2 SA"],
"units": ["g"],
"loc": "35.07899, -90.0178"
},
{
"demands": ["0.2 SA"],
"units": ["g"],
"loc": "35.027, -90.077"
},
]
eq_model_vals = hazardsvc.post_earthquake_hazard_values(eq_model_id, points)
print(eq_model_vals)
[{'hazardValues': [0.5322993805448739], 'demands': ['0.2 SA'], 'units': ['g'], 'loc': '35.07899, -90.0178'}, {'hazardValues': [0.502009539659276], 'demands': ['0.2 SA'], 'units': ['g'], 'loc': '35.027, -90.077'}]
eq_dataset_id = dataset_response['id']
points = [
{
"demands": ["PGA"],
"units": ["g"],
"loc": "35.1322, -89.9087"
},
{
"demands": ["PGA"],
"units": ["g"],
"loc": "35.1707, -89.8417"
},
]
eq_dataset_vals = hazardsvc.post_earthquake_hazard_values(eq_dataset_id, points)
print(eq_dataset_vals)
[{'hazardValues': [0.4950000047683716], 'demands': ['PGA'], 'units': ['g'], 'loc': '35.1322, -89.9087'}, {'hazardValues': [0.5059999823570251], 'demands': ['PGA'], 'units': ['g'], 'loc': '35.1707, -89.8417'}]