Skip to content

Commit

Permalink
docs: update coeval and lightcone tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-murray committed Dec 24, 2024
1 parent 5fd5117 commit 6b894c8
Show file tree
Hide file tree
Showing 4 changed files with 783 additions and 892 deletions.
16 changes: 16 additions & 0 deletions docs/faqs/misc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,19 @@ while the globally averaged quantities are in the ``global_quantities`` group::
redshifts = fl['node_redshifts']

plt.plot(redshifts, global_Tb)

Can I instantiate my own OutputStruct objects?
-------------------------------------------
Usually, you create instances of an :class:`py21cmfast.wrapper.outputs.OutputStruct`
object by running either :func:`py21cmfast.run_coeval` or some lower-level function,
like :func:`py21cmfast.compute_initial_conditions`. However, it's possible you want to
switch out a simulation step from ``21cmFAST`` and insert your own, but then go on using
that box in further ``21cmFAST`` simulation components. The way to do this is as follows,
using the ``InitialConditions`` as an example::

ics = p21c.InitialConditions.new(inputs=p21c.InputParameters())
ics.set('lowres_density', my_computed_value)

You would use this ``.set()`` method on each of the fields you needed to set. Now this
data should be properly shared with the backend C-code, and the object can be used
in subsequent steps within ``21cmFAST``.
1,384 changes: 601 additions & 783 deletions docs/tutorials/coeval_cubes.ipynb

Large diffs are not rendered by default.

268 changes: 159 additions & 109 deletions docs/tutorials/lightcones.ipynb

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/py21cmfast/run_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def _construct_param_objects(template_dict, **kwargs):
return input_dict


def list_templates() -> list[dict]:
"""Return a list of the available templates."""
with open(TEMPLATE_PATH / "manifest.toml", "rb") as f:
manifest = tomllib.load(f)
return manifest["templates"]

Check warning on line 49 in src/py21cmfast/run_templates.py

View check run for this annotation

Codecov / codecov/patch

src/py21cmfast/run_templates.py#L47-L49

Added lines #L47 - L49 were not covered by tests


def create_params_from_template(template_name: str, **kwargs):
"""
Constructs the required InputStruct instances for a run from a given template.
Expand Down

0 comments on commit 6b894c8

Please sign in to comment.