Skip to main content

PusleShape

PulseShape is an EasySpin pulse function clone written in python. The major purpose for rewriting pulse in Python is to free the function from the proprietary MATLAB universe and make it easier to use on Linux systems that often ship with e580 spectrometers.

PulseShape is built around the Pulse object which accepts arguments similar to those used by the easyspin pulse function.

Installation

PulseShape can be installed and updated using pip, the python package manager.

pip install PulseShape

PulseShape is tested to work on python 3.6-3.9. While one of the major purposes of PulseShape is to work on Linux systems, PulseShape works well on all systems (Windows, Mac and Linux) and only depends on numpy and scipy.

Alternatively, PulseShape can be installed by downloading or cloning the git repository.

git clone https://gitlab.com/mtessmer/PulseShape.git
cd PulseShape
python setup.py install

e580 Setup

Instructions for setting up python and PulseShape on the Linux system that usually ships with e580 spectrometers coming soon.

Example: sech\tanh pulse with resonator compensation

PulseShape EasySpin
import numpy as np
import matplotlib.pyplot as plt
from PulseShape import Pulse

profile = np.loadtxt('data/Transferfunction.dat')
pulse = Pulse(pulse_time=0.150, 
              time_step=0.000625, 
              flip=np.pi, 
              shape='sech/tanh', 
              freq=[40, 120], 
              beta=10, 
              profile=profile)

plt.figure(figsize=(5, 5))
plt.plot(pulse.time * 1000, pulse.IQ.real, label='real')
plt.plot(pulse.time * 1000, pulse.IQ.imag, label='imaginary')
plt.xlabel('time (ns)')
plt.ylabel('Amplitude')
plt.legend()
plt.show()
Par = struct
Par.Type = 'sech/tanh';
Par.beta = 10;
Par.tp = 0.150;
Par.Phase = 0;
Par.Flip = pi;
Par.Frequency = [40 120]
Par.TimeStep=0.000625

filename = 'Transferfunction.dat';
delimiter = ' ';
formatSpec = '%f%f%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', ... 
                    delimiter, 'MultipleDelimsAsOne', ...
                    true, 'TextType', 'string');
fclose(fileID);

Par.FrequencyResponse = [dataArray{:, 1}, dataArray{:, 2}];

[t, IQ] = pulse(Par)
[t, IQ, modulation] = pulse(Par) 

figure(1)
hold on
plot(t, real(IQ))
plot(t, imag(IQ))
xlabel('time ns')
ylabel('Amplitude')
x0=10;
y0=10;
width=465;
height=448;
set(gcf,'position',[x0,y0,width,height])

Example: Working with multiple pulses

All time, IQ, other paramters and data are stored withing the Pulse object itself so it's easy to work with multiple pulses

import numpy as np
import matplotlib.pyplot as plt
from PulseShape import Pulse

profile = np.loadtxt('data/Transferfunction.dat')
st_pulse = Pulse(pulse_time=0.150,
                 time_step=0.000625,
                 flip=np.pi,
                 shape='sech/tanh',
                 freq=[40, 120],

                 beta=10,
                 profile=profile)

g_pulse = Pulse(pulse_time=0.06,
                time_step=0.000625,
                flip=np.pi,
                shape='gaussian',
                trunc=0.1)

offsets = np.linspace(-20, 140, 256)
st_pulse.exciteprofile(offsets)
g_pulse.exciteprofile(offsets)

fig, (ax1, ax2) = plt.subplots(2, figsize=(8, 10))
ax1.set_title('Pulse IQ')
ax1.plot(st_pulse.time * 1e3, st_pulse.IQ.real, label=r'sech/tanh $\Re$', color='C0')
ax1.plot(st_pulse.time * 1e3, st_pulse.IQ.imag, label=r'sech/tanh $\Im$', alpha=0.5, color='C0')
ax1.plot(g_pulse.time * 1e3, g_pulse.IQ.real, label='gaussian', color='C1')
ax1.set_ylabel('Amplitude')
ax1.set_ylabel("Time (ns)")
ax1.legend()

ax2.set_title('Excitation Profile')
ax2.plot(offsets, st_pulse.Mz)
ax2.plot(offsets, g_pulse.Mz)
ax2.set_xlabel('Frequency Offset (MHz)')
ax2.set_ylabel('Mz')
plt.show()

Release files for PulseShape 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PulseShape 0.1.4
File Size Uploaded
PulseShape-0.1.4.tar.gz 13.9 MB Details

Release files / PulseShape-0.1.4.tar.gz

Download URL PulseShape-0.1.4.tar.gz
Size 13.9 MB
Tags Source
SHA-256 checksum
How to use checksums
e058f8f542b1793b86240edb0eebaf27fd3a1cdcefaf61388a513f3674f6d996
BLAKE2b-256 checksum
How to use checksums
61b1284a4ee7bca1a3bb3acb926e19d0c1bcf7606e4da20e2b55820d4e55165f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.0

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file

0.1.2

1 release file

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page