Solved

return leftmost or rightmost pixel on detector viewer that has flux in merit function


Userlevel 1
Badge +1

Hello All!

Is there an easy way to get the merit function to return the leftmost or rightmost pixel on a detector that has flux data? I don’t want RMS I want to return the most extreme values. 

For example, if I was looking at the detector below, I would want the merit function to return:

X Max = 0.1

X min = -0.1

 

Thanks!

icon

Best answer by Sandrine Auriol 25 May 2022, 11:30

View original

4 replies

Userlevel 6
Badge +2

Hi Kaleb

I checked the help files for NSDD and it seems we don’t have an operand to return the most extreme points of the spot on a detector. I think that a good option can be to write a user defined operand in C#.

 

With the API, you can retrieve the results of the detector as a grid using for example the GetAllDetectorDataSafe function. Let us know if that is a solution or if you need any help, and feel free to share your solution on the https://community.zemax.com/code-exchange-10

Userlevel 7
Badge +2

Hi Kaleb,

 

I was about to suggest the same as @Sandrine Auriol.

With the User Operand you could store the detector pixels in an array, threshold the array such that the pixels of the spot become 1, and the background 0. Then, sum the pixels along the rows and find the first and last non-zero values and then do the same for the columns.

I don’t know how slow your Merit Function will become though.

Take care,

 

David

Userlevel 1
Badge +1

Hi Sandrine and David,

Thank you for the responses. I ended up writing something in Matlab to get the data. It is not returned in the Merit Function, but it works fine for my application. I can still put it in the code exchange later if you are interested!

Thanks,

Kaleb

 

Userlevel 6
Badge +2

Hey Kaleb

Yes please that would be great.

Reply