def setUp(self): filename = os.path.join(BASE_DATA_PATH, 'completeness_test_cat.csv') parser0 = CsvCatalogueParser(filename) self.catalogue = parser0.read_file() self.config = {'algorithm': None, 'number_bootstraps': None} self.model = CumulativeMoment()
def test_complete_stepp_analysis_basic(self): ''' Basic test of the entire completeness analysis using a synthetic test catalogue with in-built completeness periods ''' parser0 = CsvCatalogueParser(INPUT_FILE_1) self.catalogue = parser0.read_file() self.config = {'magnitude_bin': 0.5, 'time_bin': 5.0, 'increment_lock': True, 'filename': None} expected_completeness_table = np.array([[1990., 4.25], [1962., 4.75], [1959., 5.25], [1906., 5.75], [1906., 6.25], [1904., 6.75], [1904., 7.25]]) self.assertTrue(np.allclose( expected_completeness_table, self.process.completeness(self.catalogue, self.config) ))
def setUp(self): """ Read the sample catalogue """ flnme = 'gardner_knopoff_test_catalogue.csv' filename = os.path.join(self.BASE_DATA_PATH, flnme) parser = CsvCatalogueParser(filename) self.cat = parser.read_file()
def setUp(self): parser0 = CsvCatalogueParser(TEST_CAT_1) self.catalogue = parser0.read_file() self.config = {'maximum_iterations': 1000, 'number_earthquakes': 100, 'number_samples': 51, 'tolerance': 0.05} self.model = KijkoNonParametricGaussian()
def setUp(self): filename = os.path.join(BASE_DATA_PATH,'completeness_test_cat.csv') parser0 = CsvCatalogueParser(filename) self.catalogue = parser0.read_file() self.config = {'algorithm': None, 'number_bootstraps': None} self.model = CumulativeMoment()
def setUp(self): filename = os.path.join(BASE_DATA_PATH,'completeness_test_cat.csv') parser0 = CsvCatalogueParser(filename) self.catalogue = parser0.read_file() self.config = {'maximum_iterations': 1000, 'number_earthquakes': 100, 'number_samples': 51, 'tolerance': 0.05} self.model = KijkoNonParametricGaussian()
def setUp(self): """ Read the sample catalogue """ flnme = 'afteran_test_catalogue.csv' filename = os.path.join(self.BASE_DATA_PATH, flnme) parser = CsvCatalogueParser(filename) self.cat = parser.read_file() self.dec = Afteran()
def setUp(self): test_data = np.genfromtxt(TEST_CAT_1, delimiter=',', skip_header=1) parser0 = CsvCatalogueParser(TEST_CAT_1) self.catalogue = parser0.read_file() self.config = {'algorithm': None, 'number_bootstraps': None} self.model = CumulativeMoment()
def setUp(self): parser0 = CsvCatalogueParser(TEST_CAT_1) self.catalogue = parser0.read_file() self.config = {'b-value': 1.0, 'sigma-b': 0.05, 'input_mmin': 5.0, 'input_mmax': None, 'input_mmax_uncertainty': None, 'tolerance': 0.001, 'maximum_iterations': 1000} self.model = KijkoSellevolBayes()
def setUp(self): filename = os.path.join(BASE_DATA_PATH,'completeness_test_cat.csv') parser0 = CsvCatalogueParser(filename) self.catalogue = parser0.read_file() self.config = {'b-value': 1.0, 'sigma-b': 0.05, 'input_mmin': 5.0, 'input_mmax': None, 'input_mmax_uncertainty': None, 'tolerance': 0.001, 'maximum_iterations': 1000} self.model = KijkoSellevolBayes()
def setUp(self): ''' Set up test class ''' parser0 = CsvCatalogueParser(TEST_CAT_1) self.catalogue = parser0.read_file() self.config = {'b-value': 1.0, 'input_mmin': 5.0, 'input_mmax': None, 'tolerance': 0.001, 'maximum_iterations': 1000} self.model = KijkoSellevolFixedb()
def setUp(self): ''' Set up test class ''' filename = os.path.join(BASE_DATA_PATH,'completeness_test_cat.csv') parser0 = CsvCatalogueParser(filename) self.catalogue = parser0.read_file() self.config = {'b-value': 1.0, 'input_mmin': 5.0, 'input_mmax': None, 'tolerance': 0.001, 'maximum_iterations': 1000} self.model = KijkoSellevolFixedb()
def test_complete_stepp_analysis_basic(self): ''' Basic test of the entire completeness analysis using a synthetic test catalogue with in-built completeness periods ''' parser0 = CsvCatalogueParser(INPUT_FILE_1) self.catalogue = parser0.read_file() self.config = { 'magnitude_bin': 0.5, 'time_bin': 5.0, 'increment_lock': True, 'filename': None } expected_completeness_table = np.array([[1990., 4.0], [1962., 4.5], [1959., 5.0], [1906., 5.5], [1906., 6.0], [1904., 6.5], [1904., 7.0]]) np.testing.assert_array_almost_equal( expected_completeness_table, self.process.completeness(self.catalogue, self.config))
# Set up paralell proc = pypar.size() # Number of processors as specified by mpirun myid = pypar.rank() # Id of of this process (myid in [0, proc-1]) node = pypar.get_processor_name( ) # Host name on which current process is running print 'I am proc %d of %d on node %s' % (myid, proc, node) t0 = pypar.time() config_params = params_from_shp( domains_shp, trt_ignore=['Interface', 'Active', 'Oceanic', 'Intraslab']) for config in config_params: print config #sys.exit() # Read and clean the catalogue parser = CsvCatalogueParser(ifile) catalogue = parser.read_file(start_year=1900, end_year=2016) # How many events in the catalogue? print "The catalogue contains %g events" % catalogue.get_number_events() neq = len(catalogue.data['magnitude']) print "The catalogue contains %g events" % neq # What is the geographical extent of the catalogue? bbox = catalogue.get_bounding_box() print "Catalogue ranges from %.4f E to %.4f E Longitude and %.4f N to %.4f N Latitude\n" % bbox catalogue.sort_catalogue_chronologically() index = np.logical_and(catalogue.data["magnitude"] > 1.5, catalogue.data["depth"] >= 0.0) #index = np.logical_and(catalogue.data["magnitude"] > 1.5, catalogue.data["magnitude"] < 4.0) catalogue.purge_catalogue(index) catalogue.get_number_events() # Copying the catalogue and saving it under a new name "catalogue_clean"
np.arange(map_config['min_lon'], map_config['max_lon'], 5)) plt.colorbar(label='log10(Smoothed rate per cell)') plt.legend() figname = smoother_filename[:-4] + '_smoothed_rates_map.png' plt.savefig(figname) # Set up paralell proc = pypar.size() # Number of processors as specified by mpirun myid = pypar.rank() # Id of of this process (myid in [0, proc-1]) node = pypar.get_processor_name( ) # Host name on which current process is running print 'I am proc %d of %d on node %s' % (myid, proc, node) t0 = pypar.time() parser = CsvCatalogueParser(catalogue_filename) # From .csv to hmtk # Read and process the catalogue content in a variable called "catalogue" catalogue = parser.read_file(start_year=1965, end_year=2016) # How many events in the catalogue? print "The catalogue contains %g events" % catalogue.get_number_events() # What is the geographical extent of the catalogue? bbox = catalogue.get_bounding_box() print "Catalogue ranges from %.4f E to %.4f E Longitude and %.4f N to %.4f N Latitude\n" % bbox catalogue.sort_catalogue_chronologically() catalogue.data['magnitude'] index = catalogue.data['magnitude'] > 1.5
from openquake.hazardlib.geo.point import Point from openquake.hazardlib.mfd import TruncatedGRMFD from openquake.hazardlib.geo.nodalplane import NodalPlane from openquake.hazardlib.pmf import PMF #from nrml.models import HypocentralDepth #nrml.models import HypocentralDepth print "Everything Imported OK!" # In[25]: bvalue = float(sys.argv[1]) print 'b value', bvalue #Importing catalogue catalogue_filename = "../../catalogue/data/AUSTCAT_V0.12_hmtk_declustered.csv" #catalogue_filename = "../../catalogue/data/AUSTCAT_V0.12_hmtk_mx_orig.csv" parser = CsvCatalogueParser(catalogue_filename) # From .csv to hmtk # Read and process the catalogue content in a variable called "catalogue" catalogue = parser.read_file(start_year=1965, end_year=2010) # How many events in the catalogue? print "The catalogue contains %g events" % catalogue.get_number_events() # What is the geographical extent of the catalogue? bbox = catalogue.get_bounding_box() print "Catalogue ranges from %.4f E to %.4f E Longitude and %.4f N to %.4f N Latitude\n" % bbox # In[26]: catalogue.sort_catalogue_chronologically() catalogue.data['magnitude']
from openquake.hazardlib.mfd import TruncatedGRMFD from openquake.hazardlib.geo.nodalplane import NodalPlane from openquake.hazardlib.pmf import PMF #from nrml.models import HypocentralDepth #nrml.models import HypocentralDepth print "Everything Imported OK!" bvalue = float(sys.argv[1]) catalogue_filename = sys.argv[2] print 'b value', bvalue #Importing catalogue #catalogue_filename = "../../catalogue/data/AUSTCAT_V0.12_hmtk_declustered.csv" #catalogue_filename = "../../catalogue/data/AUSTCAT_V0.12_hmtk_mx_orig.csv" parser = CsvCatalogueParser(catalogue_filename) # Read and process the catalogue content in a variable called "catalogue" catalogue = parser.read_file(start_year=1788, end_year=2010) # How many events in the catalogue? print "The catalogue contains %g events" % catalogue.get_number_events() # What is the geographical extent of the catalogue? bbox = catalogue.get_bounding_box() print "Catalogue ranges from %.4f E to %.4f E Longitude and %.4f N to %.4f N Latitude\n" % bbox # In[26]: catalogue.sort_catalogue_chronologically()
from hmtk.seismicity.smoothing.kernels.isotropic_gaussian import IsotropicGaussian #from hmtk.parsers.catalogue.csv_catalogue_parser import CsvCatalogueWriter import helmstetter_werner_2012 as h_w # To build source model from hmtk.sources.source_model import mtkSourceModel from hmtk.sources.point_source import mtkPointSource from openquake.hazardlib.geo.point import Point from openquake.hazardlib.mfd import TruncatedGRMFD from openquake.hazardlib.geo.nodalplane import NodalPlane from openquake.hazardlib.pmf import PMF print "Everything Imported OK!" ifile = "../../catalogue/data/AUSTCAT_V0.12_hmtk_declustered.csv" parser = CsvCatalogueParser(ifile) catalogue = parser.read_file(start_year=1837, end_year=2010) # How many events in the catalogue? print "The catalogue contains %g events" % catalogue.get_number_events() neq = len(catalogue.data['magnitude']) print "The catalogue contains %g events" % neq # What is the geographical extent of the catalogue? bbox = catalogue.get_bounding_box() print "Catalogue ranges from %.4f E to %.4f E Longitude and %.4f N to %.4f N Latitude\n" % bbox catalogue.sort_catalogue_chronologically() index = np.logical_and(catalogue.data["magnitude"] > 1.5, catalogue.data["depth"] >= 0.0) catalogue.purge_catalogue(index) catalogue.get_number_events()