Commit cd51c9f5 authored by Jason Reneuve's avatar Jason Reneuve
Browse files

load_spectra_kzkhomega

parent ca9a79a8d162
Pipeline #22373 failed with stage
in 11 minutes and 52 seconds
......@@ -839,6 +839,22 @@ class SpatioTemporalSpectraNS:
return spectra_kzkhomega, tspectra
def load_spectra_kzkhomega(
self, tmin=0, tmax=None, dtype=None, save_urud=False
):
"""load kzkhomega spectra from file"""
if tmax is None:
tmax = self.sim.params.time_stepping.t_end
spectra = {}
path_file = self._get_path_saved_spectra(tmin, tmax, dtype, save_urud)
with h5py.File(path_file, "r") as file:
for key in file.keys():
spectra[key] = file[key][...]
return spectra
def plot_kzkhomega(
self,
key_field=None,
......@@ -1115,7 +1131,8 @@ class SpatioTemporalSpectraNS:
if tmax is None:
tmax = self.sim.params.time_stepping.t_end
# TODO: save/load spectra instead of computing everytime
# TODO: should we always set save_urud = True?
# I think it's complicated not to (in 3d).
save_urud = True
path_file = self._get_path_saved_tspectra(tmin, tmax, dtype, save_urud)
if path_file.exists():
......
......@@ -245,7 +245,6 @@ class TestOutput(TestSimulBase):
sim3.output.temporal_spectra.save_spectra()
spatiotemporal_spectra = sim3.output.spatiotemporal_spectra
spatiotemporal_spectra.plot_temporal_spectra()
series_kxkykz = spatiotemporal_spectra.load_time_series()
spectra_kxkykzomega = spatiotemporal_spectra.compute_spectra()
......@@ -270,7 +269,8 @@ class TestOutput(TestSimulBase):
def sum_wavenumber(field):
return _sum_wavenumber3D(field, KX, kx_max)
spectra_kzkhomega, _ = spatiotemporal_spectra.save_spectra_kzkhomega(
_ = spatiotemporal_spectra.save_spectra_kzkhomega(save_urud=True)
spectra_kzkhomega = spatiotemporal_spectra.load_spectra_kzkhomega(
save_urud=True
)
......@@ -359,6 +359,8 @@ class TestOutput(TestSimulBase):
sim3.output.spatiotemporal_spectra.plot_kzkhomega(
key_field="Khr", equation="kh=1"
)
sim3.output.spatiotemporal_spectra.plot_temporal_spectra()
plt.close("all")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment