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
Admin message
Gitlab has been updated. More info
here
and
there
.
Show more breadcrumbs
LISA Simulation
LISA Instrument
Commits
c4170c5e
Commit
c4170c5e
authored
2 years ago
by
Jean-Baptiste Bayle
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for supported glitch files
parent
afbc201d
No related branches found
No related tags found
1 merge request
!123
Resolve "Add unit tests for interface with orbit, GW, and glitch files"
Pipeline
#193075
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/glitch-1-0.h5
+3
-0
3 additions, 0 deletions
tests/glitch-1-0.h5
tests/glitch-1-1.h5
+3
-0
3 additions, 0 deletions
tests/glitch-1-1.h5
tests/test_glitch.py
+178
-0
178 additions, 0 deletions
tests/test_glitch.py
with
186 additions
and
0 deletions
.gitattributes
+
2
−
0
View file @
c4170c5e
...
...
@@ -6,3 +6,5 @@ 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
tests/glitch-1-1.h5 filter=lfs diff=lfs merge=lfs -text
tests/glitch-1-0.h5 filter=lfs diff=lfs merge=lfs -text
This diff is collapsed.
Click to expand it.
tests/glitch-1-0.h5
0 → 100644
LFS
+
3
−
0
View file @
c4170c5e
File added
This diff is collapsed.
Click to expand it.
tests/glitch-1-1.h5
0 → 100644
LFS
+
3
−
0
View file @
c4170c5e
File added
This diff is collapsed.
Click to expand it.
tests/test_glitch.py
0 → 100644
+
178
−
0
View file @
c4170c5e
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Test reading of glitch files.
"""
import
numpy
as
np
from
pytest
import
approx
from
h5py
import
File
from
lisaconstants
import
c
from
lisainstrument
import
Instrument
def
test_no_glitches
():
"""
Test that we can simulate no glitches.
"""
instru
=
Instrument
(
size
=
100
,
glitches
=
None
)
instru
.
disable_all_noises
()
assert
instru
.
glitch_file
is
None
for
mosa
in
instru
.
MOSAS
:
assert
instru
.
glitch_tms
[
mosa
]
==
0
assert
instru
.
glitch_lasers
[
mosa
]
==
0
instru
.
simulate
()
for
mosa
in
instru
.
MOSAS
:
assert
instru
.
local_carrier_fluctuations
[
mosa
]
==
approx
(
0
)
assert
instru
.
local_tmi_carrier_fluctuations
[
mosa
]
==
approx
(
0
)
assert
instru
.
local_tmi_usb_fluctuations
[
mosa
]
==
approx
(
0
)
def
test_glitch_file_1_0
():
"""
Test that we can read test-mass and laser glitches from files v1.0.
Test glitch file can be generated using LISA Glitch and the following script.
from lisaglitch import ShapeletGlitch
path =
'
tests/glitch-1-0.h5
'
ShapeletGlitch(beta=2, quantum_n=1, inj_point=
'
tm_12
'
, t_inj=10.0, size=200).write(path, mode=
'
w
'
)
ShapeletGlitch(beta=1, quantum_n=2, inj_point=
'
tm_23
'
, t_inj=0.0).write(path)
ShapeletGlitch(beta=3, quantum_n=2, inj_point=
'
tm_31
'
, t_inj=5.0).write(path)
ShapeletGlitch(beta=4, quantum_n=1, inj_point=
'
laser_12
'
, t_inj=0.0).write(path)
ShapeletGlitch(beta=4, quantum_n=3, inj_point=
'
laser_31
'
, t_inj=0.0).write(path)
"""
glitch_file
=
'
tests/glitch-1-0.h5
'
glitchf
=
File
(
glitch_file
,
'
r
'
)
instru
=
Instrument
(
size
=
glitchf
.
attrs
[
'
size
'
],
t0
=
glitchf
.
attrs
[
'
t0
'
],
dt
=
glitchf
.
attrs
[
'
dt
'
],
physics_upsampling
=
1
,
aafilter
=
None
,
lock
=
'
six
'
,
glitches
=
glitch_file
,
orbits
=
'
tests/keplerian-orbits-1-0-2.h5
'
)
instru
.
disable_all_noises
()
assert
instru
.
glitch_file
is
glitch_file
for
mosa
in
instru
.
MOSAS
:
# Missing datasets should be zero
tm_dataset
=
f
'
tm_
{
mosa
}
'
if
tm_dataset
in
glitchf
:
assert
instru
.
glitch_tms
[
mosa
]
==
approx
(
glitchf
[
tm_dataset
][:])
else
:
assert
instru
.
glitch_tms
[
mosa
]
==
0
laser_dataset
=
f
'
laser_
{
mosa
}
'
if
laser_dataset
in
glitchf
:
assert
instru
.
glitch_lasers
[
mosa
]
==
approx
(
glitchf
[
laser_dataset
][:])
else
:
assert
instru
.
glitch_lasers
[
mosa
]
==
0
instru
.
simulate
()
for
mosa
in
instru
.
MOSAS
:
laser_dataset
=
f
'
laser_
{
mosa
}
'
if
laser_dataset
in
glitchf
:
assert
approx
(
instru
.
local_carrier_fluctuations
[
mosa
])
==
\
glitchf
[
laser_dataset
][:]
else
:
assert
approx
(
instru
.
local_carrier_fluctuations
[
mosa
])
==
0
tm_dataset
=
f
'
tm_
{
mosa
}
'
if
tm_dataset
in
glitchf
:
assert
approx
(
instru
.
local_tmi_carrier_fluctuations
[
mosa
],
abs
=
1E-6
)
==
\
instru
.
local_carrier_fluctuations
[
mosa
]
\
+
2
*
glitchf
[
tm_dataset
][:]
/
c
\
*
(
instru
.
central_freq
+
instru
.
local_tmi_carrier_offsets
[
mosa
])
else
:
assert
approx
(
instru
.
local_tmi_carrier_fluctuations
[
mosa
])
==
\
instru
.
local_carrier_fluctuations
[
mosa
]
if
tm_dataset
in
glitchf
:
assert
approx
(
instru
.
local_tmi_usb_fluctuations
[
mosa
],
abs
=
1E-6
)
==
\
instru
.
local_usb_fluctuations
[
mosa
]
\
+
2
*
glitchf
[
tm_dataset
][:]
/
c
\
*
(
instru
.
central_freq
+
instru
.
local_tmi_usb_offsets
[
mosa
])
else
:
assert
approx
(
instru
.
local_tmi_usb_fluctuations
[
mosa
])
==
\
instru
.
local_usb_fluctuations
[
mosa
]
def
test_glitch_file_1_1
():
"""
Test that we can read test-mass and laser glitches from files v1.1.
Test glitch file can be generated using LISA Glitch and the following script.
from lisaglitch import ShapeletGlitch
path =
'
tests/glitch-1-1.h5
'
ShapeletGlitch(beta=2, quantum_n=1, inj_point=
'
tm_12
'
, t_inj=10.0, size=200).write(path, mode=
'
w
'
)
ShapeletGlitch(beta=1, quantum_n=2, inj_point=
'
tm_23
'
, t_inj=0.0).write(path)
ShapeletGlitch(beta=3, quantum_n=2, inj_point=
'
tm_31
'
, t_inj=5.0).write(path)
ShapeletGlitch(beta=4, quantum_n=1, inj_point=
'
laser_12
'
, t_inj=0.0).write(path)
ShapeletGlitch(beta=4, quantum_n=3, inj_point=
'
laser_31
'
, t_inj=0.0).write(path)
"""
glitch_file
=
'
tests/glitch-1-1.h5
'
glitchf
=
File
(
glitch_file
,
'
r
'
)
instru
=
Instrument
(
size
=
glitchf
.
attrs
[
'
size
'
],
t0
=
glitchf
.
attrs
[
'
t0
'
],
dt
=
glitchf
.
attrs
[
'
dt
'
],
physics_upsampling
=
1
,
aafilter
=
None
,
lock
=
'
six
'
,
glitches
=
glitch_file
,
orbits
=
'
tests/keplerian-orbits-1-0-2.h5
'
)
instru
.
disable_all_noises
()
assert
instru
.
glitch_file
is
glitch_file
for
mosa
in
instru
.
MOSAS
:
# Missing datasets should be zero
tm_dataset
=
f
'
tm_
{
mosa
}
'
if
tm_dataset
in
glitchf
:
assert
instru
.
glitch_tms
[
mosa
]
==
approx
(
glitchf
[
tm_dataset
][:])
else
:
assert
instru
.
glitch_tms
[
mosa
]
==
0
laser_dataset
=
f
'
laser_
{
mosa
}
'
if
laser_dataset
in
glitchf
:
assert
instru
.
glitch_lasers
[
mosa
]
==
approx
(
glitchf
[
laser_dataset
][:])
else
:
assert
instru
.
glitch_lasers
[
mosa
]
==
0
instru
.
simulate
()
for
mosa
in
instru
.
MOSAS
:
laser_dataset
=
f
'
laser_
{
mosa
}
'
if
laser_dataset
in
glitchf
:
assert
approx
(
instru
.
local_carrier_fluctuations
[
mosa
])
==
\
glitchf
[
laser_dataset
][:]
else
:
assert
approx
(
instru
.
local_carrier_fluctuations
[
mosa
])
==
0
tm_dataset
=
f
'
tm_
{
mosa
}
'
if
tm_dataset
in
glitchf
:
assert
approx
(
instru
.
local_tmi_carrier_fluctuations
[
mosa
],
abs
=
1E-6
)
==
\
instru
.
local_carrier_fluctuations
[
mosa
]
\
+
2
*
glitchf
[
tm_dataset
][:]
/
c
\
*
(
instru
.
central_freq
+
instru
.
local_tmi_carrier_offsets
[
mosa
])
else
:
assert
approx
(
instru
.
local_tmi_carrier_fluctuations
[
mosa
])
==
\
instru
.
local_carrier_fluctuations
[
mosa
]
if
tm_dataset
in
glitchf
:
assert
approx
(
instru
.
local_tmi_usb_fluctuations
[
mosa
],
abs
=
1E-6
)
==
\
instru
.
local_usb_fluctuations
[
mosa
]
\
+
2
*
glitchf
[
tm_dataset
][:]
/
c
\
*
(
instru
.
central_freq
+
instru
.
local_tmi_usb_offsets
[
mosa
])
else
:
assert
approx
(
instru
.
local_tmi_usb_fluctuations
[
mosa
])
==
\
instru
.
local_usb_fluctuations
[
mosa
]
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