Skip to main content
Solved

Extracting Complex Components of POP

  • June 7, 2023
  • 1 reply
  • 126 views

ArmandP

Hello,

I have a quick question regarding using the POP in sequential mode. Is there a way to extract the real and imaginary components of each part of the complex number array of the POP matrix that is used to compute the phase and intensity of the POP beam? Preferably as a CSV file? Thanks!

Best answer by MichaelH

Hi Armand,

There is not a built-in way to get the electric field.  However, the real & imaginary components of the x & y e-field are saved in the ZBF file.  You can either use the ZPL with the ZBFREAD keyword or you can use the ZOS-API.  The Help Files have a really good example for using ZBFREAD...I have modified it slightly to output a more readable format:

! modified from the Help Files

BROWSE "Select ZBF file", zbf$, 0
IF SLEN(zbf$) == 0 THEN END

! First get the beam size 
ZBFPROPERTIES zbf$, 1 

nx = vec1(1)
ny = vec1(2)
ip = vec1(14) # The "is polarized" flag

! Allocate enough memory to hold the beam
IF (ip == 1)
	PRINT "this example only handles unpolarized beams"
	END
ENDIF	

DECLARE B, DOUBLE, 3, nx, ny, 2
DECLARE P, DOUBLE, 1, 20
ZBFREAD zbf$, B, P

real$ = $TEMPFILENAME()
imag$ = $TEMPFILENAME()

FORMAT 12.6

! print data to text files
OUTPUT real$
	PRINT "Real Data - ", zbf$
	FOR j, 1, ny, 1
		FOR i, 1, nx, 1
			PRINT B(i, j, 1), 
		NEXT
		PRINT
	NEXT
OUTPUT SCREEN

OUTPUT imag$
	PRINT "Imaginary Data - " , zbf$
	FOR j, 1, ny, 1
		FOR i, 1, nx, 1
			PRINT B(i, j, 2), 
		NEXT
		PRINT
	NEXT
OUTPUT SCREEN

! show the data
SHOWFILE real$
SHOWFILE imag$

Michael C also wrote some really good parsers if you want to use the ZOS-API.

Python Reading Writing Binary Files (ZRD, ZBF, DAT, SDF) | Zemax Community

 

View original
Did this topic help you find an answer to your question?

1 reply

MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • 368 replies
  • Answer
  • June 7, 2023

Hi Armand,

There is not a built-in way to get the electric field.  However, the real & imaginary components of the x & y e-field are saved in the ZBF file.  You can either use the ZPL with the ZBFREAD keyword or you can use the ZOS-API.  The Help Files have a really good example for using ZBFREAD...I have modified it slightly to output a more readable format:

! modified from the Help Files

BROWSE "Select ZBF file", zbf$, 0
IF SLEN(zbf$) == 0 THEN END

! First get the beam size 
ZBFPROPERTIES zbf$, 1 

nx = vec1(1)
ny = vec1(2)
ip = vec1(14) # The "is polarized" flag

! Allocate enough memory to hold the beam
IF (ip == 1)
	PRINT "this example only handles unpolarized beams"
	END
ENDIF	

DECLARE B, DOUBLE, 3, nx, ny, 2
DECLARE P, DOUBLE, 1, 20
ZBFREAD zbf$, B, P

real$ = $TEMPFILENAME()
imag$ = $TEMPFILENAME()

FORMAT 12.6

! print data to text files
OUTPUT real$
	PRINT "Real Data - ", zbf$
	FOR j, 1, ny, 1
		FOR i, 1, nx, 1
			PRINT B(i, j, 1), 
		NEXT
		PRINT
	NEXT
OUTPUT SCREEN

OUTPUT imag$
	PRINT "Imaginary Data - " , zbf$
	FOR j, 1, ny, 1
		FOR i, 1, nx, 1
			PRINT B(i, j, 2), 
		NEXT
		PRINT
	NEXT
OUTPUT SCREEN

! show the data
SHOWFILE real$
SHOWFILE imag$

Michael C also wrote some really good parsers if you want to use the ZOS-API.

Python Reading Writing Binary Files (ZRD, ZBF, DAT, SDF) | Zemax Community

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings