Click or drag to resize

Creating Signals

The Examples Below show how to create Differnt Type Of Signals and Attatch them to an Excitation.

Create a Gaussian Signal Example
# Python Script, API Version = V251
# Import EMA API
import clr, os
_refs, _refcount = clr.References, 0
_install_path = os.environ.get("EMA2025R1_DIR") # Change this to your local EMC Plus install directory.
_api_path = "ema3d.Api.V25.dll" # This should be the name of your EMC Plus API DLL.
for _ref in _refs:  # Check list of references, see how many EMC Plus API references are currently added.
    if "ema3d.Api" in _ref.FullName:
        _refcount += 1

if _refcount == 0:  # No references, add absolute reference
    clr.AddReferenceToFileAndPath(os.path.join(_install_path,_api_path))
    _refcount += 1
if _refcount == 1:  # 1 reference, add relative reference
    clr.AddReferenceToFileAndPath(_api_path)

from ema3d.Api.V25.Core.Signals import GaussianSignal
from ema3d.Api.V25.Core.Excitation import PlaneWave
import ema3d.Api.V25.Core.MatchDomainType as MatchDomainType

doc = Window.ActiveWindow.Document
gaussian = GaussianSignal.Create(doc)


plane_wave = PlaneWave.GetInstance()

# Modify TStart
_tstart = gaussian.TStart
_tstart.MatchDomainType = MatchDomainType.None
_tstart.Value = 10e-7
gaussian.TStart = _tstart

# Modify TEnd
_tend = gaussian.TEnd
_tend.MatchDomainType = MatchDomainType.None
_tend.Value = 20e-7
gaussian.TEnd = _tend

# Modify TStep
_tstep = gaussian.TStep
_tstep.MatchDomainType = MatchDomainType.None
_tstep.Value = 5.3E-11
gaussian.TStep = _tstep

gaussian.Amplitude = 20.6
gaussian.Alpha = 5.35e17
gaussian.TPeak = 1.26e-8
gaussian.Name = "Hello World Gaussian"

gaussian.AttachTo(plane_wave)
Create a Sine Squared Signal Example
# Python Script, API Version = V251
# Import EMA API
import clr, os
_refs, _refcount = clr.References, 0
_install_path = os.environ.get("EMA2025R1_DIR") # Change this to your local EMC Plus install directory.
_api_path = "ema3d.Api.V25.dll" # This should be the name of your EMC Plus API DLL.
for _ref in _refs:  # Check list of references, see how many EMC Plus API references are currently added.
    if "ema3d.Api" in _ref.FullName:
        _refcount += 1

if _refcount == 0:  # No references, add absolute reference
    clr.AddReferenceToFileAndPath(os.path.join(_install_path,_api_path))
    _refcount += 1
if _refcount == 1:  # 1 reference, add relative reference
    clr.AddReferenceToFileAndPath(_api_path)

from ema3d.Api.V25.Core.Signals import SineSquaredSignal
from ema3d.Api.V25.Core.Excitation import PlaneWave
import ema3d.Api.V25.Core.MatchDomainType as MatchDomainType

doc = Window.ActiveWindow.Document
sine_squared = SineSquaredSignal.Create(doc)


plane_wave = PlaneWave.GetInstance()


# Modify TStart
_tstart = sine_squared.TStart
_tstart.MatchDomainType = MatchDomainType.None
_tstart.Value = 10e-7
sine_squared.TStart = _tstart

# Modify TEnd
_tend = sine_squared.TEnd
_tend.MatchDomainType = MatchDomainType.None
_tend.Value = 20e-7
sine_squared.TEnd = _tend

# Modify TStep
_tstep = sine_squared.TStep
_tstep.MatchDomainType = MatchDomainType.None
_tstep.Value = 5.3E-11
sine_squared.TStep = _tstep

sine_squared.Amplitude = 2
sine_squared.Frequency = 2e6
sine_squared.AShift = 1
sine_squared.TShift = .001
sine_squared.Name = "Hello World Sine Squared"

sine_squared.AttachTo(plane_wave)
Create a Sine Signal Example
# Python Script, API Version = V251
# Import EMA API
import clr, os
_refs, _refcount = clr.References, 0
_install_path = os.environ.get("EMA2025R1_DIR") # Change this to your local EMC Plus install directory.
_api_path = "ema3d.Api.V25.dll" # This should be the name of your EMC Plus API DLL.
for _ref in _refs:  # Check list of references, see how many EMC Plus API references are currently added.
    if "ema3d.Api" in _ref.FullName:
        _refcount += 1

if _refcount == 0:  # No references, add absolute reference
    clr.AddReferenceToFileAndPath(os.path.join(_install_path,_api_path))
    _refcount += 1
if _refcount == 1:  # 1 reference, add relative reference
    clr.AddReferenceToFileAndPath(_api_path)

from ema3d.Api.V25.Core.Signals import SineSignal
from ema3d.Api.V25.Core.Excitation import PlaneWave
import ema3d.Api.V25.Core.MatchDomainType as MatchDomainType

doc = Window.ActiveWindow.Document
sine_signal = SineSignal.Create(doc)


plane_wave = PlaneWave.GetInstance()


# Modify TStart
_tstart = sine_signal.TStart
_tstart.MatchDomainType = MatchDomainType.None
_tstart.Value = 10e-7
sine_signal.TStart = _tstart

# Modify TEnd
_tend = sine_signal.TEnd
_tend.MatchDomainType = MatchDomainType.None
_tend.Value = 20e-7
sine_signal.TEnd = _tend

# Modify TStep
_tstep = sine_signal.TStep
_tstep.MatchDomainType = MatchDomainType.None
_tstep.Value = 5.3E-11
sine_signal.TStep = _tstep

sine_signal.Amplitude = 2
sine_signal.Frequency = 2e6
sine_signal.AShift = 1
sine_signal.TShift = .001
sine_signal.Name = "Hello World Sine"

sine_signal.AttachTo(plane_wave)
Create a Rectangular Signal Example
# Python Script, API Version = V251
# Import EMA API
import clr, os
_refs, _refcount = clr.References, 0
_install_path = os.environ.get("EMA2025R1_DIR") # Change this to your local EMC Plus install directory.
_api_path = "ema3d.Api.V25.dll" # This should be the name of your EMC Plus API DLL.
for _ref in _refs:  # Check list of references, see how many EMC Plus API references are currently added.
    if "ema3d.Api" in _ref.FullName:
        _refcount += 1

if _refcount == 0:  # No references, add absolute reference
    clr.AddReferenceToFileAndPath(os.path.join(_install_path,_api_path))
    _refcount += 1
if _refcount == 1:  # 1 reference, add relative reference
    clr.AddReferenceToFileAndPath(_api_path)

from ema3d.Api.V25.Core.Signals import RectangularSignal
from ema3d.Api.V25.Core.Excitation import PlaneWave
import ema3d.Api.V25.Core.MatchDomainType as MatchDomainType

doc = Window.ActiveWindow.Document
rectangular = RectangularSignal.Create(doc)


plane_wave = PlaneWave.GetInstance()

# Modify TStart
_tstart = rectangular.TStart
_tstart.MatchDomainType = MatchDomainType.None
_tstart.Value = 10e-7
rectangular.TStart = _tstart

# Modify TEnd
_tend = rectangular.TEnd
_tend.MatchDomainType = MatchDomainType.None
_tend.Value = 20e-7
rectangular.TEnd = _tend

# Modify TStep
_tstep = rectangular.TStep
_tstep.MatchDomainType = MatchDomainType.None
_tstep.Value = 5.3E-11
rectangular.TStep = _tstep

rectangular.Amplitude = 2
rectangular.Frequency = 2e6
rectangular.AShift = 1
rectangular.TShift =.001
rectangular.DutyCycle = .25
rectangular.TRise = 1e-10
rectangular.TFall = 1e-10
rectangular.Name = "Hello World Rectangular"

rectangular.AttachTo(plane_wave)
Create a Signal from Source File Example
# Python Script, API Version = V251
# Import EMA API
import clr, os
_refs, _refcount = clr.References, 0
_install_path = os.environ.get("EMA2025R1_DIR") # Change this to your local EMC Plus install directory.
_api_path = "ema3d.Api.V25.dll" # This should be the name of your EMC Plus API DLL.
for _ref in _refs:  # Check list of references, see how many EMC Plus API references are currently added.
    if "ema3d.Api" in _ref.FullName:
        _refcount += 1

if _refcount == 0:  # No references, add absolute reference
    clr.AddReferenceToFileAndPath(os.path.join(_install_path,_api_path))
    _refcount += 1
if _refcount == 1:  # 1 reference, add relative reference
    clr.AddReferenceToFileAndPath(_api_path)

from ema3d.Api.V25.Core.Signals import SourceFileSignal
from ema3d.Api.V25.Core.Excitation import PlaneWave
import ema3d.Api.V25.Core.MatchDomainType as MatchDomainType

doc = Window.ActiveWindow.Document
file = "C:\signal-files\my_signal.dat"
source_file_signal = SourceFileSignal.Create(file, doc)


plane_wave = PlaneWave.GetInstance()

# Modify TStart
_tstart = source_file_signal.TStart
_tstart.MatchDomainType = MatchDomainType.None
_tstart.Value = 10e-7
source_file_signal.TStart = _tstart

# Modify TEnd
_tend = source_file_signal.TEnd
_tend.MatchDomainType = MatchDomainType.None
_tend.Value = 20e-7
source_file_signal.TEnd = _tend

# Modify TStep
_tstep = source_file_signal.TStep
_tstep.MatchDomainType = MatchDomainType.None
_tstep.Value = 5.3E-11
source_file_signal.TStep = _tstep

source_file_signal.Name = "Hello World Source File Signal"

source_file_signal.AttachTo(plane_wave)