Ejemplo n.º 1
0
def make_point_source(lon=1.2, lat=3.4, **kwargs):
    default_arguments = {
        'source_id': 'source_id',
        'name': 'source name',
        'tectonic_region_type': TRT.SUBDUCTION_INTRASLAB,
        'mfd': TruncatedGRMFD(a_val=1,
                              b_val=2,
                              min_mag=3,
                              max_mag=5,
                              bin_width=1),
        'location': Point(lon, lat, 5.6),
        'nodal_plane_distribution': PMF([(1, NodalPlane(1, 2, 3))]),
        'hypocenter_distribution': PMF([(1, 4)]),
        'upper_seismogenic_depth': 1.3,
        'lower_seismogenic_depth': 4.9,
        'magnitude_scaling_relationship': PeerMSR(),
        'rupture_aspect_ratio': 1.333,
        'rupture_mesh_spacing': 1.234,
        'temporal_occurrence_model': PoissonTOM(50.)
    }
    default_arguments.update(kwargs)
    kwargs = default_arguments
    ps = PointSource(**kwargs)
    assert_pickleable(ps)
    return ps
Ejemplo n.º 2
0
def make_non_parametric_source():
    surf1 = PlanarSurface(
        mesh_spacing=2., strike=0, dip=90,
        top_left=Point(0., -1., 0.), top_right=Point(0., 1., 0.),
        bottom_right=Point(0., 1., 10.), bottom_left=Point(0., -1., 10.)
    )
    surf2 = PlanarSurface(
        mesh_spacing=2., strike=90., dip=90.,
        top_left=Point(-1., 0., 0.), top_right=Point(1., 0., 0.),
        bottom_right=Point(1., 0., 10.), bottom_left=Point(-1., 0., 10.)
    )
    rup1 = Rupture(
        mag=5., rake=90., tectonic_region_type='ASC',
        hypocenter=Point(0., 0., 5.), surface=surf1, source_typology=None
    )
    rup2 = Rupture(
        mag=6, rake=0, tectonic_region_type='ASC',
        hypocenter=Point(0., 0., 5.), surface=surf2, source_typology=None
    )
    pmf1 = PMF([(Decimal('0.7'), 0), (Decimal('0.3'), 1)])
    pmf2 = PMF([(Decimal('0.7'), 0), (Decimal('0.2'), 1), (Decimal('0.1'), 2)])
    kwargs = {
        'source_id': 'source_id', 'name': 'source name',
        'tectonic_region_type': 'tectonic region',
        'data': [(rup1, pmf1), (rup2, pmf2)]
    }
    npss = NonParametricSeismicSource(**kwargs)
    assert_pickleable(npss)
    return npss, kwargs
def make_non_parametric_source():
    surf1 = PlanarSurface(
        mesh_spacing=2., strike=0, dip=90,
        top_left=Point(0., -1., 0.), top_right=Point(0., 1., 0.),
        bottom_right=Point(0., 1., 10.), bottom_left=Point(0., -1., 10.)
    )
    surf2 = PlanarSurface(
        mesh_spacing=2., strike=90., dip=90.,
        top_left=Point(-1., 0., 0.), top_right=Point(1., 0., 0.),
        bottom_right=Point(1., 0., 10.), bottom_left=Point(-1., 0., 10.)
    )
    rup1 = Rupture(
        mag=5., rake=90., tectonic_region_type='ASC',
        hypocenter=Point(0., 0., 5.), surface=surf1, source_typology=None
    )
    rup2 = Rupture(
        mag=6, rake=0, tectonic_region_type='ASC',
        hypocenter=Point(0., 0., 5.), surface=surf2, source_typology=None
    )
    pmf1 = PMF([(Decimal('0.7'), 0), (Decimal('0.3'), 1)])
    pmf2 = PMF([(Decimal('0.7'), 0), (Decimal('0.2'), 1), (Decimal('0.1'), 2)])
    kwargs = {
        'source_id': 'source_id', 'name': 'source name',
        'tectonic_region_type': 'tectonic region',
        'data': [(rup1, pmf1), (rup2, pmf2)]
    }
    npss = NonParametricSeismicSource(**kwargs)
    assert_pickleable(npss)
    return npss, kwargs
Ejemplo n.º 4
0
    def _make_source(self, mfd, aspect_ratio, profiles=None,
                     floating_x_step=0.5, floating_y_step=0.5):
        """
        Utility method for creating quickly fault instances
        :param mfd:
            An instance of :class:`openquake.hazardlib.scalerel.base.`
        :param aspect_ratio:
            The rupture aspect ratio
        :param profiles:
            A list of profiles used to build the fault surface
        """

        # Set the fault source parameter
        source_id = name = 'test-source'
        trt = self.TRT
        rake = self.RAKE
        rupture_mesh_spacing = 2.5
        magnitude_scaling_relationship = PeerMSR()
        rupture_aspect_ratio = aspect_ratio
        tom = self.TOM
        if profiles is None:
            profiles = [Line([Point(0.0, 0.0, 0.0), Point(0.0, 0.01, 15.0)]),
                        Line([Point(0.3, 0.0, 0.0), Point(0.3, 0.01, 15.0)])]

        # Create the source instance
        kfs = KiteFaultSource(source_id, name, trt, mfd, rupture_mesh_spacing,
                              magnitude_scaling_relationship,
                              rupture_aspect_ratio, tom, profiles, rake,
                              floating_x_step=floating_x_step,
                              floating_y_step=floating_y_step)

        # Check we can create a pickled version of this object
        assert_pickleable(kfs)
        return kfs
    def _make_source(self, mfd, aspect_ratio, fault_trace=None, dip=45):
        source_id = name = 'test-source'
        trt = self.TRT
        rake = self.RAKE
        rupture_mesh_spacing = 1
        upper_seismogenic_depth = 0
        lower_seismogenic_depth = 4.2426406871192848
        magnitude_scaling_relationship = PeerMSR()
        rupture_aspect_ratio = aspect_ratio
        tom = self.TOM
        if fault_trace is None:
            fault_trace = Line([
                Point(0.0, 0.0),
                Point(0.0, 0.0359728811758),
                Point(0.0190775080917, 0.0550503815181),
                Point(0.03974514139, 0.0723925718855)
            ])

        sfs = SimpleFaultSource(
            source_id, name, trt, mfd, rupture_mesh_spacing,
            magnitude_scaling_relationship, rupture_aspect_ratio, tom,
            upper_seismogenic_depth, lower_seismogenic_depth, fault_trace, dip,
            rake)
        assert_pickleable(sfs)
        return sfs
Ejemplo n.º 6
0
 def _make_source(self, mfd, aspect_ratio, rupture_mesh_spacing, edges):
     source_id = name = 'test-source'
     trt = self.TRT
     rake = self.RAKE
     tom = self.TOM
     magnitude_scaling_relationship = PeerMSR()
     rupture_aspect_ratio = aspect_ratio
     edges = [Line([Point(*coords) for coords in edge]) for edge in edges]
     cfs = ComplexFaultSource(source_id, name, trt, mfd,
                              rupture_mesh_spacing,
                              magnitude_scaling_relationship,
                              rupture_aspect_ratio, tom, edges, rake)
     assert_pickleable(cfs)
     return cfs
 def _make_source(self):
     points = [Point(lon, lat, depth) for lon, lat, depth in
               zip(self.CORNER_LONS, self.CORNER_LATS, self.CORNER_DEPTHS)]
     source = CharacteristicFaultSource(
         source_id=self.SOURCE_ID,
         name=self.NAME,
         tectonic_region_type=self.TRT,
         mfd=EvenlyDiscretizedMFD(self.MIN_MAG, self.BIN_WIDTH, self.RATES),
         surface=PlanarSurface(self.MESH_SPACING, self.STRIKE, self.DIP,
                               points[0], points[1], points[3], points[2]),
         rake = self.RAKE
     )
     assert_pickleable(source)
     return source
 def _make_source(self, mfd, aspect_ratio, rupture_mesh_spacing, edges):
     source_id = name = 'test-source'
     trt = self.TRT
     rake = self.RAKE
     magnitude_scaling_relationship = PeerMSR()
     rupture_aspect_ratio = aspect_ratio
     edges = [Line([Point(*coords) for coords in edge])
              for edge in edges]
     cfs = ComplexFaultSource(
         source_id, name, trt, mfd, rupture_mesh_spacing,
         magnitude_scaling_relationship, rupture_aspect_ratio,
         edges, rake
     )
     assert_pickleable(cfs)
     return cfs
 def _make_source(self):
     points = [Point(lon, lat, depth) for lon, lat, depth in
               zip(self.CORNER_LONS, self.CORNER_LATS, self.CORNER_DEPTHS)]
     source = CharacteristicFaultSource(
         source_id=self.SOURCE_ID,
         name=self.NAME,
         tectonic_region_type=self.TRT,
         mfd=EvenlyDiscretizedMFD(self.MIN_MAG, self.BIN_WIDTH, self.RATES),
         temporal_occurrence_model=self.TOM,
         surface=PlanarSurface(self.STRIKE, self.DIP,
                               points[0], points[1], points[3], points[2]),
         rake=self.RAKE
     )
     assert_pickleable(source)
     return source
Ejemplo n.º 10
0
    def _make_source(self, *args, **kwargs):
        source = super()._make_source(*args, **kwargs)
        surface = SimpleFaultSurface.from_fault_data(
            source.fault_trace, source.upper_seismogenic_depth,
            source.lower_seismogenic_depth, source.dip,
            source.rupture_mesh_spacing)
        mesh = surface.mesh
        top_edge = Line(list(mesh[0:1]))
        bottom_edge = Line(list(mesh[-1:]))

        cfs = ComplexFaultSource(source.source_id, source.name,
                                 source.tectonic_region_type, source.mfd,
                                 source.rupture_mesh_spacing,
                                 source.magnitude_scaling_relationship,
                                 source.rupture_aspect_ratio,
                                 source.temporal_occurrence_model,
                                 [top_edge, bottom_edge], source.rake)
        assert_pickleable(cfs)
        return cfs
    def _make_source(self, *args, **kwargs):
        source = super(ComplexFaultSourceSimpleGeometryIterRupturesTestCase,
                       self)._make_source(*args, **kwargs)
        surface = SimpleFaultSurface.from_fault_data(
            source.fault_trace, source.upper_seismogenic_depth,
            source.lower_seismogenic_depth, source.dip,
            source.rupture_mesh_spacing
        )
        mesh = surface.get_mesh()
        top_edge = Line(list(mesh[0:1]))
        bottom_edge = Line(list(mesh[-1:]))

        cfs = ComplexFaultSource(
            source.source_id, source.name, source.tectonic_region_type,
            source.mfd, source.rupture_mesh_spacing,
            source.magnitude_scaling_relationship, source.rupture_aspect_ratio,
            [top_edge, bottom_edge], source.rake
        )
        assert_pickleable(cfs)
        return cfs
Ejemplo n.º 12
0
def make_point_source(**kwargs):
    default_arguments = {
        'source_id': 'source_id', 'name': 'source name',
        'tectonic_region_type': TRT.SUBDUCTION_INTRASLAB,
        'mfd': TruncatedGRMFD(a_val=1, b_val=2, min_mag=3,
                              max_mag=5, bin_width=1),
        'location': Point(1.2, 3.4, 5.6),
        'nodal_plane_distribution': PMF([(1, NodalPlane(1, 2, 3))]),
        'hypocenter_distribution': PMF([(1, 4)]),
        'upper_seismogenic_depth': 1.3,
        'lower_seismogenic_depth': 4.9,
        'magnitude_scaling_relationship': PeerMSR(),
        'rupture_aspect_ratio': 1.333,
        'rupture_mesh_spacing': 1.234
    }
    default_arguments.update(kwargs)
    kwargs = default_arguments
    ps = PointSource(**kwargs)
    assert_pickleable(ps)
    return ps
Ejemplo n.º 13
0
def make_point_source(**kwargs):
    default_arguments = {
        "source_id": "source_id",
        "name": "source name",
        "tectonic_region_type": TRT.SUBDUCTION_INTRASLAB,
        "mfd": TruncatedGRMFD(a_val=1, b_val=2, min_mag=3, max_mag=5, bin_width=1),
        "location": Point(1.2, 3.4, 5.6),
        "nodal_plane_distribution": PMF([(1, NodalPlane(1, 2, 3))]),
        "hypocenter_distribution": PMF([(1, 4)]),
        "upper_seismogenic_depth": 1.3,
        "lower_seismogenic_depth": 4.9,
        "magnitude_scaling_relationship": PeerMSR(),
        "rupture_aspect_ratio": 1.333,
        "rupture_mesh_spacing": 1.234,
        "temporal_occurrence_model": PoissonTOM(50.0),
    }
    default_arguments.update(kwargs)
    kwargs = default_arguments
    ps = PointSource(**kwargs)
    assert_pickleable(ps)
    return ps
    def _make_source(self, mfd, aspect_ratio, fault_trace=None, dip=45):
        source_id = name = 'test-source'
        trt = self.TRT
        rake = self.RAKE
        rupture_mesh_spacing = 1
        upper_seismogenic_depth = 0
        lower_seismogenic_depth = 4.2426406871192848
        magnitude_scaling_relationship = PeerMSR()
        rupture_aspect_ratio = aspect_ratio
        if fault_trace is None:
            fault_trace = Line([Point(0.0, 0.0),
                                Point(0.0, 0.0359728811758),
                                Point(0.0190775080917, 0.0550503815181),
                                Point(0.03974514139, 0.0723925718855)])

        sfs = SimpleFaultSource(
            source_id, name, trt, mfd, rupture_mesh_spacing,
            magnitude_scaling_relationship, rupture_aspect_ratio,
            upper_seismogenic_depth, lower_seismogenic_depth,
            fault_trace, dip, rake
        )
        assert_pickleable(sfs)
        return sfs
Ejemplo n.º 15
0
 def make_area_source(self, polygon, discretization, **kwargs):
     source = make_area_source(polygon, discretization, **kwargs)
     for key in kwargs:
         self.assertIs(getattr(source, key), kwargs[key])
     assert_pickleable(source)
     return source
Ejemplo n.º 16
0
 def make_area_source(self, polygon, discretization, **kwargs):
     source = make_area_source(polygon, discretization, **kwargs)
     for key in kwargs:
         self.assertIs(getattr(source, key), kwargs[key])
     assert_pickleable(source)
     return source