/[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 4361 by gross, Wed Mar 27 06:44:36 2013 UTC revision 4362 by caltinay, Tue Apr 16 04:37:13 2013 UTC
# Line 64  class DomainBuilder(object): Line 64  class DomainBuilder(object):
64          Adds a survey data provider to the domain builder.          Adds a survey data provider to the domain builder.
65          An exception is raised if the domain has already been built or if the          An exception is raised if the domain has already been built or if the
66          UTM zone of `source` does not match the UTM zone of sources already          UTM zone of `source` does not match the UTM zone of sources already
67          added to the domain builder.          added to the domain builder (see Inversion Cookbook for more
68            information). An exception is also raised if the dimensionality of the
69            data source is incompatible with this domain builder. That is, the
70            dimensionality of the data must be one less than the dimensionality
71            of the domain (specified in the constructor).
72    
73          :param source: The data source to be added          :param source: The data source to be added
74          :type source: `DataSource`          :type source: `DataSource`
# Line 74  class DomainBuilder(object): Line 78  class DomainBuilder(object):
78          if not isinstance(source, DataSource):          if not isinstance(source, DataSource):
79              raise TypeError("source is not a DataSource")              raise TypeError("source is not a DataSource")
80    
81            DATA_DIM = len(source.getDataExtents()[0])
82            if DATA_DIM != self.__dim-1:
83                raise ValueError("Data must be %d-dimensional."%(self.__dim-1))
84          if len(self.__sources)>0:          if len(self.__sources)>0:
85              if self.__sources[0].getUtmZone() != source.getUtmZone():              if self.__sources[0].getUtmZone() != source.getUtmZone():
86                  raise ValueError("It is not possible to combine data sources located in different UTM zones at the moment.")                  raise ValueError("It is not possible to combine data sources located in different UTM zones at the moment.")
# Line 285  class DomainBuilder(object): Line 292  class DomainBuilder(object):
292    
293      def __getTotalExtentsWithPadding(self):      def __getTotalExtentsWithPadding(self):
294          """          """
295          Helper method that computes origin and number of elements          Helper method that computes origin and number of data elements
296          after adding padding to the bounding box of all available survey data.          after adding padding to the bounding box of all available survey data.
297          """          """
298          X0, NX, DX = self.__getTotalExtents()          X0, NX, DX = self.__getTotalExtents()
299          DIM=len(X0)          DATA_DIM=len(X0)
300          frac=[]          frac=[]
301          # padding is applied to each side so multiply by 2 to get the total          # padding is applied to each side so multiply by 2 to get the total
302          # amount of padding per dimension          # amount of padding per dimension
303          pad, pt = self._padding          pad, pt = self._padding
304          for i in range(DIM):          for i in range(DATA_DIM):
305              if pad[i] is None:              if pad[i] is None:
306                  frac.append(0.)                  frac.append(0.)
307                  continue                  continue
# Line 307  class DomainBuilder(object): Line 314  class DomainBuilder(object):
314                  frac.append(2.*f/float(NX[i]))                  frac.append(2.*f/float(NX[i]))
315    
316          # calculate new number of elements          # calculate new number of elements
317          NX_padded=[int(round(NX[i]*(1+frac[i]))) for i in range(DIM)]          NX_padded=[int(round(NX[i]*(1+frac[i]))) for i in range(DATA_DIM)]
318          NXdiff=[NX_padded[i]-NX[i] for i in range(DIM)]          NXdiff=[NX_padded[i]-NX[i] for i in range(DATA_DIM)]
319          X0_padded=[X0[i]-NXdiff[i]/2.*DX[i] for i in range(DIM)]          X0_padded=[X0[i]-NXdiff[i]/2.*DX[i] for i in range(DATA_DIM)]
320          return X0_padded, NX_padded, DX          return X0_padded, NX_padded, DX
321    
322      def __getTotalExtents(self):      def __getTotalExtents(self):

Legend:
Removed from v.4361  
changed lines
  Added in v.4362

  ViewVC Help
Powered by ViewVC 1.1.26