Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: add basename for loaders #4363

Merged
merged 8 commits into from
Mar 30, 2023
Merged
Changes from 6 commits
Commits
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
36 changes: 27 additions & 9 deletions yt/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def load_uniform_grid(
axis_order: Optional[AxisOrder] = None,
cell_widths=None,
parameters=None,
basename: str = "UniformGridData",
):
r"""Load a uniform grid of data into yt as a
:class:`~yt.frontends.stream.data_structures.StreamHandler`.
Expand Down Expand Up @@ -268,6 +269,8 @@ def load_uniform_grid(
parameters: dictionary, optional
Optional dictionary used to populate the dataset parameters, useful
for storing dataset metadata.
basename: string, optional
Optional string used to assign a basename to the dataset.

Examples
--------
Expand Down Expand Up @@ -385,7 +388,7 @@ def load_uniform_grid(
parameters=parameters,
)

handler.name = "UniformGridData" # type: ignore [attr-defined]
handler.name = basename # type: ignore [attr-defined]
handler.domain_left_edge = domain_left_edge # type: ignore [attr-defined]
handler.domain_right_edge = domain_right_edge # type: ignore [attr-defined]
handler.refine_by = 2 # type: ignore [attr-defined]
Expand Down Expand Up @@ -433,6 +436,7 @@ def load_amr_grids(
default_species_fields=None,
*,
parameters=None,
basename: str = "AMRGridData",
axis_order: Optional[AxisOrder] = None,
):
r"""Load a set of grids of data into yt as a
Expand Down Expand Up @@ -499,12 +503,14 @@ def load_amr_grids(
default_species_fields : string, optional
If set, default species fields are created for H and He which also
determine the mean molecular weight. Options are "ionized" and "neutral".
axis_order: tuple of three strings, optional
Force axis ordering, e.g. ("z", "y", "x") with cartesian geometry
Otherwise use geometry-specific default ordering.
parameters: dictionary, optional
Optional dictionary used to populate the dataset parameters, useful
for storing dataset metadata.
basename: string, optional
Optional string used to assign a basename to the dataset.
axis_order: tuple of three strings, optional
Force axis ordering, e.g. ("z", "y", "x") with cartesian geometry
Otherwise use geometry-specific default ordering.

Examples
--------
Expand Down Expand Up @@ -626,7 +632,7 @@ def load_amr_grids(
parameters=parameters,
)

handler.name = "AMRGridData" # type: ignore [attr-defined]
handler.name = basename # type: ignore [attr-defined]
handler.domain_left_edge = domain_left_edge # type: ignore [attr-defined]
handler.domain_right_edge = domain_right_edge # type: ignore [attr-defined]
handler.refine_by = refine_by # type: ignore [attr-defined]
Expand Down Expand Up @@ -668,6 +674,7 @@ def load_particles(
*,
axis_order: Optional[AxisOrder] = None,
parameters=None,
basename: str = "ParticleData",
):
r"""Load a set of particles into yt as a
:class:`~yt.frontends.stream.data_structures.StreamParticleHandler`.
Expand Down Expand Up @@ -723,6 +730,8 @@ def load_particles(
parameters: dictionary, optional
Optional dictionary used to populate the dataset parameters, useful
for storing dataset metadata.
basename: string, optional
Optional string used to assign a basename to the dataset.

Examples
--------
Expand Down Expand Up @@ -821,7 +830,7 @@ def parse_unit(unit, dimension):
parameters=parameters,
)

handler.name = "ParticleData" # type: ignore [attr-defined]
handler.name = basename # type: ignore [attr-defined]
handler.domain_left_edge = domain_left_edge # type: ignore [attr-defined]
handler.domain_right_edge = domain_right_edge # type: ignore [attr-defined]
handler.refine_by = 2 # type: ignore [attr-defined]
Expand Down Expand Up @@ -858,6 +867,7 @@ def load_hexahedral_mesh(
*,
axis_order: Optional[AxisOrder] = None,
parameters=None,
basename: str = "HexahedralMeshData",
):
r"""Load a hexahedral mesh of data into yt as a
:class:`~yt.frontends.stream.data_structures.StreamHandler`.
Expand Down Expand Up @@ -915,6 +925,8 @@ def load_hexahedral_mesh(
parameters: dictionary, optional
Optional dictionary used to populate the dataset parameters, useful
for storing dataset metadata.
basename: string, optional
Optional string used to assign a basename to the dataset.
"""
from yt.frontends.stream.data_structures import (
StreamDictFieldHandler,
Expand Down Expand Up @@ -979,7 +991,7 @@ def load_hexahedral_mesh(
parameters=parameters,
)

handler.name = "HexahedralMeshData" # type: ignore [attr-defined]
handler.name = basename # type: ignore [attr-defined]
handler.domain_left_edge = domain_left_edge # type: ignore [attr-defined]
handler.domain_right_edge = domain_right_edge # type: ignore [attr-defined]
handler.refine_by = 2 # type: ignore [attr-defined]
Expand Down Expand Up @@ -1013,6 +1025,7 @@ def load_octree(
default_species_fields=None,
*,
parameters=None,
basename: str = "OctreeData",
):
r"""Load an octree mask into yt.

Expand Down Expand Up @@ -1063,6 +1076,8 @@ def load_octree(
parameters: dictionary, optional
Optional dictionary used to populate the dataset parameters, useful
for storing dataset metadata.
basename : string, optional
Optional string used to assign a basename to the dataset.

Example
-------
Expand Down Expand Up @@ -1144,7 +1159,7 @@ def load_octree(
parameters=parameters,
)

handler.name = "OctreeData"
handler.name = basename
chrishavlin marked this conversation as resolved.
Show resolved Hide resolved
handler.domain_left_edge = domain_left_edge
handler.domain_right_edge = domain_right_edge
handler.refine_by = 2
Expand Down Expand Up @@ -1181,6 +1196,7 @@ def load_unstructured_mesh(
*,
axis_order: Optional[AxisOrder] = None,
parameters=None,
basename: str = "UnstructuredMeshData",
):
r"""Load an unstructured mesh of data into yt as a
:class:`~yt.frontends.stream.data_structures.StreamHandler`.
Expand Down Expand Up @@ -1258,6 +1274,8 @@ def load_unstructured_mesh(
parameters: dictionary, optional
Optional dictionary used to populate the dataset parameters, useful
for storing dataset metadata.
basename: string, optional
Optional string used to assign a basename to the dataset.

Examples
--------
Expand Down Expand Up @@ -1391,7 +1409,7 @@ def load_unstructured_mesh(
parameters=parameters,
)

handler.name = "UnstructuredMeshData" # type: ignore [attr-defined]
handler.name = basename # type: ignore [attr-defined]
handler.domain_left_edge = domain_left_edge # type: ignore [attr-defined]
handler.domain_right_edge = domain_right_edge # type: ignore [attr-defined]
handler.refine_by = 2 # type: ignore [attr-defined]
Expand Down