Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LISA GW Response
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LISA Simulation
LISA GW Response
Commits
fa7ead15
Commit
fa7ead15
authored
2 years ago
by
Jean-Baptiste Bayle
Browse files
Options
Downloads
Plain Diff
Merge branch '44-rescale-one-sided-spectrum-in-ifft_generator' into 'master'
Resolve "Rescale one-sided spectrum in `ifft_generator`" Closes
#44
See merge request
!50
parents
f607a6a2
c2764c60
No related branches found
No related tags found
1 merge request
!50
Resolve "Rescale one-sided spectrum in `ifft_generator`"
Pipeline
#185836
passed with warnings
2 years ago
Stage: test
Stage: document
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lisagwresponse/psd.py
+1
-1
1 addition, 1 deletion
lisagwresponse/psd.py
tests/test_psd.py
+38
-0
38 additions, 0 deletions
tests/test_psd.py
with
39 additions
and
1 deletion
lisagwresponse/psd.py
+
1
−
1
View file @
fa7ead15
...
@@ -25,7 +25,7 @@ def white_generator(psd):
...
@@ -25,7 +25,7 @@ def white_generator(psd):
simulation size [samples].
simulation size [samples].
"""
"""
def
generator
(
fs
,
size
):
def
generator
(
fs
,
size
):
stddev
=
np
.
sqrt
(
psd
*
fs
/
4
)
stddev
=
np
.
sqrt
(
psd
*
fs
/
2
)
return
np
.
random
.
normal
(
scale
=
stddev
,
size
=
size
)
return
np
.
random
.
normal
(
scale
=
stddev
,
size
=
size
)
return
generator
return
generator
...
...
This diff is collapsed.
Click to expand it.
tests/test_psd.py
0 → 100644
+
38
−
0
View file @
fa7ead15
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# pylint: disable=missing-module-docstring
import
numpy
as
np
from
scipy.signal
import
welch
from
lisagwresponse.psd
import
white_generator
,
ifft_generator
def
test_white_generator
():
"""
Test that white generator generates a white noise.
"""
size
=
100000
for
fs
in
[
1.0
,
0.2
,
10.0
]:
for
psd
in
[
1.0
,
0.1
,
12.3
,
42.0
]:
generator
=
white_generator
(
psd
)
data
=
generator
(
fs
,
size
)
data_psd
=
welch
(
data
,
fs
,
nperseg
=
size
//
100
)[
1
][
5
:
-
5
]
assert
np
.
isclose
(
np
.
mean
(
data
),
0.0
,
atol
=
0.1
)
assert
np
.
all
(
np
.
isclose
(
data_psd
,
psd
,
rtol
=
0.5
))
def
test_ifft_generator_white
():
"""
Test that IFFT generator can generate a white noise.
"""
size
=
100000
for
fs
in
[
1.0
,
0.2
,
10.0
]:
for
psd
in
[
1.0
,
0.1
,
12.3
,
42.0
]:
generator
=
ifft_generator
(
lambda
_
:
psd
)
# pylint: disable=cell-var-from-loop
data
=
generator
(
fs
,
size
)
data_psd
=
welch
(
data
,
fs
,
nperseg
=
size
//
100
)[
1
][
5
:
-
5
]
assert
np
.
isclose
(
np
.
mean
(
data
),
0.0
,
atol
=
0.1
)
assert
np
.
all
(
np
.
isclose
(
data_psd
,
psd
,
rtol
=
0.5
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment