R/get.pixel.size.R

get.pixel.size = function(x, z, egg) {
  # Get the actual pixel area of a given point
  #require(numDeriv, quietly=TRUE)

  phi.size = NaN
  theta.size = NaN
  pixel.size = NaN
  tryCatch({
    pp = t(egg$R%*%cbind(c(x-egg$blunt.end[1], z-egg$blunt.end[2])) + egg$t)
    z.hat = normalise(pp[2], -egg$length/2, egg$length/2, 0, 1)
    # Phi
    phi.size = 1/cos(atan(numDeriv::grad(get.d, z.hat, egg=egg)/egg$length))
    # Theta
    d = get.d(z.hat, egg)
    d.prime = sqrt(d^2 - pp[1]^2)
    theta = acos(dot(norm(c(d.prime, pp[1])), c(0,1)))
    theta.size = 1/cos(theta - pi/2)
    # Pixel
    pixel.size = theta.size*phi.size
  }, warning = function(w) {
    #
  }, error = function(e) {
    #
  }, finally = {
    return (pixel.size)
  })
}

Try the eggs package in your browser

Any scripts or data that you put into this service are public.

eggs documentation built on May 2, 2019, 5:23 p.m.