Rotang can be called either through the IDL command line or through the afla_ang GUI. The full cummand line syntax is:

`rotang, Date, RA, Dec, Time, accS, ast=ast, ha=ha, lst=lst,
jd=jd, az=az, za=za, sep=sep, rotang=rotang, alfabeams=alfabeams`

`date`, `RA`, `Dec` and `Time` are covered
in the basic rotang documentation; the fifth
input parameter is `accS`, which
is the accuracy to which the requested time is required. This defaults to
half a second: if this requirement is not met then the calculation will be
iterated until it is. It is not normally necessary to modify this
parameter.

`ast`, `ha` and `lst` are used to specify which of
AST, LST or HA is wanted, as described in the basic documentation. The
precedence sequence for this is that if both LST takes precedence over HA
but AST takes precedence over LST. If none are specified, the program
defaults to HA. If these parameters are specified with a variable name,
e.g. `ha=haHr` then the value of the variable on return will be that
of the HA, LST or AST of the requested observation (in hours). It is thus
possible to specify, for instance:

IDL> haHr = 1 IDL> lstHr = 0 IDL> astHr = 0 IDL> rotang, ... , ha=haHr, lst=lstHr, ast=astHr

In which case, the variables `haHr`, `lstHr` and
`astHr` will, upon return, contain the requested HA and the
corresponding LST and AST in hours.

`jd`, `az`, `za`, `sep` and `rotang` are
return-parameters, returning the Julian Date, Azimuth and Zenith Angle of the
observation and the mean declination separation of the ALFA beams and optimum
rotation angle of the array respectively. `alfabeams` is a structure
which contains the elements `{angle, sep, dev, bnum, azoff, zaoff, az, za,
ra, dec, raoff, decoff}`. `alfabeams.angle` and
`alfabeams.sep` should be identical to `rotang` and `sep`,
and `alfabeams.dev` contains the error on the mean declination
separation of the ALFA beams. The other elements
are 7-element arrays containing the beam number (0-6) and the corresponding
azimuth offset, zenith angle offset, azimuth, zenith angle, right ascension,
declination, right ascension offset and declination offset. All offsets
are with respect to the central beam (beam 0).

The algorithm works quite simply. Firstly the Julian Date of the requested observations is calculated as the next time after midnight AST on the requested date that meets the specified time criterion. This is used to calculate the Az and ZA of the source from its RA and Dec. From these, the parallactic angle of the source is calculated and used to make an inital estimate of the source position. This should ensure that the rotation of the source is correct to within 4 degrees, thus the general orientation of the beams will be correct. The minimising algorithm then starts from this initial guess and finds the slope of the error on the mean vs angle, which falls almost linearly to close to zero at its minimum. By moving down this slope in one degree steps until the slop reverses, a position accurate to one degree is found. The algorithm then double-checks that the beams are in the correct places, not rotated to a minimum different from the standard at meridian crossing, and that ALFA is within its rotation limits. If ALFA is outside its rotation limits, then hte angle is increased or decreased by 180 degrees to bring it inside. A second minimization then takes place using the same algorithm, this time with 0.1 degree steps. Finally, a check is made to see whether the source is at a Zenith Angle of less than two or greater than twenty degrees, and if it is a warning is printed.

Rotang consists of the following files in addition to the standard
`aoidl` installation:

`alfa_angle`- script to launch the GUI`alfa_ang.pro`- the GUI: provides input to`rotang`and a graphical display of the results.`rotang.pro`- the main routine of the program: finds the required time, the other associated times, Az and ZA using`ao_idl`routines. Calls`radecjdtohaang`to get the hour angle,`guess_rotang`to get an initial estimate of the rotation angle from the paralactic angle and`getbestang`to find the best angle and the associated mean separation, then prints the results to the terminal (and returns them to`alfa_ang`if called from the GUI. Modified from the Cornell EGG`srcvis`routine.`radecjdtohaang.pro`- takes in the J2000 RA and Dec and the Julian Date and outputs the hour angle and the current RA and Dec. Note that the difference between LST - RA (J2000) and current HA is significant near the meridian when calculating Azimuths (for the Fixed Azimuth Drift Scan mode) and ALFA rotation angles. This uses some code from Phil Perilat's`ao_radecjtoazza`routine.`guess_rotang.pro`Cornell EGG routine to calculate the parallactic angle and use this to estimate the optimum rotation angle.`getbestang.pro`- the minimising routine: calls`getthisang`to get mean separations and errors for individual angles and steps down the slope of error vs angle to find the minimum.`getthisang.pro`- computes mean separation and error for individual angles. Calls`getabmpos`to get beam positions and the declination separations.`getabmpos.pro`- calculates the positions anf offsets of the ALFA beams given the azimuth and zenith angle of the telescope, the julian date, and the angle at which ALFA is rotated. Bases on the Cornell EGG routine`Abmpos3`, which was based on Phil Perilat's`alfabmpos`routine

Original page written by Robert Minchin, 22^{nd} November 2004.
Last modified 22^{nd} November 2004 by Robert Minchin.