Frequency-domain field and power monitor

    • djihad-amina.djemmah

      I have a question about monitors, I am using Frequency-domain field and power monitor to mesure Transmission.

      The data collected is given with a single precision numbers (have approximately 6 decimals of precision), and I am looking for a double precision (~12 decimals of precision)

      Could you please show me how to go from single to double precision?

      Looking forward to your answer.

      Thanks in advance.

    • Kyle
      Ansys Employee

      You can use the format command to change the script interpreter to 16 digits of precision. You can then print the results to the Script Prompt with the print character ?, or use thewriteandnum2strcommands to write your data to a text file.
    • djihad-amina.djemmah
      Hello Thank you for your reply.
      The problem I have, I don't know where I have to write "num2str";", I am not very familiar with lumerical sript.
      Could you tell me where exactly I have to write "write and num2str" commands to get the data of the transmission with 16 digits of precision.

      Waiting for your answer Thank you in advance
    • Kyle
      Ansys Employee

      If you are new to using the Lumerical scripting language, the online scripting course might be helpful:
      The num2str command is used to convert the numerical data to strings so it can be written to the text file. The writedocumentation page has examples on how to export data with these commands. This example also includes using "format long" to save the data with more precision:
      # define the variables to export
      # remove the file if it already exists
      # write the file header
      write("testfile.txt","theta, sin(theta)");
      # set num2str() to return 16 digits of precision
      format long;
      # write the data to the file
      for (i=1:length(a) ) {
      str= num2str(a(i))+", "+num2str(b(i));
      You may also need to use the getresult command to get the results from the monitor into the Script Workspace. Once the results dataset is in the Workspace, you can get the transmission and wavelength/frequency data from the monitor dataset with the dot operator, and save it to the text file as shown in the script above:
Viewing 3 reply threads
  • You must be logged in to reply to this topic.