/pyDigHolo

Python module to use Joel's Carpenter digHolo C++ library.

Primary LanguagePython

pyDigHolo

pyDigHolo is a Python module to use Joel Carpenter's digHolo C++ library. digHolo is a high-speed library for off-axis digital holography.

Installation

First, install digHolo C++ library.

Then, install pyDigHolo, using pip

pip install git+https://github.com/wavefrontshaping/pyDigHolo.git

or clone the repository and, in the module folder, install using

python setup.py install

Documentation

This module more or less simply wraps the functions from the digHolo C++ module, please refer to the offocial digHolo repository for documentation.

Basic usage

Import the module

from pyDigHolo import digHolo

Instantiate the digHolo object

You need the provide the file path to fetch the .dll/.so from digHolo. If you copied the .dll into your working folder, simply use

dh = digHolo('digHolo.dll')

Set the experimental parameters

dh.ConfigOffAxis(
    [frameWidth, frameHeight],
    [nx, ny], 
    resolutionMode,
    pixelSize,
    lambda0, 
    maxMG,
    polCount
)

Configure auto-align procedure

Specify what you want the algorithm to automatically calibrate. For instance:

dh.ConfigSetAutoAlign(
    enable_align_beam_centre=True,
    enable_align_defocus=False,
    enable_align_tilt=True,
    enable_align_basis_waist=True,
    enable_align_fourier_win_radius=False,
)

Give pyDigHolo a batch of interferograms to treat

dh.SetBatch(frameCount, frames, dataType = 'Python')

Perform the automatic calibration procedure

dh.AutoAlign()

Provide the intensity pattern of the reference

dh.SetRefCalibrationIntensity(ref)

Save the calibration

dh.SaveConfig('config_pola1.npz')

Load the calibration

Next time you want to use the off-axis procedure, if the system did not change, you can simply load a previous calibration file using:

dh.Loadonfig('config_pola1.npz')

Process a batch of data

It will treat the interferograms provided using SetBatch().

dh.ProcessBatch()

Retrieve the complex field maps

fields = dh.GetFields()

Examples

See the two jupyter notebook: