Example_UploadProfileFromFile
Demonstrates how a pre-existing WSP file may be easily uploaded to the WaveShaper.
WSMethods Function Set
The examples make use of a set of lower-level functions that may be used to meet a wider variety use-cases. Here is an overview:
createWspString
This function is used to combine a set of frequency, attenuation, phase and port arrays into a single WSP string. This string may be
directly uploaded to the WaveShaper, or saved to file for later use.
splitWspString
This function is used to parse a WSP string into a set of frequency, attenuation, phase and port arrays. These arrays may then be
processed in any way that fits your application.
uploadProfile
This function simplifies the task of uploading arbitrary filter shapes by abstracting away the handling of JSON strings and HTTP
commands.
uploadPredefinedProfile
This function simplifies the task of uploading predefined profile by abstracting away the handling of JSON strings and HTTP
commands.
5.4
Python Examples
The Python example code below is written for use with Python 3. In addition, the following packages must be installed:
numpy
requests
json
A complete copy of the code examples may be downloaded from within the help section of the WaveShaper Software.
Example_UploadPredefinedProfile.py
import
requests
import
json
from
WSMethods
import
*
# Define device IP
ip
=
'169.254.6.8'
# Define profile according to API
profileType
=
'bandpass'
# blockall, transmit, bandpass, bandstop, gaussian
centerFreq
=
194.000
# THz
bandwidth
=
1
# THz
attenuation
=
0
# dB
port
=
1
# Upload predefined profile using above definition
r
=
uploadPredefinedProfile
(
ip
,
profileType
,
centerFreq
,
bandwidth
,
attenuation
,
port
)
WaveShaper A Series User Manual
38