def test_point_in_tectonic_region(self): # Basic check to ensure that a point is correctly identified as being # inside the regional polygon # Setup Model polygon = { 'long_lims': [-1.0, 1.0], 'lat_lims': [-1.0, 1.0], 'area': 1.0, 'region_type': 'XXX' } self.model = GeodeticStrain() self.model.data = { 'longitude': np.array([-1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5]), 'latitude': np.array([-1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5]), 'region': np.zeros(7, dtype='|S3'), 'area': np.zeros(7, dtype=float), 'exx': np.zeros(7, dtype=float) } self.reader = KreemerRegionalisation('a filename') self.reader.strain = self.model self.reader._point_in_tectonic_region(polygon) expected_region = [b'', b'XXX', b'XXX', b'XXX', b'XXX', b'', b''] for iloc in range(0, 7): self.assertEqual(expected_region[iloc], self.reader.strain.data['region'][iloc]) np.testing.assert_array_almost_equal( self.reader.strain.data['area'], np.array([0., 1., 1., 1., 1., 0., 0.]))
def test_continuum_seismicity(self): # Tests the function hmtk.strain.shift.Shift.continuum_seismicity - # the python implementation of the Subroutine Continuum Seismicity # from the Fortran 90 code GSRM.f90 self.strain_model = GeodeticStrain() # Define a simple strain model test_data = { 'longitude': np.zeros(3, dtype=float), 'latitude': np.zeros(3, dtype=float), 'exx': np.array([1E-9, 1E-8, 1E-7]), 'eyy': np.array([5E-10, 5E-9, 5E-8]), 'exy': np.array([2E-9, 2E-8, 2E-7]) } self.strain_model.get_secondary_strain_data(test_data) self.model = Shift([5.66, 6.66]) threshold_moment = moment_function(np.array([5.66, 6.66])) expected_rate = np.array([[-14.43624419, -22.48168502], [-13.43624419, -21.48168502], [-12.43624419, -20.48168502]]) np.testing.assert_array_almost_equal( expected_rate, np.log10( self.model.continuum_seismicity( threshold_moment, self.strain_model.data['e1h'], self.strain_model.data['e2h'], self.strain_model.data['err'], BIRD_GLOBAL_PARAMETERS['OSRnor'])))
def setUp(self): ''' ''' self.writer = None self.model = GeodeticStrain() self.model.data = OrderedDict([ ('longitude', np.array([30., 30., 30.])), ('latitude', np.array([30., 30., 30.])), ('exx', np.array([1., 2., 3.])), ('eyy', np.array([1., 2., 3.])), ('exy', np.array([1., 2., 3.]))]) self.filename = None
def test_full_regionalisation_workflow(self): # Tests the function to apply the full Kreemer regionalisation workflow # using a simple 2 polygon case self.reader = KreemerRegionalisation(KREEMER_2REG_FILE) self.model = GeodeticStrain() self.model.data = { 'longitude': np.array([179.7, -179.7, 10.0]), 'latitude': np.array([-65.7, -65.7, 10.0]), 'exx': 1E-9 * np.ones(3), 'eyy': 1E-9 * np.ones(3), 'exy': 1E-9 * np.ones(3) } self.model = self.reader.get_regionalisation(self.model) np.testing.assert_array_equal(self.model.data['region'], np.array([b'R', b'C', b'IPL'])) np.testing.assert_array_equal(self.model.data['area'], np.array([1., 5., np.nan]))
def test_get_number_observations(self): ''' Tests the count of the number of observations ''' self.data = { 'longitude': np.array([10., 20., 30.]), 'latitude': np.array([10., 20., 30.]), 'exx': np.array([1E-9, 20E-9, 25E-9]), 'eyy': np.array([1E-9, 20E-9, 25E-9]), 'exy': np.array([1E-9, 20E-9, 25E-9]) } self.model = GeodeticStrain() # Test when no data is input (should equal 0) self.assertEqual(self.model.get_number_observations(), 0) # Test with data self.model.data = self.data self.assertEqual(self.model.get_number_observations(), 3)
def __init__(self, strain_file): ''' ''' self.filename = strain_file self.strain = GeodeticStrain()
def setUp(self): ''' ''' self.data = {} self.model = GeodeticStrain()
def setUp(self): self.model = None self.strain_model = GeodeticStrain()