Commit 633b64ea authored by Edward Fauchon-Jones's avatar Edward Fauchon-Jones
Browse files

Add spec to validate sense of (2,2) phase

parent 06ccc67e
Pipeline #25106 failed with stage
in 2 minutes and 26 seconds
......@@ -62,7 +62,8 @@ format1 = OrderedDict((
format1Interfield = OrderedDict((
("mass-ordering", MassOrdering),
("peak-near-zero", PeakNearZero)))
("peak-near-zero", PeakNearZero),
("phase-sense", PhaseSense)))
format2 = OrderedDict((
('mass1-vs-time', Mass1VsTime),
......@@ -18,6 +18,7 @@ from . import errors as err
import numpy as np
import re
from scipy.interpolate import insert, splrep, PPoly
from scipy.interpolate import InterpolatedUnivariateSpline as IUS
class Spec(object):
......@@ -904,3 +905,31 @@ class PeakNearZero(InterfieldSpec):
" which is greater than {1:.2f}M from zero").format(
maximumPoint, tol)
return err.InvalidInterfield(self)
class PhaseSense(InterfieldSpec):
"""Specification for the sense of the waveform pahse"""
name = "phase-sense"
validMsg = "(2,2) phase is decreasing on average"
invalidMsg = "(2,2) phase is not decreasing on average"
def valid(self, sim):
# Validate (2,2) multipole moment phase
phaseMode = Phaselm(name='phase_l2_m2')
phaseModeValid = phaseMode.valid(sim)
if not isinstance(phaseModeValid, err.Valid):
self.invalidMsg = "phase_l2_m2 is invalid"
return err.InvalidInterfields(self)
# Determine sense from middle of pre-merger waveform
phase = np.array([sim['phase_l2_m2/X'][:], sim['phase_l2_m2/Y'][:]])
t0 = phase[0][0]*(3.0/4.0)
t1 = t0*(1.0/3.0)
X = np.arange(t0, t1, 0.1)
Y = IUS(*phase, k=5)(X)
sense = np.mean(np.diff(Y))
if sense < 0:
return err.ValidInterfield(self)
return err.InvalidInterfield(self)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment