|
| 1 | +#!/usr/bin/env python |
| 2 | +""" |
| 3 | +Copyright 2010-2020 University Of Southern California |
| 4 | +
|
| 5 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +you may not use this file except in compliance with the License. |
| 7 | +You may obtain a copy of the License at |
| 8 | +
|
| 9 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +
|
| 11 | +Unless required by applicable law or agreed to in writing, software |
| 12 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +See the License for the specific language governing permissions and |
| 15 | +limitations under the License. |
| 16 | +
|
| 17 | +Define the configuration parameters for the GP rupture generator |
| 18 | +""" |
| 19 | +from __future__ import division, print_function |
| 20 | + |
| 21 | +# Import Python modules |
| 22 | +import os |
| 23 | +import sys |
| 24 | +import random |
| 25 | + |
| 26 | +# Import Broadband modules |
| 27 | +import bband_utils |
| 28 | + |
| 29 | +def calculate_rvfac(mean_rvfac, range_rvfac, seed, count=0): |
| 30 | + """ |
| 31 | + This function calculates a random rvfac value based on the mean |
| 32 | + and range values, plus a seed to generate a random number |
| 33 | + """ |
| 34 | + random.seed(seed) |
| 35 | + while count > 0: |
| 36 | + count = count - 1 |
| 37 | + random.seed(int(random.random() * 100000000)) |
| 38 | + rvfac = mean_rvfac + range_rvfac * ((random.random() * 2) - 1) |
| 39 | + return rvfac |
| 40 | + |
| 41 | +class GenslipCfg(object): |
| 42 | + """ |
| 43 | + Define the configuration parameters for the GP rupture generator |
| 44 | + """ |
| 45 | + |
| 46 | + def __init__(self, a_srcfiles): |
| 47 | + """ |
| 48 | + Sets basic class parameters, then parses a_srcname for more information |
| 49 | + """ |
| 50 | + |
| 51 | + # User defined parms |
| 52 | + self.SLIP_SIGMA = 0.75 |
| 53 | + # This is now the default inside genslip-3.3, so don't need to use it |
| 54 | + # self.RAND_RAKE_RANGE = 60 |
| 55 | + |
| 56 | + self.RTDEP = 6.5 |
| 57 | + self.RTDEP_RANGE = 1.5 |
| 58 | + |
| 59 | + # mod Kevin 2/23/22, temporary, conversation with RWG |
| 60 | + self.MEAN_RVFAC = 0.75 |
| 61 | +# self.MEAN_RVFAC = 0.8 |
| 62 | + self.RANGE_RVFAC = 0.05 |
| 63 | + self.SHAL_VRUP = 0.6 |
| 64 | + |
| 65 | + # Default RANGE_FWIDTH_FRAC value (randomization disabled) |
| 66 | + self.RANGE_FWIDTH_FRAC = 0.0 |
| 67 | + |
| 68 | + # Default RISETIME_COEF set for western US simulations, |
| 69 | + # override in velocity model config file. This parameter used |
| 70 | + # to be set to 1.6, but was modified by RWG in November 2013 |
| 71 | + # when the Rupture Generator was updated to version 3.3. The |
| 72 | + # value was reset to 1.6 for Genslip 5.0.1 |
| 73 | +# self.RISETIME_COEF = 1.6 |
| 74 | + # mod Kevin 2/23/22, temporary, conversation with RWG |
| 75 | + self.RISETIME_COEF = 2.4 |
| 76 | + |
| 77 | + # self.EXTRA_RTFAC = 0.0 |
| 78 | + self.RISETIME_FAC = 2 |
| 79 | + self.RT_SCALEFAC = 1 |
| 80 | + self.RT_RAND = 0 |
| 81 | + |
| 82 | + # As in genslip-3.3, we are using 'Mliu' stype, which is the default |
| 83 | + # self.STYPE = "ucsb" |
| 84 | + |
| 85 | + # Extra parameters in genslip-3.3, updated for genslip-5.0.1 |
| 86 | + self.SLIP_WATER_LEVEL = -1 |
| 87 | + self.DEEP_RISETIMEDEP = 17.5 |
| 88 | + self.DEEP_RISETIMEDEP_RANGE = 2.5 |
| 89 | + self.DEEP_RISETIME_FAC = 2.0 |
| 90 | + |
| 91 | + # Read src files |
| 92 | + self.CFGDICT = [] |
| 93 | + self.num_srcfiles = len(a_srcfiles) |
| 94 | + for a_srcfile in a_srcfiles: |
| 95 | + self.CFGDICT.append(bband_utils.parse_src_file(a_srcfile)) |
| 96 | + |
| 97 | +if __name__ == "__main__": |
| 98 | + ME = GenslipCfg(sys.argv[1:]) |
| 99 | + print("Created Test Config Class: %s" % os.path.basename(sys.argv[0])) |
0 commit comments