zpm_cart: Zernike polynomials

View source: R/RcppExports.R

zpm_cartR Documentation

Zernike polynomials

Description

Calculate Zernike polynomial values in ISO/ANSI sequence for a set of Cartesian coordinates.

Usage

zpm_cart(x, y, maxorder = 12L, unit_variance = TRUE)

Arguments

x

a vector of x coordinates for points on a unit disk.

y

a vector of y coordinates.

maxorder

the maximum radial polynomial order (defaults to 12).

unit_variance

logical: return with orthonormal scaling? (default true)

Details

This is the same algorithm and essentially the same code as gradzpm_cart() except directional derivatives aren't calculated.

Value

a matrix of Zernike polynomial values evaluated at the input Cartesian coordinates and all radial and azimuthal orders from 0 through maxorder.

Examples

  ##illustrates difference in smoothed wavefront from using zpm_cart with ISO sequence of same order

  require(zernike)
  fpath <- file.path(find.package(package="zernike"), "psidata")
  files <- scan(file.path(fpath, "files.txt"), what="character")
  for (i in 1:length(files)) files[i] <- file.path(fpath, files[i])
  
  ## load the images into an array
  
  images <- load.images(files)
  
  ## parameters for this run
  
  source(file.path(fpath, "parameters.txt"))
  
  ## phase shifts
  
  phases <- wrap((0:(dim(images)[3]-1))/frames.per.cycle*2*pi)
  phases <- switch(ps.dir, ccw = -phases, cw = phases, phases)
  
  ## target SA coefficients for numerical null.
  
  sa.t <- sconic(diam,roc,lambda=wavelength)
  zopt <- psfit_options()
  zopt$satarget <- sa.t
  psfit <- psifit(images, phases, psialg="ls", options=zopt)
  
  ## get back the raw wavefront
  
  wf.raw <- qpuw(psfit$phi, psfit$mod)
  
  ## This will tell wf_net to use zpm_cart instead
  
  zopt$isoseq <- TRUE
  ifit <- wf_net(wf.raw, cp = psfit$cp, options=zopt)
  
  ## plotn does a direct comparison
  
  plotn(psfit, ifit, wftype="smooth", qt=c(0,1))


mlpeck/zernike documentation built on April 19, 2024, 3:16 p.m.