Esempio n. 1
0
    def load_gfs(self, crust_inds=None, make_shared=True):
        """
        Load Greens Function matrixes for each variable to be inverted for.
        Updates gfs and gf_names attributes.

        Parameters
        ----------
        crust_inds : list
            of int to indexes of Green's Functions
        make_shared : bool
            if True transforms gfs to :class:`theano.shared` variables
        """
        if not isinstance(crust_inds, list):
            raise TypeError('crust_inds need to be a list!')

        if crust_inds is None:
            crust_inds = range(*self.config.gf_config.n_variations)

        for wmap in self.wavemaps:
            for crust_ind in crust_inds:
                gfs = {}
                for var in self.slip_varnames:
                    gflib_name = get_gf_prefix(
                        datatype=self.name, component=var,
                        wavename=wmap.config.name, crust_ind=crust_ind)
                    gfpath = os.path.join(
                        self.gfpath, gflib_name)

                    gfs = load_gf_library(
                        directory=self.gfpath, filename=gflib_name)

                    if make_shared:
                        gfs.init_optimization()

                    key = self.get_gflibrary_key(
                        crust_ind=crust_ind,
                        wavename=wmap.config.name,
                        component=var)

                    self.gf_names[key] = gfpath
                    self.gfs[key] = gfs
Esempio n. 2
0
        #stime = num.round(starttime / starttime_sampling) * starttime_sampling
        patch.update(slip=float(slip), time=event.time + float(starttime))
        # print(patch)

# synthetics generation
engine = gf.LocalEngine(store_superdirs=store_superdirs)

patchidx = fault.patchmap(
    index=0, dipidx=nuc_dip_idx, strikeidx=nuc_strike_idx)

targets = sc.wavemaps[0].targets
filterer = sc.wavemaps[0].config.filterer
ntargets = len(targets)

gfs = ffi.load_gf_library(
    directory=project_dir + '/ffi/linear_gfs/',
    filename='seismic_uparr_any_P_0')
ats = gfs.reference_times - arrival_taper.b

traces, tmins = heart.seis_synthetics(
    engine, patches, targets, arrival_times=ats,
    wavename='any_P', arrival_taper=arrival_taper,
    filterer=filterer, outmode='stacked_traces')

targetidxs = num.lib.index_tricks.s_[:]

if False:
    # for station corrections maybe in the future?
    station_corrections = num.zeros(len(traces))
    starttimes = (num.tile(starttimes, ntargets) + num.repeat(
        station_corrections, fault.npatches)).reshape(