pro sunad2xy,a,d,b0,p0,x,y,z=z

  a1=a*!dtor
  d1=d*!dtor

  y=sin(d1)
  x=sin(a1)*cos(d1)
  z=cos(d1)*cos(a1)

  if b0 ne 0 then begin
	b=-b0*!dtor
	z1=z & y1=y
	z=z1*cos(b)-y1*sin(b)
	y=z1*sin(b)+y1*cos(b)
	end

  i=where(z gt 0)
  if i(0) ne (-1) then begin
	x=x(i) & y=y(i)
  endif else begin
	x=-2 & y=-2 &return
  end

  if p0 ne 0 then begin
	x1=x &y1=y
	p=-p0*!dtor
	x=x1*cos(p)-y1*sin(p)
	y=x1*sin(p)+y1*cos(p)
	end
end



