Пример #1
0
    def from_config(cls, stream, config=None, event=None):
        """
        Args:
            stream (obspy.core.stream.Stream): Strong motion timeseries
                for one station.
            event (ScalarEvent):
                Object containing latitude, longitude, depth, and magnitude.
            config (dictionary): Configuration dictionary.

        Note:
            Assumes a processed stream with units of gal (1 cm/s^2).
            No processing is done by this class.
        """
        if config is None:
            config = get_config()
        station = cls()

        damping = config['metrics']['sa']['damping']
        smoothing = config['metrics']['fas']['smoothing']
        bandwidth = config['metrics']['fas']['bandwidth']

        station._damping = damping
        station._smoothing = smoothing
        station._bandwidth = bandwidth
        station._stream = stream
        station.event = event
        station.set_metadata()

        metrics = MetricsController.from_config(stream,
                                                config=config,
                                                event=event)

        pgms = metrics.pgms
        if pgms is None:
            station._components = metrics.imcs
            station._imts = metrics.imts
            station.pgms = pd.DataFrame.from_dict({
                'IMT': [],
                'IMC': [],
                'Result': []
            })
        else:
            station._components = set(pgms['IMC'].tolist())
            station._imts = set(pgms['IMT'].tolist())
            station.pgms = pgms
        station._summary = station.get_summary()
        return station
    def from_config(cls, stream, config=None, event=None):
        """
        Args:
            stream (obspy.core.stream.Stream): Strong motion timeseries
                for one station.
            event (ScalarEvent):
                Object containing latitude, longitude, depth, and magnitude.
            config (dictionary): Configuration dictionary.

        Note:
            Assumes a processed stream with units of gal (1 cm/s^2).
            No processing is done by this class.
        """
        if config is None:
            config = get_config()
        station = cls()

        damping = config['metrics']['sa']['damping']
        smoothing = config['metrics']['fas']['smoothing']
        bandwidth = config['metrics']['fas']['bandwidth']

        station._damping = damping
        station._smoothing = smoothing
        station._bandwidth = bandwidth
        station._stream = stream
        station.event = event
        station.set_metadata()
        metrics = MetricsController.from_config(stream, config=config,
                                                event=event)
        pgms = metrics.pgms
        if pgms is None:
            station._components = metrics.imcs
            station._imts = metrics.imts
            station.pgms = pd.DataFrame.from_dict({
                'IMT': [],
                'IMC': [],
                'Result': []
            })
        else:
            station._components = set(pgms['IMC'].tolist())
            station._imts = set(pgms['IMT'].tolist())
            station.pgms = pgms
        station._summary = station.get_summary()
        return station
Пример #3
0
    def from_config(cls,
                    stream,
                    config=None,
                    event=None,
                    calc_waveform_metrics=True,
                    calc_station_metrics=True,
                    rupture=None,
                    vs30_grids=None):
        """
        Args:
            stream (obspy.core.stream.Stream): Strong motion timeseries
                for one station.
            config (dictionary): Configuration dictionary.
            event (ScalarEvent):
                Object containing latitude, longitude, depth, and magnitude.
            calc_waveform_metrics (bool):
                Whether to calculate waveform metrics. Default is True.
            calc_station_metrics (bool):
                Whether to calculate station metrics. Default is True.
            rupture (PointRupture or QuadRupture):
                impactutils rupture object. Default is None.
            vs30_grids (dict):
                A dictionary containing the vs30 grid files, names, and
                descriptions (see config).
        Note:
            Assumes a processed stream with units of gal (1 cm/s^2).
            No processing is done by this class.
        """
        if config is None:
            config = get_config()
        station = cls()

        damping = config['metrics']['sa']['damping']
        smoothing = config['metrics']['fas']['smoothing']
        bandwidth = config['metrics']['fas']['bandwidth']

        station._damping = damping
        station._smoothing = smoothing
        station._bandwidth = bandwidth
        station._stream = stream
        station.event = event
        station.set_metadata()

        if stream.passed and calc_waveform_metrics:
            metrics = MetricsController.from_config(stream,
                                                    config=config,
                                                    event=event)

            station.channel_dict = metrics.channel_dict.copy()

            pgms = metrics.pgms
            if pgms is None:
                station._components = metrics.imcs
                station._imts = metrics.imts
                station.pgms = pd.DataFrame.from_dict({
                    'IMT': [],
                    'IMC': [],
                    'Result': []
                })
            else:
                station._components = set(pgms.index.get_level_values('IMC'))
                station._imts = set(pgms.index.get_level_values('IMT'))
                station.pgms = pgms
        if calc_station_metrics:
            station.compute_station_metrics(rupture, vs30_grids)

        return station