Skip to content

Commit 862318b

Browse files
authored
Merge pull request #180 from ammarhakim/metadata_retrocompatibility_fix
add geqdsk_sign_convention and geometry_type as None in the ctx dict.
2 parents 4afafea + 4a0c476 commit 862318b

File tree

17 files changed

+114
-107
lines changed

17 files changed

+114
-107
lines changed

environment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
name: pgkyl
1+
name: pgkylSrcH5
22
channels:
33
- defaults
44
- conda-forge
55
dependencies:
6-
- conda-forge::adios2==2.9.2
76
- click>=8.1.7
87
- matplotlib>=3.7.0
98
- msgpack-python>=1.0.3
@@ -13,3 +12,4 @@ dependencies:
1312
- python>=3.11
1413
- scipy>=1.10.1
1514
- sympy>=1.12
15+
- h5py

src/postgkyl/commands/animate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ def _update(frame, data, fig, kwargs):
2727
for i, dat in enumerate(data[frame]):
2828
kwargs["title"] = ""
2929
if not kwargs["notitle"]:
30-
if dat.ctx["frame"] is not None:
30+
if dat.ctx.get("frame"):
3131
kwargs["title"] = f"{kwargs['title']:s} frame: {dat.ctx['frame']:d} "
3232
# end
33-
if dat.ctx["time"] is not None:
33+
if dat.ctx.get("time"):
3434
kwargs["title"] = f"{kwargs['title']:s} time: {dat.ctx['time']:.4e}"
3535
# end
3636
# end
3737

3838
if i == 0:
39-
if kwargs["arg"] is not None:
39+
if kwargs.get("arg"):
4040
im = postgkyl.output.plot(dat, kwargs["arg"], **kwargs)
4141
else:
4242
im = postgkyl.output.plot(dat, **kwargs)
4343
# end
4444
else:
4545
kwargs_ncb = kwargs.copy()
4646
kwargs_ncb["colorbar"] = False
47-
if kwargs["arg"] is not None:
47+
if kwargs.get("arg"):
4848
im = postgkyl.output.plot(dat, kwargs["arg"], **kwargs_ncb)
4949
else:
5050
im = postgkyl.output.plot(dat, **kwargs_ncb)

src/postgkyl/commands/collect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def collect(ctx, **kwargs):
9292
time[i] = np.array(time[i])
9393
values[i] = np.array(values[i])
9494

95-
if kwargs["period"] is not None:
95+
if "period" in kwargs.keys():
9696
time[i] = (time[i] - kwargs["offset"]) % kwargs["period"]
9797
# end
9898

src/postgkyl/commands/differentiate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def differentiate(ctx, **kwargs):
2424

2525
basis_type = None
2626
is_modal = None
27-
if kwargs["basis_type"] is not None:
27+
if "basis_type" in kwargs.keys():
2828
if kwargs["basis_type"] == "ms":
2929
basis_type = "serendipity"
3030
is_modal = True

src/postgkyl/commands/gk_energy_balance.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ def absy_disabled(data_in):
233233
field_dot_file = block_path_prefix + 'field_energy_dot.gkyl'
234234

235235
has_field_dot, time_field_dot, field_dot_pb, gdat = read_gfile_if_present(field_dot_file)
236+
if not has_field_dot or gdat is None:
237+
raise FileNotFoundError(f"Required file not found: {field_dot_file}")
236238
gdat_field_dot = GData(tag="field_dot", label="field_dot", ctx=gdat.ctx)
237239

238240
fdot_pb = None
@@ -247,7 +249,9 @@ def absy_disabled(data_in):
247249
else:
248250
fdot_file = block_path_prefix + spec_nm + '_fdot_integrated_moms.gkyl'
249251

250-
_, time_fdot, fdot_ps, gdat = read_gfile_if_present(fdot_file)
252+
has_fdot, time_fdot, fdot_ps, gdat = read_gfile_if_present(fdot_file)
253+
if not has_fdot or gdat is None:
254+
raise FileNotFoundError(f"Required file not found: {fdot_file}")
251255
gdat_fdot = GData(tag="fdot", label="fdot", ctx=gdat.ctx)
252256

253257
# Load integrated moments of the source.

src/postgkyl/commands/gk_nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def is_geo_mapc2p(gdata):
1919
gdata_meta = gdata.get_ctx()
2020
is_mapc2p = True
2121
if ("geometry_type" in gdata_meta):
22-
if gdata_meta["geometry_type"] is not None:
22+
if "geometry_type" in gdata_meta.keys():
2323
mc2p_idx = gkenums.enum_key_to_idx(gkenums.gkyl_geometry_id,"GKYL_GEOMETRY_MAPC2P")
2424
is_mapc2p = mc2p_idx == gdata_meta["geometry_type"]
2525
# end

src/postgkyl/commands/gk_particle_balance.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ def absy_disabled(data_in):
218218
else:
219219
fdot_file = block_path_prefix + kwargs["species"] + '_fdot_integrated_moms.gkyl'
220220

221-
_, time_fdot, fdot_pb, gdat = read_gfile_if_present(fdot_file)
221+
has_fdot, time_fdot, fdot_pb, gdat = read_gfile_if_present(fdot_file)
222+
if not has_fdot or gdat is None:
223+
raise FileNotFoundError(f"Required file not found: {fdot_file}")
222224
gdat_fdot = GData(tag="fdot", label="fdot", ctx=gdat.ctx)
223225

224226
# Load integrated moments of the source.

src/postgkyl/commands/interpolate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def interpolate(ctx, **kwargs):
2424

2525
basis_type = None
2626
is_modal = None
27-
if kwargs["basis_type"] is not None:
27+
if "basis_type" in kwargs.keys():
2828
if kwargs["basis_type"] == "ms":
2929
basis_type = "serendipity"
3030
is_modal = True

src/postgkyl/commands/mask.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ def mask(ctx, **kwargs):
2828
if kwargs["filename"]:
2929
mask_fld_rep = np.repeat(mask_fld, dat.get_num_comps(), axis=-1)
3030
data.set_values(np.ma.masked_where(mask_fld_rep < 0.0, values))
31-
elif kwargs["lower"] is not None and kwargs["upper"] is not None:
31+
elif "lower" in kwargs.keys() and "upper" in kwargs.keys():
3232
dat.set_values(np.ma.masked_outside(values, kwargs["lower"], kwargs["upper"]))
33-
elif kwargs["lower"] is not None:
33+
elif "lower" in kwargs.keys():
3434
dat.set_values(np.ma.masked_less(values, kwargs["lower"]))
35-
elif kwargs["upper"] is not None:
35+
elif "upper" in kwargs.keys():
3636
dat.set_values(np.ma.masked_greater(values, kwargs["upper"]))
3737
else:
3838
data.set_values(values)

src/postgkyl/commands/old/recovery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def recovery(ctx, **kwargs):
2525
verb_print(ctx, "Starting recovery")
2626
data = ctx.obj["data"]
2727

28-
if kwargs["basis_type"] is not None:
28+
if "basis_type" in kwargs.keys():
2929
if kwargs["basis_type"] == "ms" or kwargs["basis_type"] == "ns":
3030
basis_type = "serendipity"
3131
elif kwargs["basis_type"] == "mo":

0 commit comments

Comments
 (0)