Ejemplo n.º 1
0
    def assemble_results(self, point):
        """
        Assemble seismic traces for given point in solution space.

        Parameters
        ----------
        point : :func:`pymc3.Point`
            Dictionary with model parameters

        Returns
        -------
        List with :class:`heart.SeismicResult`
        """
        logger.debug('Assembling seismic waveforms ...')

        syn_proc_traces, obs_proc_traces = self.get_synthetics(
            point, outmode='stacked_traces')

        syn_filt_traces, obs_filt_traces = self.get_synthetics(
            point, outmode='stacked_traces', taper_tolerance_factor=2.)

        ats = []
        for wmap in self.wavemaps:
            wc = wmap.config
            ats.extend(wmap.n_t * [wc.arrival_taper])

        results = []
        for i, (obs_tr, at) in enumerate(zip(obs_proc_traces, ats)):

            dtrace_proc = obs_tr.copy()
            dtrace_proc.set_ydata(
                (obs_tr.get_ydata() - syn_proc_traces[i].get_ydata()))

            dtrace_filt = obs_filt_traces[i].copy()
            dtrace_filt.set_ydata((obs_filt_traces[i].get_ydata() -
                                   syn_filt_traces[i].get_ydata()))

            taper = at.get_pyrocko_taper(float(obs_tr.tmin + num.abs(at.a)))

            results.append(
                heart.SeismicResult(processed_obs=obs_tr,
                                    processed_syn=syn_proc_traces[i],
                                    processed_res=dtrace_proc,
                                    filtered_obs=obs_filt_traces[i],
                                    filtered_syn=syn_filt_traces[i],
                                    filtered_res=dtrace_filt,
                                    taper=taper))

        return results
Ejemplo n.º 2
0
    def assemble_results(self,
                         point,
                         chop_bounds=['a', 'd'],
                         order='list',
                         outmode='stacked_traces'):
        """
        Assemble seismic traces for given point in solution space.

        Parameters
        ----------
        point : :func:`pymc3.Point`
            Dictionary with model parameters

        Returns
        -------
        List with :class:`heart.SeismicResult`
        """
        if point is None:
            raise ValueError('A point has to be provided!')

        logger.debug('Assembling seismic waveforms ...')

        syn_proc_traces, obs_proc_traces = self.get_synthetics(
            point, outmode=outmode, chop_bounds=chop_bounds, order='wmap')

        # will yield exactly the same as previous call needs wmap.prepare data
        # to be aware of taper_tolerance_factor
        # DEPRECATED but keep for now
        # syn_filt_traces, obs_filt_traces = self.get_synthetics(
        #    point, outmode=outmode, taper_tolerance_factor=0.,
        #    chop_bounds=chop_bounds, order='wmap')
        # syn_filt_traces, obs_filt_traces = syn_proc_traces, obs_proc_traces
        #from pyrocko import trace
        #trace.snuffle(syn_proc_traces + obs_proc_traces)

        results = []
        for i, wmap in enumerate(self.wavemaps):
            wc = wmap.config
            at = wc.arrival_taper

            wmap_results = []
            for j, obs_tr in enumerate(obs_proc_traces[i]):

                taper = at.get_pyrocko_taper(float(obs_tr.tmin - at.a))

                if outmode != 'tapered_data':
                    source_contributions = [syn_proc_traces[i][j]]
                else:
                    source_contributions = syn_proc_traces[i][j]

                wmap_results.append(
                    heart.SeismicResult(
                        point=point,
                        processed_obs=obs_tr,
                        source_contributions=source_contributions,
                        taper=taper))

            if order == 'list':
                results.extend(wmap_results)

            elif order == 'wmap':
                results.append(wmap_results)

            else:
                raise ValueError('Order "%s" is not supported' % order)

        return results
Ejemplo n.º 3
0
    def assemble_results(
            self, point, chop_bounds=['a', 'd'], order='list',
            outmode='stacked_traces'):
        """
        Assemble seismic traces for given point in solution space.

        Parameters
        ----------
        point : :func:`pymc3.Point`
            Dictionary with model parameters

        Returns
        -------
        List with :class:`heart.SeismicResult`
        """
        if point is None:
            raise ValueError('A point has to be provided!')

        logger.debug('Assembling seismic waveforms ...')

        syn_proc_traces, obs_proc_traces = self.get_synthetics(
            point, outmode=outmode,
            chop_bounds=chop_bounds, order='wmap')

        # will yield exactly the same as previous call needs wmap.prepare data
        # to be aware of taper_tolerance_factor
        syn_filt_traces, obs_filt_traces = self.get_synthetics(
            point, outmode=outmode, taper_tolerance_factor=0.,
            chop_bounds=chop_bounds, order='wmap')

        results = []
        for i, wmap in enumerate(self.wavemaps):
            wc = wmap.config
            at = wc.arrival_taper

            wmap_results = []
            for j, obs_tr in enumerate(obs_proc_traces[i]):

                dtrace_proc = obs_tr.copy()
                dtrace_proc.set_ydata(
                    (obs_tr.get_ydata() - syn_proc_traces[i][j].get_ydata()))

                dtrace_filt = obs_filt_traces[i][j].copy()
                dtrace_filt.set_ydata(
                    (obs_filt_traces[i][j].get_ydata() -
                        syn_filt_traces[i][j].get_ydata()))

                taper = at.get_pyrocko_taper(
                    float(obs_tr.tmin - at.a))

                wmap_results.append(heart.SeismicResult(
                    processed_obs=obs_tr,
                    processed_syn=syn_proc_traces[i][j],
                    processed_res=dtrace_proc,
                    filtered_obs=obs_filt_traces[i][j],
                    filtered_syn=syn_filt_traces[i][j],
                    filtered_res=dtrace_filt,
                    taper=taper))

            if order == 'list':
                results.extend(wmap_results)

            elif order == 'wmap':
                results.append(wmap_results)

            else:
                raise ValueError('Order "%s" is not supported' % order)

        return results
Ejemplo n.º 4
0
    def assemble_seismic_results(self, point):
        """
        Assemble seismic traces for given point in solution space.

        Parameters
        ----------
        point : :func:`pymc3.Point`
            Dictionary with model parameters

        Returns
        -------
        List with :class:`heart.SeismicResult`
        """
        assert self._seismic_flag

        logger.debug('Assembling seismic waveforms ...')

        if self._geodetic_flag:
            self._geodetic_flag = False
            reset_flag = True
        else:
            reset_flag = False

        syn_proc_traces = self.get_synthetics(
            point, outmode='stacked_traces')['seismic']

        tmins = [tr.tmin for tr in syn_proc_traces]

        at = copy.deepcopy(self.config.seismic_config.arrival_taper)

        obs_proc_traces = heart.taper_filter_traces(
            self.data_traces,
            arrival_taper=at,
            filterer=self.config.seismic_config.filterer,
            tmins=tmins,
            outmode='traces')

        self.config.seismic_config.arrival_taper = None

        syn_filt_traces = self.get_synthetics(
            point, outmode='data')['seismic']

        obs_filt_traces = heart.taper_filter_traces(
            self.data_traces,
            filterer=self.config.seismic_config.filterer,
            outmode='traces')

        factor = 2.
        for i, (trs, tro) in enumerate(zip(syn_filt_traces, obs_filt_traces)):

            trs.chop(tmin=tmins[i] - factor * at.fade,
                     tmax=tmins[i] + factor * at.fade + at.duration)
            tro.chop(tmin=tmins[i] - factor * at.fade,
                     tmax=tmins[i] + factor * at.fade + at.duration)

        self.config.seismic_config.arrival_taper = at

        results = []
        for i, obstr in enumerate(obs_proc_traces):
            dtrace = obstr.copy()
            dtrace.set_ydata(
                (obstr.get_ydata() - syn_proc_traces[i].get_ydata()))

            taper = trace.CosTaper(
                tmins[i],
                tmins[i] + at.fade,
                tmins[i] + at.duration - at.fade,
                tmins[i] + at.duration)
            results.append(heart.SeismicResult(
                    processed_obs=obstr,
                    processed_syn=syn_proc_traces[i],
                    processed_res=dtrace,
                    filtered_obs=obs_filt_traces[i],
                    filtered_syn=syn_filt_traces[i],
                    taper=taper))

        if reset_flag:
            self._geodetic_flag = True

        return results