Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
614 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name = "shakelab" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# ============================================================================ | ||
# | ||
# Copyright (C) 2019 Valerio Poggi. | ||
# This file is part of ShakeLab. | ||
# | ||
# ShakeLab is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, | ||
# or (at your option) any later version. | ||
# | ||
# ShakeLab is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# with this download. If not, see <http://www.gnu.org/licenses/> | ||
# | ||
# ============================================================================ | ||
""" | ||
""" | ||
|
||
import numpy as _np | ||
from scipy.constants import g | ||
|
||
from quakelab.modeling.gmpe.base import GMPE | ||
|
||
class Atkinson2015(GMPE): | ||
""" | ||
Reference pubblication: | ||
Atkinson, G. A. (2015) Ground-Motion Prediction Equation for | ||
Small-to-Moderate Events at Short Hypocentral Distances, | ||
with Application to Induced-Seismicity Hazards. | ||
Bulletin of the Seismological Society of America. 105(2) | ||
Distance: hypocentral | ||
""" | ||
|
||
COEFF_FILE = 'atkinson_2015.json' | ||
|
||
def __init__(self): | ||
super().__init__(self.COEFF_FILE) | ||
|
||
def ground_motion(self, imt, mag, dist): | ||
|
||
# Extract coefficients for the give intensity measure type | ||
C = self.get_coefficients(imt) | ||
|
||
# Compute mean | ||
heff = _np.max([1., 10.**(-1.72+0.43*mag)]) | ||
mean = C['c0'] + C['c1']*mag + C['c2']*(mag**2.) | ||
mean += C['c3']*_np.log10(_np.sqrt(dist**2. + heff**2.)) | ||
|
||
# Compute standard deviation | ||
stdv = C['phi'] | ||
|
||
# Convert to natural log | ||
mean *= _np.log(10.) | ||
stdv *= _np.log(10.) | ||
|
||
if not imt == 'PGV': | ||
# Convert from cm/s2 to g | ||
mean -= _np.log(100.*g) | ||
else: | ||
# Convert from cm/s to m/s | ||
mean -= _np.log(100.) | ||
|
||
return (mean, stdv) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# ============================================================================ | ||
# | ||
# Copyright (C) 2019 Valerio Poggi. | ||
# This file is part of ShakeLab. | ||
# | ||
# ShakeLab is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, | ||
# or (at your option) any later version. | ||
# | ||
# ShakeLab is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# with this download. If not, see <http://www.gnu.org/licenses/> | ||
# | ||
# ============================================================================ | ||
""" | ||
""" | ||
|
||
import abc as _abc | ||
import os as _os | ||
import json as _json | ||
|
||
class GMPE(metaclass=_abc.ABCMeta): | ||
""" | ||
Base class for ground motion prediction equation models (GMPEs). | ||
""" | ||
|
||
def __init__(self, json_file, version='default'): | ||
self.import_coeff_from_json(json_file, version) | ||
|
||
def import_coeff_from_json(self, json_file, version='default'): | ||
""" | ||
Loads the coefficient from a separate file in json format. | ||
File has to be stored in the same directory of the GMPE class. | ||
""" | ||
full_path = _os.path.dirname(__file__) | ||
path_file = _os.path.join(full_path, 'data', json_file) | ||
|
||
self.coeff = {} | ||
with open(path_file) as jf: | ||
data = _json.load(jf)['coefficients'][version] | ||
self.keys = data['keys'] | ||
for kp in data['type']: | ||
self.coeff[kp] = [float(c) for c in data['type'][kp]] | ||
|
||
def get_coefficients(self, imt): | ||
""" | ||
Extract coefficients corresponding to a given intensity | ||
measure type. | ||
""" | ||
if imt in self.coeff: | ||
return dict(zip(self.keys, self.coeff[imt])) | ||
else: | ||
print('Error: Not a valid intensity measure type') | ||
|
||
@_abc.abstractmethod | ||
def ground_motion(self, imt, magnitude, distance): | ||
""" | ||
""" | ||
pass | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{"coefficients" : | ||
{"default" : | ||
{"keys" : ["c0", "c1", "c2", "c3", "phi", "tau", "sigma"], | ||
"type" : { | ||
"PGV" : ["-4.198", "1.818", "-0.1009", "-1.721", "0.28", "0.18", "0.33"], | ||
"PGA" : ["-2.427", "1.877", "-0.1214", "-1.806", "0.29", "0.24", "0.37"] | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.