     ## IAPACK

The interferogram analysis package uses Python script language. This package contains a set of scripts that can be used for interferogram capture and analysis. It extends Python with C control and mathematical modules to provide a fast image capture and short calculation time. Scripts are very flexible and designed for easy integration into a laboratory or workshop automatic optical measuring systems.

## dtmath

C Python extension package for interferogram analysis implements basic calculation algorithms.

### Functions

roundmask ( r, w, h )

Parameters:
r - normalized mask radius, flat in range from 0. to 1.
w - width, positive integer
h - height, positive integer

Return values:

Parameters:
data - reference data, numpy 2D double array
level - threshold level, double

Return values:

Generate surface using Zernike coefficients. Surface shape is equal to mask shape

Parameters:
z - Zernuke coefficients, numpy double array

Return values:
surface - surface, numpy double array

Generate matrix of Zernike surfaces. Surface shape is equal to mask shape

Parameters:
n - number of Zernike polynomials, positive integer

Return values:
matrix - matrix of Zernike surfaces, numpy double array

interferogram ( sc, phase, max, mask, surface )

Generate interferogram for given surface. Image shape is equal to mask and surface shapes

Parameters:
sc - scale coefficient, float
phase - phase shift, float
max - maximal value in result array, positive integer
surface - surface, numpy double array

Return values:
frame - image, numpy uint16 array

phase ( images )

Calculate phase map from images. Phase map shape is equal to shapes of images

Parameters:
images - images, list of uint16 arrays (must have 4, 5 or 7 elements)

Return values:
phase - phase map, numpy double array

phase5 ( images )

Calculate phase map from 5 images. Phase map shape is equal to shapes of images

Parameters:
images - images, list of uint16 arrays (must have 5 elements)

Return values:
phase - phase map, numpy double array

unwrap ( mask, phase, level )

Unwrap phase map. Surface shape is equal to phase map

Parameters:
phase - phase map, numpy double array
level - threshold level

Return values:
surface - surface, numpy double array

wrap( surface, level )

Create phase map from surface. Phase map shape is equal to surface shape

Parameters:
surface - surface, numpy double array
level - threshold level

Return values:
phase - phase map, numpy double array

binning ( data, bc )

Make array binning.

Parameters:
data - numpy double array
phase - binning coefficient, positive integer

Return values:
result - numpy double array

## calibrate

Python extension package for interferogram analysis implements PZT calibration.

### Functions

calibrate ( port, umax, p, n, verb = False, sve = False )

This function implements PZT calibration. FFT is used as phase detection algorithm. The calibration refers to vertical interference fringes of flat surface.

Parameters:
port - dtcam object
umax - normalized maximal PZT voltage, float in fange from 0. to 1.
p - number of acquired points, positive integer
n - number of measurements, positive integer
verb - verbose output, boolean
sve - save intermediate results, boolean

Return values:
res - result of operation, True if success
list - normalized calibrated PZT voltages, list of floats in fange from 0. to 1.

## phase

Python extension package for interferogram analysis, implements functions to get images and phase maps from DTI interferometers.

### Functions

get_frame ( port, shift, verb = False )

This function captures one frame with desired phase shifting

Parameters:
port - dtcam object
shift - normalized PZT voltage, float in fange from 0. to 1.
verb - verbose output, boolean

Return values:
frame - image, numpy uint16 array

get_phase ( port, ref, verb = False, sve = False )

This function captures frames and calculates phase map

Parameters:
port - dtcam object
ref - reference points for phase shifting, list of floats in range from 0. to 1.
verb - verbose output, boolean
sve - save intermediate results, boolean

Return values:
phase - phase map, numpy float array

get_phase_dev ( port, ref, verb = False, sve = False )

This function gets phase map using device build-in phase calculation algorithm

Parameters:
port - dtcam object
ref - reference points for phase shifting, list of floats in range from 0. to 1.
verb - verbose output, boolean
sve - save intermediate results, boolean

Return values:
phase - phase map, numpy float array

## zernike

Python extension package for interferogram analysis implements Zernike coefficients calculation algorithms.

### Functions

fast_zernike_coefficients( m, s, n, verb = False )

This function tries first to reduce data size and then it calculates Zernike coefficients.

Parameters:
m - mask, numpy bool array
s - surface (opd), numpy float array
n - number of polynomials, positive integer
verb - verbose output, boolean

Return values:
z - Zernike coefficients, numpy bool array

zernike_coefficients( m, s, n )

This function calculates Zernike coefficients for a given surface

Parameters:
m - mask, numpy bool array
s - surface (opd), numpy float array
n - number of polynomials, positive integer

Return values:
z - Zernike coefficients, numpy bool array

## dti

dti is a command line tool and usage example of interferogram analysis package. It provides basic acquisition and calculation operations.

### Usage

```dti  [options...]

command          frame|calibrate|phase|phasedev|opd

common options
-h, --help     print this message
--port         interferometer http server port
--save-prefix  save file prefix
--save-data    save data (npy and pgm file formats)
--save-error   save error (text file format)
-n             repeat command
-v             verbose output
-s             save intermediate results

commsnd-dependent options
-a             make data averaging
--pzt-max      normalized maximal PZT voltage in range from 0. to 1.
-pzt-ref       load normalized calibrated PZT voltages from file
(use .npy file extension)
--zernike      calculate Zernike polynomial coefficients

capture frame
command        frame
options        -a,

calibrate PZT
command        calibrate
options        --pzt-max,

capture frames and calculate phase map
command        phase
options        --pzt-ref,

get phase map from device (DTI build-in algorithm)
command        phasedev
options        --pzt-ref,

calculate opd (surface reconstruction)
command        opd
```

### Examples

Capture frame from device and save result.
`python dti.py frame --save-data`
Calibrate PZT (normalized maximal PZT voltage 0.85) and save reference values
`python dti.py calibrate --pzt-max=0.85 -a5 --save-data`
Get phase map using device build-in algorithm.
`python dti.py phasedev --pzt-ref=test_calibrate_0.npy --save-data`
Get 4 phase maps, calculate OPD and Zernike polynomials coefficients.
`python dti.py opd --pzt-ref=test_calibrate_0.npy --zernike=16 --save-data --save-error -a4`
Stability test. Calculate and save rms deviation of 20 sequential measured OPDs
`python dti.py opd --pzt-ref=test_calibrate_0.npy -n20 --save-error`

## Requirements

Python 2.6 - programming language

Numpy 1.5.1 - fundamental package needed for scientific computing with Python

# Новости

• 25.03.2013 выпущен новый прибор DTI3-40 с апертурой 40 мм • 22.03.2012 выпущена корпусная модификация прибора DTI2-20
• 26.12.2011 версия 1.0.4 пакета утилит IAPACK с встроенным генератором отчетов
• 26.12.2011 версия 1.5.1 DTI tools доступна для скачивания
• 21.02.2011 выпущена корпусная модификация прибора DTI2-5
• 30.01.2011 новая версия DTCAMview доступна для скачивания
• 24.10.2010 модуль DTI2-5 с апертурой 5 мм