/[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 4657 by jfenwick, Thu Feb 6 06:12:20 2014 UTC revision 4729 by gross, Sat Mar 8 00:56:37 2014 UTC
# Line 33  from esys.ripley import Brick, Rectangle Line 33  from esys.ripley import Brick, Rectangle
33  from .datasources import DataSource  from .datasources import DataSource
34  from .coordinates import ReferenceSystem, CartesianReferenceSystem  from .coordinates import ReferenceSystem, CartesianReferenceSystem
35    
36    
37  class DomainBuilder(object):  class DomainBuilder(object):
38      """      """
39      This class is responsible for constructing an escript Domain object with      This class is responsible for constructing an escript Domain object with
# Line 75  class DomainBuilder(object): Line 76  class DomainBuilder(object):
76          self.__dim=dim          self.__dim=dim
77          self.__sources=[]          self.__sources=[]
78          self.__background_magnetic_field=None          self.__background_magnetic_field=None
79            self.__tags=[]   # list of all tags being used by all data sources beeing attached:
80          self.setElementPadding()          self.setElementPadding()
81          self.setVerticalExtents()          self.setVerticalExtents()
82          self.fixDensityBelow()          self.fixDensityBelow()
83          self.fixSusceptibilityBelow()          self.fixSusceptibilityBelow()
84            self.fixVelocityBelow()
85                    
86      def getReferenceSystem(self):      def getReferenceSystem(self):
87          """          """
# Line 87  class DomainBuilder(object): Line 90  class DomainBuilder(object):
90          :rtype: `ReferenceSystem`          :rtype: `ReferenceSystem`
91          """          """
92          return self.__reference_system          return self.__reference_system
93                def getTags(self):
94            """
95            returns a list of all tags beeing used by the attached data sources.
96            the list may be empty.
97            """
98            return self.__tags
99                
100      def addSource(self, source):      def addSource(self, source):
101          """          """
102          Adds a survey data provider to the domain builder.          Adds a survey data provider to the domain builder.
# Line 118  class DomainBuilder(object): Line 127  class DomainBuilder(object):
127                  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.")
128    
129          self.__sources.append(source)          self.__sources.append(source)
130            if source.getTags(): self.__tags=list(set(self.__tags + source.getTags()))
131    
132      def setFractionalPadding(self, pad_x=None, pad_y=None, pad_lat=None, pad_lon=None):      def setFractionalPadding(self, pad_x=None, pad_y=None, pad_lat=None, pad_lon=None):
133          """          """
# Line 268  class DomainBuilder(object): Line 278  class DomainBuilder(object):
278          """          """
279          return self.getSurveys(DataSource.MAGNETIC)          return self.getSurveys(DataSource.MAGNETIC)
280    
281            
282      def fixDensityBelow(self, depth=None):      def fixDensityBelow(self, depth=None):
283          """          """
284          Defines the depth below which the density anomaly is set to a given          Defines the depth below which the density anomaly is set to a given
# Line 290  class DomainBuilder(object): Line 301  class DomainBuilder(object):
301          """          """
302          self.__fix_susceptibility_below=depth          self.__fix_susceptibility_below=depth
303    
304      def getSurveys(self, datatype):      def fixVelocityBelow(self, depth=None):
305            """
306            Defines the depth below which the velocity and Q index is set to a
307            given value. If no value is given zero is assumed.
308            
309            :param depth: depth below which the velocity is fixed. If not
310                          set, no constraint at depth is applied.
311            :type depth: ``float``
312            """
313            self.__fix_velocity_below=depth
314    
315    
316        def getSurveys(self, datatype, tags=None):
317          """          """
318          Returns a list of `Data` objects for all surveys of type `datatype`          Returns a list of `Data` objects for all surveys of type `datatype`
319          available to this domain builder.          available to this domain builder. If a list of `tags` is given
320            only data sources whose tag matching the tag list are returned
321    
322          :return: List of surveys which are tuples (anomaly,error).          :return: List of surveys which are tuples (anomaly,error).
323          :rtype: ``list``          :rtype: ``list``
# Line 301  class DomainBuilder(object): Line 325  class DomainBuilder(object):
325          surveys=[]          surveys=[]
326          for src in self.__sources:          for src in self.__sources:
327              if src.getDataType()==datatype:              if src.getDataType()==datatype:
328                  surveys.append(src.getSurveyData(self.getDomain(), self._dom_origin, self._dom_NE, self._spacing))                  if tags is None or ( src.getTags() is not None and all( [ t in tags for t in src.getTags() ] )  ) :
329                        surveys.append(src.getSurveyData(self.getDomain(), self._dom_origin, self._dom_NE, self._spacing))
330          return surveys          return surveys
331    
332      def setBackgroundMagneticFluxDensity(self, B):      def setBackgroundMagneticFluxDensity(self, B):

Legend:
Removed from v.4657  
changed lines
  Added in v.4729

  ViewVC Help
Powered by ViewVC 1.1.26