- This topic has 7 replies, 3 voices, and was last updated 5 years, 6 months ago by Ahmad Atieh.
-
AuthorPosts
-
-
March 24, 2019 at 10:26 pm #50903prebenParticipant
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?
-
March 26, 2019 at 9:06 am #50913Ahmad AtiehModerator
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 -
April 1, 2019 at 11:54 pm #50967prebenParticipant
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 syssys.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?
-
April 4, 2019 at 2:17 pm #51026Ahmad AtiehModerator
Hello,
You don’t need to load anything else.
please note that SignalLibrary, CalculationResult, and SystemManager are .py files under .. \PythonScripts\PythonSignalLibraryRegards,
Ahmad -
April 7, 2019 at 9:17 pm #51034prebenParticipant
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.
-
April 10, 2019 at 11:13 am #51064divya khanureParticipant
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.. -
April 17, 2019 at 2:23 pm #51149Ahmad AtiehModerator
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 -
April 17, 2019 at 2:25 pm #51150Ahmad AtiehModerator
Dear Divya,
Yes, you can modify the python script and run it in a similar way as VB script.
Regards,
Ahmad
-
-
AuthorPosts
- You must be logged in to reply to this topic.