Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions exopy_pulses/pulses/manifest.enaml
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,12 @@ enamldef PulsesManagerManifest(PluginManifest):
Shape:
shape = 'slope_shape:SlopeShape'
view = 'views.slope_shape_view:SlopeShapeView'
Shape:
shape = 'gaussian_shape:GaussianShape'
view = 'views.gaussian_shape_view:GaussianShapeView'
Shape:
shape = 'tanh_shape:TanhShape'
view = 'views.tanh_shape_view:TanhShapeView'

PulsesBuildingDependenciesExtension:
pass
Expand Down
86 changes: 86 additions & 0 deletions exopy_pulses/pulses/shapes/gaussian_shape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2015-2018 by ExopyPulses Authors, see AUTHORS for more details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the copyright does not make sense, I would expect to see 2021

#
# Distributed under the terms of the BSD license.
#
# The full license is in the file LICENCE, distributed with this software.
# -----------------------------------------------------------------------------
"""Most basic shape for an analogical pulse.

"""
from numbers import Real

import numpy as np
from atom.api import Str

from ..utils.validators import Feval

from .base_shape import AbstractShape


class GaussianShape(AbstractShape):
""" Gaussian pulse with a variable amplitude and sigma.

"""
#: Amplitude of the pulse this should be a number between -1.0 and 1.0
amplitude = Str('1.0').tag(pref=True, feval=Feval(types=Real))
sigma = Str('10.0').tag(pref=True, feval=Feval(types=Real))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally a comment for sigma too


def eval_entries(self, root_vars, sequence_locals, missing, errors):
""" Evaluate the amplitude of the pulse.

Parameters
----------
root_vars : dict
Global variables. As shapes and modulation cannot update them an
empty dict is passed.

sequence_locals : dict
Known locals variables for the pulse sequence.

missing : set
Set of variables missing to evaluate some entries in the sequence.

errors : dict
Errors which occurred when trying to compile the pulse sequence.

Returns
-------
result : bool
Flag indicating whether or not the evaluation succeeded.

"""
res = super(GaussianShape, self).eval_entries(root_vars, sequence_locals,
missing, errors)

if res:
if not -1.0 <= self._cache['amplitude'] <= 1.0:
msg = 'Shape amplitude must be between -1 and 1.'
errors[self.format_error_id('amplitude')] = msg
res = False

return res

def compute(self, time, unit):
""" Computes the shape of the pulse at a given time.

Parameters
----------
time : ndarray
Times at which to compute the modulation.

unit : str
Unit in which the time is expressed.

Returns
-------
shape : ndarray
Amplitude of the pulse.

"""
amp = self._cache['amplitude']
sigma = self._cache['sigma']
t0 = (time[0]+time[-1])/2
pulse_shape = [amp*np.exp(-(t-t0)**2/2/sigma**2) for t in time]
return np.asarray(pulse_shape)
88 changes: 88 additions & 0 deletions exopy_pulses/pulses/shapes/tanh_shape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2015-2018 by ExopyPulses Authors, see AUTHORS for more details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

#
# Distributed under the terms of the BSD license.
#
# The full license is in the file LICENCE, distributed with this software.
# -----------------------------------------------------------------------------
"""Most basic shape for an analogical pulse.

"""
from numbers import Real

import numpy as np
from atom.api import Str

from ..utils.validators import Feval

from .base_shape import AbstractShape


class TanhShape(AbstractShape):
""" Atan pulse with a variable amplitude and sigma.

"""
#: Amplitude of the pulse this should be a number between -1.0 and 1.0
amplitude = Str('1.0').tag(pref=True, feval=Feval(types=Real))
sigma = Str('10.0').tag(pref=True, feval=Feval(types=Real))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in Gaussian


def eval_entries(self, root_vars, sequence_locals, missing, errors):
""" Evaluate the amplitude of the pulse.

Parameters
----------
root_vars : dict
Global variables. As shapes and modulation cannot update them an
empty dict is passed.

sequence_locals : dict
Known locals variables for the pulse sequence.

missing : set
Set of variables missing to evaluate some entries in the sequence.

errors : dict
Errors which occurred when trying to compile the pulse sequence.

Returns
-------
result : bool
Flag indicating whether or not the evaluation succeeded.

"""
res = super(TanhShape, self).eval_entries(root_vars, sequence_locals,
missing, errors)

if res:
if not -1.0 <= self._cache['amplitude'] <= 1.0:
msg = 'Shape amplitude must be between -1 and 1.'
errors[self.format_error_id('amplitude')] = msg
res = False

return res

def compute(self, time, unit):
""" Computes the shape of the pulse at a given time.

Parameters
----------
time : ndarray
Times at which to compute the modulation.

unit : str
Unit in which the time is expressed.

Returns
-------
shape : ndarray
Amplitude of the pulse.

"""
amp = self._cache['amplitude']
sigma = self._cache['sigma']
t0 = (time[0]+time[-1])/2
duration = time[-1]-time[0]
func = lambda t:(0.5+0.5*np.tanh((t+duration/2)/sigma*2*np.pi-np.pi))
pulse_shape = [amp*func(t-t0)*func(-(t-t0)) for t in time]
return np.asarray(pulse_shape)
42 changes: 42 additions & 0 deletions exopy_pulses/pulses/shapes/views/gaussian_shape_view.enaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2015-2018 by ExopyPulses Authors, see AUTHORS for more details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

#
# Distributed under the terms of the BSD license.
#
# The full license is in the file LICENCE, distributed with this software.
# -----------------------------------------------------------------------------
"""View for the Gaussian Shape.

"""
from enaml.layout.api import hbox, vbox, align
from enaml.widgets.api import (Label, GroupBox)

from exopy.utils.widgets.qt_completers import QtLineCompleter
from ...utils.entry_eval import EVALUATER_TOOLTIP

from .base_shape_view import AbstractShapeView

enamldef GaussianShapeView(AbstractShapeView): view:
""" View for a Gaussian pulse.

"""
GroupBox:
title = 'Gaussian'
constraints = [hbox(amp_lab, amp_val, sigma_lab, sigma_val),
align('v_center', amp_lab, amp_val, sigma_lab, sigma_val)]

Label: amp_lab:
text = 'Amplitude'
QtLineCompleter: amp_val:
text := shape.amplitude
entries_updater = item.parent.get_accessible_vars
tool_tip = ('Relative amplitude of the pulse (should be between '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe worth adding the default tooltip after since those field can be evaluated

'-1.0 and 1.0)')

Label: sigma_lab:
text = 'Sigma'
QtLineCompleter: sigma_val:
text := shape.sigma
entries_updater = item.parent.get_accessible_vars
tool_tip = ('Sigma of gaussian pulse, units are AWG context units')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

42 changes: 42 additions & 0 deletions exopy_pulses/pulses/shapes/views/tanh_shape_view.enaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2015-2018 by ExopyPulses Authors, see AUTHORS for more details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

#
# Distributed under the terms of the BSD license.
#
# The full license is in the file LICENCE, distributed with this software.
# -----------------------------------------------------------------------------
"""View for the Gaussian Shape.

"""
from enaml.layout.api import hbox, vbox, align
from enaml.widgets.api import (Label, GroupBox)

from exopy.utils.widgets.qt_completers import QtLineCompleter
from ...utils.entry_eval import EVALUATER_TOOLTIP

from .base_shape_view import AbstractShapeView

enamldef TanhShapeView(AbstractShapeView): view:
""" View for a Tanh pulse.

"""
GroupBox:
title = 'Tanh'
constraints = [hbox(amp_lab, amp_val, sigma_lab, sigma_val),
align('v_center', amp_lab, amp_val, sigma_lab, sigma_val)]

Label: amp_lab:
text = 'Amplitude'
QtLineCompleter: amp_val:
text := shape.amplitude
entries_updater = item.parent.get_accessible_vars
tool_tip = ('Relative amplitude of the pulse (should be between '
'-1.0 and 1.0)')

Label: sigma_lab:
text = 'Sigma'
QtLineCompleter: sigma_val:
text := shape.sigma
entries_updater = item.parent.get_accessible_vars
tool_tip = ('Sigma of tanh pulse, basically raising time, units are AWG context units')
8 changes: 8 additions & 0 deletions exopy_pulses/tasks/manifest.enaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ enamldef PulsesTasksManifest(PluginManifest):
# Way to declare instrument dependencies without specifying
# any instrument.
instruments = [None]
path = 'exopy_pulses.tasks.tasks.instrs'
Task:
task = 'transfer_pulse_loop_task:TransferPulseLoopTask'
view = ('views.transfer_pulse_loop_task_view:'
'TransferPulseLoopView')
# Way to declare instrument dependencies without specifying
# any instrument.
instruments = [None]
Loading