Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LISA Instrument
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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 Instrument
Commits
5365b6b1
Commit
5365b6b1
authored
2 years ago
by
Jean-Baptiste Bayle
Browse files
Options
Downloads
Patches
Plain Diff
Add unit tests for GW response reading
parent
8fa2d565
No related branches found
No related tags found
1 merge request
!118
Resolve "Add support for v2.0 gw response files"
Pipeline
#184801
passed
2 years ago
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitattributes
+2
-0
2 additions, 0 deletions
.gitattributes
tests/gws-1-1.h5
+3
-0
3 additions, 0 deletions
tests/gws-1-1.h5
tests/gws-2-0-dev.h5
+3
-0
3 additions, 0 deletions
tests/gws-2-0-dev.h5
tests/test_gws.py
+164
-0
164 additions, 0 deletions
tests/test_gws.py
with
172 additions
and
0 deletions
.gitattributes
+
2
−
0
View file @
5365b6b1
...
...
@@ -4,3 +4,5 @@ tests/keplerian-orbits-2-0.h5 filter=lfs diff=lfs merge=lfs -text
tests/esa-trailing-orbits-2-0.h5 filter=lfs diff=lfs merge=lfs -text
tests/keplerian-fplan-1-1.h5 filter=lfs diff=lfs merge=lfs -text
tests/esa-trailing-fplan-1-1.h5 filter=lfs diff=lfs merge=lfs -text
tests/gws-1-1.h5 filter=lfs diff=lfs merge=lfs -text
tests/gws-2-0-dev.h5 filter=lfs diff=lfs merge=lfs -text
This diff is collapsed.
Click to expand it.
tests/gws-1-1.h5
0 → 100644
LFS
+
3
−
0
View file @
5365b6b1
File added
This diff is collapsed.
Click to expand it.
tests/gws-2-0-dev.h5
0 → 100644
LFS
+
3
−
0
View file @
5365b6b1
File added
This diff is collapsed.
Click to expand it.
tests/test_gws.py
0 → 100644
+
164
−
0
View file @
5365b6b1
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Test reading of GW response and GW files.
"""
import
numpy
as
np
from
pytest
import
approx
from
h5py
import
File
from
lisainstrument
import
Instrument
def
test_no_gws
():
"""
Test that we simulate without GWs.
"""
instru
=
Instrument
(
size
=
100
,
gws
=
None
)
instru
.
disable_all_noises
()
assert
instru
.
gw_file
is
None
for
mosa
in
instru
.
MOSAS
:
assert
instru
.
gws
[
mosa
]
==
0
instru
.
simulate
()
for
mosa
in
instru
.
MOSAS
:
assert
instru
.
distant_carrier_fluctuations
[
mosa
]
==
approx
(
0
)
assert
instru
.
distant_usb_fluctuations
[
mosa
]
==
approx
(
0
)
assert
instru
.
tps_isi_carrier_fluctuations
[
mosa
]
==
approx
(
0
)
assert
instru
.
tps_isi_usb_fluctuations
[
mosa
]
==
approx
(
0
)
assert
instru
.
isi_carrier_fluctuations
[
mosa
]
==
approx
(
0
)
assert
instru
.
isi_usb_fluctuations
[
mosa
]
==
approx
(
0
)
def
test_dict_of_gws
():
"""
Test that we pass link responses in a dictionary.
"""
responses
=
{
mosa
:
np
.
random
.
normal
(
size
=
100
*
16
)
for
mosa
in
Instrument
.
MOSAS
}
instru
=
Instrument
(
size
=
100
,
lock
=
'
six
'
,
gws
=
responses
)
instru
.
disable_all_noises
()
assert
instru
.
gw_file
is
None
for
mosa
in
instru
.
MOSAS
:
assert
np
.
all
(
instru
.
gws
[
mosa
]
==
responses
[
mosa
])
instru
.
simulate
()
for
mosa
in
instru
.
MOSAS
:
assert
approx
(
instru
.
distant_carrier_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_carrier_offsets
[
mosa
])
*
responses
[
mosa
]
assert
approx
(
instru
.
distant_usb_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_usb_offsets
[
mosa
])
*
responses
[
mosa
]
assert
approx
(
instru
.
tps_isi_carrier_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_carrier_offsets
[
mosa
])
*
responses
[
mosa
]
assert
approx
(
instru
.
tps_isi_usb_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_usb_offsets
[
mosa
])
*
responses
[
mosa
]
def
test_gw_file_1_1
():
"""
Test that we can read GW files v1.1 with orbit files v1.0.2.
Test GW file can be generated using LISA GW Response and the following script.
from h5py import File
from lisagwresponse import GalacticBinary
orbits =
'
tests/keplerian-orbits-1-0-2.h5
'
with File(orbits,
'
r
'
) as f:
t0 = f.attrs[
'
t0
'
] + 10
galbin = GalacticBinary(
A=1.0,
f=1E-3,
orbits=orbits,
t0=t0,
size=100,
gw_beta=0, gw_lambda=0,
)
galbin.write(
'
tests/gws-1-1.h5
'
)
"""
gw_file
=
'
tests/gws-1-1.h5
'
gwf
=
File
(
gw_file
,
'
r
'
)
instru
=
Instrument
(
size
=
100
,
t0
=
gwf
.
attrs
[
'
t0
'
],
dt
=
gwf
.
attrs
[
'
dt
'
],
physics_upsampling
=
1
,
aafilter
=
None
,
lock
=
'
six
'
,
gws
=
gw_file
,
orbits
=
'
tests/keplerian-orbits-1-0-2.h5
'
)
instru
.
disable_all_noises
()
assert
instru
.
gw_file
is
gw_file
for
mosa
in
instru
.
MOSAS
:
assert
instru
.
gws
[
mosa
]
==
approx
(
gwf
[
f
'
tcb/l_
{
mosa
}
'
][:])
instru
.
simulate
()
for
mosa
in
instru
.
MOSAS
:
assert
approx
(
instru
.
distant_carrier_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_carrier_offsets
[
mosa
])
*
gwf
[
f
'
tcb/l_
{
mosa
}
'
][:]
assert
approx
(
instru
.
distant_usb_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_usb_offsets
[
mosa
])
*
gwf
[
f
'
tcb/l_
{
mosa
}
'
][:]
assert
approx
(
instru
.
tps_isi_carrier_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_carrier_offsets
[
mosa
])
*
gwf
[
f
'
tcb/l_
{
mosa
}
'
][:]
assert
approx
(
instru
.
tps_isi_usb_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_usb_offsets
[
mosa
])
*
gwf
[
f
'
tcb/l_
{
mosa
}
'
][:]
def
test_gw_file_2_0_dev
():
"""
Test that we can read GW files v2.0.dev with orbit files v2.0.
Test GW file can be generated using LISA GW Response and the following script.
from h5py import File
from lisagwresponse import GalacticBinary
orbits =
'
tests/keplerian-orbits-2-0.h5
'
with File(orbits,
'
r
'
) as f:
t0 = f.attrs[
'
t0
'
] + 10
galbin = GalacticBinary(
A=1.0,
f=1E-3,
orbits=orbits,
t0=t0,
size=100,
gw_beta=0, gw_lambda=0,
)
galbin.write(
'
tests/gws-2-0-dev.h5
'
)
"""
gw_file
=
'
tests/gws-2-0-dev.h5
'
gwf
=
File
(
gw_file
,
'
r
'
)
instru
=
Instrument
(
size
=
100
,
t0
=
gwf
.
attrs
[
'
t0
'
],
dt
=
gwf
.
attrs
[
'
dt
'
],
physics_upsampling
=
1
,
aafilter
=
None
,
lock
=
'
six
'
,
gws
=
gw_file
,
orbits
=
'
tests/keplerian-orbits-2-0.h5
'
)
instru
.
disable_all_noises
()
assert
instru
.
gw_file
is
gw_file
for
imosa
,
mosa
in
enumerate
(
instru
.
MOSAS
):
assert
instru
.
gws
[
mosa
]
==
approx
(
gwf
[
'
tcb/y
'
][:,
imosa
])
instru
.
simulate
()
for
imosa
,
mosa
in
enumerate
(
instru
.
MOSAS
):
assert
approx
(
instru
.
distant_carrier_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_carrier_offsets
[
mosa
])
*
gwf
[
'
tcb/y
'
][:,
imosa
]
assert
approx
(
instru
.
distant_usb_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_usb_offsets
[
mosa
])
*
gwf
[
'
tcb/y
'
][:,
imosa
]
assert
approx
(
instru
.
tps_isi_carrier_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_carrier_offsets
[
mosa
])
*
gwf
[
'
tcb/y
'
][:,
imosa
]
assert
approx
(
instru
.
tps_isi_usb_fluctuations
[
mosa
])
==
\
-
(
instru
.
central_freq
+
instru
.
local_usb_offsets
[
mosa
])
*
gwf
[
'
tcb/y
'
][:,
imosa
]
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