Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fluiddyn
fluidsim
Commits
c9c4074385da
Commit
36f1928c
authored
Mar 11, 2021
by
Jason Reneuve
Browse files
save_spectra for temporal_spectra
parent
834fd0420d26
Changes
3
Show whitespace changes
Inline
Side-by-side
fluidsim/base/output/temporal_spectra.py
View file @
c9c40743
...
...
@@ -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
)
fluidsim/solvers/ns3d/output/spatiotemporal_spectra.py
View file @
c9c40743
...
...
@@ -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
)
...
...
fluidsim/solvers/ns3d/test_solver.py
View file @
c9c40743
...
...
@@ -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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment