We’re putting the final touches on our new badges platform. Badge issuance remains temporarily paused, but all completions are being recorded and will be fulfilled once the platform is live. Thank you for your patience.
Photonics – Chinese

Photonics – Chinese

Topics related to Lumerical and more, in Chinese language.

对于如何使用script element的脚本编辑问题

    • QuickChen
      Subscriber

      您好,我在INTERCONNECT中创建了一个script element,其结构是三输入,单输出,输入输出均为光脉冲信号;想实现的功能是:y是一组权重矩阵【10.523】,in端口为输入信号,dropthrough端口为权值修改信号,y的起始权重为2,当检测到drop口有输入时,y的索引值会向上增加一个,即y变为3;当检测到through口有输入时,y的索引值会向下减少一个,即y变为0.5;当两个端口都检测不到数值时,y值会变为1;并将最终得到的y的数值成作为信号增益权重,将乘完权重的信号输出。

      目前遇到的问题时,当drop口有输入,through没有输入时,依然显示的是y=1(正常情况应该是y=3),请问该如何解决?

      dropthrough口的输入,零输入有幅值为0的噪声提供,其余输入由0.01w光脉冲提供)

      signalIn = popportframe( "in" );

      signalIn2 = popportframe( "drop" );

      signalIn3 = popportframe( "through" );

      if( signalIn.valid and signalIn2.valid and signalIn3.valid ) {

       

      for( i = 1:length( signalIn.data.signal ) ) {

      nChannels = length( signalIn.data.signal{i}.channel );

      for( j = 1:nChannels ) {

       

      for(k=1:length(signalIn.data.signal{i}.channel{j}.value)) {

      y = [1,0.5,2,3];

      if(signalIn2.data.signal{i}.channel{j}.value(k)>0){

      y_index = find(y == 2);

      y_index = mod(y_index, length(y)) + 1; } #2>0,3

      if(signalIn3.data.signal{i}.channel{j}.value(k)>0){

      y_index = find(y == 2);

      y_index = mod(y_index - 2, length(y)) + 1;} #3>0,0.5

      else{

      y_index = find(y == 2);

      y_index = mod(y_index - 3, length(y)) + 1;

      }

      signalIn.data.signal{i}.channel{j}.value(k) = y(y_index) * signalIn.data.signal{i}.channel{j}.value(k);

       

       

      }

      }

      }

      }

      pushportframe( "out", signalIn );

    • Chih-Hao Chen
      Ansys Employee

      您好

      我有幾個疑問。看您的腳本中,如果signalIn3有大於零的值(drop),腳本是直接用等於2的index減掉二,若以[1,0.5,2,3]為例,相當於變成index 1。這好像和您描述的行為不一致。(到drop有输入时,y的索引值会向上增加一个,即y变为3)

      同理,如果drop和through都沒有值,腳本是用2的index減掉3,若以[1,0.5,2,3]為例,相當於要找索引值為-1,我覺得有點奇怪。

      然後,腳本中是以有沒有大於0去判斷有沒有值,我們能確保通過物件的值都是大於零嗎?有沒有負數甚至是複數的可能呢?

      我會建議您先用簡單的腳本出發,先個別測試情況是否符合預期,最後再組合起來。

       

       

Viewing 1 reply thread
  • The topic ‘对于如何使用script element的脚本编辑问题’ is closed to new replies.