/[escript]/trunk/downunder/py_src/domainbuilder.py
ViewVC logotype

Diff of /trunk/downunder/py_src/domainbuilder.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4145 by caltinay, Fri Jan 18 00:51:49 2013 UTC revision 4150 by caltinay, Mon Jan 21 04:14:24 2013 UTC
# Line 66  class DomainBuilder(object): Line 66  class DomainBuilder(object):
66          :param source: The data source to be added          :param source: The data source to be added
67          :type source: `DataSource`          :type source: `DataSource`
68          """          """
69            if self.__domain is not None:
70                raise RuntimeError("Invalid call to addSource(). Domain is already built.")
71          if not isinstance(source, DataSource):          if not isinstance(source, DataSource):
72              raise TypeError("source is not a DataSource")              raise TypeError("source is not a DataSource")
73          self.__sources.append(source)          self.__sources.append(source)
# Line 75  class DomainBuilder(object): Line 77  class DomainBuilder(object):
77          Sets the amount of padding around the dataset as a fraction of the          Sets the amount of padding around the dataset as a fraction of the
78          dataset side lengths.          dataset side lengths.
79    
80          For example, calling ``setFractionalPadding(0.2, 0.1)`` to a data          For example, calling ``setFractionalPadding(0.2, 0.1)`` with a data
81          source with size 10x20 will result in the padded data set size          source of size 10x20 will result in the padded data set size
82          14x24 (10*(1+2*0.2), 20*(1+2*0.1))          14x24 (10*(1+2*0.2), 20*(1+2*0.1))
83    
84          :param pad_x: Padding per side in x direction (default: no padding)          :param pad_x: Padding per side in x direction (default: no padding)
85          :type pad_x: ``float``          :type pad_x: ``float``
86          :param pad_y: Padding per side in y direction (default: no padding)          :param pad_y: Padding per side in y direction (default: no padding)
87          :type pad_y: ``float``          :type pad_y: ``float``
88          :note: `pad_y` is ignored for 2-dimensional datasets.          :note: `pad_y` is ignored for 2-dimensional domains.
89          """          """
90            if self.__domain is not None:
91                raise RuntimeError("Invalid call to setFractionalPadding(). Domain is already built.")
92          if pad_x is not None:          if pad_x is not None:
93              if pad_x < 0:              if pad_x < 0:
94                  raise ValueError("setFractionalPadding: Arguments must be non-negative")                  raise ValueError("setFractionalPadding: Arguments must be non-negative")
# Line 109  class DomainBuilder(object): Line 113  class DomainBuilder(object):
113          :type pad_x: ``float``          :type pad_x: ``float``
114          :param pad_y: Padding per side in y direction (default: no padding)          :param pad_y: Padding per side in y direction (default: no padding)
115          :type pad_y: ``float``          :type pad_y: ``float``
116          :note: `pad_y` is ignored for 2-dimensional datasets.          :note: `pad_y` is ignored for 2-dimensional domains.
117          """          """
118            if self.__domain is not None:
119                raise RuntimeError("Invalid call to setPadding(). Domain is already built.")
120          if pad_x is not None:          if pad_x is not None:
121              if pad_x < 0:              if pad_x < 0:
122                  raise ValueError("setPadding: Arguments must be non-negative")                  raise ValueError("setPadding: Arguments must be non-negative")
# Line 134  class DomainBuilder(object): Line 140  class DomainBuilder(object):
140          :type pad_y: ``int``          :type pad_y: ``int``
141          :note: `pad_y` is ignored for 2-dimensional datasets.          :note: `pad_y` is ignored for 2-dimensional datasets.
142          """          """
143            if self.__domain is not None:
144                raise RuntimeError("Invalid call to setElementPadding(). Domain is already built.")
145          if pad_x is not None:          if pad_x is not None:
146              if type(pad_x) is not int:              if type(pad_x) is not int:
147                  raise TypeError("setElementPadding expects integer arguments")                  raise TypeError("setElementPadding expects integer arguments")
# Line 176  class DomainBuilder(object): Line 184  class DomainBuilder(object):
184          Returns a list of `Data` objects for all surveys of type `datatype`          Returns a list of `Data` objects for all surveys of type `datatype`
185          available to this domain builder.          available to this domain builder.
186    
187          :return: List of gravity surveys which are tuples (anomaly,error).          :return: List of surveys which are tuples (anomaly,error).
188          :rtype: ``list``          :rtype: ``list``
189          """          """
190          surveys=[]          surveys=[]
# Line 203  class DomainBuilder(object): Line 211  class DomainBuilder(object):
211              return np.array([-B[1], -B[2], -B[0]])              return np.array([-B[1], -B[2], -B[0]])
212    
213      def getSetDensityMask(self):      def getSetDensityMask(self):
214            """
215            Returns the density mask data object which is non-zero for cells
216            whose density value is fixed, zero otherwise.
217            """
218          z=self.getDomain().getX()[self.__dim-1]          z=self.getDomain().getX()[self.__dim-1]
219          m = whereNonNegative(z)          m = whereNonNegative(z)
220          if self.__fix_density_below:          if self.__fix_density_below:
# Line 210  class DomainBuilder(object): Line 222  class DomainBuilder(object):
222          return m          return m
223    
224      def getSetSusceptibilityMask(self):      def getSetSusceptibilityMask(self):
225            """
226            Returns the susceptibility mask data object which is non-zero for
227            cells whose susceptibility value is fixed, zero otherwise.
228            """
229          z=self.getDomain().getX()[self.__dim-1]          z=self.getDomain().getX()[self.__dim-1]
230          m = whereNonNegative(z)          m = whereNonNegative(z)
231          if self.__fix_susceptibility_below:          if self.__fix_susceptibility_below:
# Line 244  class DomainBuilder(object): Line 260  class DomainBuilder(object):
260                            dimension                            dimension
261          :type num_cells: ``int``          :type num_cells: ``int``
262          """          """
263            if self.__domain is not None:
264                raise RuntimeError("Invalid call to setVerticalExtents(). Domain is already built.")
265          self._v_depth=depth          self._v_depth=depth
266          self._v_air_layer=air_layer          self._v_air_layer=air_layer
267          self._v_num_cells=num_cells          self._v_num_cells=num_cells

Legend:
Removed from v.4145  
changed lines
  Added in v.4150

  ViewVC Help
Powered by ViewVC 1.1.26