test_eclipse

test_eclipse.test_unitEclipse(show_plots, eclipseCondition, planet)[source]

The unit test validates the internal aspects of the Basilisk eclipse module by comparing simulated output with expected output. It validates the computation of a shadow factor for total eclipse, partial eclipse,annular eclipse, and no eclipse scenarios. The test is designed to analyze one type at a time for both Earth and Mars and is then repeated for all three.

Sun States This test begins by specifying a UTC time through the use of a Spice object. This, along with the implementation of Spice kernels, allows the states of the sun and any desired planets to be determined. One time is provided, fixing the sun and planet states so the spacecraft states may be varied. After specifying these, the spacecraft states are set and the three eclipse types are considered.

Spacecraft States Earth is set as the zero base for all eclipse types to test it as the occulting body. For full, partial, and no eclipse cases, orbital elements describing the spacecraft states are then converted to Cartesian vectors. These orbital elements vary for each eclipse type since the Sun and planet states are fixed. The conversion is made using the orbitalMotion elem2rv function, where the inputs are six orbital elements (a, e, i, Omega, omega, f) and the outputs are Cartesian position and velocity vectors. For the annular eclipse case, the conversion is avoided and a Cartesian position vector is initially provided instead. The vectors are then passed into spacecraftPlus and, subsequently, the eclipse module through the Basilisk messaging system.

Testing the no eclipse case with Mars as the occulting body is the same as the Earth no eclipse test, except Mars is set as the zero base. The Mars full, partial, and annular eclipse cases, however, are like the Earth annular case where Cartesian vectors are, instead, the initial inputs. Since the test is performed as a single step process, the velocity is not necessarily needed as an input, so only a position vector is provided for these cases.

Planet States Once the spacecraft states are defined, the planet names are provided as Spice objects. Since the module determines the closest planet to the spacecraft, multiple names may be input and the chosen one depends purely on the position of the spacecraft. For this test, only Earth and Mars were used as occulting bodies, since no appreciable difference in the algorithm presents itself when testing various planets.

Comparison The shadow factor obtained through the module is compared to the expected result, which is either trivial or calculated, depending on the eclipse type. Full eclipse and no eclipse shadow factors are compared without the need for computation, since they are just 0.0 and 1.0, respectively. The partial and annular eclipse shadow factors, however, vary between 0.0 and 1.0, based on the cone dimensions, and are calculated using MATLAB and Spice data.

  • eclipseCondition: [string]

    defines if the eclipse is partial, full, none or annual

  • planet: [string]

    defines which planet to use. Options include “earth” and “mars”

In each test scenario the shadow eclipse variable

shadowFactor

is pulled from the log data and compared to expected truth values.

The previous description only briefly mentions the input parameters required to perform the tests on this module, so this section further details the parameters set by the user and built into the unit test.

Eclipse Condition Input: One of the two user-defined inputs is the eclipse identifier, appropriately named eclipseCondition. This specifies the eclipse type and can be set, via string inputs, to either full, partial, annular, or none for the full, partial, annular, and no eclipse cases. This input changes the spacecraft state parameters to position the spacecraft in the desired eclipse.

Planet Input: The second user input is planet, which allows the user to test either Earth or Mars as the occulting body. Only these two planets are tested since there is no appreciable difference in the eclipse algorithm when varying the planet. This input changes the zero base to reference the chosen planet and the spacecraft state parameters to position the spacecraft in the desired eclipse.

Zero Base: The zero base references either Earth or Mars depending on the planet input.

Orbital Elements: Orbital elements describe the characteristics of the orbit plane and are used in this module to define the states of the spacecraft. They consist of the semimajor axis a in units of kilometers, eccentricity e, inclination i, ascending node Omega, argument of pariapses omega, and the true anomaly f. The Euler angles and true anomaly are all in units of degrees but are converted to radians in the test. Using orbitalMotion, all of the elements are converted to Cartesian position and velocity vectors that are then translated from kilometers to meters. The table below shows the values used when testing full, partial, and no eclipse cases for Earth as well as the no eclipse case for Mars.

Table: Orbital Element Values for Each Eclipse Condition Element Full Eclipse Partial Eclipse No Eclipse ——————————————————————– a 6878.1366km 6878.1366km 9959991.68982km e 0.00001$ 0.00001 0.00001 i 5deg 5deg 5deg Omega 48.2deg 48.2deg 48.2deg omega 0deg 0deg 0deg f 173deg 107.5deg 107.5deg ——————————————————————–

The orbital elements remain the same when testing the no eclipse case for Earth and Mars, but the zero base is changed to reference the appropriate planet. The parameters used when testing full, partial, and annular eclipse cases for Mars as well as the annular case for Earth are shown under Cartesian Vectors.

Cartesian Vectors: Cartesian position vectors are used as inputs when testing the full, partial, and annular eclipse cases for Mars as well as the annular case for Earth. Velocity vectors are not needed since this test is performed as a single step process and eclipses at a single point in time depend only on the position of the celestial bodies at that time. The vectors are shown in the Table below. The parameters for the no eclipse case were given previously under Orbital Elements.

Full Eclipse -2930233.559m 2567609.100m 41384.233$ m Partial Eclipse -6050166.455m 2813822.447m 571725.565 m Annular Eclipse (Earth) -326716535.629km -287302983.139km -124542549.301$ km Annular Eclipse (Mars) -427424601.171km 541312532.797km 259820030.623 km ———————————————————————————-

Standard Gravitational Parameter: The gravitational parameter mu is necessary for converting between orbital elements and Cartesian vectors. It is the product of a body’s gravitational constant and mass, specifying the attracting body in units of km^3/s^2. This test only uses the conversion when considering Earth as the occulting body, so only Earth’s gravitational parameter is given below. The value is obtained through orbitalMotion.

mu_{Earth} = GM_{Earth}=398600.436 km^3/s^2

Planet Names: The eclipse module accepts and will analyze multiple planets at a time, so to indicate which planets are of interest, the names must be input. These are input as Spice objects of type string and can either be venus, earth, or mars barycenter. Spice uses this information and the time input to provide state data, which is then used to determine the closest planet. The closest planet is the only one further evaluated for potential eclipse conditions.

Time: In order to specify the states of the planets and sun, time is a neccessary input. Only one time is used for every test, fixing the sun and planet states and varying the states of the spacecraft. For this test, the input “2021 MAY 04 07:47:49.965 (UTC)” is used, where the time is represented in UTC form.

Spice Kernels: Spice information is gathered from a collection of kernels, specfically SPK, LSK, and PCK files. The binary SPK used is de430.bsp, which provides ephemeris data. The LSK file is naif0012.tls, which offers leapsecond information. For reference frame orientation, two PCK files are given. These are de-403-masses.tpc and pck00010.tpc.