Create Earthquakes
Contents
Create Earthquakes#
from pyincore import HazardService, IncoreClient
import json
client = IncoreClient()
Connection successful to IN-CORE services. pyIncore version detected: 0.9.4
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": "61003eb41f652f176aeb5ad2",
"name": "Memphis EQ Model",
"description": "Memphis model based hazard",
"date": "2021-07-27T17:13:23+0000",
"creator": "mondrejc",
"spaces": [
"mondrejc"
],
"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",
"rasterDataset": {
"hazardType": "deterministic",
"datasetId": "61003eb3d3c92a78c89d759b",
"demandType": "PGA",
"demandUnits": "g",
"period": 0.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"
}
}
}
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": "61003eb6720d7a6076acd363",
"name": "Memphis Deterministic EQ",
"description": "Memphis dataset based deterministic hazard",
"date": "2021-07-27T17:13:25+0000",
"creator": "mondrejc",
"spaces": [
"mondrejc"
],
"hazardDatasets": [
{
"hazardType": "deterministic",
"datasetId": "61003eb560b3f412430223fe",
"demandType": "SA",
"demandUnits": "g",
"period": 0.2,
"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": "61003eb6544e944c3cee1d4d",
"demandType": "PGA",
"demandUnits": "g",
"period": 0.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"
}
}
]
}
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": "42.3677, -89.9087"
},
{
"demands": ["PGA"],
"units": ["g"],
"loc": "42.3667, -89.9187"
},
]
eq_dataset_vals = hazardsvc.post_earthquake_hazard_values(eq_dataset_id, points)
print(eq_dataset_vals)
[{'hazardValues': [0.0], 'demands': ['PGA'], 'units': ['g'], 'loc': '42.3677, -89.9087'}, {'hazardValues': [0.0], 'demands': ['PGA'], 'units': ['g'], 'loc': '42.3667, -89.9187'}]