Skip to content

Commit

Permalink
Make sure integer arguments are integers.
Browse files Browse the repository at this point in the history
  • Loading branch information
blakejohnson committed Feb 27, 2017
1 parent fce6718 commit b4b9b54
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions QGL/PulseShapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def gaussian(amp=1, length=0, cutoff=2, samplingRate=1e9, **params):
cutoff is how many sigma the pulse goes out
'''
#Round to how many points we need
numPts = np.round(length * samplingRate)
numPts = int(np.round(length * samplingRate))
xPts = np.linspace(-cutoff, cutoff, numPts)
xStep = xPts[1] - xPts[0]
return (amp * (np.exp(-0.5 * (xPts**2)) - np.exp(-0.5 * (
Expand All @@ -30,7 +30,7 @@ def constant(amp=1, length=0, samplingRate=1e9, **params):
'''
A constant section.
'''
numPts = np.round(length * samplingRate)
numPts = int(np.round(length * samplingRate))
return amp * np.ones(numPts, dtype=np.complex)

# square is deprecated but alias square to constant
Expand All @@ -46,7 +46,7 @@ def drag(amp=1,
A gaussian pulse with a drag correction on the quadrature channel.
'''
#Create the gaussian along x and the derivative along y
numPts = np.round(length * samplingRate)
numPts = int(np.round(length * samplingRate))
xPts = np.linspace(-cutoff, cutoff, numPts)
xStep = xPts[1] - xPts[0]
IQuad = np.exp(-0.5 * (xPts**2)) - np.exp(-0.5 * ((xPts[0] - xStep)**2))
Expand All @@ -62,7 +62,7 @@ def gaussOn(amp=1, length=0, cutoff=2, samplingRate=1e9, **params):
A half-gaussian pulse going from zero to full
'''
#Round to how many points we need
numPts = np.round(length * samplingRate)
numPts = int(np.round(length * samplingRate))
xPts = np.linspace(-cutoff, 0, numPts)
#Pull the edge down to zero so there is no big step
#i.e. find the shift such that the next point in the pulse would be zero
Expand All @@ -78,7 +78,7 @@ def gaussOff(amp=1, length=0, cutoff=2, samplingRate=1e9, **params):
A half-gaussian pulse going from full to zero
'''
#Round to how many points we need
numPts = np.round(length * samplingRate)
numPts = int(np.round(length * samplingRate))
xPts = np.linspace(0, cutoff, numPts)
#Pull the edge down to zero so there is no big step
#i.e. find the shift such that the next point in the pulse would be zero
Expand All @@ -98,7 +98,7 @@ def dragGaussOn(amp=1,
'''
A half-gaussian pulse with drag correction going from zero to full
'''
numPts = np.round(length * samplingRate)
numPts = int(np.round(length * samplingRate))
xPts = np.linspace(-cutoff, 0, numPts)
xStep = xPts[1] - xPts[0]
IQuad = np.exp(-0.5 * (xPts**2)) - np.exp(-0.5 * ((xPts[0] - xStep)**2))
Expand All @@ -116,7 +116,7 @@ def dragGaussOff(amp=1,
'''
A half-gaussian pulse with drag correction going from full to zero
'''
numPts = np.round(length * samplingRate)
numPts = int(np.round(length * samplingRate))
xPts = np.linspace(0, cutoff, numPts)
xStep = xPts[1] - xPts[0]
IQuad = np.exp(-0.5 * (xPts**2)) - np.exp(-0.5 * ((xPts[-1] + xStep)**2))
Expand All @@ -129,7 +129,7 @@ def tanh(amp=1, length=0, sigma=0, cutoff=2, samplingRate=1e9, **params):
'''
A rounded constant shape from the sum of two tanh shapes.
'''
numPts = np.round(length * samplingRate)
numPts = int(np.round(length * samplingRate))
xPts = np.linspace(-length / 2, length / 2, numPts)
x1 = -length / 2 + cutoff * sigma
x2 = +length / 2 - cutoff * sigma
Expand All @@ -142,7 +142,7 @@ def exp_decay(amp=1, length=0, sigma=0, samplingRate=1e9, steady_state=0.4, **pa
An exponentially decaying pulse to try and populate the cavity as quickly as possible.
But then don't overdrive it.
"""
numPts = np.round(length * samplingRate)
numPts = int(np.round(length * samplingRate))
timePts = (1.0 / samplingRate) * np.arange(numPts)
return amp * ((1-steady_state) * np.exp(-timePts / sigma) + steady_state).astype(np.complex)

Expand All @@ -159,7 +159,7 @@ def CLEAR(amp=1, length=0, sigma=0, samplingRate=1e9, **params):
params['step_length'] = 100e-9
timePts = (1.0 / samplingRate) * np.arange(np.round((length-2*params['step_length']) * samplingRate))
flat_step = amp * (0.6 * np.exp(-timePts / sigma) + 0.4).astype(np.complex)
numPts_clear_step = np.round(params['step_length'] * samplingRate)
numPts_clear_step = int(np.round(params['step_length'] * samplingRate))
clear_step_one = amp * params['amp1'] * np.ones(numPts_clear_step, dtype=np.complex)
clear_step_two = amp * params['amp2'] * np.ones(numPts_clear_step, dtype=np.complex)
return np.append(flat_step, [clear_step_one, clear_step_two])
Expand Down Expand Up @@ -220,9 +220,8 @@ def arb_axis_drag(nutFreq=10e6,

frameChange = sum(phaseSteps)

shape = (1.0 /
nutFreq) * sin(polarAngle) * calScale * gaussPulse * np.exp(
1j * phaseRamp)
shape = (1.0 / nutFreq) * sin(polarAngle) * calScale * gaussPulse * \
np.exp(1j * phaseRamp)

elif abs(polarAngle) < 1e-10:
#Otherwise assume we have a zero-length Z rotation
Expand Down

0 comments on commit b4b9b54

Please sign in to comment.