anchor.diff:      !Compute local d spacing in nm
       d = dpermm * sqrt(y(i)**2 + x(i)**2)
       !Compute local yaw
  -    !yaw = pi/2 - atan(-x(i)/abs(y(i)))
  -    !print *, yaw
       yaw = -pi/2 - atan2(x(i),y(i))
       !print *, yaw
       !read *, dum
  
positive.code:     d = dpermm * sqrt(y(i)**2 + x(i)**2)
      !Compute local yaw
      sn = y(i) / abs(y(i))
      yaw = pi/2 + atan(x(i)/abs(y(i)))
      !print *, x(i),y(i),d,yaw
      !print *, l(i),m(i),n(i)
  
  
negative.code: end subroutine itransform
  
  !Radially grooved grating diffraction
  !Assumes grating in x y plane, with hub at origin
  subroutine radgrat(x,y,l,m,n,wave,num,dpermm,order)
    !Declarations
    integer, intent(in) :: num
  