fitting
fit_tods(model, todvec, maxiter=10, chitol=1e-05)
Fit a model to TODs. This uses a modified Levenberg–Marquardt fitter with flat priors. This function is MPI aware.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Model
|
The model object that defines the model and grid we are fitting with. |
required |
todvec
|
TODVec
|
The TODs to fit.
The |
required |
maxiter
|
int
|
The maximum number of iterations to fit. |
10
|
chitol
|
float
|
The delta chisq to use as the convergence criteria. |
1e-5
|
Returns:
Name | Type | Description |
---|---|---|
model |
Model
|
Model with the final set of fit parameters, errors, and chisq. |
final_iter |
int
|
The number of iterations the fitter ran for. |
delta_chisq |
float
|
The final delta chisq. |
Source code in witch/fitting.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
|
invsafe(matrix, thresh=1e-14)
Safe SVD based psuedo-inversion of the matrix. This zeros out modes that are too small when inverting. Use with caution in cases where you really care about what the inverse is.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Array
|
The matrix to invert.
Should be a |
required |
thresh
|
float
|
Threshold at which to zero out a mode. |
1e-14
|
Returns:
Name | Type | Description |
---|---|---|
invmat |
Array
|
The inverted matrix.
Same shape as |
Source code in witch/fitting.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
invscale(matrix, thresh=1e-14)
Invert and rescale a matrix by the diagonal.
This uses invsafe
for the inversion.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Parameters
|
|
required | |
matrix
|
Array
|
The matrix to invert and sxane.
Should be a |
required |
thresh
|
float
|
Threshold for |
1e-14
|
Returns:
Name | Type | Description |
---|---|---|
invmat |
Array
|
The inverted and rescaled matrix.
Same shape as |
Source code in witch/fitting.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
objective(pars, model, todvec, errs)
Objective function to minimize when fitting. This is also responsible for updating our model with the current guess. This is an MPI aware function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pars
|
Array
|
New parameters for our model. |
required |
model
|
Model
|
The model object we are using to fit. |
required |
todvec
|
TODVec
|
The TODs to fit against. This is what we use to compute our fit residuals. |
required |
errs
|
Array
|
The error on |
required |
Returns:
Name | Type | Description |
---|---|---|
new_model |
Model
|
An updated model object.
This contains the newly computed |
grad |
Array
|
The gradient of the paramaters at there current values.
This is a |
curve |
Array
|
The curvature of the parameter space at the current values.
This is a |
Source code in witch/fitting.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|