Skip to main content

I write next code, but it gives me incorrect PSF. Can you help me with finding of mistake?

 

function  r] = BeginApplication(TheApplication, args)

import ZOSAPI.*;

% creates a new API directory
apiPath = System.String.Concat(TheApplication.SamplesDir, '\API\Matlab');
if (exist(char(apiPath)) == 0) mkdir(char(apiPath)); end

% Set up primary optical system
TheSystem = TheApplication.PrimarySystem;
sampleDir = TheApplication.SamplesDir;


% Open file
testFile = System.String.Concat(sampleDir, '\API\Matlab\TwoSystems.zos');

if (exist(char(testFile)) == 0)
fprintf('You need to run Example 01 before running this example\n');
r = ];
return;
end


% Create analysis
% Open the Huygen's PSF. We will use the default settings for now
huygensPSF = TheSystem.Analyses.New_HuygensPsf();

% Settings
huygensPSF_Settings = huygensPSF.GetSettings();
huygensPSF_Settings.ImageSampleSize = ZOSAPI.Analysis.SampleSizes.S_128x128;
huygensPSF_Settings.PupilSampleSize = ZOSAPI.Analysis.SampleSizes.S_128x128;
huygensPSF_Settings.ImageDelta = 0;
%! e04s03_m]


% Run the analysis with the current settings and pull the results
huygensPSF.ApplyAndWaitForCompletion();
huygensResults = huygensPSF.GetResults();
%! e04s04_m]


% The results will be split into multiple data structures
% One structure will house the header information
% Another structure will house the relative intensity values
% Pull the structure with the intensity values
matrixData = huygensResults.DataGrids(1).Values.double;

% OpticStudio has pixel (1,1) in the top left of the matrix
% Matlab places the (1,1) at the bottom so we need to flip the matrix
huygensData = flipud(matrixData);

% Use pixel data to create a figure
% The jet colormap will match closely with the False Color plot
imagesc(huygensData)
colormap jet;
axis square;

% Close the Huygen's plot
huygensPSF.Close();

r = ];
end

 

 The PSF chart doesn't depend on the system I use for analysis. It gives me one picture for different systems 


Reply