From f9a954369ae68bb6e58367f9c503c24d66293a4d Mon Sep 17 00:00:00 2001 From: Forrest Glines Date: Thu, 1 Feb 2024 14:48:56 -0700 Subject: [PATCH 1/4] WIP: Fix order of cylindrical coords, GR broke --- yt/frontends/athena_pp/data_structures.py | 30 ++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/yt/frontends/athena_pp/data_structures.py b/yt/frontends/athena_pp/data_structures.py index 95ed790e1a..c9999daa9d 100644 --- a/yt/frontends/athena_pp/data_structures.py +++ b/yt/frontends/athena_pp/data_structures.py @@ -15,15 +15,20 @@ from .fields import AthenaPPFieldInfo +#geom_map = { +# "cartesian": "cartesian", +# "cylindrical": "cylindrical", +# "spherical_polar": "spherical", +# "minkowski": "cartesian", +# "tilted": "cartesian", +# "sinusoidal": "cartesian", +# "schwarzschild": "spherical", +# "kerr-schild": "spherical", +#} geom_map = { - "cartesian": "cartesian", - "cylindrical": "cylindrical", - "spherical_polar": "spherical", - "minkowski": "cartesian", - "tilted": "cartesian", - "sinusoidal": "cartesian", - "schwarzschild": "spherical", - "kerr-schild": "spherical", + "cartesian": (Geometry.CARTESIAN,("x","y","z")), + "cylindrical": (Geometry.CYLINDRICAL,("r","theta","z")), + "spherical_polar": (Geometry.SPHERICAL,("r","theta","phi")), } @@ -153,6 +158,11 @@ def __init__( zrat = self._handle.attrs["RootGridX3"][2] self._nonuniform = xrat != 1.0 or yrat != 1.0 or zrat != 1.0 self._magnetic_factor = get_magnetic_normalization(magnetic_normalization) + + geom = self._handle.attrs["Coordinates"].decode("utf-8") + self.geometry = geom_map[geom][0] + axis_order = geom_map[geom][1] + Dataset.__init__( self, filename, @@ -160,6 +170,7 @@ def __init__( units_override=units_override, unit_system=unit_system, default_species_fields=default_species_fields, + axis_order=axis_order ) if storage_filename is None: storage_filename = self.basename + ".yt" @@ -200,9 +211,6 @@ def _parse_parameter_file(self): self.domain_left_edge = np.array([xmin, ymin, zmin], dtype="float64") self.domain_right_edge = np.array([xmax, ymax, zmax], dtype="float64") - self.geometry = Geometry( - geom_map[self._handle.attrs["Coordinates"].decode("utf-8")] - ) self.domain_width = self.domain_right_edge - self.domain_left_edge self.domain_dimensions = self._handle.attrs["RootGridSize"] From 4c48783ca6f6d6e412279d1814ba2843dca5dbe2 Mon Sep 17 00:00:00 2001 From: Forrest Glines Date: Thu, 1 Feb 2024 21:51:29 -0700 Subject: [PATCH 2/4] Cleanup fix, make less intrusive. GR untouched --- yt/frontends/athena_pp/data_structures.py | 29 ++++++++++------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/yt/frontends/athena_pp/data_structures.py b/yt/frontends/athena_pp/data_structures.py index c9999daa9d..7e515d1fdc 100644 --- a/yt/frontends/athena_pp/data_structures.py +++ b/yt/frontends/athena_pp/data_structures.py @@ -15,23 +15,17 @@ from .fields import AthenaPPFieldInfo -#geom_map = { -# "cartesian": "cartesian", -# "cylindrical": "cylindrical", -# "spherical_polar": "spherical", -# "minkowski": "cartesian", -# "tilted": "cartesian", -# "sinusoidal": "cartesian", -# "schwarzschild": "spherical", -# "kerr-schild": "spherical", -#} geom_map = { - "cartesian": (Geometry.CARTESIAN,("x","y","z")), - "cylindrical": (Geometry.CYLINDRICAL,("r","theta","z")), - "spherical_polar": (Geometry.SPHERICAL,("r","theta","phi")), + "cartesian": "cartesian", + "cylindrical": "cylindrical", + "spherical_polar": "spherical", + "minkowski": "cartesian", + "tilted": "cartesian", + "sinusoidal": "cartesian", + "schwarzschild": "spherical", + "kerr-schild": "spherical", } - class AthenaPPGrid(AMRGridPatch): _id_offset = 0 @@ -160,8 +154,11 @@ def __init__( self._magnetic_factor = get_magnetic_normalization(magnetic_normalization) geom = self._handle.attrs["Coordinates"].decode("utf-8") - self.geometry = geom_map[geom][0] - axis_order = geom_map[geom][1] + self.geometry = Geometry(geom_map[geom]) + if geom_map[geom] == "cylindrical": + axis_order = ("r","theta","z") + else: + axis_order = None Dataset.__init__( self, From 4e5cce37e2fe71754da64b0a8193f2f5daf19318 Mon Sep 17 00:00:00 2001 From: forrestglines Date: Mon, 5 Feb 2024 13:59:03 -0700 Subject: [PATCH 3/4] Update yt/frontends/athena_pp/data_structures.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Robert --- yt/frontends/athena_pp/data_structures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt/frontends/athena_pp/data_structures.py b/yt/frontends/athena_pp/data_structures.py index 7e515d1fdc..b93717a787 100644 --- a/yt/frontends/athena_pp/data_structures.py +++ b/yt/frontends/athena_pp/data_structures.py @@ -155,7 +155,7 @@ def __init__( geom = self._handle.attrs["Coordinates"].decode("utf-8") self.geometry = Geometry(geom_map[geom]) - if geom_map[geom] == "cylindrical": + if self.geometry == "cylindrical": axis_order = ("r","theta","z") else: axis_order = None From 2aba96bfca504081352d3204a829c8cf1d516e86 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 10:00:48 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- yt/frontends/athena_pp/data_structures.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yt/frontends/athena_pp/data_structures.py b/yt/frontends/athena_pp/data_structures.py index 307c47c2b4..37f6881205 100644 --- a/yt/frontends/athena_pp/data_structures.py +++ b/yt/frontends/athena_pp/data_structures.py @@ -26,6 +26,7 @@ "kerr-schild": "spherical", } + class AthenaPPGrid(AMRGridPatch): _id_offset = 0 @@ -156,7 +157,7 @@ def __init__( geom = self._handle.attrs["Coordinates"].decode("utf-8") self.geometry = Geometry(geom_map[geom]) if self.geometry == "cylindrical": - axis_order = ("r","theta","z") + axis_order = ("r", "theta", "z") else: axis_order = None @@ -167,7 +168,7 @@ def __init__( units_override=units_override, unit_system=unit_system, default_species_fields=default_species_fields, - axis_order=axis_order + axis_order=axis_order, ) if storage_filename is None: storage_filename = self.basename + ".yt"