!
!-----------------------------------------------------------------------------
! Help file 
!-----------------------------------------------------------------------------
!
begin help rotator.hlp

Derotator limits plotter                                   R. Lucas 2001-08-28

This procedure plots the Frame Derotator angle of HERA as a function of UTC.
- 1) Enter the source name
- 2) The source coordinates may be entered in the input dialog or taken
     from a catalog. Frame is EQ 2000 by default.
- 3) Enter the position angle of HERA (E from North) in degrees (default 0)
- 4) press GO.
The Frame derotator angle is plotted, for the time ranges when the source is
above horizon and the derotator angle is within limits (+/-83 degrees, green 
line).

2 SOURCE_NAME
  The name of the source (12 characters max.).
2 DO_CATALOG
  Use directly input coordinates or those in a catalog (CATALOG_NAME).
2 POSITION_ANGLE
  Position angle of HERA (East from North) in degrees.
2 CATALOG_NAME
  Name of the catalog in ASTRO format.
2 SOURCE_SYSTEM
  Source coordinate system (EQ, GA, ...); see ASTRO command SOURCE.
2 SOURCE_EPOCH
  Source coordinates epoch (e.g. 2000).
2 SOURCE_RA
  Source right ascension (hh:mm:ss.s) 
2 SOURCE_DEC
  Source declination (sdd:mm:ss.s).

end help rotator.hlp
!
!-----------------------------------------------------------------------------
! x_do_plot.astro 
!-----------------------------------------------------------------------------
!
begin procedure x_do_plot
let source_name 'source_name' /upper
if do_catalog then
  astro\catalog gag_astro:'catalog_name'
  astro\source 'source_name'
else
  sic out gag_tmp:1.sou
  say 'source_name' 'source_system' 'source_epoch' 'source_ra' 'source_dec'
  sic out
  astro\catalog gag_tmp:1.sou
  astro\source 'source_name'
endif
!
sou p 0 90
def real clat slat cb sb
define integer n
let n 100
def real time[n] azim[n] elev[n] pa[n] drot[n]
let clat cos(elevation)
let slat sin(elevation)
exa clat
exa slat
let time[i] 24*(i-1)|(n-1)
for i 1 to n
  time time[i] /nodraw
  astro\source 'source_name' /print
  let elev[i] elevation*180|pi
  let azim[i] azimuth*180|pi
  let sb clat*sin(azimuth)/cos(dec)
  let cb (slat-sin(dec)*sin(elevation))/cos(dec)/cos(elevation)
  let pa[i] atan2(sb,cb)*180|pi
  let drot[i] (elev[i]+position_angle-pa[i])/2
let drot[i] mod(drot[i]+90.,180.)-90.
next
let drot -999 /where (abs(drot).gt.83).or.(elev.le.0)
set blank -999 1
limits 0 24 -90 90
destroy all
tick 1 6 10 30
pen 0
box
pen 1
connect time drot
!
pen 2 /col 2 /dash 2
dra rel 0 83 /user
draw line 24 83 /user
dra rel 0 -83 /user
draw line 24 -83 /user
!
pen 0
set orient 0
draw text 0 0.5 "Source: "'source_name' 6 /box 7
draw text 0 0.5 "HERA Position Angle = "'position_angle'" deg." 4 /box 9
label "Frame Derotator Angle (deg)" /y
label "UT (h)" /x
!
end procedure x_do_plot
!
!-----------------------------------------------------------------------------
! Main procedure
!-----------------------------------------------------------------------------
!
observatory veleta
time /nodraw
gui\panel "HERA Derotator Angle Limits" rotator.hlp
if .not.exist(source_name) then
  define character source_name*80 /global
endif
let source_name 'source_name' /prompt "Source Name"
!
if .not.exist(do_catalog) then
  define logical do_catalog /global
  let do_catalog no
endif
let do_catalog 'do_catalog' /prompt "Use Source Catalog Coordinates ?"
!
if .not.exist(position_angle) then
  define real position_angle /global
  let position_angle 0.
endif
let position_angle 'position_angle' /prompt "HERA Position Angle"
!
say ""
say "If Source Catalog is used"
if .not.exist(catalog_name) then
  define character catalog_name*80 /global
  let catalog_name ""
endif
let catalog_name 'catalog_name' /prompt "Source Catalog Name"
!
say ""
say "If Source Catalog is not used"
!
if .not.exist(source_system) then
  define character source_system*6 /global
  let source_system "EQ"
endif
let source_system 'source_system' /prompt "Coordinate System"
!
if .not.exist(source_epoch) then
  define real source_epoch /global
  let source_epoch 2000.0
endif
let source_epoch 'source_epoch' /prompt "Source epoch"
!
if .not.exist(source_ra) then
  define character source_ra*20 /global
endif
let source_ra 'source_ra' /prompt "Right Ascension"
!
if .not.exist(source_dec) then
  define character source_dec*20 /global
endif
let source_dec 'source_dec' /prompt "Declination"
!
gui\go "@ x_do_plot"

