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.
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
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
convertQuatToRADecRoll([args->align, <quaternion>, &ra, &dec, &roll) PNT_RA = ra PNT_DEC = dec PNT_ROLL = roll
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
AtVect sunPosition AtVect sunNormal atSun([mjd], sunPosition) atNormVect(sunPosition, sunNormal) atEarthOccult([position], sunNormal, sunPosition, &flag, &dummy) if (flag == 0) SUNSHINE = 1 else SUNSHINE = 0
double angle AtVect sunPosition atSun([mjd], sunPosition) atAngDistance(sunPosition, <pointingVector>, &angle) SUN_ANGLE = radians_to_degrees(angle)
double angle AtVect moonPosition double size, phase, distance atMoon([mjd], moonPosition, &size, &phase, &distance) atAngDistance(moonPosition, <pointingVector>, &angle) MOON_ANGLE = radians_to_degrees(angle)
double angle atAngDistance([velocity], <pointingVector>, &angle) RAM_ANGLE = radians_to_degrees(angle)
double angle AtVect nominal atPolDegToVect(1, [nomra], [nomdec], nominal); atAngDistance(nominal, <pointingVector>, &angle) ANG_DIST = radians_to_degrees(angle)
float rigidity atRigSet([rigname]) atRigidity(<polarPosition>, &rigidity) COR_ASCA = rigidity
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
real scpos[3] = <geodetic> / EARTH_RADIUS shellc_(&scpos[0], &mcIlwainL, &icode, &b0); MCILWAIN_L = mcIlwainL
<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 ifis not null SAA_TIME = mission time - <timeChangeSAA>
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.
The prefilter process is implemented in C
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.