;+
; NAME:
; 	HEL2CCD
; PURPOSE:
;	computes CCD target coordinates (256x256) from heliographic input
; CALL:
; 	hel2ccd, nn, ww, suncenter = suncenter, date = date
;       hel2ccd, 'N30', 'E23'
; INPUT: 
;	heliographic coordinates nn, ww in solar degrees
;                (north and west are positive)
;       suncenter the FR pixel coordinates of sun center (default [528, 581])
; OUTPUT:
;       half-resolution SXT pixel coordinates of target location
;	CCD quarter resoution SXTSPT target coordinates
; HISTORY:
;	Written by HSH 4/8/92, with shameless plagiarism of Wuelser's
;	   routine gbo_hel
;       Updated October 1992 to match the conventions N, W positive
;          and (N,W) order, for both input and output
;	Made procedure, allow input of string heliographic coordinates,
;	   and output CCD target coordinates.  LWA  10/19/92.
;       Update to call HEL2PIX.   LWA 9-Dec-92
;       Update SXT suncenter coordinates to [528,581].  LWA  9-Dec-92
;-
pro hel2ccd, nn, ww, suncenter = suncenter, date = date

strtest = size(nn)
if strtest(1) eq 7 then begin
  n = fix(strmid(nn,1,2))
  if strupcase(strmid(nn,0,1)) eq 'S' then n = -n
  w = fix(strmid(ww,1,2))
  if strupcase(strmid(ww,0,1)) eq 'E' then w = -w
endif else begin
  n = nn
  w = ww 
endelse

if NOT keyword_set(suncenter) then sunxy = [528,581] else sunxy = suncenter

;get system time, if required
if NOT keyword_set(date) then dat = !stime else dat = date 

loc=hel2pix(n,w,suncenter=sunxy,date=dat)

yy=loc(0)
xx=loc(1)

yyy = fix((0.5 + yy)/4.)
xxx = fix((0.5+ (1024 - xx))/4.)

print,  'Coordinates of heliographic location on HR image:'
print,'HR:   IDL(Y) =', fix(yy/2),'  IDL(X) =', fix(xx/2)
print
print,  'SXT Target coordinates for SXTSPT table:'
print,'CCD:  CCD(y) or NS =', yyy,'  CCD(x) or EW =', xxx

end


