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
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
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
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
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
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 | |