-
Notifications
You must be signed in to change notification settings - Fork 4
Changes from Lyon #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. | ||
| # | ||
| # 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)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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') | ||
There was a problem hiding this comment.
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