This instance will be upgraded to Heptapod 0.26.0rc1 on 2021-10-25 at 14:00 UTC+2 (a few minutes of down time)

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

return onesided spectra

parent 3f32c90a869d
......@@ -58,8 +58,7 @@ class TemporalSpectra3D(SpecificOutput):
attribs["probes_deltaz"] = 0.1 # m
params.output._set_child(
tag,
attribs=attribs,
tag, attribs=attribs,
)
params.output.temporal_spectra._set_doc(
......@@ -101,8 +100,7 @@ class TemporalSpectra3D(SpecificOutput):
return
super().__init__(
output,
period_save=params.output.periods_save.temporal_spectra,
output, period_save=params.output.periods_save.temporal_spectra,
)
oper = self.sim.oper
......@@ -561,9 +559,18 @@ class TemporalSpectra3D(SpecificOutput):
freq, spectrum = self._compute_spectrum(
np.concatenate(series[key])
)
spectra["spectrum_" + key[7:-4]] = spectrum.mean(0)
spectrum = spectrum.mean(0)
# get one-sided spectra
nomega = freq.size // 2 + 1
spectrum_onesided = np.zeros(nomega)
spectrum_onesided[0] = spectrum[0]
spectrum_onesided[1:] = (
spectrum[1:nomega] + spectrum[-1:-nomega:-1]
)
spectra["spectrum_" + key[7:-4]] = spectrum_onesided
spectra["omegas"] = 2 * pi * freq
spectra["omegas"] = 2 * pi * freq[:nomega]
return spectra
......@@ -598,10 +605,7 @@ class TemporalSpectra3D(SpecificOutput):
ax.set_yscale("log")
ax.plot(
spectra["omegas"],
spectra["spectrum_" + key],
"k",
linewidth=2,
spectra["omegas"], spectra["spectrum_" + key], "k", linewidth=2,
)
def save_data_as_phys_fields(self, delta_index_times=1):
......
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