Skip to content

Commit

Permalink
Check lengths for short tanh pulses and add a special case for zero
Browse files Browse the repository at this point in the history
length pulses.  -MW
  • Loading branch information
matthewware committed Sep 24, 2019
1 parent c308c38 commit f52d820
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions QGL/PulseShapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,17 @@ def tanh(amp=1, length=0, sigma=0, cutoff=2, sampling_rate=1e9, **params):
'''
A rounded constant shape from the sum of two tanh shapes.
'''
numPts = int(np.round(length * sampling_rate))
xPts = np.linspace(-length / 2, length / 2, numPts)
x1 = -length / 2 + cutoff * sigma
x2 = +length / 2 - cutoff * sigma
return amp * 0.5 * (np.tanh((xPts - x1) / sigma) + np.tanh(
(x2 - xPts) / sigma)).astype(np.complex)
if length == 0.0:
return np.empty(shape=(0,)).astype(np.complex)
else:
numPts = int(np.round(length * sampling_rate))
xPts = np.linspace(-length / 2, length / 2, numPts)
x1 = -length / 2 + cutoff * sigma
x2 = +length / 2 - cutoff * sigma
assert x1 < 0 and x2 > 0, ("Pulse length must be greater than 2 * "
"cuttoff * sigma. Consider using a Gaussian pulse instead.")
return amp * 0.5 * (np.tanh((xPts - x1) / sigma) + np.tanh(
(x2 - xPts) / sigma)).astype(np.complex)


def exp_decay(amp=1, length=0, sigma=0, sampling_rate=1e9, steady_state=0.4, **params):
Expand Down

0 comments on commit f52d820

Please sign in to comment.