Exemple #1
0
    def _make_hvsr(self,
                   method,
                   resampling,
                   bandwidth,
                   f_low=None,
                   f_high=None,
                   azimuth=None):
        if method in ["squared-average", "geometric-mean"]:
            ffts = self.transform()
            hor = self._combine_horizontal_fd(method=method,
                                              ew=ffts["ew"],
                                              ns=ffts["ns"])
            ver = ffts["vt"]
            del ffts
        elif method == "single-azimuth":
            hor = self._combine_horizontal_td(method=method, azimuth=azimuth)
            hor = FourierTransform.from_timeseries(hor)
            ver = FourierTransform.from_timeseries(self.vt)
        else:
            msg = f"`method`={method} has not been implemented."
            raise NotImplementedError(msg)

        self.meta["method"] = method
        self.meta["azimuth"] = azimuth

        if resampling["res_type"] == "linear":
            frq = np.linspace(resampling["minf"], resampling["maxf"],
                              resampling["nf"])
        elif resampling["res_type"] == "log":
            frq = np.geomspace(resampling["minf"], resampling["maxf"],
                               resampling["nf"])
        else:
            msg = f"`res_type`={resampling['res_type']} has not been implemented."
            raise NotImplementedError(msg)

        hor.smooth_konno_ohmachi_fast(frq, bandwidth)
        ver.smooth_konno_ohmachi_fast(frq, bandwidth)
        hor._amp /= ver._amp
        hvsr = hor
        del ver

        if self.ns.nseries == 1:
            window_length = max(self.ns.time)
        else:
            window_length = max(self.ns.time[0])

        self.meta["Window Length"] = window_length

        return Hvsr(hvsr.amplitude,
                    hvsr.frequency,
                    find_peaks=False,
                    f_low=f_low,
                    f_high=f_high,
                    meta=self.meta)
Exemple #2
0
    def _make_hvsr(self, method, resampling, bandwidth, azimuth=None):
        if method in ["squared-average", "geometric-mean"]:
            ffts = self.transform()
            hor = self.combine_horizontals(method=method, horizontals=ffts)
            ver = ffts["vt"]
            del ffts
        elif method == "single-azimuth":
            hor = self.combine_horizontals(method=method,
                                           horizontals={"ew": self.ew,
                                                        "ns": self.ns},
                                           azimuth=azimuth)
            if isinstance(hor, WindowedTimeSeries):
                hor = FourierTransformSuite.from_timeseries(hor)
                ver = FourierTransformSuite.from_timeseries(self.vt)
            elif isinstance(hor, TimeSeries):
                hor = FourierTransform.from_timeseries(hor)
                ver = FourierTransform.from_timeseries(self.vt)
            else:
                raise NotImplementedError
        else:
            msg = f"`method`={method} has not been implemented."
            raise NotImplementedError(msg)

        self.meta["method"] = method
        self.meta["azimuth"] = azimuth

        if resampling["res_type"] == "linear":
            frq = np.linspace(resampling["minf"],
                              resampling["maxf"],
                              resampling["nf"])
        elif resampling["res_type"] == "log":
            frq = np.geomspace(resampling["minf"],
                               resampling["maxf"],
                               resampling["nf"])
        else:
            raise NotImplementedError

        hor.smooth_konno_ohmachi_fast(frq, bandwidth)
        ver.smooth_konno_ohmachi_fast(frq, bandwidth)
        hor.amp /= ver.amp
        hvsr = hor
        del ver

        if self.ns.n_windows == 1:
            window_length = max(self.ns.time)
        else:
            window_length = max(self.ns.time[0])

        self.meta["Window Length"] = window_length

        return Hvsr(hvsr.amp, hvsr.frq, find_peaks=False, meta=self.meta)
Exemple #3
0
    def _combine_horizontal_fd(method, ns, ew):
        """Combine horizontal components in the frequency domain.

        Parameters
        ----------
        method : {'squared-average', 'geometric-mean'}
            Defines how the two horizontal components are combined.
        ns, ew : FourierTransform
            Frequency domain representation of each component.

        Returns
        -------
        FourierTransform
            Representing the combined horizontal components.

        """
        if method == "squared-average":
            horizontal = np.sqrt((ns.mag * ns.mag + ew.mag * ew.mag) / 2)
        elif method == "geometric-mean":
            horizontal = np.sqrt(ns.mag * ew.mag)
        else:
            msg = f"`method`={method} has not been implemented."
            raise NotImplementedError(msg)

        return FourierTransform(horizontal, ns.frequency, dtype=float)
Exemple #4
0
    def transform(self, **kwargs):
        """Perform Fourier transform on components.

        Returns
        -------
        dict
            With `FourierTransform`-like objects, one for for each
            component, indicated by the key 'ew','ns', 'vt'.

        """
        ffts = {}
        for attr in ["ew", "ns", "vt"]:
            tseries = getattr(self, attr)
            fft = FourierTransform.from_timeseries(tseries, **kwargs)
            ffts[attr] = fft
        return ffts
Exemple #5
0
    def _combine_horizontal_fd(method, horizontals, **kwargs):
        ns = horizontals["ns"]
        ew = horizontals["ew"]

        if method == "squared-average":
            horizontal = np.sqrt((ns.mag*ns.mag + ew.mag*ew.mag)/2)
        elif method == "geometric-mean":
            horizontal = np.sqrt(ns.mag * ew.mag)
        else:
            msg = f"`method`={method} has not been implemented."
            raise NotImplementedError(msg)

        if isinstance(ns, FourierTransformSuite):
            return FourierTransformSuite(horizontal, ns.frq)
        elif isinstance(ns, FourierTransform):
            return FourierTransform(horizontal, ns.frq)
        else:
            raise NotImplementedError
Exemple #6
0
    def transform(self, **kwargs):
        """Perform Fourier transform on components.

        Returns
        -------
        dict
            With `FourierTransform`-like objects, one for for each
            component, indicated by the key 'ew','ns', 'vt'.

        """
        ffts = {}
        for attr in ["ew", "ns", "vt"]:
            tseries = getattr(self, attr)
            if isinstance(tseries, WindowedTimeSeries):
                fft = FourierTransformSuite.from_timeseries(tseries, **kwargs)
            elif isinstance(tseries, TimeSeries):
                fft = FourierTransform.from_timeseries(tseries, **kwargs)
            else:
                raise NotImplementedError
            ffts[attr] = fft
        return ffts
Exemple #7
0
 def new_fseries(self):
     self.applied_smoothing = False
     self.applied_resampling = False
     self.fseries = FourierTransform.from_timeseries(self.tseries)
     self.update_fseries_plot()