Example #1
0
    def save(self,
             dict,
             path,
             parameters=['vp', 'vs', 'rho'],
             prefix='',
             suffix=''):
        """ 
          Saves SPECFEM2D/3D models or kernels

          :input dict :: model stored as a dictionary or Container
          :input path :: directory to which model is written
          :input parameters :: list of material parameters to be written
          :input prefix :: optional filename prefix
          :input suffix :: optional filename suffix, eg '_kernel'
        """
        unix.mkdir(path)

        # fill in any missing parameters
        missing_keys = diff(parameters, dict.keys())
        for iproc in range(self.mesh_properties.nproc):
            for key in missing_keys:
                dict[key] += self.io.read_slice(PATH.MODEL_INIT,
                                                prefix + key + suffix, iproc)

        # write slices to disk
        for iproc in range(self.mesh_properties.nproc):
            for key in parameters:
                self.io.write_slice(dict[key][iproc], path,
                                    prefix + key + suffix, iproc)
Example #2
0
    def save(self,
             dict,
             path,
             parameters=['vp', 'vs', 'rho'],
             prefix='',
             suffix=''):
        """ Writes SPECFEM model or kernels

          INPUT
              DICT - ModelDict object containing model
              PATH - the directory to which model is saved
              PARAMETERS - list of material parameters to be loaded
              PREFIX - optional filename prefix
              SUFFIX - optional filename suffix, eg '_kernel'
        """
        unix.mkdir(path)

        # fill in any missing parameters
        missing_keys = diff(parameters, dict.keys())
        for iproc in range(self.mesh_properties.nproc):
            for key in missing_keys:
                dict[key] += self.io.read_slice(PATH.MODEL_INIT,
                                                prefix + key + suffix, iproc)

        # write slices to disk
        for iproc in range(self.mesh_properties.nproc):
            for key in parameters:
                self.io.write_slice(dict[key][iproc], path,
                                    prefix + key + suffix, iproc)
Example #3
0
    def save(self, dict, path, parameters=['vp','vs','rho'],
             prefix='', suffix=''):
        """ 
          Saves SPECFEM2D/3D models or kernels

          :input dict :: model stored as a dictionary or Container
          :input path :: directory to which model is written
          :input parameters :: list of material parameters to be written
          :input prefix :: optional filename prefix
          :input suffix :: optional filename suffix, eg '_kernel'
        """
        unix.mkdir(path)

        # fill in any missing parameters
        missing_keys = diff(parameters, dict.keys())
        for iproc in range(self.mesh_properties.nproc):
            for key in missing_keys:
                dict[key] += self.io.read_slice(
                    PATH.MODEL_INIT, prefix+key+suffix, iproc)

        # write slices to disk
        for iproc in range(self.mesh_properties.nproc):
            for key in parameters:
                self.io.write_slice(
                    dict[key][iproc], path, prefix+key+suffix, iproc)
Example #4
0
    def save(self, dict, path, parameters=['vp','vs','rho'], prefix='', suffix=''):
        """ Writes SPECFEM model or kernels
        """
        unix.mkdir(path)

        # fill in missing parameters
        missing_keys = diff(parameters, dict.keys())
        for iproc in range(self.mesh_properties.nproc):
            for key in missing_keys:
                dict[key] += self.io.read_slice(
                    PATH.MODEL_INIT, prefix+key+suffix, iproc)

        # write model or kernel files to disk
        for iproc in range(self.mesh_properties.nproc):
            for key in parameters:
                self.io.write_slice(
                    dict[key][iproc], path, prefix+key+suffix, iproc)
Example #5
0
    def save(self, dict, path, parameters=['vp','vs','rho'], prefix='', suffix=''):
        """ Writes SPECFEM model or kernels

          INPUT
              DICT - ModelDict object containing model
              PATH - the directory to which model is saved
              PARAMETERS - list of material parameters to be loaded
              PREFIX - optional filename prefix
              SUFFIX - optional filename suffix, eg '_kernel'
        """
        unix.mkdir(path)

        # fill in any missing parameters
        missing_keys = diff(parameters, dict.keys())
        for iproc in range(self.mesh_properties.nproc):
            for key in missing_keys:
                dict[key] += self.io.read_slice(
                    PATH.MODEL_INIT, prefix+key+suffix, iproc)

        # write slices to disk
        for iproc in range(self.mesh_properties.nproc):
            for key in parameters:
                self.io.write_slice(
                    dict[key][iproc], path, prefix+key+suffix, iproc)