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

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

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

revision 4386 by jfenwick, Tue Apr 30 02:58:02 2013 UTC revision 4393 by caltinay, Mon May 6 03:35:48 2013 UTC
# Line 44  class InversionCostFunction(MeteredCostF Line 44  class InversionCostFunction(MeteredCostF
44      defect cost functions involving a physical forward model using the      defect cost functions involving a physical forward model using the
45      physical parameter(s) *p* and *mu_f* is the trade-off factor for model f.      physical parameter(s) *p* and *mu_f* is the trade-off factor for model f.
46    
   
47      A forward model depends on a set of physical parameters *p* which are      A forward model depends on a set of physical parameters *p* which are
48      constructed from components of the level set function *m* via mappings.      constructed from components of the level set function *m* via mappings.
49    
# Line 61  class InversionCostFunction(MeteredCostF Line 60  class InversionCostFunction(MeteredCostF
60    
61           J=InversionCostFunction(Regularization(), mappings=[m0, m1], forward_models=[(f0, 0), (f1,1)])           J=InversionCostFunction(Regularization(), mappings=[m0, m1], forward_models=[(f0, 0), (f1,1)])
62    
63       Example 2 (two forward models on 2-valued level set)      Example 3 (two forward models on 2-valued level set)
64           m0=Mapping()           m0=Mapping()
65           m1=Mapping()           m1=Mapping()
66           f0=ForwardModel()           f0=ForwardModel()
# Line 86  class InversionCostFunction(MeteredCostF Line 85  class InversionCostFunction(MeteredCostF
85                           where the first component map defines a `Mapping` and                           where the first component map defines a `Mapping` and
86                           the second component *i* defines the index of the                           the second component *i* defines the index of the
87                           component of level set function to be used to                           component of level set function to be used to
88                           calculate the mapping. An item in the list can be just                           calculate the mapping. Items in the list may also be
89                           a `Mapping` object then the entire level set function                           just `Mapping` objects in which case the entire level
90                           function is fed into the `Mapping` (typically used for                           set function is fed into the `Mapping` (typically used
91                           a single-component level set function.                           for a single-component level set function.
92          :type mappings: ``list`` where each item is a ``tuple`` of `Mapping`          :type mappings: `Mapping` or ``list``
                         and ``int`` or just a `Mapping`  
93          :param forward_models: the forward models involved in the calculation          :param forward_models: the forward models involved in the calculation
94                                 of the cost function. This is a list of 2-tuples                                 of the cost function. This is a list of 2-tuples
95                                 *(f, ii)* where the first component f defines a                                 *(f, ii)* where the first component f defines a
96                                 `ForwardModel` and the second component *ii* a                                 `ForwardModel` and the second component *ii* a
97                                 list of indexes referring to the physical                                 list of indexes referring to the physical
98                                 parameters in the `mappings` list. The 2-tuple                                 parameters in the `mappings` list. The 2-tuple
99                                 can be replaced by a `ForwardModel` if a                                 can be replaced by a `ForwardModel` if the
100                                 `mappings` list as a single entry.                                 `mappings` list has a single entry.
101          :param forward_models: ``list`` where each item is ``tuple`` of          :param forward_models: `ForwardModel` or ``list``
                                `ForwardModel` and ``list`` of ``int`` or is  
                                `ForwardModel`.  
102          """          """
103          super(InversionCostFunction, self).__init__()          super(InversionCostFunction, self).__init__()
104          self.regularization=regularization          self.regularization=regularization
# Line 112  class InversionCostFunction(MeteredCostF Line 108  class InversionCostFunction(MeteredCostF
108          else:          else:
109               self.mappings = mappings               self.mappings = mappings
110    
111          if  isinstance(forward_models, ForwardModel):          if isinstance(forward_models, ForwardModel):
112              self.forward_models = [ forward_models ]              self.forward_models = [ forward_models ]
113          else:          else:
114              self.forward_models=forward_models              self.forward_models=forward_models
115            
116          trafo =  regularization.getCoordinateTransformation()          trafo = regularization.getCoordinateTransformation()
117          for m in self.forward_models :          for m in self.forward_models:
118           if not m[0].getCoordinateTransformation() == trafo:              if isinstance(m, ForwardModel):
119             raise ValueError("Coordinate transformation for regularization and model %m don't match.")                  F=m
120                else:
121                    F=m[0]
122                if not F.getCoordinateTransformation() == trafo:
123                    raise ValueError("Coordinate transformation for regularization and model don't match.")
124    
125          self.numMappings=len(self.mappings)          self.numMappings=len(self.mappings)
126          self.numModels=len(self.forward_models)          self.numModels=len(self.forward_models)

Legend:
Removed from v.4386  
changed lines
  Added in v.4393

  ViewVC Help
Powered by ViewVC 1.1.26