Esempio n. 1
0
    def dm(self, dm):
        """
        Set a new model perturbation.

        Parameters
        ----------
        dm : float or array
            New model perturbation
        """
        # Update the square slowness according to new value
        if isinstance(dm, np.ndarray):
            if not isinstance(self._dm, Function):
                self._dm = self._gen_phys_param(dm, 'dm', self.space_order)
            elif dm.shape == self.shape:
                initialize_function(self._dm, dm, self.nbl)
            elif dm.shape == self.dm.shape:
                self.dm.data[:] = dm[:]
            else:
                raise ValueError("Incorrect input size %s for model of size" %
                                 dm.shape + " %s without or %s with padding" %
                                 (self.shape, self.dm.shape))
        else:
            try:
                self._dm.data = dm
            except AttributeError:
                self._dm = dm
Esempio n. 2
0
 def _gen_phys_param(self,
                     field,
                     name,
                     space_order,
                     is_param=False,
                     default_value=0,
                     func=lambda x: x):
     """
     Create symbolic object an initiliaze its data
     """
     if field is None:
         return func(default_value)
     if isinstance(field, np.ndarray) and (name == 'm' or
                                           np.min(field) != np.max(field)):
         function = Function(name=name,
                             grid=self.grid,
                             space_order=space_order,
                             parameter=is_param)
         if field.shape == self.shape:
             initialize_function(function, func(field), self.padsizes)
         else:
             function._data_with_outhalo[:] = func(field)
     else:
         return func(np.min(field))
     self._physical_parameters.append(name)
     return function
Esempio n. 3
0
    def m(self, m):
        """
        Set a new squared slowness model.

        Parameters
        ----------
        m : float or array
            New squared slowness in s^2/km^2.
        """
        # Update the square slowness according to new value
        if isinstance(m, np.ndarray):
            if m.shape == self.m.shape:
                self.m.data[:] = m[:]
            elif m.shape == self.shape:
                initialize_function(self._m, m, self.nbl)
            else:
                raise ValueError("Incorrect input size %s for model of size" %
                                 m.shape + " %s without or %s with padding" %
                                 (self.shape, self.m.shape))
        else:
            self._m.data = m
Esempio n. 4
0
    def vp(self, vp):
        """
        Set a new velocity model.

        Parameters
        ----------
        vp : float or array
            New velocity in km/s.
        """
        # Update the square slowness according to new value
        if isinstance(vp, np.ndarray):
            if vp.shape == self.vp.shape:
                self.vp.data[:] = vp[:]
            elif vp.shape == self.shape:
                initialize_function(self._vp, vp, self.nbl)
            else:
                raise ValueError("Incorrect input size %s for model of size" % vp.shape +
                                 " %s without or %s with padding" % (self.shape,
                                                                     self.vp.shape))
        else:
            self._vp.data = vp
Esempio n. 5
0
 def _gen_phys_param(self,
                     field,
                     name,
                     space_order,
                     is_param=False,
                     default_value=0,
                     func=lambda x: x):
     """
     Create symbolic object an initiliaze its data
     """
     if field is None:
         return default_value
     if isinstance(field, np.ndarray):
         function = Function(name=name,
                             grid=self.grid,
                             space_order=space_order,
                             parameter=is_param)
         initialize_function(function, field, self.nbl)
     else:
         return field
     self._physical_parameters.append(name)
     return function