def test_middle_point_multi_surfaces(self): surf = MultiSurface([ PlanarSurface(1.0, 0.0, 90.0, Point(0.0, -1.0, 0.0), Point(0.0, 1.0, 0.0), Point(0.0, 1.0, 10.0), Point(0.0, -1.0, 10.0)), PlanarSurface(1.0, 135.0, 90.0, Point(0.0, -1.0, 0.0), Point(1.0, 1.0, 0.0), Point(1.0, 1.0, 10.0), Point(0.0, -1.0, 10.0)) ]) middle_point = surf.get_middle_point() self.assertTrue(Point(0.5, 0.0, 5.0) == middle_point)
def _make_rupture(self, width, length, dip): mid_left = self.hypocenter.point_at(length / 2.0, 0, azimuth=270) mid_right = self.hypocenter.point_at(length / 2.0, 0, azimuth=90) hwidth = width * numpy.cos(numpy.radians(dip)) / 2.0 vwidth = width * numpy.sin(numpy.radians(dip)) / 2.0 top_left = mid_left.point_at(hwidth, -vwidth, azimuth=0) bottom_left = mid_left.point_at(hwidth, vwidth, azimuth=180) top_right = mid_right.point_at(hwidth, -vwidth, azimuth=0) bottom_right = mid_right.point_at(hwidth, vwidth, azimuth=180) surface = PlanarSurface(1, 2, dip, top_left, top_right, bottom_right, bottom_left) rupture = ParametricProbabilisticRupture( mag=1, rake=2, tectonic_region_type=TRT.VOLCANIC, hypocenter=self.hypocenter, surface=surface, source_typology=PointSource, occurrence_rate=3, temporal_occurrence_model=PoissonTOM(1) ) return rupture
def create_planar_surface(top_centroid, strike, dip, area, aspect): """ Given a central location, create a simple planar rupture :param top_centroid: Centroid of trace of the rupture, as instance of :class: openquake.hazardlib.geo.point.Point :param float strike: Strike of rupture(Degrees) :param float dip: Dip of rupture (degrees) :param float area: Area of rupture (km^2) :param float aspect: Aspect ratio of rupture :returns: Rupture as an instance of the :class: openquake.hazardlib.geo.surface.planar.PlanarSurface """ rad_dip = dip * pi / 180. width = sqrt(area / aspect) length = aspect * width # Get end points by moving the top_centroid along strike top_right = top_centroid.point_at(length / 2., 0., strike) top_left = top_centroid.point_at(length / 2., 0., (strike + 180.) % 360.) # Along surface width surface_width = width * cos(rad_dip) vertical_depth = width * sin(rad_dip) dip_direction = (strike + 90.) % 360. bottom_right = top_right.point_at(surface_width, vertical_depth, dip_direction) bottom_left = top_left.point_at(surface_width, vertical_depth, dip_direction) # Create the rupture return PlanarSurface(strike, dip, top_left, top_right, bottom_right, bottom_left)