core
Core module for generating models and their gradients.
model = jax.jit(model, static_argnums=model_static)
module-attribute
Generically create models with substructure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xyz
|
tuple[Array, Array, Array, float, float]
|
Grid to compute model on.
See |
required |
n_structs
|
tuple[int, ...]
|
Number of each structure to use.
Should be in the same order as |
required |
n_rbins
|
tuple[int]
|
Number of rbins for each non-parametric model |
required |
dz
|
float
|
Factor to scale by while integrating. Should at least include the pixel size along the LOS. |
required |
to_run
|
tuple[bool, bool, bool, bool]
|
Which stages to run.
Should be a 5 element tuple of bools, see |
required |
*pars
|
Unpack[tuple[float, ...]]
|
1D container of model parameters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
model |
Array
|
The model with the specified substructure evaluated on the grid. |
model_grad = jax.jit(model_grad, static_argnums=model_grad_static)
module-attribute
A wrapper around model that also returns the gradients of the model.
Only the additional arguments are described here, see model for the others.
Note that the additional arguments are passed before the *params argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
argnums
|
tuple[int, ...]
|
The indices of the arguments to evaluate the gradient at. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
model |
Array
|
The model with the specified substructure evaluated on the grid. |
grad |
Array
|
The gradient of the model with respect to the model parameters.
Has shape |
make_to_run(stage_m1=True, stage_0=True, stage_1=True, stage_2=True)
Constructs the to_run tuple needed for calls to model and model_grad in the correct order.
This is genrally prefered over manual construction, if you need to contsruct manualy the order of parameters in
this function is the order of the to_run tuple.
Any stages that are set to False here will not be run when computing the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage_m1
|
bool
|
If True run stage -1. This is non-parametric models. |
True
|
stage_0
|
bool
|
If True run stage 0. This is 3D parametric models. |
True
|
stage_1
|
bool
|
If True run stage 1. This is 3D sub-structure. |
True
|
stage_2
|
bool
|
If True run stage 2. This is 2D structure. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
to_run |
tuple[bool, bool, bool, bool, bool, bool]
|
Which stages to run in the order needed for |
Source code in witch/core.py
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 267 | |
model3D(xyz, n_structs, n_rbins, params)
Generate a 3D profile from params on xyz.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xyz
|
tuple[Array, Array, Array, float, float]
|
Grid to compute model on.
See |
required |
n_structs
|
tuple[int, ...]
|
Number of each structure to use.
Should be in the same order as |
required |
n_rbins
|
tuple[int]
|
Number of rbins for each non-parametric model |
required |
params
|
Array
|
1D container of model parameters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
pressure |
Array
|
The 3D model with the specified substructure evaluated on the grid. |
Source code in witch/core.py
190 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 | |
stage2_model(xyz, n_structs, dz, *pars)
Only returns the second stage of the model. Used for visualizing shocks, etc. that can otherwise be hard to see in a model plot
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xyz
|
tuple[Array, Array, Array, float, float]
|
Grid to compute model on.
See |
required |
n_structs
|
tuple[int, ...]
|
Number of each structure to use.
Should be in the same order as |
required |
dz
|
float
|
Factor to scale by while integrating. Should at least include the pixel size along the LOS. |
required |
*pars
|
Unpack[tuple[float, ...]]
|
1D container of model parameters. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
model |
Array
|
The model with the specified substructure evaluated on the grid. No stage 3 structures are included. |
Source code in witch/core.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |