API for iadpython package

iadpython.ad Module

Class for doing adding-doubling calculations for a sample.

Example:

>>> import iadpython as iad
>>> n=4
>>> sample = iad.Sample(a=0.9, b=10, g=0.9, n=1.5, quad_pts=4)
>>> r, t = sample.rt()
>>> print(r)
>>> print(t)

Classes

Sample([a, b, g, d, n, n_above, n_below, ...])

Container class for details of a sample.

iadpython.combine Module

Module for adding layers together.

Two types of starting methods are possible.

Example:

>>> import iadpython as iad

>>> # Isotropic finite layer with mismatched slides the hard way.
>>> s = iad.Sample(a=0.5, b=1, g=0.0, n=1.4, n_above=1.5, n_below=1.6)
>>> s.quad_pts = 4
>>> R01, R10, T01, T10 = iad.boundary_matrices(s, top=True)
>>> R23, R32, T23, T32 = iad.boundary_matrices(s, top=False)
>>> R12, T12 = iad.simple_layer_matrices(s)
>>> R02, R20, T02, T20 = iad.add_layers(s, R01, R10, T01, T10, R12, R12, T12, T12)
>>> rr03, rr30, tt03, tt30 = iad.add_layers(s, R02, R20, T02, T20, R23, R32, T23, T32)

Functions

add_layers(sample, R01, R10, T01, T10, R12, ...)

Add two layers together.

add_layers_basic(sample, R10, T01, R12, R21, ...)

Add two layers together.

simple_layer_matrices(sample)

Create R and T matrices for multiple layers without boundaries.

add_slide_above(sample, R01, R10, T01, T10, ...)

Calculate matrices for a slab with a boundary placed above.

add_slide_below(sample, R01, R10, T01, T10, ...)

Calculate matrices for a slab with a boundary placed below.

add_same_slides(sample, R01, R10, T01, T10, R, T)

Find matrix when slab is sandwiched between identical slides.

iadpython.fresnel Module

Module for generating boundary matrices.

Two types of starting methods are possible.

Example

>>> import iadpython as iad
>>> n = 4
>>> slab = iad.Slab(a = 0.9, b = 10, g = 0.9, n = 1.5)
>>> method = iad.Method(slab)
>>> r, t = iad.init_layer(slab, method)
>>> print(r)
>>> print(t)

Functions

cos_critical(n_i, n_t)

Calculate the cosine of the critical angle.

cos_snell(n_i, nu_i, n_t)

Return the cosine of the transmitted angle.

fresnel_reflection(n_i, nu_i, n_t)

Fresnel Reflection.

absorbing_glass_RT(n_i, n_g, n_t, nu_i, b)

Reflection and transmission of an absorbing slide.

specular_rt(n_top, n_slab, n_bot, b_slab, nu)

Unscattered refl and trans for a sample.

diffuse_glass_R(n_air, n_slide, n_slab)

Calculate the total diffuse specular reflection for air-glass-tissue interface.

glass(n_i, n_g, n_t, nu_i)

Reflection from a glass slide.

iadpython.grid Module

Class for doing inverse adding-doubling calculations for a sample.

Example:

>>> import iadpython

>>> exp = iadpython.Experiment(0.5, 0.1, default_g=0.5)
>>> grid = iadpython.Grid()
>>> grid.calc(exp)
>>> print(grid)

Functions

matrix_as_string(x[, label])

Return matrix as a string.

Classes

Grid([search, default, N])

Class to track pre-calculated R & T values.

iadpython.iad Module

Class for doing inverse adding-doubling calculations for a sample.

Example:

>>> import iadpython as iad

>>> exp = iad.Experiment(0.5,0.1,0.01)
>>> a, b, g = exp.invert()
>>> print("a = %7.3f" % a)
>>> print("b = %7.3f" % b)
>>> print("g = %7.3f" % g)

>>> s = iad.Sample(0.5,0.1,0.01,n=1.4, n_top=1.5, n_bottom=1.5)
>>> exp = iad.Experiment(s)
>>> a, b, g = exp.invert()
>>> print("a = %7.3f" % a)
>>> print("b = %7.3f" % b)
>>> print("g = %7.3f" % g)

Functions

abfun(x, *args)

Vary the ab.

afun(x, *args)

Vary the albedo.

agfun(x, *args)

Vary the ag.

bfun(x, *args)

Vary the optical thickness.

bgfun(x, *args)

Vary the bg.

gfun(x, *args)

Vary the anisotropy.

Classes

Experiment([r, t, u, sample, r_sphere, ...])

Container class for details of an experiment.

iadpython.nist Module

Module for importing reflection spectra from NIST database.

Example:

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> import iadpython as iad

>>> # Retrieve and plot subject 5

>>> subject_number = 5
>>> lambda0, R = iad.subject_average_reflectance(subject_number)
>>> plt.plot(lambda0, R)
>>> plt.xlabel("Wavelength (nm)")
>>> plt.ylabel("Total Reflectance")
>>> plt.title("Subject #%d" % subject_number)
>>> plt.show()

>>> # Retrieve and plot all subjects

>>> lambda0, R = iad.all_average_reflectances()
>>> for i in range(100):
>>>     plt.plot(lambda0, R[:, i])
>>> plt.xlabel("Wavelength (nm)")
>>> plt.ylabel("Total Reflectance")
>>> plt.title("All Subjects")
>>> plt.show()
Reference:

<https://nvlpubs.nist.gov/nistpubs/jres/122/jres.122.026.pdf> nist_db = ‘https://doi.org/10.18434/M38597

Functions

subject_reflectances(subject_number)

Extract all reflection data for one subject.

subject_average_reflectance(subject_number)

Extract average reflection for one subject.

all_average_reflectances()

Extract average reflectance for all subjects.

iadpython.quadrature Module

Module for obtaining quadrature points and weights.

Three types of gaussian quadrature are supported: normal Gaussian, Radau quadrature, and Lobatto quadrature. The first method does not include either endpoint of integration, Radau quadrature includes one endpoint of the integration range, and Lobatto quadrature includes both endpoints.

Example:

>>> import iad.quadrature

>>> n=8
>>> x, w = iad.quadrature.gauss(n)
>>> print(" i        x         weight")
>>> for i,x in enumerate(xi):
>>>     print("%2d   %+.12f %+.12f" % (i, x[i], w[i]))

>>> x, w = iad.quadrature.radau(n)
>>> print(" i        x         weight")
>>> for i,x in enumerate(xi):
>>>     print("%2d   %+.12f %+.12f" % (i, x[i], w[i]))

>>> x, w = iad.quadrature.lobatto(n)
>>> print(" i        x         weight")
>>> for i,x in enumerate(xi):
>>>     print("%2d   %+.12f %+.12f" % (i, x[i], w[i]))

Functions

gauss(n[, a, b])

Return abscissas and weights for Gaussian quadrature.

radau(n[, a, b])

Return abscissas and weights for Radau quadrature.

lobatto(n[, a, b])

Return abscissas and weights for Lobatto quadrature.

iadpython.redistribution Module

Module for calculating the redistribution function.

The single scattering phase function ..math:p(nu) for a tissue determines the amount of light scattered at an angle nu=cos(theta) from the direction of incidence. The subtended angle nu is the dot product incident and exiting of the unit vectors.

The redistribution function ..math:h[i,j] determines the fraction of light scattered from an incidence cone with angle nu_i into a cone with angle ..math:nu_j. The redistribution function is calculated by averaging the phase function over all possible azimuthal angles for fixed angles ..math:nu_i and ..math:nu_j,

Note that the angles ..math:nu_i and ..math:nu_j may also be negative (light travelling in the opposite direction).

When the cosine of the angle of incidence or exitance is unity (..math:nu_i=1 or ..math:nu_j=1), then the redistribution function is equivalent to the phase function ..math:p(nu_j).

Functions

hg_elliptic(sample)

Calculate redistribution function using elliptic integrals.

hg_legendre(sample)

Calculate the HG redistribution matrix using Legendre polynomials.

iadpython.sphere Module

Class for managing integrating spheres.

Example:

>>> import iadpython
>>> s = iadpython.Sphere(250,20)
>>> print(s)

Functions

Gain_11(RS, TS, URU, tdiffuse)

Net gain for on detector in reflection sphere for two sphere configuration.

Gain_22(RS, TS, URU, tdiffuse)

Two sphere gain in T sphere for light starting in T sphere.

Two_Sphere_R(RS, TS, UR1, URU, UT1, UTU[, f])

Total gain in R sphere for two sphere configuration.

Two_Sphere_T(RS, TS, UR1, URU, UT1, UTU[, f])

Total gain in T sphere for two sphere configuration.

Classes

Sphere(d_sphere, d_sample[, d_entrance, ...])

Container class for an integrating sphere.

iadpython.start Module

Module for generating the starting layer for adding-doubling.

Two types of starting methods are possible IGI and Diamond.

Example:

>>> import iadpython as iad
>>> s = iad.Sample(a=0.9, b=10, g=0.9, n=1.5)
>>> r, t = iad.init_layer(s)
>>> print(r)
>>> print(t)

Functions

zero_layer(sample)

Create R and T matrices for thinnest_layer with zero thickness.

starting_thickness(sample)

Find the best starting thickness to start the doubling process.

igi(sample)

Infinitesmal Generator Initialization.

diamond(sample)

Diamond initialization.

thinnest_layer(sample)

Reflection and transmission matrices for a thin thinnest_layer.

boundary_layer(s[, top])

Create reflection and transmission arrays for a boundary_layer.

boundary_matrices(s[, top])

Create reflection and transmission matrices for a boundary_layer.

unscattered_rt(s)

Unscattered reflection and transmission for a slide-slab-slide sandwich.