コード例 #1
0
ファイル: specfem2d.py プロジェクト: zyex1108/seisflows
    def check_solver_parameter_files(self):
        """ Checks solver parameters
        """
        nt = getpar('nt', cast=int)
        dt = getpar('deltat', cast=float)
        f0 = getpar('f0', file='DATA/SOURCE', cast=float)

        if nt != PAR.NT:
            if self.getnode == 0: print "WARNING: nt != PAR.NT"
            setpar('nt', PAR.NT)

        if dt != PAR.DT:
            if self.getnode == 0: print "WARNING: dt != PAR.DT"
            setpar('deltat', PAR.DT)

        if f0 != PAR.F0:
            if self.getnode == 0: print "WARNING: f0 != PAR.F0"
            setpar('f0', PAR.F0, file='DATA/SOURCE')

        if self.mesh_properties.nproc != PAR.NPROC:
            if self.getnode == 0:
                print 'Warning: mesh_properties.nproc != PAR.NPROC'

        if 'MULTIPLES' in PAR:
            if PAR.MULTIPLES:
                setpar('absorbtop', '.false.')
            else:
                setpar('absorbtop', '.true.')
コード例 #2
0
    def check_solver_parameter_files(self):
        """ Checks solver parameters
        """
        nt = getpar('nt', cast=int)
        dt = getpar('deltat', cast=float)
        f0 = getpar('f0', file='DATA/SOURCE', cast=float)

        if nt != PAR.NT:
            if system.getnode() == 0: print "WARNING: nt != PAR.NT"
            setpar('nt', PAR.NT)

        if dt != PAR.DT:
            if system.getnode() == 0: print "WARNING: dt != PAR.DT"
            setpar('deltat', PAR.DT)
        
        if f0 != PAR.F0:
            if system.getnode() == 0: print "WARNING: f0 != PAR.F0"
            setpar('f0', PAR.F0, file='DATA/SOURCE')

        if self.mesh.nproc != PAR.NPROC:
            if system.getnode() == 0:
                print 'WARNING: mesh.nproc != PAR.NPROC'


        if 'MULTIPLES' in PAR:
            if PAR.MULTIPLES:
                setpar('absorbtop', '.false.')
            else:
                setpar('absorbtop', '.true.')
コード例 #3
0
ファイル: specfem3d.py プロジェクト: HongjianFang/seisflows
    def generate_mesh(self, model_path=None, model_name=None, model_type='gll'):
        """ Performs meshing and database generation
        """
        assert(model_name)
        assert(model_type)

        self.initialize_solver_directories()
        unix.cd(self.getpath)

        if model_type in ['gll']:
            par = getpar('MODEL').strip()
            if par != 'gll':
                if self.getnode == 0:
                    print 'WARNING: Unexpected Par_file setting:'
                    print 'MODEL =', par
            
            assert(exists(model_path))
            self.check_mesh_properties(model_path)

            src = glob(model_path +'/'+ '*')
            dst = self.model_databases
            unix.cp(src, dst)

            self.call('bin/xmeshfem3D')
            self.call('bin/xgenerate_databases')
            self.export_model(PATH.OUTPUT +'/'+ model_name)

        else:
            raise NotImplementedError
コード例 #4
0
ファイル: specfem3d.py プロジェクト: zyex1108/seisflows
    def generate_mesh(self, model_path=None, model_name=None, model_type='gll'):
        """ Performs meshing and database generation
        """
        assert(model_name)
        assert(model_type)

        self.initialize_solver_directories()
        unix.cd(self.getpath)

        if model_type in ['gll']:
            par = getpar('MODEL').strip()
            if par != 'gll':
                if self.getnode == 0:
                    print 'WARNING: Unexpected Par_file setting:'
                    print 'MODEL =', par
            
            assert(exists(model_path))
            self.check_mesh_properties(model_path)

            src = glob(model_path +'/'+ '*')
            dst = self.model_databases
            unix.cp(src, dst)

            call_solver(system.mpiexec(), 'bin/xmeshfem3D')
            call_solver(system.mpiexec(), 'bin/xgenerate_databases')
            self.export_model(PATH.OUTPUT +'/'+ model_name)

        else:
            raise NotImplementedError
コード例 #5
0
ファイル: specfem3d.py プロジェクト: HongjianFang/seisflows
    def check_solver_parameter_files(self):
        """ Checks solver parameters
        """
        nt = getpar('NSTEP', cast=int)
        dt = getpar('DT', cast=float)

        if nt != PAR.NT:
            if self.getnode == 0: print "WARNING: nt != PAR.NT"
            setpar('NSTEP', PAR.NT)

        if dt != PAR.DT:
            if self.getnode == 0: print "WARNING: dt != PAR.DT"
            setpar('DT', PAR.DT)

        if self.mesh.nproc != PAR.NPROC:
            if self.getnode == 0:
                print 'Warning: mesh.nproc != PAR.NPROC'

        if 'MULTIPLES' in PAR:
            raise NotImplementedError
コード例 #6
0
ファイル: specfem3d.py プロジェクト: zyex1108/seisflows
    def check_solver_parameter_files(self):
        """ Checks solver parameters
        """
        nt = getpar('NSTEP', cast=int)
        dt = getpar('DT', cast=float)

        if nt != PAR.NT:
            if self.getnode == 0: print "WARNING: nt != PAR.NT"
            setpar('NSTEP', PAR.NT)

        if dt != PAR.DT:
            if self.getnode == 0: print "WARNING: dt != PAR.DT"
            setpar('DT', PAR.DT)

        if self.mesh_properties.nproc != PAR.NPROC:
            if self.getnode == 0:
                print 'Warning: mesh_properties.nproc != PAR.NPROC'

        if 'MULTIPLES' in PAR:
            raise NotImplementedError
コード例 #7
0
def write_sources(coords, path='.', ws=1., suffix=''):
    """ Writes source information to text file
    """
    sx, sy, sz = coords

    filename = findpath('seisflows.seistools') + '/' + 'specfem2d/SOURCE'
    with open(filename, 'r') as f:
        lines = f.readlines()

    filename = 'DATA/SOURCE' + suffix
    with open(filename, 'w') as f:
        f.writelines(lines)

    # adjust source coordinates
    setpar('xs', sx, filename)
    setpar('zs', sy, filename)
    #setpar('ts', ts[0], filename)

    # adjust source amplitude
    try:
        fs = float(getpar('factor', filename))
        fs *= ws
        setpar('factor', str(fs), filename)
    except:
        pass

    # adjust source wavelet
    if 1:
        # Ricker wavelet
        setpar('time_function_type', 1, filename)
    elif 0:
        # first derivative of Gaussian
        setpar('time_function_type', 2, filename)
    elif 0:
        # Gaussian
        setpar('time_function_type', 3, filename)
    elif 0:
        # Dirac
        setpar('time_function_type', 4, filename)
    elif 0:
        # Heaviside
        setpar('time_function_type', 5, filename)
コード例 #8
0
ファイル: specfem2d.py プロジェクト: HongjianFang/seisflows
def write_sources(par, hdr, path='.', suffix=''):
    """ Writes source information to text file
    """
    file = findpath('sesiflows.seistools') + '/' + 'specfem2d/SOURCE'
    with open(file, 'r') as f:
        lines = f.readlines()

    file = path + '/' + 'DATA/SOURCE' + suffix
    _writelines(file, lines)

    # adjust source coordinates
    setpar('xs', hdr.sx[0], file)
    setpar('zs', hdr.sy[0], file)
    setpar('ts', hdr.ts, file)

    # adjust source amplitude
    try:
        fs = float(getpar('factor', file))
        setpar('factor', str(fs*hdr.fs), file)
    except:
        pass

    # adjust source wavelet
    if 1:
        # Ricker wavelet
        setpar('time_function_type', 1, file)
    elif 0:
        # first derivative of Gaussian
        setpar('time_function_type', 2, file)
    elif 0:
        # Gaussian
        setpar('time_function_type', 3, file)
    elif 0:
        # Dirac
        setpar('time_function_type', 4, file)
    elif 0:
        # Heaviside
        setpar('time_function_type', 5, file)

    setpar('f0', par['F0'], file)
コード例 #9
0
ファイル: specfem2d.py プロジェクト: umairbinwaheed/seisflows
def write_sources(par, hdr, path='.', suffix=''):
    """ Writes source information to text file
    """
    file = findpath('seistools') + '/' + 'specfem2d/SOURCE'
    with open(file, 'r') as f:
        lines = f.readlines()

    file = path + '/' + 'DATA/SOURCE' + suffix
    _writelines(file, lines)

    # adjust source coordinates
    setpar('xs', hdr.sx[0], file)
    setpar('zs', hdr.sy[0], file)
    setpar('ts', hdr.ts, file)

    # adjust source amplitude
    try:
        fs = float(getpar('factor', file))
        setpar('factor', str(fs * hdr.fs), file)
    except:
        pass

    # adjust source wavelet
    if 1:
        # Ricker wavelet
        setpar('time_function_type', 1, file)
    elif 0:
        # first derivative of Gaussian
        setpar('time_function_type', 2, file)
    elif 0:
        # Gaussian
        setpar('time_function_type', 3, file)
    elif 0:
        # Dirac
        setpar('time_function_type', 4, file)
    elif 0:
        # Heaviside
        setpar('time_function_type', 5, file)

    setpar('f0', par['F0'], file)
コード例 #10
0
ファイル: specfem2d.py プロジェクト: iceseismic/seisflows
def write_sources(par, hdr, path=".", suffix=""):
    """ Writes source information to text file
    """
    file = findpath("seistools") + "/" + "specfem2d/SOURCE"
    with open(file, "r") as f:
        lines = f.readlines()

    file = path + "/" + "DATA/SOURCE" + suffix
    _writelines(file, lines)

    # adjust source coordinates
    setpar("xs", hdr.sx[0], file)
    setpar("zs", hdr.sy[0], file)
    setpar("ts", hdr.ts, file)

    # adjust source amplitude
    try:
        fs = float(getpar("factor", file))
        setpar("factor", str(fs * hdr.fs), file)
    except:
        pass

    # adjust source wavelet
    if 1:
        # Ricker wavelet
        setpar("time_function_type", 1, file)
    elif 0:
        # first derivative of Gaussian
        setpar("time_function_type", 2, file)
    elif 0:
        # Gaussian
        setpar("time_function_type", 3, file)
    elif 0:
        # Dirac
        setpar("time_function_type", 4, file)
    elif 0:
        # Heaviside
        setpar("time_function_type", 5, file)

    setpar("f0", par["F0"], file)