Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def gen_gaussians(params, N):
"""
gen_gaussians(params, N):
Return a model of a DC-component + M gaussians
params is a sequence of 1+M*3 values
the first value is the DC component. Each remaining
group of three represents the gaussians phase (0-1),
FWHM (0-1), and amplitude (>0.0).
N is the number of points in the model.
"""
numgaussians = (len(params)-1) // 3
model = Num.zeros(N, dtype='d') + params[0]
for ii in range(numgaussians):
phase, FWHM, amp = params[1+ii*3:4+ii*3]
model += amp * gaussian_profile(N, phase, FWHM)
return model
def plot_gaussians(self, params):
plt.subplot(211)
plt.cla()
# Re-plot the original profile
plt.plot(self.phases, self.profile, c='black', lw=3, alpha=0.3)
plt.xlabel('Pulse Phase')
plt.ylabel('Pulse Amplitude')
DC = params[0]
# Plot the individual gaussians
for ii in range(self.numgaussians):
phase, FWHM, amp = params[1+ii*3:4+ii*3]
plt.plot(self.phases, DC + amp*gaussian_profile(self.proflen, phase, FWHM))