Find out how you can save time and energy using the Zemax Programming Language!
- 165 Topics
- 442 Replies
Hi all,I want to save data and images of detectors automatically with ZPL. So I made the ZPL code as below. For n = 2, 6, 1 ####### get Detector viewer in img. winnum = n+1 OpenAnalysisWindow "Dvr", cfgpath$ ExportJPG winnum, imgfile$ ####### get Detector viewer in dat. #ModifySettings cfgtxt$, DVW_SHOW, 1 # extraction middle row data from 2d data GetTextFile datfile$, "Dvr", cfgtxt$ , 1 ConvertFileFormat datfile$, 1 #Unicode to ANSINext Once I open all detector viewer windows, I tried to save images and data in detector number order. However, I couldn’t save each detector data/image because it cannot recognize the number of detector in this code. What should I do? Or, are there better method to do it? Please help me. Thanks in advance.
Is it possible to calculate the 'field Type' 'Angle' (Code 0) from the 'field Type' 'Real Image Height' (Code 3) with a ZPL script? It is basically what the Zemax 'Field data editor' offers with the 'Convert to' option. However, I do not need to *convert* the field type, but just have to determine the value. With 'Single Ray Trace' as well as with the operand 'RAID', I only get one angle. But I need the two angles as defined for the 'field Type' 'Angle' Thank you and best regards, Christof.
Sometimes, we may design the system starting from the 'image' back to the 'object'. For example, this is often the case for those systems that are designed to be viewed by eye, like AR/VR, HUD. In this case, normally, if we want to check the relative illumination, we need to reverse the system to check because the tool 'Relative Illumination' only calculates that on last surface in the system.Here we will provide another way to calculate it using a macro so that you don't need to reverse the system.Note here we at the same time is also demoing how you can verify the calculation theory of the RI. RI is actually much easier to calculate if the system is reversely designed! First, by reading the following forum post, we know that relative illumination at each field is exactly linearly dependent to the area of the beam in cosine space in image space.So, here is the plan. We want to write a macro to calculate the beam area in cosine space for each field, normalize it, and then get the the R
Hello. I guess my question is fairly straight forward. However, I am not very used to any optimization procedures, so any help will be appreciated. Assuming I have a source and a detector, and some surfaces inbetween in a non-sequential setting. I need to write a merit funtion that maximizes flux on the detector - but only for rays hitting a specific surface in between source and detector. While this is easily done by filter strings in a simple detector view, I was unsure on how to implement this in the optimization. Therefore Zemax provided some help a while ago in form of this ZPLM operand detector = PVHX() clear = NSDD(1,0,0,0) NSTR 1, 0, 0, 0, 0, 0, 0, 1, 'Test.ZRD', 'H4' ZRDPLAYBACK 'Test.ZRD', 1, detector, 1 X = NSDD(1, detector, -3, 0) OPTRETURN 0, X So I specify my detector in H(x) and then clear all detectors, run a raytrace with the filter string applied (in this case hit surface 4) and point it back to the detector. So now this returns the rays hitting the detector under con
I use Detectorviewers in text mode to export the results of my simulations to disk.Futher processing is done via python, where the plain textfile gets parsed.I prefer to not using the ZOS API as this limits me in the python verison i use. Problem is: The Detector Viewer numbers are really error-prone as sometimes i close a window and open another one and the numbers i have to put into SAVEWINDOW keyword are just wrong by then.I would prefer using the detector number instead using SAVEDETECTOR keyword. But this saves in some binary format i did not find any specs upon for reading that in. Is there any description on the DDR/DDx file format?Is there any way to obtaining the detector data into python? Best regardsOlli
A user asked why when using ZPL macro to save the Cross Section Row Coherent Irradiance data from Detector Viewer, the .txt file he got does not match the information displayed in the Text tab of the Detector Viewer. Instead of seeing a 2-column data of X position versus Irradiance, he kept seeing 3-column data displaying “Spatial Frequency, X and Y” This is because in his code, the Configuration file is saved with the settings displayed in the Graph tab of the Detector Viewer, where the Cross Section Row is data value #4 in the “Show As:” dropdown list, (the index starts at 0). However, the GETTEXTFILE keyword is retrieving data from the Text tab of the Detector Viewer, where there isn’t a data value #4 in the “Show As:” dropdown list, so OpticStudio simply saves the data from the last available data value #3 which is the “Geometric MTF”. In order to save the data for the Cross Section Row irradiance, you need to use MODIFYSETTINGS
Hello all,I am a student in internship and I need to use ZPL to automate my system. I have a system with LED, which I am optimizing. After this optimization I have to measure the power received on the detector for different Z positions (34 positions).I do not know how to make a list of my different Z positions, how to change the value of the Z position for my detector and how to retrieve the value of the power received on my detector.Thank you in advance,Léo
This code calculates grid distortion based on centroid. The advantage is it works for systems where the chief ray cannot reach image surface. Note that, although chief ray doesn't need to reach image surface, there should still be some rays reaching the image surface. This only works when the field type is either Angle or Object Height. Another useful points of this tool is it shows data on image coordinate, not object coordinate as in the native Grid Distortion analysis.In the generated layout, you can see red and blue marks.Red marks are the centroid position of each sampled field. Blue marks are the 'reference' that serves as definition of 'no distortion'.Note Red marks are the ray-tracing result of your system and cannot be changed. However, the blue marks is defined by ABCD matrix, which can be user-defined. In other words, there is no a standard of 'no distortion'.The macro will automatically find a reasonable ABCD matrix just like the native Grid Distortion, but you can definit
I would like to create a new text file from inside of a ZPL macro for saving data while the macro runs. I see the OPEN command, but it requires the file to already be created. I do not see any keyword for creating the new file. Is there a way to create new files from inside of a running Macro? Thanks Chris Buchholz
Error in converting from CodeV file to Zemax. Maximum length for a string variable is exceeded. Please shorten string and try again SEQ Command: VUX 0.2862643455614489e-9 -0.002507618428442271 -0.01007430775580165 -0.02275146039691922 -0.04038529897597765 -0.06242137400922543 -0.08826487454143517 -0.1181757056085635 -0.1349076575530941 -0.152878222887056 -0.1719304103266932 -0.1914365142446497 -0.2096016968531782 -0.2187861418214183 -0.2257120003786426 How to debug this. Please let me know
Dear support team, I am working with a complex off-axis optics with several stray-light baffles. I need to determine the vignetting as a function of the two field coordinates. The first surface of my afocal system is the aperture stop. With vignetting I mean a geometrical quantity defined as the number of rays from one field that reach the image divided by the number of rays that pass my aperture stop. I think this is basically what the Zemax 'Vignetting Plot' does. But: 'This feature is appropriate for rotationally symmetric lenses and fields' only. The Footprint Diagram determines the 'percentage of rays through', which should be the same. Is this correct? Is there an Operand available, that calculates the vignetting according to what these two plots do and which I can calculate over a 2D-field with ZPL? I found the IMAE Operand: 'The IMAE operand estimates the efficiency of an optical system by launching many rays into the entrance pupil; computing the fraction of rays t
Good morning, I am designing a broadband spectrometer (currently in sequential mode). I think someone may answer the following questions way faster than I can. I am interested in measuring the spot size in the dispersion direction (therefore not as a general RMS parameter, as it is usually given). Is there a way in Zemax to automatically measure it through the merit function? I know that the optimization wizard allows to choose a X Weight and an Y Weight. Is there any reference I can read of the topic? Can you advice any specific reference on how to relate the calculated RMS spot size in Zemax to the spectrometer resolution? Thank you very much, Cinzia
How does one do a bulk raytrace in ZPL, similar to pressing the “Ray Trace” button in regular, non-sequential mode. From the help files, it looks like RAYTRACE and RAYTRACEX only traces one particular ray, which is not useful for determining the total illumination on a detector. Thanks!
Hi all,I’m facing a problem of applying ‘Chief ray solve’ for multiple configurations inside the multi-configuration editor. I was trying to use ‘Chief ray solve’ for Decenter and Tilt to one configuration and let other configurations ‘pick up’ the value of the first one. However, the ‘Chief ray solve’ for Decenter and Tilt in multi-configuration is grayed out. So I was wondering whether it is possible to create a ZPLM solve that is identical to the ‘Chief ray solve’ used in the lens data editor and applies it into the multi-configruaton editor? If this is possible, can anyone shares the logic behind the implementation of ‘Chief ray solve’ for decenter and tilt? ThanksBest wishes and Happy new year! Daoming
I have a very simple question. How could I define a source Gaussian out from a single mode fiber, which core size is 4 micro, NA =0.12. I know the beam size (diameter) should be set to be MFD, how to put the parameter for position? should I put the parameter of the position as Rayleigh distance Zr? or should I use MFD/(2*NA)? Thanks for your answer in advance.
Hi! I’m calculating the energy inside a surface with LEDS with different detectors: volume detector, sphere as detector, volume pipe as detector… but I can’t get the same values across them… I don’t know why if I hace the same system…From objects as a detector I get total power, but from volume detector total flux (all of them in mW); is this the same?When I take a value from the matrix in volume detector, what is this? flux, power¿?This is my file, I calculate the three detectors individuallyThanks in advance,Carmen
I'm having trouble to read detector pixels using a ZPL. The syntax should be NSCDetectorData,surface,object,pixel,data However, I get error message and do not know how to solve. Can somebody provide me with a example of a piece of ZPL code to get the job done. Ideally reading the detector into a 2D array But I'm already happy with a single statement reading out say the 6th pixel iof the 5th row Hope somebody can help me Pascal
Hello! When calculating the FFT PSF, I sometimes get the error message 'Computation aborted, invalid results'. When I change the PSF sampling, the error disappears. It is probably linked to a user defined surface (based on the multizone asphere surface example) combined with specific values of decentrations of the optical elements. Do you have any ideas about the meaning of the error-message and how to debug it / get rid of it? I am saving the FFT PSF window within a ZPL macro. Is there a way to do error-handling in the ZPL macro? (E.g. if the error occurs, the sampling of the FFT PSF calculation will be decreased and the calculation repeated...) Thank you!
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.