# Calculating with the ray trace model (synthetic)

The ray trace optics model is the most complex of the ISET optics models. It applies a space-varying and wavelength dependent point spread functions (svPSF). These can be created either by calculating from a Zemax file, or as we do here, a ray trace synthetic model.

The space-varying PSFs are computed and shown here.

## Contents

```ieInit
wbStatus = ieSessionGet('waitbar');
ieSessionSet('waitbar','on');
```

## Alternatively, you can run an oiCompute in the ray trace mode

```% In this case, the svPSF structure will be stored in the oi. You
% can get the shift variant PSFs that were computed and stored
% this way.
scene = sceneCreate('point array',384);
scene = sceneSet(scene,'h fov',4);
scene = sceneInterpolateW(scene,550:100:650);
```

## Create the space-varying optics

```oi = oiCreate;
rtOptics = []; spreadLimits = [1 5]; xyRatio = 1.6;
oi = oiSet(oi,'optics',rtOptics);
```

## Compute the irradiance and space-varying PSF

```oi    = oiCompute(oi,scene);
```
```Scene distance (1.20 m) does not match ray trace assumption (0.01 m)
Geometric distortion ...
Pre-computing PSFs...Eccentricity bands: 0.000 (um)
Eccentricity bands: 50.000 (um)
Eccentricity bands: 100.000 (um)
Eccentricity bands: 150.000 (um)
PSF sample grid: 58 by 58
Done precomputing PSFs.
Applying PSFs.
4 eccentricity bands
Done applying PSFs.
```

## View the PSFs at the various field heights

```vcNewGraphWin;
% These are the computed PSFs
svPSF = oiGet(oi,'psf struct');
for ii=1:size(svPSF.psf,2)
imagesc(svPSF.psf{1,ii,1}), axis image; pause(0.3);
end
```

## These are PSFs at the various sample angles

```vcNewGraphWin;
for ii=1:size(svPSF.psf,1)
imagesc(svPSF.psf{ii,end,1}); axis image; pause(0.3);
end
```

## The point spread at two field heights

```% At the center
rtPlot(oi,'psf',550,0);

% At the largest field height
imgHeight = oiGet(oi,'psf image heights','mm');
rtPlot(oi,'psf',550,max(imgHeight(end)));

% Replace the wait bar status
ieSessionSet('waitbar',wbStatus);
```