def test_parse_simple_fault_src(self):

        expected = (
            {'table': 'hzrdi.mfd_evd', 'data': {
                'max_val': 6.9500000000000002,
                'total_cumulative_rate': 1.8988435199999998e-05,
                'min_val': 6.5499999999999998,
                'bin_size': 0.10000000000000009,
                'mfd_values': [
                    0.0010614989, 0.00088291626999999998,
                    0.00073437776999999999, 0.00061082879999999995,
                    0.00050806530000000003],
                'total_moment_rate': 281889786038447.25,
                'owner_id': None}},
            {'table': 'hzrdi.simple_fault', 'data': {
                'name': u'Mount Diablo Thrust',
                'upper_depth': 8.0,
                'mgf_evd_id': None,
                'mfd_tgr_id': None,
                'outline': \
                    geoalchemy.WKTSpatialElement(SIMPLE_FAULT_OUTLINE_WKT),
                'edge': geoalchemy.WKTSpatialElement(SIMPLE_FAULT_EDGE_WKT),
                'lower_depth': 13.0,
                'gid': u'src01',
                'owner_id': None,
                'dip': 38.0,
                'description': None}},
            {'table': 'hzrdi.source', 'data': {
                'r_depth_distr_id': None,
                'name': u'Mount Diablo Thrust',
                'tectonic_region': 'active',
                'rake': 90.0,
                'si_type': 'simple',
                'gid': u'src01',
                'simple_fault_id': None,
                'owner_id': None,
                'hypocentral_depth': None,
                'description': None,
                'input_id': None}})

        simple_data = db_loader.parse_simple_fault_src(self.simple)

        # The WKTSpatialElement objects do not make for nice comparisons.
        # So instead, we'll just test the text element of each object
        # to make sure the coords and spatial reference system match.
        # To do that, we need to remove the WKTSpatialElements so
        # we can compare the rest of the dicts for equality.
        exp_outline = expected[1]['data'].pop('outline')
        actual_outline = simple_data[1]['data'].pop('outline')

        self.assertEqual(exp_outline.geom_wkt, actual_outline.geom_wkt)

        exp_edge = expected[1]['data'].pop('edge')
        actual_edge = simple_data[1]['data'].pop('edge')

        self.assertEqual(exp_edge.geom_wkt, actual_edge.geom_wkt)

        # Now we can test the rest of the data.
        for idx, exp in enumerate(expected):
            helpers.assertDictAlmostEqual(self, exp, simple_data[idx])
Esempio n. 2
0
    def test_parse_simple_fault_src(self):

        expected = (
            {'table': 'pshai.mfd_evd', 'data': {
                'max_val': 6.9500000000000002,
                'total_cumulative_rate': 1.8988435199999998e-05,
                'min_val': 6.5499999999999998,
                'bin_size': 0.10000000000000009,
                'mfd_values': [
                    0.0010614989, 0.00088291626999999998,
                    0.00073437776999999999, 0.00061082879999999995,
                    0.00050806530000000003],
                'total_moment_rate': 281889786038447.25,
                'owner_id': None}},
            {'table': 'pshai.simple_fault', 'data': {
                'name': u'Mount Diablo Thrust',
                'upper_depth': 8.0,
                'mgf_evd_id': None,
                'mfd_tgr_id': None,
                'outline': \
                    geoalchemy.WKTSpatialElement(SIMPLE_FAULT_OUTLINE_WKT),
                'edge': geoalchemy.WKTSpatialElement(SIMPLE_FAULT_EDGE_WKT),
                'lower_depth': 13.0,
                'gid': u'src01',
                'owner_id': None,
                'dip': 38.0,
                'description': None}},
            {'table': 'pshai.source', 'data': {
                'r_depth_distr_id': None,
                'name': u'Mount Diablo Thrust',
                'tectonic_region': 'active',
                'rake': 90.0,
                'si_type': 'simple',
                'gid': u'src01',
                'simple_fault_id': None,
                'owner_id': None,
                'hypocentral_depth': None,
                'description': None,
                'input_id': None}})

        simple_data = db_loader.parse_simple_fault_src(self.simple)

        # The WKTSpatialElement objects do not make for nice comparisons.
        # So instead, we'll just test the text element of each object
        # to make sure the coords and spatial reference system match.
        # To do that, we need to remove the WKTSpatialElements so
        # we can compare the rest of the dicts for equality.
        exp_outline = expected[1]['data'].pop('outline')
        actual_outline = simple_data[1]['data'].pop('outline')

        self.assertEqual(exp_outline.geom_wkt, actual_outline.geom_wkt)

        exp_edge = expected[1]['data'].pop('edge')
        actual_edge = simple_data[1]['data'].pop('edge')

        self.assertEqual(exp_edge.geom_wkt, actual_edge.geom_wkt)

        # Now we can test the rest of the data.
        for idx, exp in enumerate(expected):
            helpers.assertDictAlmostEqual(self, exp, simple_data[idx])
Esempio n. 3
0
    def test_parse_simple_fault_src(self):

        expected = (
            models.MfdEvd(
                max_val=6.9500000000000002,
                total_cumulative_rate=1.8988435199999998e-05,
                min_val=6.5499999999999998,
                bin_size=0.10000000000000009,
                mfd_values=[
                    0.0010614989, 0.00088291626999999998,
                    0.00073437776999999999, 0.00061082879999999995,
                    0.00050806530000000003],
                total_moment_rate=281889786038447.25,
                owner_id=None),
            models.SimpleFault(
                name='Mount Diablo Thrust',
                upper_depth=8.0,
                outline=SIMPLE_FAULT_OUTLINE_WKT,
                edge=SIMPLE_FAULT_EDGE_WKT,
                lower_depth=13.0,
                gid='src01',
                dip=38.0,
                description=None),
            models.Source(
                name='Mount Diablo Thrust',
                tectonic_region='active',
                rake=90.0,
                si_type='simple',
                gid='src01',
                hypocentral_depth=None,
                description=None))

        simple_data = db_loader.parse_simple_fault_src(self.simple)

        # Now we can test the rest of the data.
        helpers.assertModelAlmostEqual(self, expected[0], simple_data[0])
        helpers.assertModelAlmostEqual(self, expected[1], simple_data[1])
        helpers.assertModelAlmostEqual(self, expected[2], simple_data[2])
Esempio n. 4
0
    def test_parse_simple_fault_src(self):

        expected = (models.MfdEvd(max_val=6.9500000000000002,
                                  total_cumulative_rate=1.8988435199999998e-05,
                                  min_val=6.5499999999999998,
                                  bin_size=0.10000000000000009,
                                  mfd_values=[
                                      0.0010614989, 0.00088291626999999998,
                                      0.00073437776999999999,
                                      0.00061082879999999995,
                                      0.00050806530000000003
                                  ],
                                  total_moment_rate=281889786038447.25,
                                  owner_id=None),
                    models.SimpleFault(name='Mount Diablo Thrust',
                                       upper_depth=8.0,
                                       outline=SIMPLE_FAULT_OUTLINE_WKT,
                                       edge=SIMPLE_FAULT_EDGE_WKT,
                                       lower_depth=13.0,
                                       gid='src01',
                                       dip=38.0,
                                       description=None),
                    models.Source(name='Mount Diablo Thrust',
                                  tectonic_region='active',
                                  rake=90.0,
                                  si_type='simple',
                                  gid='src01',
                                  hypocentral_depth=None,
                                  description=None))

        simple_data = db_loader.parse_simple_fault_src(self.simple)

        # Now we can test the rest of the data.
        helpers.assertModelAlmostEqual(self, expected[0], simple_data[0])
        helpers.assertModelAlmostEqual(self, expected[1], simple_data[1])
        helpers.assertModelAlmostEqual(self, expected[2], simple_data[2])