Home Forums GENERAL Python in OptiSystem

Viewing 7 reply threads
  • Author
    Posts
    • #50903
      preben
      Participant

      Dear all,

      I am trying to use Python in OptiSystem. I tried to run the OptiSystem example such as PythonExample_ClockRecoveryComponent.osd. However, it showed me an error: calculation failed.

      Should I install some special python packages?

    • #50913
      Ahmad Atieh
      Moderator

      Hello,
      You need to make sure that you download some python packages as described in the attached readme file.
      Also, make sure that you have the correct path for the python file stored in the component.
      Regards,
      Ahmad

    • #50967
      preben
      Participant

      Thank you so much for your reply. I checked the python file for the ClockRecoveryComponent.osd project.

      there are several packages like:
      import numpy as np
      import math
      import tempfile
      import sys

      sys.path.append(‘/Temp/PythonScripts/PythonSignalLibrary’) #the directory that contains CDS_SystemManager
      sys.path.append(tempfile.gettempdir() + ‘/OptiSystemTempDir’)

      from SystemManager import *
      from CalculationResult import *
      from SignalLibrary import *

      where can I download the three modules: SystemManager, CalculationResult,SignalLibrary?

    • #51026
      Ahmad Atieh
      Moderator

      Hello,
      You don’t need to load anything else.
      please note that SignalLibrary, CalculationResult, and SystemManager are .py files under .. \PythonScripts\PythonSignalLibrary

      Regards,
      Ahmad

    • #51034
      preben
      Participant

      Thank you so much for your help, Ahmad.
      I found the SignalLibrary,CalculationResult, and CDS-SystemManager as your guide. I didn’t see SystemManager.py file. do I missing this python file, or the CDS_SystemManager.py is same with SystemManager.py? if so, could you please upload this file?

      I have added “sys.path.append(‘D:/OptiSamples/OptiSystem 15.0 Samples/PythonScripts/PythonSignalLibrary’) ” in ClockRecoveryComponent.py

      I tried to change the “from SystemManager import *” to “from CDS_SystemManager import *” in ClockRecoveryComponent.py. but it didn’t work.

      when I run the ClockRecoveryComponent.osd project. it still shows me the error while calculating the component Clock Recovery_1. and the caculation cancelled.

      I already changed the path in the component,as “D:\OptiSamples\OptiSystem 15.0 Samples\PythonScripts\PythonComponents”

      I cannot figure out where the problem is.

    • #51064
      divya khanure
      Participant

      once we design a system in optisystem, we can extract python script… can we make changes in the script n run it?
      if so, how to run the python script? please help me..

    • #51149
      Ahmad Atieh
      Moderator

      Hello,
      This is the feedback from our software Engineer.
      First: you should add those two lines. The fist is the location where PyhonScripts are install. The second is temp location where the output temp files.
      sys.path.append(‘/../../PythonScripts/PythonSignalLibrary’) #the directory that contains CDS_SystemManager
      sys.path.append(tempfile.gettempdir() + ‘/OptiSystemTempDir’)

      Second: SignalLibrary.py contains all necessary .py files including “from CDS_SystemManager import *”. You need to verify that.
      Third: “from SystemManager import *” – Yes there is SystemManager.py file that is generated during calculation but is hidden for the user. The location is in ../OptiSystemTempDir You should not worry about this one.
      Fourth: It is not necessary for the you to add to the path of the computer ..\PythonScripts\PythonComponents.

      The calculation could fail if there is a problem with Python installation (adding necessary paths to computer est.. ).
      Regards,
      Ahmad

    • #51150
      Ahmad Atieh
      Moderator

      Dear Divya,
      Yes, you can modify the python script and run it in a similar way as VB script.
      Regards,
      Ahmad

Viewing 7 reply threads
  • You must be logged in to reply to this topic.