Skip to content
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
eacc9b7
Add Quokka dataset and hierarchy support with metadata and header par…
Rongjun-ANU Nov 20, 2024
cd0dab6
Rongjun update support for temperature, scalars, rad, velocities, BFi…
Rongjun-ANU Dec 10, 2024
f5acf45
add support of multiple particle types (#6)
Rongjun-ANU Dec 10, 2024
bd7dc58
Merge branch 'main' into Rongjun-ANUquokka-frontend
chongchonghe Dec 17, 2024
ae0dd25
further support for particles and their units (#8)
Rongjun-ANU Jan 7, 2025
cdb1997
clean up
chongchonghe Jan 14, 2025
6b45542
more cleanup
chongchonghe Jan 14, 2025
7910f07
Merge branch 'main' into Rongjun-ANUquokka-frontend
chongchonghe Jan 14, 2025
c7ad3e6
Rongjun read quokka metadata header (#10)
Rongjun-ANU Jan 14, 2025
0fefa61
rename Fields.json to Fields.yaml
Rongjun-ANU Mar 20, 2025
5988844
add quokka = ["PyYAML>=6.0.1"] (#13)
chongchonghe Mar 20, 2025
8aad9dc
Remove rebundancy (#14)
Rongjun-ANU Mar 20, 2025
9c1103d
supported structured metadata.yaml (#15)
chongchonghe Mar 21, 2025
7755781
add PyYAML to amrex (#16)
chongchonghe Mar 24, 2025
075769d
Chong/update-loading_data-rst (#17)
chongchonghe Mar 24, 2025
932b7c4
test_quokka (#19)
Rongjun-ANU Apr 27, 2025
5ad1e78
Add face-centered dataset support (#20)
chongchonghe May 15, 2025
60db2cf
Merge branch 'main' into Rongjun-ANUquokka-frontend
chongchonghe May 15, 2025
2250410
format
chongchonghe May 15, 2025
fa2289a
fix pre-commit.ci errors
chongchonghe May 15, 2025
8935ab7
fix lambda error
chongchonghe May 15, 2025
bf56f91
remove trailing white space
chongchonghe May 15, 2025
9997397
fix style issue
chongchonghe May 16, 2025
145d0ea
fix style
chongchonghe May 16, 2025
1542a02
pre-commit run all
chongchonghe May 16, 2025
75bfe3f
add tests of face-centered data
chongchonghe May 18, 2025
dfc69a8
rename dataset name
chongchonghe May 18, 2025
d6799ce
whitespace
chongchonghe May 18, 2025
581ad28
make PyYAML a dependency of Quokka only
chongchonghe Jun 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 176 additions & 0 deletions doc/source/examining/loading_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,182 @@ zero.
* Particles may be difficult to integrate.
* Data must already reside in memory.


.. _loading-quokka-data:

QUOKKA Data
-----------

`QUOKKA <https://github.com/quokka-astro/quokka>`_ data is supported and cared
for by ChongChong He and Rongjun Huang. QUOKKA is based on the AMReX framework.
Uniform-grid and AMR datasets in cartesian coordinates and particle data are
fully supported.

A standard QUOKKA dataset includes the following components:

.. code-block:: bash

plt00007/
├── Level_0/ # QUOKKA data
├── Header # Dataset header information
├── metadata.yaml # Configuration file
├── XXX_particles/ # Optional, particle data (e.g., Rad or Sink)
│ ├── Fields.yaml # Particle field names and units
│ ├── Header
│ └── Level_0/

Loading QUOKKA data is straightforward with the ``load`` command:

.. code-block:: python

import yt

ds = yt.load("sample/RadBeam/plt00007")

Boxlib Fields and Units
^^^^^^^^^^^^^^^^^^^^^^^

The QUOKKA frontend is built upon the AMReX framework, which follows the BoxLib
data format. When a QUOKKA dataset is loaded, yt automatically:

- Detects and loads all available fields in the dataset from the ``Header`` file
- Maps the native field names to (field_type, field_name) tuples
- Assigns physical units based on metadata information

QUOKKA datasets include six mandatory gas fields:

.. code-block:: python

[
("boxlib", "gasDensity"),
("boxlib", "gasEnergy"),
("boxlib", "gasInternalEnergy"),
("boxlib", "x-GasMomentum"),
("boxlib", "y-GasMomentum"),
("boxlib", "z-GasMomentum"),
]

For simulations with radiative transfer, the following fields are also available:

.. code-block:: python

[
("boxlib", "radEnergy-Group0"),
("boxlib", "x-RadFlux-Group0"),
("boxlib", "y-RadFlux-Group0"),
("boxlib", "z-RadFlux-Group0"),
("boxlib", "radEnergy-Group1"),
("boxlib", "x-RadFlux-Group1"),
("boxlib", "y-RadFlux-Group1"),
("boxlib", "z-RadFlux-Group1"),
...,
]

To see all available native fields in your dataset, do ``print(ds.field_list)``.

Derived Fields
^^^^^^^^^^^^^

When a QUOKKA dataset is loaded by yt, the native fields are mapped to derived
fields with appropriate physical units. The frontend handles:

- Converting dimensionless native fields to physically meaningful units
- Creating convenient derived fields for analysis and visualization

You can view all available derived fields with ``print(ds.derived_field_list)``.
For example, the native ('boxlib', 'gasDensity') field is mapped to ('gas',
'density') with proper units:

.. code-block:: python

# Accessing density with units
print(ds.r[("boxlib", "gasDensity")])
print(ds.r[("gas", "density")])

.. code-block:: python

unyt_array([1.0, 1.0, 1.0, ..., 1.0, 1.0, 1.0], "code_mass/code_length**3")
unyt_array([1.0, 1.0, 1.0, ..., 1.0, 1.0, 1.0], "g/cm**3")

Particle Data
^^^^^^^^^^^^

QUOKKA supports various types of particle data. When particles are present,
they're stored in dedicated directories:

.. code-block:: bash

dataset_folder/
├── Level_0/
├── Header
├── metadata.yaml
├── XXX_particles/ # Particle fields (e.g., Rad or Sink or CIC)
│ ├── Fields.yaml # Particle field names and units
│ ├── Header
│ └── Level_0/

The particle types and fields are automatically detected and loaded. The
``Fields.yaml`` file defines particle field names and their units, which YT will
read and automatically convert to physical units.

To access particle data in your analysis:

.. code-block:: python

# Access particle data
ad = ds.all_data()

# print particle info
print(ds.parameters["particle_info"])

# List particle fields available for the selected particle type
print(ad["Rad_particles", "particle_position_x"])
print(ad["Rad_particles", "luminosity"])

# Convert to physical units
print(ad["Rad_particles", "luminosity"].to("erg/s"))

To annotate particles in a plot, use the ``annotate_particles`` method:

.. code-block:: python

yt.SlicePlot(ds, "z", ("gas", "density")).annotate_particles(
1, p_size=400.0, col="blue", marker="*", ptype="Rad_particles"
)

Face-Centered Variables
^^^^^^^^^^^^^^^^^^^^^^^

QUOKKA datasets can also include face-centered variables. These are stored in
the ``fc_vars`` directory which is inside the plotfile directory. When loading a
Quokka dataset, YT automatically detects and loads any face-centered variables
from the ``fc_vars/x*****``, ``fc_vars/y*****``, and ``fc_vars/z*****``
subdirectories. These are made available as attributes of the main dataset
(``ds.ds_fc_x``, ``ds.ds_fc_y``, ``ds.ds_fc_z``). Each face-centered dataset is a full
YT dataset object with its own fields and mesh structure, and includes a
reference back to the parent dataset, ``ds.ds_fc_x.parent_ds``. This allows for
easy access to both cell-centered and face-centered data in the same analysis
workflow.

Support for Legacy Datasets
^^^^^^^^^^^^^^^^^^^^^^^^^^^

The ``metadata.yaml`` file is the key to determining if a dataset is a QUOKKA
data object. For data generated by early versions of QUOKKA that might be
missing this file, you can bypass metadata parsing:

.. code-block:: python

from yt.frontends.amrex.data_structures import QuokkaDataset


class OldQuokkaDataset(QuokkaDataset):
def _parse_metadata_file(self):
pass


ds_old = OldQuokkaDataset("sample/RadBeam/plt007")

.. _loading-semi-structured-mesh-data:

Semi-Structured Grid Data
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Fortran = ["f90nml>=1.1"]
# We also normalize all target names to lower case for consistency.
adaptahop = []
ahf = []
amrex = []
amrex = ["PyYAML>=6.0.1"]
amrvac = ["yt[Fortran]"]
art = []
arepo = ["yt[HDF5]"]
Expand Down Expand Up @@ -121,6 +121,7 @@ open-pmd = ["yt[HDF5]"]
owls = ["yt[HDF5]"]
owls-subfind = ["yt[HDF5]"]
parthenon = ["yt[HDF5]"]
quokka = ["PyYAML>=6.0.1"]
ramses = ["yt[Fortran]", "scipy"]
rockstar = []
sdf = ["requests>=2.20.0"]
Expand Down Expand Up @@ -181,6 +182,7 @@ full = [
"yt[owls]",
"yt[owls_subfind]",
"yt[parthenon]",
"yt[quokka]",
"yt[ramses]",
"yt[rockstar]",
"yt[sdf]",
Expand Down
3 changes: 3 additions & 0 deletions yt/frontends/amrex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
NyxHierarchy,
OrionDataset,
OrionHierarchy,
QuokkaDataset,
QuokkaHierarchy,
WarpXDataset,
WarpXHierarchy,
)
Expand All @@ -19,6 +21,7 @@
CastroFieldInfo,
MaestroFieldInfo,
NyxFieldInfo,
QuokkaFieldInfo,
WarpXFieldInfo,
)
from .io import IOHandlerBoxlib
Loading
Loading