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

Add spec to validate location of the waveform peak

parent 1a91e3ba
......@@ -872,3 +872,35 @@ class Amplm(ROMSplineSpec):
lm = [Amplm(name=k) for k in keys]
return lm
class PeakNearZero(InterfieldSpec):
"""Specification for the location of the waveform peak"""
name = "peak-near-zero"
validMsg = "waveform peak is near zero"
invalidMsg = "waveform peak is not near zero"
def valid(self, sim, tol=10.0):
# Validate multipole moment amplitudes
ampModes = Amplm.getlm(sim)
for ampMode in ampModes:
ampModeValid = ampMode.valid(sim)
if not isinstance(ampModeValid, err.Valid):
self.invalidMsg = "amp_l{0:d}_m{1:d} is invalid".format(
ampMode.l, ampMode.m)
return err.InvalidInterfields(self)
maximumPoint, maximum = get_waveform_peak(sim)
if np.abs(maximumPoint) < tol:
self.validMsg = (
"waveform peak is at {0:.2f}M"
" which is less than {1:.2f}M from zero").format(
maximumPoint, tol)
return err.ValidInterfield(self)
else:
self.invalidMsg = (
"waveform peak is at {0:.2f}M"
" which is greater than {1:.2f}M from zero").format(
maximumPoint, tol)
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