\section{{\bf Spacecraft Attitude and Ephemeris}}

\subsection{Routines for Determining Spacecraft Pointing}
\index{pointing, spacecraft}
\index{spacecraft pointing}
\index{ATT database}

\subsubsection{RD\_PNT\_HIST}
\index{pointing history}
\index{history of S/C commanded pointings}
\index{spacecraft pointing, history}

The routine RD\_PNT\_HIST will read the file {\tt \$DIR\_GEN\_STATUS/pointing.history} to
determine all of the spacecraft commanded off-points.  The structure returned has
the .TIME and .DAY when the pointing change has occurred, and the offset (.OFFSET)
for that pointing change.  The S/C pointing bias is taken into account (the pointing
bias has not been changed since 28-Oct-91).\index{pointing bias}
A sample call is:
%
\idlinputa{rd\_pnt\_hist, pntdata}\index{RD\_PNT\_HIST}
%
PR\_PNT\_HIST provides 
a simple method to display a summary of the commanded spacecraft pointing changes.
Sample calls are:
%
\idlinputa{pr\_pnt\_hist}
\idlinputb{pr\_pnt\_hist, outfil='pr\_pnt\_hist.txt'}\index{PR\_PNT\_HIST}
%
The routine SXT\_CMD\_PNT will return the SXT pixel coordinates of the
center of the sun using the spacecraft commanded pointing history database file
(calls to SXT\_CEN with the $/cmd$ switch simply call SXT\_CMD\_PNT).  A sample
call is:
%
\idlinputd{xy = sxt\_cmd\_pnt(index)}\index{SXT\_CMD\_PNT}

\subsubsection{SXT\_CEN}
\index{GET\_SUNCENTER}\index{SXT\_CEN}

The routine SXT\_CEN should be used by all routines that wish to
determine the S/C pointing.  The function will return the pointing
in SXT full resolution pixels for the set of times passed.  The
following logic is used if no switches are used

\IItem
\item Check to see if the ATT database files are available.  The
	processed pointing value has already been calculated and is
	saved in those files.
\item If the ATT step above fails, check to see if the ATR database file exist (or old PNT files).
	If they do, call GET\_SUNCENTER to reduce the raw
	IRU and HXA data stored in the PNT files and return the
	actual S/C pointing.
\item If the ATT and PNT steps fail, then read the commanded S/C file.  This
	result gives the coarse pointing and will not correct for S/C drift.
\end{itemize}

Some sample calls are:
%
\idlinputa{cen = sxt\_cen(times)}
\idlinputb{cen = sxt\_cen(roadmap, /cmd)}
\idlinputb{cen = sxt\_cen(index, roll=roll)}
%
The S/C roll value can optionally be returned with the keyword parameter {\it roll}.
The roll values are only valid if the ATT database is available.  If the {\it /cmd}
option is used, it will use the commanded S/C data file which is much faster than
reading the ATT database files.  See the discussion on
page~\pageref{get_suncenter} for more details on the ATT database.

\subsubsection{GET\_ROLL}
\index{spacecraft roll}
\index{roll, spacecraft}

The spacecraft is generally aligned to solar north, although it oscillates
around slightly.  The actual S/C roll value is determined from the
star tracker and is stored in the ATT database file.  There is also a one 
degree offset between the spacecraft and the SXT CCD-north.  The orientation
of the offset is shown in Fig.~\ref{fighelproll1}.

\insertplot{fig_help_roll1.eps}{Roll Angle Offset for the SXT}{fighelproll1}{6.25}{3.5}

The sign convention of the roll value which is returned by GET\_ROLL is
shown in Fig. ~\ref{fighelproll2}.

\insertplot{fig_help_roll2.eps}{Sign Convention for the SXT Roll Angle}{fighelproll2}{6.25}{3.5}

Figs.~\ref{fighelproll1} and~\ref{fighelproll2} can be displayed on the screen by
using the IDL routine HELP\_ROLL.  \index{HELP\_ROLL}

Some sample calls to GET\_ROLL are (it only accesses the date and time in {\it index}):
%
\idlinputa{roll = get\_roll(index)}\index{GET\_ROLL}
\idlinputb{print, get\_roll('23-jun-93 1:00')}
\idlinputb{print, get\_roll('23-jun-93 1:00', /predict)}
%
The {\it /predict} option tells it to not access the ATT database but to use the
predicted roll based on seasonal variations.  This value can be very incorrect
for certain times.  The {\it /notsxt} option will return the S/C roll value
without the SXT offset, and {\it /sxt\_offset} will just return the fixed
offset value between S/C north and SXT north.  The routine SXT\_CEN calls
GET\_ROLL automatically and you can get the roll using the keyword {\it roll}
with SXT\_CEN.

\subsubsection{HXA\_SUNCENTER}
\index{HXA aspect sensor}

Calculate the suncenter position (in SXT pixel coordinates) from
the HXA info in the ATR (or PNT) files.  Tries to reconstruct hidden limbs.
%
\idlinputa{sunc = hxa\_suncenter(atr)}	\index{HXA\_SUNCENTER}
\idlinputb{sunc = hxa\_suncenter(index=index)}
%
If the input {\it atr} or {\it index} have N elements, then the
result will be a floating array of 4xN elements.  {\it sunc(0,*)}
is the SXT column number in `IDL coordinates'\footnote{See the Appendix of the 
Instrument Guide for a discussion of SXT pixel coordinates}, {\it sunc(1,*)} 
is the SXT line number, {\it sunc(2,*)}
is the milliseconds of day for the input time, and {\it sunc(3,*)}
is the days since 1-Jan-79 number for the input time.

\subsection{Routines to Access the Yohkoh Attitude Database}

\subsubsection{RD\_PNT}\index{RD\_PNT}

The PNT database was broken up into two parts in mid-1993.  See
RD\_ATR and RD\_ATT.  The PNT database is no longer used.

\subsubsection{RD\_ATR and RD\_ATT}
\index{ATT database}

The RD\_ATR routine allows a user to read the raw S/C pointing information
which is stored in secondary database files.  The
ATR files have the IRU, HXA, and TFSS information for every major
frame.  The RD\_ATT routine allows a user to read the processed S/C pointing
information.  Sample calls would be:
%
\idlinputa{rd\_atr, sttim, entim, atr}	\index{RD\_ATR}
\idlinputb{rd\_att, sttim, entim, att}	\index{RD\_ATT}
\idlinputb{rd\_atr, '1-nov-91', '3-nov-91', atr} 
%
The ATR structure that is returned has the following tags:

\vspace{0.2in}\begin{tabular}{lp{15.0cm}}
{\tt .TIME} 	& {\raggedright  The major frame time for the data}\\
{\tt .DAY} 	& {\raggedright  The major frame day for the data}\\
{\tt .DP\_MODE}	& {\raggedright  The S/C DP mode (see GT\_DP\_MODE)}\\
{\tt .DP\_RATE}	& {\raggedright  The S/C telemetry rate (see GT\_DP\_RATE)}\\
{\tt .IRU} 	& {\raggedright  A three element array with the raw IRU X,Y,Z values}\\
{\tt .TFSS} 	& {\raggedright  A two element array with the raw TFSS values}\\
{\tt .HXA} 	& {\raggedright  A four element array with the addresses of the \\
				limbs as detected by the HXA}\\
\end{tabular}

\label{get_suncenter}
The ATT database is derived from the HXA and IRU data using the routine
IRUHXA2SXT \index{IRUHXA2SXT} which was written by Jean-Pierre Wuelser.
The ATT structure that is returned has the following tags:

\vspace{0.2in}\begin{tabular}{lp{15.0cm}}
{\tt .TIME} 	& {\raggedright  The major frame time for the data}\\
{\tt .DAY} 	& {\raggedright  The major frame day for the data}\\
{\tt .DP\_MODE}	& {\raggedright  The S/C DP mode (see GT\_DP\_MODE)}\\
{\tt .DP\_RATE}	& {\raggedright  The S/C telemetry rate (see GT\_DP\_RATE)}\\
{\tt .PNT} 	& {\raggedright  A three element array with the derived center for the sun in \\
				 SXT full resolution pixels. \\ 
				 (0) = E/W (East has smaller values) in 1/100 SXT FR pixel units. \\
				 (1) = N/S (South has smaller values) in 1/100 SXT FR pixel units. \\
				 (2) = Roll in 0.1 arcsecond units - Negative values are S/C rotating \\
					counter-clockwise relative to solar north }\\
{\tt .STATUS1} 	& {\raggedright  Indicates the reliability of each sun center position.\\
				1: plain S/C commanded value used, no dejittering with IRU.\\
				2: S/C commanded value dejittered with IRU.\\
				4: HXA value dejittered with IRU.  Standard result, good.\\
				Note: S/C commanded values can be several pixels off.}\\
{\tt .STATUS2} 	& {\raggedright  - Reserved}\\
{\tt .ADS} 	& {\raggedright  - If set, then the S/C roll value from the ADS database was \\
				inserted into the structure}\\
\end{tabular}


\subsubsection{GET\_ATT}

For a given set of input times, GET\_ATT will read the relevant
ATT records (if 100 input times are passed in, then 100 ATT records
are returned).  This routine is useful when trying to access ATT
data that covers a set of times over a long time span.
A sample call would be:
%
\idlinputd{get\_att, index, att}\index{GET\_ATT} 
%
\subsubsection{GT\_HXA}

GT\_HXA will extract the HXA data from a ATR structure or
from an ADA data structure.  Some sample calls are:
%
\idlinputa{hxa = gt\_hxa(atr)}	\index{GT\_HXA}
\idlinputb{sxtcen = gt\_hxa(atr\_data, /sxtpix)}	
\idlinputb{sxtcen = gt\_hxa(atr\_data, /sxtpix, /x)}	
\idlinputb{hxacen = gt\_hxa(atr\_data, /hxacen)}	
\idlinputb{hxacen = gt\_hxa(atr\_data, /hxacen, /y)}	
\idlinputb{x1 = gt\_hxa(atr\_data, 0)}	
\idlinputb{x2 = gt\_hxa(atr\_data, 1)}	
\idlinputb{y1 = gt\_hxa(ada\_data, 2)}
%
The {\it hxa} result would be 4xN where there are four addresses
for HXA limbs.
The {\it /x} or {\it /y} switches will result in a
single address being returned, and the {\it /sxtpix} will return
the results in SXT pixel coordinates.

\subsubsection{GT\_IRU}

It is possible to extract the IRU information from the ATR or ADA
structures using GT\_IRU.  The output is in arcseconds.  It
is also possible to have the drift in the IRU removed for short
time periods by using the /RESID switch (it fits a line to the drift
and subtracts that drift).  Sample calls are:
%
\idlinputa{iru = gt\_iru(atr)}	\index{GT\_IRU}
\idlinputb{iru = gt\_iru(atr, /resid)}	
\idlinputb{iru = gt\_iru(ada)}	
\idlinputc{iru = gt\_iru(ada, index, /resid)}
%

\subsection{Spacecraft Ephemeris}

\subsubsection{ORB files}

\subsubsection{FEM Files}

some text?
