Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AWG control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
whuie2
AWG control
Commits
1ed4bb8f
Commit
1ed4bb8f
authored
2 years ago
by
xiyehu2
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
2495e5d3
5bbfe736
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Python/waveform.py
+36
-29
36 additions, 29 deletions
Python/waveform.py
with
36 additions
and
29 deletions
Python/waveform.py
+
36
−
29
View file @
1ed4bb8f
...
...
@@ -3,7 +3,7 @@ from typing import Dict, Tuple, Any, List
import
numpy
as
np
from
scipy.interpolate
import
interp1d
from
AWG
import
*
import
cupy
as
cp
#
import cupy as cp
class
Waveform
:
...
...
@@ -214,7 +214,8 @@ def create_path_table_gpu(
path_table
=
{}
# lookup table to store all moves
static_sig
=
cp
.
zeros
(
sample_len
)
# for fast real-time waveform generation purposes
t
=
cp
.
arange
(
sample_len
)
/
wfm
.
sample_rate
# time series
dt
=
t
[
1
]
t
+=
dt
nt
=
len
(
wfm
.
omega
)
diagonal_mat
=
cp
.
sin
(
...
...
@@ -239,7 +240,7 @@ def create_path_table_gpu(
# I advise reading through the notes page first before going further
dw
=
omega_j
-
omega_i
# delta omega in the equation
adw
=
abs
(
dw
)
t_tot
=
np
.
sqrt
(
abs
(
4
*
dw
/
a_max
))
# calculate minimum time to complete move
t_tot
=
np
.
sqrt
(
abs
(
4
*
dw
/
a_max
))
+
dt
# calculate minimum time to complete move
phi_j
=
wfm
.
phi
[
j
]
%
twopi
# wrap around two pi
phi_i
=
wfm
.
phi
[
i
]
%
twopi
...
...
@@ -396,57 +397,63 @@ def create_moving_array_GPUOTF(
return
def
create_moving_signal_single
(
omega_i
,
omega_f
,
sample_rate
,
signal_time
):
min_len
=
2
*
sample_rate
/
(
10e3
)
def
create_moving_signal_single
(
omega_i
,
omega_f
,
sample_rate
,
signal_time
,
amp
=
2
**
12
,
phi
=
0
):
min_len
=
2
*
sample_rate
/
(
1e3
)
sample_len
=
sample_rate
*
signal_time
sample_len
+=
min_len
-
sample_len
%
min_len
sample_len
=
int
(
sample_len
)
t
=
np
.
arange
(
sample_len
)
/
sample_rate
t_tot
=
sample_len
/
sample_rate
t
+=
t
[
1
]
t_tot
=
sample_len
/
sample_rate
+
t
[
1
]
a
=
4
*
(
omega_i
-
omega_f
)
/
(
t_tot
**
2
)
end
=
sample_len
half
=
int
(
end
/
2
)
+
1
t1
=
t
[:
half
]
t2
=
t
[
half
:
end
]
-
t_tot
/
2
amps
=
2
**
12
signal
=
np
.
zeros
(
sample_len
)
signal
[:
half
]
=
omega_i
*
t1
-
a
/
6
*
t1
**
3
# t<=T/2
signal
[:
half
]
=
phi
+
omega_i
*
t1
-
a
/
6
*
t1
**
3
# t<=T/2
# ph = wfm.phi[i] + omega_i * t_tot / 2 + a / 6 * (t_tot / 2) ** 3
signal
[
half
:
end
]
=
signal
[
half
-
1
]
+
\
(
omega_i
-
a
/
2
*
(
t_tot
/
2
)
**
2
)
*
t2
-
\
a
/
2
*
t_tot
/
2
*
t2
**
2
+
\
a
/
6
*
t2
**
3
# t>=T/2
signal
[
end
:]
=
signal
[
end
-
1
]
+
omega_f
*
(
t
[
end
:]
-
t
[
end
-
1
])
signal
=
(
amps
*
np
.
sin
(
signal
)).
astype
(
np
.
int16
)
return
signal
phi_end
=
signal
[
-
1
]
signal
=
amp
*
np
.
sin
(
signal
)
return
signal
.
astype
(
np
.
int16
),
phi_end
def
create_move_then_back
(
omega_i
,
omega_f
,
sample_rate
,
move_time
,
stay_time
):
min_len
=
2
*
sample_rate
/
0.1e3
sample_len
=
sample_rate
*
(
move_time
*
2
+
stay_time
)
def
create_static_signal_single
(
omega
,
sample_rate
,
signal_time
,
amp
=
2
**
12
,
phi
=
0
):
min_len
=
2
*
sample_rate
/
(
1e3
)
sample_len
=
sample_rate
*
signal_time
sample_len
+=
min_len
-
sample_len
%
min_len
sample_len
=
int
(
sample_len
)
t
=
np
.
arange
(
sample_len
)
/
sample_rate
t_tot
=
sample_len
/
sample_rate
a
=
4
*
(
omega_i
-
omega_f
)
/
(
t_tot
**
2
)
end
=
sample_len
half
=
int
(
end
/
2
)
+
1
t1
=
t
[:
half
]
t2
=
t
[
half
:
end
]
-
t_tot
/
2
t
+=
t
[
1
]
signal
=
phi
+
omega
*
t
phi_end
=
signal
[
-
1
]
signal
=
amp
*
np
.
sin
(
signal
)
return
signal
.
astype
(
np
.
int16
),
phi_end
amps
=
2
**
12
signal
=
np
.
zeros
(
sample_len
)
signal
[:
half
]
=
omega_i
*
t1
-
a
/
6
*
t1
**
3
# t<=T/2
# ph = wfm.phi[i] + omega_i * t_tot / 2 + a / 6 * (t_tot / 2) ** 3
signal
[
half
:
end
]
=
signal
[
half
-
1
]
+
\
(
omega_i
-
a
/
2
*
(
t_tot
/
2
)
**
2
)
*
t2
-
\
a
/
2
*
t_tot
/
2
*
t2
**
2
+
\
a
/
6
*
t2
**
3
# t>=T/2
signal
[
end
:]
=
signal
[
end
-
1
]
+
omega_f
*
(
t
[
end
:]
-
t
[
end
-
1
])
signal
=
(
amps
*
np
.
sin
(
signal
)).
astype
(
np
.
int16
)
def
create_move_then_back
(
omega_i
,
omega_f
,
sample_rate
,
move_time
,
stay_time
):
move0
,
phi0
=
create_moving_signal_single
(
omega_i
,
omega_f
,
sample_rate
,
move_time
)
stay
,
phi1
=
create_static_signal_single
(
omega_f
,
sample_rate
,
stay_time
,
phi
=
phi0
)
move1
,
phi2
=
create_moving_signal_single
(
omega_f
,
omega_i
,
sample_rate
,
move_time
,
phi
=
phi1
)
signal
=
np
.
concatenate
((
move0
,
stay
,
move1
))
return
signal
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment