本文整理汇总了Python中openquake.hmtk.seismicity.catalogue.Catalogue.make_from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Catalogue.make_from_dict方法的具体用法?Python Catalogue.make_from_dict怎么用?Python Catalogue.make_from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openquake.hmtk.seismicity.catalogue.Catalogue
的用法示例。
在下文中一共展示了Catalogue.make_from_dict方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import make_from_dict [as 别名]
def setUp(self):
"""
"""
# Read initial dataset
filename = os.path.join(self.BASE_DATA_PATH,
'completeness_test_cat.csv')
test_data = np.genfromtxt(filename, delimiter=',', skip_header=1)
# Create the catalogue A
self.catalogueA = Catalogue.make_from_dict(
{'year': test_data[:,3], 'magnitude': test_data[:,17]})
# Read initial dataset
filename = os.path.join(self.BASE_DATA_PATH,
'recurrence_test_cat_B.csv')
test_data = np.genfromtxt(filename, delimiter=',', skip_header=1)
# Create the catalogue A
self.catalogueB = Catalogue.make_from_dict(
{'year': test_data[:,3], 'magnitude': test_data[:,17]})
# Read the verification table A
filename = os.path.join(self.BASE_DATA_PATH,
'recurrence_table_test_A.csv')
self.true_tableA = np.genfromtxt(filename, delimiter = ',')
# Read the verification table A
filename = os.path.join(self.BASE_DATA_PATH,
'recurrence_table_test_B.csv')
self.true_tableB = np.genfromtxt(filename, delimiter = ',')
示例2: setUp
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import make_from_dict [as 别名]
def setUp(self):
"""
This generates a minimum data-set to be used for the regression.
"""
# Test A: Generates a data set assuming b=1 and N(m=4.0)=10.0 events
self.dmag = 0.1
mext = np.arange(4.0, 7.01, 0.1)
self.mval = mext[0:-1] + self.dmag / 2.0
self.bval = 1.0
self.numobs = np.flipud(
np.diff(np.flipud(10.0 ** (-self.bval * mext + 8.0))))
# Test B: Generate a completely artificial catalogue using the
# Gutenberg-Richter distribution defined above
numobs = np.around(self.numobs)
size = int(np.sum(self.numobs))
magnitude = np.zeros(size)
lidx = 0
for mag, nobs in zip(self.mval, numobs):
uidx = int(lidx + nobs)
magnitude[lidx:uidx] = mag + 0.01
lidx = uidx
year = np.ones(size) * 1999
self.catalogue = Catalogue.make_from_dict(
{'magnitude': magnitude, 'year': year})
# Create the seismicity occurrence calculator
self.aki_ml = AkiMaxLikelihood()
示例3: test_input_checks_sets_magnitude_interval
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import make_from_dict [as 别名]
def test_input_checks_sets_magnitude_interval(self):
fake_completeness_table = 0.0
catalogue = Catalogue.make_from_dict({'year': [1900]})
config = {'magnitude_interval' : 0.1}
cmag, ctime, ref_mag, dmag, _ = rec_utils.input_checks(catalogue,
config, fake_completeness_table)
self.assertEqual(0.1, dmag)
示例4: test_input_checks_use_reference_magnitude
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import make_from_dict [as 别名]
def test_input_checks_use_reference_magnitude(self):
fake_completeness_table = 0.0
catalogue = Catalogue.make_from_dict({'year': [1900]})
config = {'reference_magnitude' : 3.0}
cmag, ctime, ref_mag, dmag, _ = rec_utils.input_checks(catalogue,
config, fake_completeness_table)
self.assertEqual(3.0, ref_mag)
示例5: test_kijko_smit_set_reference_magnitude
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import make_from_dict [as 别名]
def test_kijko_smit_set_reference_magnitude(self):
completeness_table = np.array([[1900, 1.0]])
catalogue = Catalogue.make_from_dict(
{'magnitude': np.array([5.0, 6.0]),
'year': np.array([2000, 2000])})
config = {'reference_magnitude': 0.0}
self.ks_ml.calculate(catalogue, config, completeness_table)
示例6: build_catalogue_from_file
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import make_from_dict [as 别名]
def build_catalogue_from_file(filename):
"""
Creates a "minimal" catalogue from a raw csv file
"""
raw_data = np.genfromtxt(filename, delimiter=",")
return Catalogue.make_from_dict({"eventID": raw_data[:, 0].astype(int),
"year": raw_data[:, 1].astype(int),
"dtime": raw_data[:, 2],
"longitude": raw_data[:, 3],
"latitude": raw_data[:, 4],
"magnitude": raw_data[:, 5],
"depth": raw_data[:, 6]})
示例7: test_generate_synthetic_catalogues
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import make_from_dict [as 别名]
def test_generate_synthetic_catalogues(self):
'''
Tests the openquake.hmtk.seismicity.occurence.utils function
generate_synthetic_magnitudes
'''
bvals = []
# Generate set of synthetic catalogues
for i in range(0, 100):
cat1 = rec_utils.generate_synthetic_magnitudes(4.5, 1.0, 4.0, 8.0,
1000)
bvals.append(self.occur.calculate(
Catalogue.make_from_dict(cat1))[0])
bvals = np.array(bvals)
self.assertAlmostEqual(np.mean(bvals), 1.0, 1)
示例8: test_generate_magnitudes
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import make_from_dict [as 别名]
def test_generate_magnitudes(self):
'''
Tests the openquake.hmtk.seismicity.occurence.utils function
generate_trunc_gr_magnitudes
'''
bvals = []
# Generate set of synthetic catalogues
for _ in range(0, 100):
mags = rec_utils.generate_trunc_gr_magnitudes(1.0, 4.0, 8.0, 1000)
cat = Catalogue.make_from_dict(
{'magnitude': mags,
'year': np.zeros(len(mags), dtype=int)})
bvals.append(self.occur.calculate(cat)[0])
bvals = np.array(bvals)
self.assertAlmostEqual(np.mean(bvals), 1.0, 1)
示例9: setUp
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import make_from_dict [as 别名]
def setUp(self):
"""
This generates a catalogue to be used for the regression.
"""
# Generates a data set assuming b=1
self.dmag = 0.1
mext = np.arange(4.0, 7.01, 0.1)
self.mval = mext[0:-1] + self.dmag / 2.0
self.bval = 1.0
numobs = np.flipud(np.diff(np.flipud(10.0**(-self.bval*mext+7.0))))
# Define completeness window
numobs[0:6] *= 10
numobs[6:13] *= 20
numobs[13:22] *= 50
numobs[22:] *= 100
compl = np.array([[1900, 1950, 1980, 1990], [6.34, 5.44, 4.74, 3.0]])
print(compl)
self.compl = compl.transpose()
print('completeness')
print(self.compl)
print(self.compl.shape)
numobs = np.around(numobs)
print(numobs)
magnitude = np.zeros(int(np.sum(numobs)))
year = np.zeros(int(np.sum(numobs))) * 1999
lidx = 0
for mag, nobs in zip(self.mval, numobs):
uidx = int(lidx+nobs)
magnitude[lidx:uidx] = mag + 0.01
year_low = compl[0, np.min(np.nonzero(compl[1, :] < mag)[0])]
year[lidx:uidx] = (year_low + np.random.rand(uidx-lidx) *
(2000-year_low))
print('%.2f %.0f %.0f' % (mag, np.min(year[lidx:uidx]),
np.max(year[lidx:uidx])))
lidx = uidx
self.catalogue = Catalogue.make_from_dict(
{'magnitude': magnitude, 'year': year})
self.b_ml = BMaxLikelihood()
self.config = {'Average Type': 'Weighted'}
示例10: test_input_checks_use_a_float_for_completeness
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import make_from_dict [as 别名]
def test_input_checks_use_a_float_for_completeness(self):
fake_completeness_table = 0.0
catalogue = Catalogue.make_from_dict({'year': [1900]})
config = {}
rec_utils.input_checks(catalogue, config, fake_completeness_table)
示例11: test_input_checks_simple_input
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import make_from_dict [as 别名]
def test_input_checks_simple_input(self):
completeness_table = [[1900, 2.0]]
catalogue = Catalogue.make_from_dict(
{'magnitude': [5.0, 6.0], 'year': [2000, 2000]})
config = {}
rec_utils.input_checks(catalogue, config, completeness_table)