Example #1
0
    def _parse_distance_data(self, event, site, metadata):
        """
        Read in the distance related metadata and return an instance of the
        :class: smtk.sm_database.RecordDistance
        """
        # Compute various distance metrics
        # Add calculation of Repi, Rhypo from event and station localizations (latitudes, longitudes, depth, elevation)?
        target_site = Mesh(np.array([site.longitude]),
                           np.array([site.latitude]), np.array([0.0]))
        # Warning ratio fixed to 1.5
        ratio = 1.5
        surface_modeled = rcfg.create_planar_surface(
            Point(event.longitude, event.latitude, event.depth),
            event.mechanism.nodal_planes.nodal_plane_1['strike'],
            event.mechanism.nodal_planes.nodal_plane_1['dip'],
            event.rupture.area, ratio)
        hypocenter = rcfg.get_hypocentre_on_planar_surface(
            surface_modeled, event.rupture.hypo_loc)
        # Rhypo
        Rhypo = get_float(metadata["HypD (km)"])
        if Rhypo is None:
            Rhypo = hypocenter.distance_to_mesh(target_site)
        # Repi
        Repi = get_float(metadata["EpiD (km)"])
        if Repi is None:
            Repi = hypocenter.distance_to_mesh(target_site, with_depths=False)
        # Rrup
        Rrup = get_float(metadata["Campbell R Dist. (km)"])
        if Rrup is None:
            Rrup = surface_modeled.get_min_distance(target_site)
        # Rjb
        Rjb = get_float(metadata["Joyner-Boore Dist. (km)"])
        if Rjb is None:
            Rjb = surface_modeled.get_joyner_boore_distance(target_site)
        # Need to check if Rx and Ry0 are consistant with the other metrics
        # when those are coming from the flatfile?
        # Rx
        Rx = surface_modeled.get_rx_distance(target_site)
        # Ry0
        Ry0 = surface_modeled.get_ry0_distance(target_site)

        distance = RecordDistance(repi=float(Repi),
                                  rhypo=float(Rhypo),
                                  rjb=float(Rjb),
                                  rrup=float(Rrup),
                                  r_x=float(Rx),
                                  ry0=float(Ry0))
        distance.azimuth = get_float(metadata["Source to Site Azimuth (deg)"])
        distance.hanging_wall = get_float(metadata["FW/HW Indicator"])
        #        distance = RecordDistance(
        #            get_float(metadata["EpiD (km)"]),
        #            get_float(metadata["HypD (km)"]),
        #            get_float(metadata["Joyner-Boore Dist. (km)"]),
        #            get_float(metadata["Campbell R Dist. (km)"]))
        #        distance.azimuth = get_float(metadata["Source to Site Azimuth (deg)"])
        #        distance.hanging_wall = get_float(metadata["FW/HW Indicator"])
        return distance
 def _parse_distance_data(self, event, site, metadata):
     """
     Read in the distance related metadata and return an instance of the
     :class: smtk.sm_database.RecordDistance
     """
     # Compute various distance metrics
     # Add calculation of Repi, Rhypo from event and station localizations 
     # (latitudes, longitudes, depth, elevation)?
     target_site = Mesh(np.array([site.longitude]),
                        np.array([site.latitude]),
                        np.array([-site.altitude / 1000.0]))
     # Warning ratio fixed to 1.5
     ratio=1.5
     surface_modeled = rcfg.create_planar_surface(
         Point(event.longitude, event.latitude, event.depth),
         event.mechanism.nodal_planes.nodal_plane_1['strike'],
         event.mechanism.nodal_planes.nodal_plane_1['dip'],
         event.rupture.area,
         ratio)
     hypocenter = rcfg.get_hypocentre_on_planar_surface(
         surface_modeled,
         event.rupture.hypo_loc)
     
     # Rhypo
     Rhypo = get_float(metadata["Hypocentral Distance (km)"])
     if Rhypo is None:
         Rhypo = hypocenter.distance_to_mesh(target_site)
     # Repi
     Repi = get_float(metadata["Epicentral Distance (km)"])
     if Repi is None:
         Repi= hypocenter.distance_to_mesh(target_site, with_depths=False)
     # Rrup
     Rrup = get_float(metadata["Rupture Distance (km)"])
     if Rrup is None:
         Rrup = surface_modeled.get_min_distance(target_site)
     # Rjb
     Rjb = get_float(metadata["Joyner-Boore Distance (km)"])
     if Rjb is None:
         Rjb = surface_modeled.get_joyner_boore_distance(target_site)
     # Need to check if Rx and Ry0 are consistant with the other metrics
     # when those are coming from the flatfile?
     # Rx
     Rx = surface_modeled.get_rx_distance(target_site)
     # Ry0
     Ry0 = surface_modeled.get_ry0_distance(target_site)
     
     distance = RecordDistance(
         repi = float(Repi),
         rhypo = float(Rhypo),
         rjb = float(Rjb),
         rrup = float(Rrup),
         r_x = float(Rx),
         ry0 = float(Ry0))
     distance.azimuth = get_float(metadata["Source to Site Azimuth (deg)"])
     distance.hanging_wall = get_float(metadata["FW/HW Indicator"])
     return distance
Example #3
0
 def _parse_distance_data(self, event, site, metadata):
     """
     Read in the distance related metadata and return an instance of the
     :class: smtk.sm_database.RecordDistance
     """
     # Compute various distance metrics
     # Add calculation of Repi, Rhypo from event and station localizations 
     # (latitudes, longitudes, depth, elevation)?
     target_site = Mesh(np.array([site.longitude]),
                        np.array([site.latitude]),
                        np.array([-site.altitude / 1000.0]))
     # Warning ratio fixed to 1.5
     ratio=1.5
     surface_modeled = rcfg.create_planar_surface(
         Point(event.longitude, event.latitude, event.depth),
         event.mechanism.nodal_planes.nodal_plane_1['strike'],
         event.mechanism.nodal_planes.nodal_plane_1['dip'],
         event.rupture.area,
         ratio)
     hypocenter = rcfg.get_hypocentre_on_planar_surface(
         surface_modeled,
         event.rupture.hypo_loc)
     try:
         surface_modeled._create_mesh()
     except:
         dip = surface_modeled.get_dip()
         dip_dir = (surface_modeled.get_strike() - 90.) % 360.
         ztor = surface_modeled.top_left.depth
         d_x = ztor * np.tan(np.radians(90.0 - dip))
         top_left_surface = surface_modeled.top_left.point_at(d_x,
                                                              -ztor,
                                                              dip_dir)
         top_left_surface.depth = 0.
         top_right_surface = surface_modeled.top_right.point_at(d_x,
                                                                -ztor,
                                                                dip_dir)
         top_right_surface.depth = 0.
         surface_modeled = SimpleFaultSurface.from_fault_data(
             Line([top_left_surface, top_right_surface]),
             surface_modeled.top_left.depth,
             surface_modeled.bottom_left.depth,
             surface_modeled.get_dip(),
             1.0)
         
     # Rhypo
     Rhypo = get_float(metadata["Hypocentral Distance (km)"])
     if Rhypo is None:
         Rhypo = hypocenter.distance_to_mesh(target_site)
     # Repi
     Repi = get_float(metadata["Epicentral Distance (km)"])
     if Repi is None:
         Repi= hypocenter.distance_to_mesh(target_site, with_depths=False)
     # Rrup
     Rrup = get_float(metadata["Rupture Distance (km)"])
     if Rrup is None:
         Rrup = surface_modeled.get_min_distance(target_site)
     # Rjb
     Rjb = get_float(metadata["Joyner-Boore Distance (km)"])
     if Rjb is None:
         Rjb = surface_modeled.get_joyner_boore_distance(target_site)
     # Rcdpp
     Rcdpp = get_float(metadata["Rcdpp"])
     if Rcdpp is None:
         Rcdpp = surface_modeled.get_cdppvalue(target_site)
     # Need to check if Rx and Ry0 are consistant with the other metrics
     # when those are coming from the flatfile?
     # Rx
     Rx = surface_modeled.get_rx_distance(target_site)
     # Ry0
     Ry0 = surface_modeled.get_ry0_distance(target_site)
     
     distance = RecordDistance(
         repi = float(Repi),
         rhypo = float(Rhypo),
         rjb = float(Rjb),
         rrup = float(Rrup),
         r_x = float(Rx),
         ry0 = float(Ry0),
         rcdpp = float(Rcdpp) )
     distance.azimuth = get_float(metadata["Source to Site Azimuth (deg)"])
     #distance.hanging_wall = get_float(metadata["FW/HW Indicator"])
     if metadata["FW/HW Indicator"] == "HW":
         distance.hanging_wall = True
     elif metadata["FW/HW Indicator"] == "FW":
         distance.hanging_wall = False
     else:
         pass
     
     return distance
Example #4
0
    def _parse_distance_data(self, event, site, metadata):
        """
        Read in the distance related metadata and return an instance of the
        :class: smtk.sm_database.RecordDistance
        """
        # Compute various distance metrics
        # Add calculation of Repi, Rhypo from event and station localizations
        # (latitudes, longitudes, depth, elevation)?
        target_site = Mesh(np.array([site.longitude]),
                           np.array([site.latitude]),
                           np.array([-site.altitude / 1000.0]))
        # Warning ratio fixed to 1.5
        ratio = 1.5
        if not event.rupture.area:
            event.rupture.area = WC1994().get_median_area(
                event.magnitude.value, None)
        surface_modeled = rcfg.create_planar_surface(
            Point(event.longitude, event.latitude, event.depth),
            event.mechanism.nodal_planes.nodal_plane_1['strike'],
            event.mechanism.nodal_planes.nodal_plane_1['dip'],
            event.rupture.area, ratio)
        hypocenter = rcfg.get_hypocentre_on_planar_surface(
            surface_modeled, event.rupture.hypo_loc)
        try:
            surface_modeled._create_mesh()
        except:
            dip = surface_modeled.get_dip()
            dip_dir = (surface_modeled.get_strike() - 90.) % 360.
            ztor = surface_modeled.top_left.depth
            d_x = ztor * np.tan(np.radians(90.0 - dip))
            top_left_surface = surface_modeled.top_left.point_at(
                d_x, -ztor, dip_dir)
            top_left_surface.depth = 0.
            top_right_surface = surface_modeled.top_right.point_at(
                d_x, -ztor, dip_dir)
            top_right_surface.depth = 0.
            surface_modeled = SimpleFaultSurface.from_fault_data(
                Line([top_left_surface,
                      top_right_surface]), surface_modeled.top_left.depth,
                surface_modeled.bottom_left.depth, surface_modeled.get_dip(),
                1.0)

        # Rhypo
        Rhypo, Repi, Rrup, Rjb, Ry0 = tuple(
            map(get_positive_float, [
                metadata[key] for key in [
                    "Hypocentral Distance (km)", "Epicentral Distance (km)",
                    "Rupture Distance (km)", "Joyner-Boore Distance (km)",
                    "Ry0 (km)"
                ]
            ]))
        Rx = get_float(metadata["Rx (km)"])  # Rx can be negative

        #Rhypo = get_float(metadata["Hypocentral Distance (km)"])
        if Rhypo is None or Rhypo < 0.0:
            Rhypo = hypocenter.distance_to_mesh(target_site)
        # Repi
        #Repi = get_float(metadata["Epicentral Distance (km)"])
        if Repi is None or Repi < 0.0:
            Repi = hypocenter.distance_to_mesh(target_site, with_depths=False)
        # Rrup
        #Rrup = get_float(metadata["Rupture Distance (km)"])
        if Rrup is None or Rrup < 0.0:
            Rrup = surface_modeled.get_min_distance(target_site)[0]
        # Rjb
        #Rjb = get_float(metadata["Joyner-Boore Distance (km)"])
        if Rjb is None or Rjb < 0.0:
            Rjb = surface_modeled.get_joyner_boore_distance(target_site)[0]
        # Need to check if Rx and Ry0 are consistant with the other metrics
        # when those are coming from the flatfile?
        # Rx
        #Rx = get_float(metadata["Rx (km)"])
        if Rx is None or Rx < 0.0:
            Rx = surface_modeled.get_rx_distance(target_site)[0]
        # Ry0
        Ry0 = get_float(metadata["Ry0 (km)"])
        if Ry0 is None or Ry0 < 0.0:
            Ry0 = surface_modeled.get_ry0_distance(target_site)[0]

        distance = RecordDistance(repi=Repi,
                                  rhypo=Rhypo,
                                  rjb=Rjb,
                                  rrup=Rrup,
                                  r_x=Rx,
                                  ry0=Ry0)
        distance.azimuth = get_float(metadata["Source to Site Azimuth (deg)"])
        #distance.hanging_wall = get_float(metadata["FW/HW Indicator"])
        if metadata["FW/HW Indicator"] == "HW":
            distance.hanging_wall = True
        elif metadata["FW/HW Indicator"] == "FW":
            distance.hanging_wall = False
        else:
            pass

        return distance

        return
    def _parse_distance_data(self, event, site, metadata):
        """
        Read in the distance related metadata and return an instance of the
        :class: smtk.sm_database.RecordDistance
        """
        # Compute various distance metrics
        # Add calculation of Repi, Rhypo from event and station localizations 
        # (latitudes, longitudes, depth, elevation)?
        target_site = Mesh(np.array([site.longitude]),
                           np.array([site.latitude]),
                           np.array([-site.altitude / 1000.0]))
        # Warning ratio fixed to 1.5
        ratio=1.5
        if not event.rupture.area:
            event.rupture.area = WC1994().get_median_area(event.magnitude.value,
                                                          None)
        surface_modeled = rcfg.create_planar_surface(
            Point(event.longitude, event.latitude, event.depth),
            event.mechanism.nodal_planes.nodal_plane_1['strike'],
            event.mechanism.nodal_planes.nodal_plane_1['dip'],
            event.rupture.area,
            ratio)
        hypocenter = rcfg.get_hypocentre_on_planar_surface(
            surface_modeled,
            event.rupture.hypo_loc)
        try:
            surface_modeled._create_mesh()
        except:
            dip = surface_modeled.get_dip()
            dip_dir = (surface_modeled.get_strike() - 90.) % 360.
            ztor = surface_modeled.top_left.depth
            d_x = ztor * np.tan(np.radians(90.0 - dip))
            top_left_surface = surface_modeled.top_left.point_at(d_x,
                                                                 -ztor,
                                                                 dip_dir)
            top_left_surface.depth = 0.
            top_right_surface = surface_modeled.top_right.point_at(d_x,
                                                                   -ztor,
                                                                   dip_dir)
            top_right_surface.depth = 0.
            surface_modeled = SimpleFaultSurface.from_fault_data(
                Line([top_left_surface, top_right_surface]),
                surface_modeled.top_left.depth,
                surface_modeled.bottom_left.depth,
                surface_modeled.get_dip(),
                1.0)
        
        # Rhypo
        Rhypo, Repi, Rrup, Rjb, Ry0 = tuple(map(
            get_positive_float, [metadata[key] for key in [
                "Hypocentral Distance (km)", "Epicentral Distance (km)",
                "Rupture Distance (km)", "Joyner-Boore Distance (km)",
                "Ry0 (km)"]]))
        Rx = get_float(metadata["Rx (km)"]) # Rx can be negative

        #Rhypo = get_float(metadata["Hypocentral Distance (km)"])
        if Rhypo is None or Rhypo < 0.0:
            Rhypo = hypocenter.distance_to_mesh(target_site)
        # Repi
        #Repi = get_float(metadata["Epicentral Distance (km)"])
        if Repi is None or Repi < 0.0:
            Repi= hypocenter.distance_to_mesh(target_site, with_depths=False)
        # Rrup
        #Rrup = get_float(metadata["Rupture Distance (km)"])
        if Rrup is None or Rrup < 0.0:
            Rrup = surface_modeled.get_min_distance(target_site)[0]
        # Rjb
        #Rjb = get_float(metadata["Joyner-Boore Distance (km)"])
        if Rjb is None or Rjb < 0.0:
            Rjb = surface_modeled.get_joyner_boore_distance(
                target_site)[0]
        # Need to check if Rx and Ry0 are consistant with the other metrics
        # when those are coming from the flatfile?
        # Rx
        #Rx = get_float(metadata["Rx (km)"])
        if Rx is None or Rx < 0.0:
            Rx = surface_modeled.get_rx_distance(target_site)[0]
        # Ry0
        Ry0 = get_float(metadata["Ry0 (km)"])
        if Ry0 is None or Ry0 < 0.0:
            Ry0 = surface_modeled.get_ry0_distance(target_site)[0]
        
        distance = RecordDistance(
            repi = Repi,
            rhypo = Rhypo,
            rjb = Rjb,
            rrup = Rrup,
            r_x = Rx,
            ry0 = Ry0)
        distance.azimuth = get_float(metadata["Source to Site Azimuth (deg)"])
        #distance.hanging_wall = get_float(metadata["FW/HW Indicator"])
        if metadata["FW/HW Indicator"] == "HW":
            distance.hanging_wall = True
        elif metadata["FW/HW Indicator"] == "FW":
            distance.hanging_wall = False
        else:
            pass
        
        return distance
    
        return
 def _parse_distance_data(self, event, site, metadata):
     """
     Read in the distance related metadata and return an instance of the
     :class: smtk.sm_database.RecordDistance
     """
     # Compute various distance metrics
     # Add calculation of Repi, Rhypo from event and station localizations 
     # (latitudes, longitudes, depth, elevation)?
     target_site = Mesh(np.array([site.longitude]),
                        np.array([site.latitude]),
                        np.array([-site.altitude / 1000.0]))
     # Warning ratio fixed to 1.5
     ratio=1.5
     surface_modeled = rcfg.create_planar_surface(
         Point(event.longitude, event.latitude, event.depth),
         event.mechanism.nodal_planes.nodal_plane_1['strike'],
         event.mechanism.nodal_planes.nodal_plane_1['dip'],
         event.rupture.area,
         ratio)
     hypocenter = rcfg.get_hypocentre_on_planar_surface(
         surface_modeled,
         event.rupture.hypo_loc)
     try:
         surface_modeled._create_mesh()
     except:
         dip = surface_modeled.get_dip()
         dip_dir = (surface_modeled.get_strike() - 90.) % 360.
         ztor = surface_modeled.top_left.depth
         d_x = ztor * np.tan(np.radians(90.0 - dip))
         top_left_surface = surface_modeled.top_left.point_at(d_x,
                                                              -ztor,
                                                              dip_dir)
         top_left_surface.depth = 0.
         top_right_surface = surface_modeled.top_right.point_at(d_x,
                                                                -ztor,
                                                                dip_dir)
         top_right_surface.depth = 0.
         surface_modeled = SimpleFaultSurface.from_fault_data(
             Line([top_left_surface, top_right_surface]),
             surface_modeled.top_left.depth,
             surface_modeled.bottom_left.depth,
             surface_modeled.get_dip(),
             1.0)
         
     # Rhypo
     Rhypo = get_float(metadata["Hypocentral Distance (km)"])
     if Rhypo is None:
         Rhypo = hypocenter.distance_to_mesh(target_site)
     # Repi
     Repi = get_float(metadata["Epicentral Distance (km)"])
     if Repi is None:
         Repi= hypocenter.distance_to_mesh(target_site, with_depths=False)
     # Rrup
     Rrup = get_float(metadata["Rupture Distance (km)"])
     if Rrup is None:
         Rrup = surface_modeled.get_min_distance(target_site)
     # Rjb
     Rjb = get_float(metadata["Joyner-Boore Distance (km)"])
     if Rjb is None:
         Rjb = surface_modeled.get_joyner_boore_distance(target_site)
     # Rcdpp
     Rcdpp = get_float(metadata["Rcdpp"])
     if Rcdpp is None:
         Rcdpp = surface_modeled.get_cdppvalue(target_site)
     # Need to check if Rx and Ry0 are consistant with the other metrics
     # when those are coming from the flatfile?
     # Rx
     Rx = surface_modeled.get_rx_distance(target_site)
     # Ry0
     Ry0 = surface_modeled.get_ry0_distance(target_site)
     
     distance = RecordDistance(
         repi = float(Repi),
         rhypo = float(Rhypo),
         rjb = float(Rjb),
         rrup = float(Rrup),
         r_x = float(Rx),
         ry0 = float(Ry0),
         rcdpp = float(Rcdpp) )
     distance.azimuth = get_float(metadata["Source to Site Azimuth (deg)"])
     #distance.hanging_wall = get_float(metadata["FW/HW Indicator"])
     if metadata["FW/HW Indicator"] == "HW":
         distance.hanging_wall = True
     elif metadata["FW/HW Indicator"] == "FW":
         distance.hanging_wall = False
     else:
         pass
     
     return distance