Skip to content

Commit e962538

Browse files
authored
Merge pull request #5276 from Yurlungur/jmm/parthenon-frontend-updates
Fix small bugs/edge cases in the parthenon frontend
2 parents 744b51b + a39fbd5 commit e962538

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

yt/frontends/parthenon/data_structures.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ def _setup_dx(self):
5353
id = self.id - self._id_offset
5454
LE, RE = self.index.grid_left_edge[id, :], self.index.grid_right_edge[id, :]
5555
self.dds = self.ds.arr((RE - LE) / self.ActiveDimensions, "code_length")
56-
if self.ds.dimensionality < 2:
57-
self.dds[1] = 1.0
58-
if self.ds.dimensionality < 3:
59-
self.dds[2] = 1.0
6056
self.field_data["dx"], self.field_data["dy"], self.field_data["dz"] = self.dds
6157

6258
def retrieve_ghost_zones(self, n_zones, fields, all_levels=False, smoothed=False):
@@ -164,19 +160,13 @@ def __init__(
164160

165161
self.geometry = _geom_map[self._handle["Info"].attrs["Coordinates"]]
166162

167-
if self.geometry is Geometry.CYLINDRICAL:
168-
axis_order = ("r", "theta", "z")
169-
else:
170-
axis_order = None
171-
172163
Dataset.__init__(
173164
self,
174165
filename,
175166
dataset_type,
176167
units_override=units_override,
177168
unit_system=unit_system,
178169
default_species_fields=default_species_fields,
179-
axis_order=axis_order,
180170
)
181171
if storage_filename is None:
182172
storage_filename = self.basename + ".yt"

yt/frontends/parthenon/io.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ def _read_fluid_selection(self, chunks, selector, fields, size):
5252
for gs in grid_sequences(chunk.objs):
5353
start = gs[0].id - gs[0]._id_offset
5454
end = gs[-1].id - gs[-1]._id_offset + 1
55-
data = ds[start:end, fdi, :, :, :].transpose()
55+
if len(ds.shape) == 4:
56+
data = ds[start:end, :, :, :].transpose()
57+
else:
58+
data = ds[start:end, fdi, :, :, :].transpose()
5659
for i, g in enumerate(gs):
5760
ind += g.select(selector, data[..., i], rv[field], ind)
5861
last_dname = dname
@@ -72,7 +75,10 @@ def _read_chunk_data(self, chunk, fields):
7275
for gs in grid_sequences(chunk.objs):
7376
start = gs[0].id - gs[0]._id_offset
7477
end = gs[-1].id - gs[-1]._id_offset + 1
75-
data = ds[start:end, fdi, :, :, :].transpose()
78+
if len(ds.shape) == 4:
79+
data = ds[start:end, :, :, :].transpose()
80+
else:
81+
data = ds[start:end, fdi, :, :, :].transpose()
7682
for i, g in enumerate(gs):
7783
rv[g.id][field] = np.asarray(data[..., i], "=f8")
7884
return rv

yt/frontends/parthenon/tests/test_outputs.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,25 @@ def test_load_cylindrical():
179179
# Check that the domain edges match r in [0.5,2.0], theta in [0, 2pi]
180180
assert_equal(ds.domain_left_edge.in_units("code_length").v[:2], (0.5, 0))
181181
assert_equal(ds.domain_right_edge.in_units("code_length").v[:2], (2.0, 2 * np.pi))
182+
183+
184+
# Sedov blast wave with curvlinear coords run with RIOT
185+
riot_sedov_curvlinear = "riot_sedov_curvlinear/sedov.out1.final.phdf"
186+
187+
188+
@requires_file(riot_sedov_curvlinear)
189+
def test_load_riot_curvilinear():
190+
# Load a cylindrical dataset of a full disk
191+
ds = data_dir_load(riot_sedov_curvlinear)
192+
193+
assert ("parthenon", "c.c.bulk.pressure") in ds.field_list
194+
195+
ad = ds.all_data()
196+
dth = ad["index", "dtheta"]
197+
vol = ad["index", "cell_volume"]
198+
rho = ad["parthenon", "c.c.bulk.rho"]
199+
200+
assert np.all(np.abs(dth - 2 * np.pi) <= 1e-12)
201+
202+
total_mass = (rho * vol).sum()
203+
assert np.all(np.abs(total_mass.value - 0.169646) <= 1e-8)

0 commit comments

Comments
 (0)