Skip to main content

A pulse shaping program for EPR!

Project description

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.

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, 
              freq=[40, 120], 
              type='sech/tanh', 
              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,
                 freq=[40, 120],
                 type='sech/tanh',
                 beta=10,
                 profile=profile)

g_pulse = Pulse(pulse_time=0.06,
                time_step=0.000625,
                flip=np.pi,
                type='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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PulseShape-0.1.0.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

PulseShape-0.1.0-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file PulseShape-0.1.0.tar.gz.

File metadata

  • Download URL: PulseShape-0.1.0.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.7

File hashes

Hashes for PulseShape-0.1.0.tar.gz
Algorithm Hash digest
SHA256 85a4e66345e9e4b0d56c22ef5d63c43a0b1a2b7386431c9c7f596f5c4b702616
MD5 e5db04542129bdb9e4235c1e29cc2225
BLAKE2b-256 b8bc25edb643cbd183a6c6864c4ea0def28a53f73b87933a1acf74cef7b8f589

See more details on using hashes here.

File details

Details for the file PulseShape-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: PulseShape-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.7

File hashes

Hashes for PulseShape-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5462066d22edc5ec2ed40e6cdff5f75574fd91f69d2d526b83f88b19bf56b2fe
MD5 3f942afbbcc48f9c6fa49ceb5e2f80a4
BLAKE2b-256 35c99e14ab84f7bdceee60a657ba6e039268972062e5ffdcf10b4f7e096a1f6a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page