Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F66398081
statistics.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jun 10, 06:49
Size
1 KB
Mime Type
text/x-python
Expires
Wed, Jun 12, 06:49 (2 d)
Engine
blob
Format
Raw Data
Handle
18216861
Attached To
rTAMAAS tamaas
statistics.py
View Options
#!/usr/bin/env python3
# @file
# @section LICENSE
#
# Copyright (©) 2016-19 EPFL (École Polytechnique Fédérale de Lausanne),
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
matplotlib.colors
import
LogNorm
import
tamaas
as
tm
# Initialize threads and fftw
tm
.
initialize
()
tm
.
set_log_level
(
tm
.
LogLevel
.
info
)
# Show progression of solver
# Surface size
n
=
512
# Surface generator
sg
=
tm
.
SurfaceGeneratorFilter2D
()
sg
.
setSizes
([
n
,
n
])
sg
.
random_seed
=
0
# Spectrum
spectrum
=
tm
.
Isopowerlaw2D
()
sg
.
setFilter
(
spectrum
)
# Parameters
spectrum
.
q0
=
16
spectrum
.
q1
=
16
spectrum
.
q2
=
64
spectrum
.
hurst
=
0.8
# Generating surface
surface
=
sg
.
buildSurface
()
# Computing PSD and shifting for plot
psd
=
tm
.
Statistics2D
.
computePowerSpectrum
(
surface
)
psd
=
np
.
fft
.
fftshift
(
psd
,
axes
=
0
)
plt
.
imshow
(
psd
.
real
,
norm
=
LogNorm
())
plt
.
gca
()
.
set_title
(
'Power Spectrum Density'
)
plt
.
gcf
()
.
tight_layout
()
# Computing autocorrelation and shifting for plot
acf
=
tm
.
Statistics2D
.
computeAutocorrelation
(
surface
)
acf
=
np
.
fft
.
fftshift
(
acf
)
plt
.
figure
()
plt
.
imshow
(
acf
)
plt
.
gca
()
.
set_title
(
'Autocorrelation'
)
plt
.
gcf
()
.
tight_layout
()
plt
.
show
()
Event Timeline
Log In to Comment