File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,13 +121,40 @@ def initialize(self):
121121 dmisfit .simulation .coordinate_system = self .mode
122122
123123 def endIter (self ):
124+
125+ model = self .invProb .model .copy ()
126+
127+ # Project bounds
128+ if self .mode == "cartesian" and np .any (~ np .isinf (self .opt .upper )):
129+ vec_model = []
130+ indices = []
131+ upper_bound = []
132+ for reg in self .regularizations .objfcts :
133+ vec_model .append (reg .mapping * model )
134+ upper_bound .append (reg .mapping * self .opt .upper )
135+ mapping = reg .mapping .deriv (np .zeros (reg .mapping .shape [1 ]))
136+ indices .append (mapping .indices )
137+
138+ amplitude = np .linalg .norm (np .vstack (vec_model ), axis = 0 )
139+ upper_bound = np .hstack (upper_bound )
140+ upper_bound = np .max (upper_bound [~ np .isinf (upper_bound )])
141+ out_bound = amplitude > upper_bound
142+
143+ if np .any (out_bound ):
144+ scale = upper_bound / amplitude
145+ for ind in indices :
146+ model [ind ] *= scale
147+
148+ self .invProb .model = model
149+ self .opt .xc = model
150+
124151 if (
125152 self .invProb .phi_d < self .target
126153 ) and self .mode == "cartesian" : # and self.inversion_type == 'mvis':
127154 print ("Switching MVI to spherical coordinates" )
128155 self .mode = "spherical"
129- self .cartesian_model = self . invProb . model
130- model = self . invProb . model . copy ()
156+ self .cartesian_model = model
157+
131158 vec_model = []
132159 vec_ref = []
133160 indices = []
You can’t perform that action at this time.
0 commit comments