Skip to main content

Difference between GetAllDetectorData() and GetAllDetectorDataSafe()

  • April 4, 2023
  • 1 reply
  • 259 views

Julia
Zemax Staff
Forum|alt.badge.img+2
  • Zemax Staff
  • 53 replies

GetAllDetectorData() and GetAllDetectorDataSafe() are both methods that can be used to retrieve detector data for a specified detector object. 

  1. The main difference between the two methods is that GetAllDetectorDataSafe() returns a two-dimensional array of double values double[,] that contains all the detector data for the detector object, while GetAllDetectorData() returns a boolean value that indicates whether the detector data was retrieved successfully, and one-dimensional array double[] .
  2. GetAllDetectorDataSafe() does not require the input of numPixels and detectorData, whereas GetAllDetectorData() requires these parameters in addition to (detector) ObjectNumber and Data(type).

Check the examples to use the two methods: 

For python: 

1TheNCE = TheSystem.NCE
2DetObj = 4
3obj = TheSystem.NCE.GetObjectAt(DetObj);
4numXPixels = obj.ObjectData.NumberXPixels;
5numYPixels = obj.ObjectData.NumberYPixels;
6
7DetRectangleData_FluxArea = TheSystem.NCE.GetAllDetectorDataSafe(4, 1)
8for x in range(numXPixels):
9 for y in range(numYPixels):
10 print(DetRectangleData_FluxArea[x,y])
11
12numPixels=numXPixels*numYPixels
13detectorData=np.zeros(numPixels, dtype=np.float64)
14bool_value, detectorData= TheNCE.GetAllDetectorData(DetObj, 1, numPixels,detectorData)
15for i in range(numPixels):
16 print(detectorData[i])

For matlab: 

1TheNCE = TheSystem.NCE;
2
3DetObj = 4;
4obj = TheSystem.NCE.GetObjectAt(DetObj);
5numXPixels = obj.ObjectData.NumberXPixels;
6numYPixels = obj.ObjectData.NumberYPixels;
7
8DetRectangleData_FluxArea = TheSystem.NCE.GetAllDetectorDataSafe(4, 1);
9for x = 1:numXPixels
10 for y = 1:numYPixels
11 disp(DetRectangleData_FluxArea(x,y));
12 end
13end
14
15numPixels=numXPixels*numYPixels;
16detectorData=NET.createArray('System.Double', TheNCE.GetDetectorSize(4));
17bool_value=TheSystem.NCE.GetAllDetectorData(DetObj, 1,TheNCE.GetDetectorSize(4),detectorData);
18for i = 1:numPixels
19 disp(detectorData(i));
20end
21
22

 

In matlab, the retrieved data from GetAllDetectorData() need to be rearranged from 1D array to a matrix, detectorData = flipud(rot90(reshape(data.double, rows, cols)));

and here is a simple example to show the transform:

 

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

1 reply

Julia
Zemax Staff
Forum|alt.badge.img+2
  • Author
  • Zemax Staff
  • 53 replies
  • May 31, 2023

If the detector pattern is not symmetric or the X/Y pixels are not the same, use (in Matlab):

[~, rows, cols] = TheNCE.GetDetectorDimensions(4);

detectorData = flipud(rot90(reshape(data.double, cols, rows)));

% Create new figure figure;

figure;

surf(detectorData);

axis([1 cols 1 rows]);

view(2);

xlabel('X pixel');

ylabel('Y pixel');

title('Incoherent Illuminance [lm/cm^2]');

colorbar;


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