forked from AmbaPant/mantid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ModOsc.py
33 lines (25 loc) · 1.18 KB
/
ModOsc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
# pylint: disable=invalid-name, anomalous-backslash-in-string, attribute-defined-outside-init
from mantid.api import IFunction1D, FunctionFactory
import numpy as np
import scipy.special as sp
class ModOsc(IFunction1D):
def category(self):
return "Muon\\MuonSpecific"
def init(self):
self.declareParameter("A0", 0.2)
self.declareParameter("Freq", 1.0, 'Oscillation Frequency (MHz)')
self.declareParameter("ModFreq", 0.1, 'Modulation Frequency (MHz)')
self.declareParameter("Phi", 0.0, 'Phase')
def function1D(self, x):
A0 = self.getParameterValue("A0")
Freq = self.getParameterValue("Freq")
ModFreq = self.getParameterValue("ModFreq")
phi = self.getParameterValue("Phi")
return A0 * np.cos(2 * np.pi * Freq * x + phi) * sp.j0(2 * np.pi * ModFreq * x + phi)
FunctionFactory.subscribe(ModOsc)