# libyt API ```{toctree} :hidden: yt_initialize yt_set_parameters yt_set_userparameter field/yt_get_fieldsptr yt_get_particlesptr yt_get_gridsptr yt_getgridinfo yt_commit run-python-function yt_run_interactivemode yt_run_reloadscript yt_run_jupyterkernel yt_free yt_finalize data-type ``` ## Procedure It can break down into five stages: - initialization, - loading simulation data into Python[^1], - do in situ analysis, - free resources allocated by `libyt`, - and finalization. ## libyt API

Stage

libyt API

Description

Initialization

yt_initialize

Initialize embedded Python and import inline Python script.
Loading data

yt_set_Parameters, yt_set_UserParameter*

Set yt parameters and user specific parameters.

yt_get_FieldsPtr, yt_get_ParticlesPtr, yt_get_GridsPtr

Get fields, particles, and grids information array (ptr), and write corresponding data in.

yt_commit

Tell libyt you're done.
In situ analysis

yt_run_Function, yt_run_FunctionArguments

Run Python functions.

yt_run_InteractiveMode

Activate interactive prompt. This is only available in interactive mode.

yt_run_ReloadScript

Enter reloading script phase. This is only available in interactive mode.

yt_run_JupyterKernel

Activate interactive prompt. This is only available in Jupyter kernel mode.
Reset

yt_free

Free resources for in situ analysis.
Finalization

yt_finalize

Finalize libyt.
[^1]: {octicon}`calendar;1em;sd-text-secondary;` Currently, `libyt` only supports loading simulation data with adaptive mesh refinement grid structure ( AMR grid) to Python. We are trying to make `libyt` works with more data structure.