当前位置: 首页>>代码示例>>Python>>正文


Python base_database_parser.get_float函数代码示例

本文整理汇总了Python中smtk.parsers.base_database_parser.get_float函数的典型用法代码示例。如果您正苦于以下问题:Python get_float函数的具体用法?Python get_float怎么用?Python get_float使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_float函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _parse_component_data

    def _parse_component_data(self, wfid, proc_data):
        """
        Parses the information for each component
        """
        filter_params = {
            'Type': proc_data['comp_ordered.filter_type'],
            'Order': proc_data['comp_ordered.filter_order'],
            'Passes': get_int(
                proc_data['comp_ordered.filter_number_of_passes']),
            'NRoll': get_int(proc_data['comp_ordered.nroll']),
            'High-Cut': get_float(proc_data['comp_ordered.high_cut_freq']),
            'Low-Cut': get_float(proc_data['comp_ordered.low_cut_freq'])}

        intensity_measures = {
            # All m - convert to cm
            'PGA': get_float(proc_data['comp_ordered.pga']),
            'PGV': get_float(proc_data['comp_ordered.pgv']),
            'PGD': get_float(proc_data['comp_ordered.pgd'])
            }

        for imkey in intensity_measures.keys():
            if intensity_measures[imkey]:
                intensity_measures[imkey] = 100.0 * intensity_measures[imkey]
            
        comp = Component(wfid,
            proc_data['comp_ordered.orientation'],
            ims=intensity_measures,
            longest_period=None,
            waveform_filter=filter_params,
            baseline=proc_data['comp_ordered.baseline_correction'])
        return comp
开发者ID:g-weatherill,项目名称:gmpe-smtk,代码行数:31,代码来源:sigma_database_parser.py

示例2: _parse_site_data

    def _parse_site_data(self, metadata):
        """
        Parses the site metadata. Coordinates in western hemisphere
        are returned as negative values.
        """
        try:
            altitude = get_float(metadata["ALTITUD (msnm)"])
        except:
            altitude = 0

        site = RecordSite(
            "|".join([metadata["INSTITUCION RESPONSABLE"],
                    metadata["CLAVE DE LA ESTACION"]]),
            metadata["CLAVE DE LA ESTACION"],
            metadata["NOMBRE DE LA ESTACION"],
            -get_float(metadata["COORDENADAS DE LA ESTACION"].split(" ")[3]),
            get_float(metadata["COORDENADAS DE LA ESTACION"].split(" ")[0]),
            altitude)

        if "UNAM" in metadata["INSTITUCION RESPONSABLE"]:
            site.network_code = "UNAM"
        elif "CICESE" in metadata["INSTITUCION RESPONSABLE"]:
            site.network_code = "CICESE"
        else:
            site.network_code = "unknown"

        try:
            site.morphology = metadata["TIPO DE SUELO"]
        except:
            site.morphology = None

        site.instrument_type = metadata["MODELO DEL ACELEROGRAFO"]

        return site
开发者ID:GEMScienceTools,项目名称:gmpe-smtk,代码行数:34,代码来源:asa_database_parser.py

示例3: _parse_focal_mechanism

    def _parse_focal_mechanism(self, eq_id, eq_name, metadata):
        """
        Parses the focal mechanism returning an instance of FocalMechanism
        """
        nodal_planes = GCMTNodalPlanes()
        nodal_planes.nodal_plane_1 = {
            'strike': get_float(metadata['event.strike1']),
            'dip': get_float(metadata['event.dip1']),
            'rake': get_float(metadata['event.slip1'])
            }
        nodal_planes.nodal_plane_2 = {
            'strike': get_float(metadata['event.strike2']),
            'dip': get_float(metadata['event.dip2']),
            'rake': get_float(metadata['event.slip2'])
            }

        principal_axes = GCMTPrincipalAxes()
        principal_axes.t_axes = {
            'eigenvalue': None,
            'plunge': get_float(metadata['event.t_axes_plg']),
            'azimuth': get_float(metadata['event.t_axes_az'])}
        principal_axes.p_axes = {
            'eigenvalue': None,
            'plunge': get_float(metadata['event.p_axes_plg']),
            'azimuth': get_float(metadata['event.p_axes_az'])}
        principal_axes.b_axes = {
            'eigenvalue': None,
            'plunge': None,
            'azimuth': None}

        return FocalMechanism(eq_id, eq_name, nodal_planes, principal_axes,
            mechanism_type=metadata['event.fault_mechanism.name'])
开发者ID:g-weatherill,项目名称:gmpe-smtk,代码行数:32,代码来源:sigma_database_parser.py

示例4: _parse_distance_data

    def _parse_distance_data(self, metadata, file_str, eqk):
        """
        Parses the event metadata to return an instance of the :class:
        smtk.sm_database.RecordDistance. Coordinates in western hemisphere
        are converted to negative values.
        """

        epi_lon = -get_float(
            metadata["COORDENADAS DEL EPICENTRO"].split(" ")[3])
        epi_lat = get_float(
            metadata["COORDENADAS DEL EPICENTRO"].split(" ")[0])
        sta_lon = -get_float(
            metadata["COORDENADAS DE LA ESTACION"].split(" ")[3])
        sta_lat = get_float(
            metadata["COORDENADAS DE LA ESTACION"].split(" ")[0])

        p = Point(longitude=epi_lon, latitude=epi_lat)
        repi = p.distance(Point(longitude=sta_lon, latitude=sta_lat))

        # No hypocentral distance in file - calculate from event
        rhypo = sqrt(repi ** 2. + eqk.depth ** 2.)

        azimuth = Point(epi_lon, epi_lat, eqk.depth).azimuth(
            Point(sta_lon, sta_lat))

        dists = RecordDistance(repi, rhypo)
        dists.azimuth = azimuth
        return dists
开发者ID:GEMScienceTools,项目名称:gmpe-smtk,代码行数:28,代码来源:asa_database_parser.py

示例5: _parse_rupture

    def _parse_rupture(self, eq_id, metadata):
        """

        """
        return Rupture(eq_id,
                       get_float(metadata['event.fault_rupture_length']),
                       get_float(metadata['event.fault_rupture_width']),
                       get_float(metadata['event.fault_rupture_depth']))
开发者ID:luisera,项目名称:gmpe-smtk,代码行数:8,代码来源:sigma_database_parser.py

示例6: _parse_distance_data

 def _parse_distance_data(self, metadata):
     """
     Parses the distance data
     """
     return RecordDistance(get_float(metadata['distance_repi']),
                           get_float(metadata['distance_rhyp']),
                           rjb = get_float(metadata['distance_rjb']),
                           rrup = get_float(metadata['distance_rrup']),
                           r_x = None,
                           flag = get_int(metadata['distance_flag']))
开发者ID:g-weatherill,项目名称:gmpe-smtk,代码行数:10,代码来源:sigma_database_parser.py

示例7: _build_spectra_hdf5_from_row

  def _build_spectra_hdf5_from_row(self, output_file, row, periods,
                                   scalar_fields, spectra_fields, component,
                                   damping, units):
      """
 
      """
      fle = h5py.File(output_file, "w-")
      ts_grp = fle.create_group("Time Series")
      ims_grp = fle.create_group("IMS")
      h_grp = ims_grp.create_group("H")
      scalar_grp = h_grp.create_group("Scalar")
      # Create Scalar values
      for f_attr, imt in scalar_fields:
          dset = scalar_grp.create_dataset(imt, (1,), dtype="f")
          dset.attrs["Component"] = component
          input_units = re.search('\((.*?)\)', f_attr).group(1)
          if imt == "PGA":
              # Convert acceleration from reported units to cm/s/s
              dset.attrs["Units"] = "cm/s/s"
              dset[:] = utils.convert_accel_units(get_float(row[f_attr]),
                                                  input_units)
          else:
              # For other values take direct from spreadsheet
              # Units should be given in parenthesis from fieldname 
              dset.attrs["Units"] = input_units
              dset[:] = get_float(row[f_attr])
              
      spectra_grp = h_grp.create_group("Spectra")
      rsp_grp = spectra_grp.create_group("Response")
      # Setup periods dataset
      per_dset = rsp_grp.create_dataset("Periods",
                                        (len(periods),),
                                        dtype="f")
      per_dset.attrs["High Period"] = np.max(periods)
      per_dset.attrs["Low Period"] = np.min(periods)
      per_dset.attrs["Number Periods"] = len(periods)
      per_dset[:] = periods
      # Get response spectra
      spectra = np.array([get_float(row[f_attr])
                          for f_attr in spectra_fields])
      acc_grp = rsp_grp.create_group("Acceleration")
      comp_grp = acc_grp.create_group(component)
      spectra_dset = comp_grp.create_dataset("damping_{:s}".format(damping),
                                             (len(spectra),),
                                             dtype="f")
      spectra_dset.attrs["Units"] = "cm/s/s"
      spectra_dset[:] = utils.convert_accel_units(spectra, units)
      fle.close()
开发者ID:g-weatherill,项目名称:gmpe-smtk,代码行数:48,代码来源:sm_database_builder.py

示例8: parse_metadata

 def parse_metadata(self, metadata, file_str):
     """
     Parses the metadata dictionary
     """
     # Waveform id
     wfid = metadata['waveform_sourceid']
     # Get event information
     event = self._parse_event_data(metadata)
     # Get distance information
     distances = self._parse_distance_data(metadata)
     # Get site data
     site = self._parse_site_data(metadata)
     # Get processing data
     x_comp, y_comp, z_comp = self._parse_processing_data(wfid, metadata)
     # Create and return record
     rec_file = os.path.join(file_str + "/" + file_str)
                             
     return GroundMotionRecord(wfid,
         [rec_file + self.XCOMP_STR, 
          rec_file + self.YCOMP_STR,
          rec_file + self.ZCOMP_STR],
         event,
         distances,
         site,
         x_comp,
         y_comp,
         vertical=z_comp,
         ims=None,
         longest_period=get_float(metadata['up4horiz_components']),
         spectra_file=[rec_file + self.XSPEC_STR,
                       rec_file + self.YSPEC_STR,
                       rec_file + self.ZSPEC_STR])
开发者ID:g-weatherill,项目名称:gmpe-smtk,代码行数:32,代码来源:sigma_database_parser.py

示例9: _parse_site_data

 def _parse_site_data(self, metadata):
     """
     Returns the site data as an instance of the :class:
     smtk.sm_database.RecordSite
     """
     site = RecordSite(metadata["Station Sequence Number"],
                       metadata["Station ID  No."],
                       metadata["Station ID  No."],
                       get_float(metadata["Station Longitude"]),
                       get_float(metadata["Station Latitude"]),
                       0.0, # Elevation data not given
                       get_float(metadata["Preferred Vs30 (m/s)"]),
                       network_code=metadata["Owner"])
     site.nehrp = metadata["Preferred NEHRP Based on Vs30"]
     site.vs30_measured_type = metadata["Measured/Inferred Class"]
     if site.vs30_measured_type in ["0", "5"]:
         site.vs30_measured = True
     else:
         site.vs30_measured = False
     site.vs30_uncertainty = get_float(
         metadata["Sigma of Vs30 (in natural log Units)"])
     site.z1pt0 = get_float(metadata["Z1 (m)"])
     site.z1pt5 = get_float(metadata["Z1.5 (m)"])
     site.z2pt5 = get_float(metadata["Z2.5 (m)"])
     # Implement default values for z1pt0 and z2pt5
     if site.z1pt0 is None:
         site.z1pt0 = rcfg.vs30_to_z1pt0_as08(site.vs30)
     if site.z2pt5 is None:
         site.z2pt5 = rcfg.z1pt0_to_z2pt5(site.z1pt0)
     site.arc_location = metadata["Forearc/Backarc for subduction events"]
     site.instrument_type = metadata["Type of Recording"]
     return site
开发者ID:g-weatherill,项目名称:gmpe-smtk,代码行数:32,代码来源:simple_flatfile_parser.py

示例10: _parse_event_data

    def _parse_event_data(self, metadata):
        """
        """
        # Get datetime
        if len(metadata['event.datetime']) > 20:
            eq_datetime = datetime.strptime(metadata['event.datetime'],
                                        "%Y-%m-%d %H:%M:%S.%f")
        else:
            eq_datetime = datetime.strptime(metadata['event.datetime'],
                                        "%Y-%m-%d %H:%M:%S")
        # Event ID and Name
        if metadata['event.unid']:
            eq_id = metadata['event.unid']
        else:
            eq_id = eq_datetime.isoformat()
        
        eq_name = metadata['event.name']
        
        # Get focal mechanism
        focal_mech = self._parse_focal_mechanism(eq_id, eq_name, metadata)

        # Get preferred magnitude
        pref_mag = Magnitude(get_float(metadata['event.pref_mag']),
                             metadata['event.pref_mag_type'])
        # Get magnitude list
        mag_list = []
        for kstr in ['0', '1', '2', '3', '4']:
            mag_list.append(Magnitude(
                get_float(metadata['event.magnitudes/' + kstr + '.value']),
                metadata['event.magnitudes/' + kstr + '.magtype']))

        eqk = Earthquake(eq_id, eq_name, eq_datetime,
            get_float(metadata['event.longitude']),
            get_float(metadata['event.latitude']),
            get_float(metadata['event.focaldepth']),
            pref_mag,
            focal_mech,
            metadata['event.country.name'])
        eqk.magnitude_list = mag_list
        # Get Rupture data
        eqk.rupture = self._parse_rupture(eq_id, eq_name, pref_mag, metadata)
        return eqk
开发者ID:g-weatherill,项目名称:gmpe-smtk,代码行数:42,代码来源:sigma_database_parser.py

示例11: _parse_site_data

 def _parse_site_data(self, metadata):
     """
     Parse the site data
     """
     site = RecordSite(
         metadata['station.oid'],
         metadata['station.name'],
         metadata['station.code'],
         get_float(metadata['station.longitude']),
         get_float(metadata['station.latitude']),
         get_float(metadata['station.altitude']),
         vs30=get_float(metadata['station.vs30']),
         vs30_measured=get_int(metadata['station.vs30_measured']),
         network_code=metadata['station.agency.name'],
         country=metadata['station.country.name'])
     site.vs30_measured_type = metadata['station.vs30_measured_type']
     site.instrument_type = metadata['recording_type']
     site.digitiser = metadata['digitalizer']
     site.building_structure = metadata['station.building_struct.name']
     site.number_floors = get_int(metadata['station.number_of_floor'])
     site.floor = metadata['station.installed_on_floor']
     site.ec8 = metadata['station.ec8']
     return site
开发者ID:g-weatherill,项目名称:gmpe-smtk,代码行数:23,代码来源:sigma_database_parser.py

示例12: _get_focal_mechanism

    def _get_focal_mechanism(self, eq_id, eq_name, metadata):
        """
        Returns the focal mechanism information as an instance of the
        :class: smtk.sigma_database.FocalMechanism 
        """
        nodal_planes = GCMTNodalPlanes()
        strike = get_float(metadata["Strike (deg)"])
        if strike is None:
            strike = 0.0
        dip = get_float(metadata["Dip (deg)"])
        if dip is None:
            dip = 90.0
        nodal_planes.nodal_plane_1 = {
            "strike": strike,
            "dip": dip,
            "rake": get_float(metadata["Rake Angle (deg)"])}

        nodal_planes.nodal_plane2 = {"strike": None,
                                     "dip": None,
                                     "rake": None}
        principal_axes = GCMTPrincipalAxes()
        return FocalMechanism(eq_id, eq_name, nodal_planes, principal_axes,
            mechanism_type=metadata["Mechanism Based on Rake Angle"])
开发者ID:g-weatherill,项目名称:gmpe-smtk,代码行数:23,代码来源:simple_flatfile_parser.py

示例13: _parse_distance_data

 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
开发者ID:preinh,项目名称:gmpe-smtk,代码行数:56,代码来源:simple_flatfile_parser_sara.py

示例14: _sanitise

 def _sanitise(self, row, reader):
     """
     If all of the strong motion values are negative the record is null
     and should be removed
     """
     iml_vals = []
     for fname in reader.fieldnames:
         if fname.startswith("SA(") or fname in SCALAR_LIST:
             # Ground motion value
             iml = get_float(row[fname])
             if iml:
                 iml_vals.append(iml)
             else:
                 iml_vals.append(-999.0)
     # If all ground motion values are negative then the record is null
     # return false
     if np.all(np.array(iml_vals) < 0.0):
         return False
     else:
         return True
开发者ID:GEMScienceTools,项目名称:gmpe-smtk,代码行数:20,代码来源:general_flatfile_parser.py

示例15: _parse_processing_data

    def _parse_processing_data(self, wfid, metadata):
        """
        Parses the information for each component
        """
        filter_params1 = {
            'Type': FILTER_TYPE[metadata["Type of Filter"]] ,
            'Order': None,
            'Passes': get_int(metadata['npass']),
            'NRoll': get_int(metadata['nroll']),
            'High-Cut': get_float(metadata["LP-H1 (Hz)"]),
            'Low-Cut': get_float(metadata["HP-H1 (Hz)"])}

        filter_params2 = {
            'Type': FILTER_TYPE[metadata["Type of Filter"]] ,
            'Order': None,
            'Passes': get_int(metadata['npass']),
            'NRoll': get_int(metadata['nroll']),
            'High-Cut': get_float(metadata["LP-H2 (Hz)"]),
            'Low-Cut': get_float(metadata["HP-H2 (Hz)"])}
        intensity_measures = {
            # All m - convert to cm
            'PGA': None,
            'PGV': None,
            'PGD': None
            }

        lup1 = 1. / get_float(metadata["Lowest Usable Freq - H1 (Hz)"])
        lup2 = 1. / get_float(metadata["Lowest Usable Freq - H2 (Hz)"])
        xcomp = Component(wfid, "1",
            ims=intensity_measures,
            longest_period=lup1,
            waveform_filter=filter_params1,
            units=metadata["Unit"])
        ycomp = Component(wfid, "2",
            ims=intensity_measures,
            longest_period=lup2,
            waveform_filter=filter_params2,
            units=metadata["Unit"]) 
        return xcomp, ycomp, None
开发者ID:g-weatherill,项目名称:gmpe-smtk,代码行数:39,代码来源:simple_flatfile_parser.py


注:本文中的smtk.parsers.base_database_parser.get_float函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。