NAME

prefilter - Derive attitude and orbit related quantities for Swift.

ALGORITHMS

prefilter makes use of the atFunctions library almost exclusively for its calculations. The exceptions are calls being made to derive the McIlwain L parameter and SAX cut off rigidity.

The following descriptions may be clarified by reading the IMPLEMENTATION section.

Items in square brackets [ ] are taken from the Context object.
Items in angle brackets < > are taken from the Derived object.

Position

Derivation
[orbmode=TLE] Based on NORAD TLEs received from Swift MOC and the SGP4 modelling defined by NORAD (see www.celestrak.com/WhitePaper for SGP modelling details).
The latest TLE available before the output start time is used in the SGP4 model to find the position and velocity at the desired timestamp (TIME_ADJ).

[orbmode=atSetElement/atSetElement2] Position is read from a text/FITS file appropriate for the corresponding atFunctions call.

[orbmode=XTE] Position and attitude are taken directory from orbname file which is expected to use the xtefilt output format.

Attitude

Derivation
Attitude is determined using the coord and coordfits libraries.
Quaternions from the FITS file are interpolated to the desired timestamp (TIME).

Polar position

FITS columns
SAT_ALT
SAT_LAT
SAT_LON

Derivation
	AtPolarVect polar
	AtVect geodetic

	atGeodetic([mjd], [position], geodetic)
	atVectToPol(geodetic, &polar)

	SAT_ALT = polar.r
	SAT_LON = radians_to_degrees(polar.lon)
	SAT_LAT = radians_to_degrees(polar.lat)

	<polar> = polar

Pointing vector

Derivation
	AtRotMat rm
	AtRotMat aib
	AtQuat qhat
	AtVect zAzis = { 0, 0, 1 }
	AtVector pointingVector

	qhat = [quaternion] * [args->align->q_inverse]

	atQuatToRM(qhat, rm)
	atInvRotMat(rm, aib)
	atRotVect(rm, zAxis, pointingVector)

	<pointingVector> = pointingVector

Right ascension, declination, roll

FITS columns
PNT_RA
PNT_DEC
PNT_ROLL

Derivation

	convertQuatToRADecRoll([args->align, <quaternion>,
			&ra, &dec, &roll)
	PNT_RA = ra
	PNT_DEC = dec
	PNT_ROLL = roll

Earth angles

FITS columns
ELV
BR_EARTH
FOV_FLAG

Dependencies
pointingVector

Derivation
	double angle[3]
	AtVect sunPosition

	atSun([mjd], sunPosition)
	atEarthElev2([position], <pointingVector>, sunPosition, &flag, angle)

	ELV = radians_to_degrees(angle[0])
	BR_EARTH = radians_to_degrees(angle[1])
	FOV_FLAG = flag

Sunshine

FITS columns
SUNSHINE

Derivation
	AtVect sunPosition
	AtVect sunNormal

	atSun([mjd], sunPosition)
	atNormVect(sunPosition, sunNormal)

	atEarthOccult([position], sunNormal, sunPosition, &flag, &dummy)

	if (flag == 0)
		SUNSHINE = 1
	else
		SUNSHINE = 0

Sun angle

FITS columns
SUN_ANGLE

Dependencies
pointingVector

Derivation
	double angle
	AtVect sunPosition

	atSun([mjd], sunPosition)
	atAngDistance(sunPosition, <pointingVector>, &angle)

	SUN_ANGLE = radians_to_degrees(angle)

Moon angle

FITS columns
MOON_ANGLE

Dependencies
pointingVector

Derivation
	double angle
	AtVect moonPosition
	double size, phase, distance

	atMoon([mjd], moonPosition, &size, &phase, &distance)
	atAngDistance(moonPosition, <pointingVector>, &angle)

	MOON_ANGLE = radians_to_degrees(angle)

Ram angle

FITS columns
RAM_ANGLE

Dependencies
pointingVector

Derivation
	double angle

	atAngDistance([velocity], <pointingVector>, &angle)

	RAM_ANGLE = radians_to_degrees(angle)

Pointing separation

FITS columns
ANG_DIST

Dependencies
pointingVector

Derivation
	double angle
	AtVect nominal

	atPolDegToVect(1, [nomra], [nomdec], nominal);
	atAngDistance(nominal, <pointingVector>, &angle)

	ANG_DIST = radians_to_degrees(angle)

Cut off rigidity ASCA

FITS columns
COR_ASCA

Dependencies
polarPosition

Derivation
	float rigidity

	atRigSet([rigname])
	atRigidity(<polarPosition>, &rigidity)

	COR_ASCA = rigidity

Cut off rigidity SAX

FITS columns
COR_SAX

Derivation
	real tjd
	real xyz[3]
	real b0, fl, latitude, world

	tjd = [mjd] - 40000
	xyz = [position]

	xyzmag(&tjd, xyz, &b0, &fl, &rigidity, &latitude, world);

	COR_SAX = rigidity

McIlwain L

FITS columns
MCILWAIN_L

Dependencies
geodetic

Derivation
	real scpos[3] = <geodetic> / EARTH_RADIUS

	shellc_(&scpos[0], &mcIlwainL, &icode, &b0);

	MCILWAIN_L = mcIlwainL

SAA

FITS columns
SAA
SAA_TIME

Dependencies
polarPosition

Derivation
	<timeChangeSAA> is initialized to null once per run

	int flag

	atBrazil(<polarPostion.lon>, <polarPosition.lat>, &flag)

	SAA = flag

	if SAA != previous value
		<timeChangeSAA> = mission time

	if  is not null
		SAA_TIME = mission time - <timeChangeSAA>


EXTENSION

prefilter is implemented to be readily extended.

To add an output parameter modify swift_register_parameter in derive.c, add a variable for the calculation to the Derived structure, and implement the appropriate Derivation function.

For example, say we want to derive the parameter foo. Foo will be calculated using a double precision floating point variable (foo), and stored to a FITS TFLOAT column. The FITS column will have name 'FOO' and units m/s.

Modify Derived (in derive.h) to include the appropriate field

	struct Derived
	{
		...
		double foo;
		...
	};
Modify swift_register_parameters to include
	Parameter *p = create_parameter("FOO");

	p->derivation = &swift_derive_foo;

	p->derivedType = PREFILTER_DOUBLE;
	p->derivedOffset = PREFILTER_OFFSET(foo);
	p->fitsType = TFLOAT;
	p->fitsColumn = "FOO";
	p->fitsUnits = "[m/s]";

	/*
	 * note that define_parameter passes ownership of the parameter to
	 * the Setup object
	 */
	define_parameter(setup, p);
And implement
	int swift_derive_foo (const Context *context, Derived *derived)
	{
		/* totally bogus computation for illustrative purposes only */
		derived->foo = context->position[0] / context->met;
		return derived->code;
	}
Multiple output parameters can share the same derivation function. It will only be called once per timestamp.

The actual parameters that are output can be a subset of those built into the system using the parameters argument.

IMPLEMENTATION

The prefilter process is implemented in C

prefilter.h
mission-independent prefilter interface
derive.h
swift prefilter Argument, Context, Derived declarations
driver.c
performs Argument setup
prefilter.c
mission-independent prefilter implementation
derive.c
derivation of filter parameters

Derivation functions are passed pointers to two objects - a (constant) Context struct and a modifiable Derived struct. The convention as to what belongs in the Context versus Derived is somewhat arbitrary. It is expected that extensions will add only to the Derived structure and leave the Context alone.

The Context provides mission time (AtTime), position and velocity (AtVect), and attitude (AtQuat). It also has some state that is used to iterate the Context between time points, and FITS null values.

ACRONYMS

FITS
Flexible Image Transport System
MOC
Mission Operations Center
NORAD
North American Aerospace Defense Command
SAA
South Atlantic Anomaly
SAX
Satellite per Astronomia in raggi X
SGP
Space Geodesy Project
TLE
Two Line Elements

LAST MODIFIED

May 2002