File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
src/easydiffraction/analysis Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -144,14 +144,24 @@ def _residual_function(self,
144
144
residuals : List [float ] = []
145
145
146
146
for (expt_id , experiment ), weight in zip (experiments ._items .items (), _weights ):
147
+
148
+ # Calculate the difference between measured and calculated patterns
147
149
y_calc : np .ndarray = calculator .calculate_pattern (sample_models ,
148
150
experiment ,
149
- called_by_minimizer = True ) # True False
151
+ called_by_minimizer = True )
150
152
y_meas : np .ndarray = experiment .datastore .pattern .meas
151
153
y_meas_su : np .ndarray = experiment .datastore .pattern .meas_su
152
- excluded : np .ndarray = experiment .datastore .pattern .excluded
153
- diff = ((y_meas - y_calc ) / y_meas_su )[~ excluded ] # Exclude points that are marked as excluded
154
- diff *= np .sqrt (weight ) # Residuals are squared before going into reduced chi-squared
154
+ diff = ((y_meas - y_calc ) / y_meas_su )
155
+
156
+ # Exclude points that are marked as excluded
157
+ excluded = experiment .datastore .pattern .excluded
158
+ if excluded is not None :
159
+ diff = diff [~ excluded ]
160
+
161
+ # Residuals are squared before going into reduced chi-squared
162
+ diff *= np .sqrt (weight )
163
+
164
+ # Append the residuals for this experiment
155
165
residuals .extend (diff )
156
166
157
167
return self .minimizer .tracker .track (np .array (residuals ), parameters )
You can’t perform that action at this time.
0 commit comments