Commit 36f1928c authored by Jason Reneuve's avatar Jason Reneuve
Browse files

save_spectra for temporal_spectra

parent 834fd0420d26
......@@ -579,3 +579,21 @@ class TemporalSpectra(SpecificOutput):
create_ds(k, data=v)
# sim info
self.sim.info._save_as_hdf5(hdf5_parent=file)
def save_spectra(self, region=None, tmin=0, tmax=None):
"""compute temporal spectra from files"""
if region is None:
oper = self.sim.oper
region = (0, oper.Lx, 0, oper.Ly, 0, oper.Lz)
if tmax is None:
tmax = self.sim.params.time_stepping.t_end
dict_spectra = self.compute_spectra(region=region, tmin=tmin, tmax=tmax)
path_file = Path(self.sim.output.path_run) / "temporal_spectra.h5"
with h5py.File(path_file, "w") as file:
file.attrs["region"] = region
file.attrs["tmin"] = tmin
file.attrs["tmax"] = tmax
for key, val in dict_spectra.items():
file.create_dataset(key, data=val)
......@@ -117,6 +117,8 @@ class SpatioTemporalSpectraNS3D(SpatioTemporalSpectra):
# save to file
path_file = Path(self.sim.output.path_run) / "spatiotemporal_spectra.h5"
with h5py.File(path_file, "w") as file:
file.attrs["tmin"] = tmin
file.attrs["tmax"] = tmax
for key, val in dict_spectra_kzkhomega.items():
file.create_dataset(key, data=val)
......
......@@ -222,6 +222,7 @@ class TestOutput(TestSimulBase):
sim3.output.temporal_spectra.save_data_as_phys_fields(
delta_index_times=2
)
sim3.output.temporal_spectra.save_spectra()
sim3.output.spatiotemporal_spectra.plot_kzkhomega(equation="kh=1")
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