Viewing contents of file '../idllib/sdss/allpro/gc2survey.pro'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+
;
; NAME:
;    GC2SURVEY
;       
; PURPOSE:
;    convert from SDSS great circle to SDSS survey coordinates
;
; CALLING SEQUENCE:
;    gc2eq, mu, nu, node, inc, lambda, eta
;
; INPUTS: 
;    mu, nu: great circle coords.
;    node, inc: node and inclination of the stripe.
;       
; OUTPUTS: 
;   lambda, eta: survye coords. 
;
;
; CALLED ROUTINES:
;    ATBOUND
;    ATBOND2 
;
; PROCEDURE: 
;    Taken from astrotools
;	
;
; REVISION HISTORY:
;    14-NOV-2000  Erin Scott Sheldon UofMich Taken from astrotools
;       
;                                      
;-                                       
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

PRO atbound, angle, min, max

  w=where(angle LT min,nw)
  WHILE nw NE 0 DO BEGIN 
      angle[w] = angle[w] + 360.0
      w=where(angle LT min,nw)
  ENDWHILE 

  w=where(angle GE max,nw)
  WHILE nw NE 0 DO BEGIN 
      angle[w] = angle[w] - 360.0
      w=where(angle GT max,nw)
  ENDWHILE 

  return
END 

PRO atbound2, theta, phi

  atbound, theta, -180.0, 180.0
  w = where( abs(theta) GT 90.,nw)
  IF nw NE 0 THEN BEGIN
      theta[w] = 180. - theta[w]
      phi[w] = phi[w] + 180.
  ENDIF 
  atbound, theta, -180.0, 180.0
  atbound, phi, 0.0, 360.0

  w=where( abs(theta) EQ 90., nw)
  IF nw NE 0 THEN phi[w] = 0.0

  return
END 

PRO gc2survey, mu_in, nu_in, node_in, inc_in, lambda, eta

  IF n_params() LT 2 THEN BEGIN 
      print,'-Syntax: mu, nu, node, inc, lambda, eta'
      print,' mu, nu, node, inc in degrees'
      return
  ENDIF 

  ;; just convert to ra,dec and then convert
  ;; to survey

  gc2eq, mu_in, nu_in, node_in, inc_in, ra, dec
  eq2survey, ra, dec, lambda, eta

  return
END