--[[

References:
[1]     Source :    http://www.asteroidmission.org/about-mission/
        Date :      2016-08-23
        Comment :   Precision is not even month - it just defines the overall mission approach

[2]     Source :    http://brinktest.lpl.arizona.edu/mission/
        Date :      2016-08-23
        Comment :   Data taken from text descriptions of the visualizations. There is a little time bar up
                    in the upper right corner.

[3]     Source :    SPICE kernel data coverage
        Date :      2016-08-23
        Comment :   The spice data is split up into across different files. These files
                    seems to represent different phases. A script was used to extract the
                    SPICE coverage from all .bc files and use the names of the files as
                    mission names and associate the name with the time coverage.
                    Script used: support/mission/ckbrief2mission.js

[4]     Source :    Visual interpretation of SPICE kernel data coverage
        Date :      2016-08-23
        Comment :   Based on observation of the visualized spice data through OpenSpace.

[5]     Source :    https://www.asteroidmission.org/asteroid-operations/
        Date :      2023-03-30
        Comment :   Text about the phases

https://www.asteroidmission.org/wp-content/uploads/2018/10/SPP-Approach-Poster-10-03-18.pdf
--]]

local Mission = {
  Name = "OSIRIS-REx",
  Description = "Launched on Sept. 8, 2016, the Origins, Spectral Interpretation, Resource Identification, Security-Regolith Explorer (OSIRIS-REx) spacecraft traveled to a near-Earth asteroid called Bennu (formerly 1999 RQ36), and collected a sample of the of rocks and material from the surface that it will return to Earth in 2023. The mission will help scientists investigate how planets formed and how life began, as well as improve our understanding of asteroids that could impact Earth.",
  Image = "https://www.nasa.gov/sites/default/files/styles/full_width_feature/public/thumbnails/image/osiris-rex-mission-logo12_copy.png",
  Actions = { "os.osirisrex.AimAtBennu", "os.osirisrex.SetLaunchTime", "os.osirisrex.LookImageCapture" },
  Phases = {
    -- All 1-level phases based on [1]
    {
      Name = "Outbound Cruise",
      Image = "https://www.nasa.gov/sites/default/files/styles/full_width_feature/public/thumbnails/image/28929096574_85a647dc8e_o.jpg",
      Phases = {
        -- Phases from [4]
        {
          Name = "Pre Launch", TimeRange = { Start = "2016 SEP 03 01:00:00", End = "2016 SEP 08 23:05:05" }
        },
        {
          Name = "Launch",
          TimeRange = { Start = "2016 SEP 08 23:05:05", End = "2016 SEP 08 23:09:00" }
        },
        {
          Name = "Earth Orbit",
          TimeRange = { Start = "2016 SEP 08 23:09:00", End = "2016 SEP 08 23:45:00" }
        },
        {
          Name = "Solar Orbit",
          TimeRange = { Start = "2016 SEP 08 23:45:00", End = "2018 SEP 01 00:00:00" },
          Image = "https://www.nasa.gov/sites/default/files/styles/full_width_feature/public/thumbnails/image/ega_1ms_mapcam_color_corrected_0.png",
          Description = "A color composite image of Earth taken on Sept. 22 by the MapCam camera on NASA's OSIRIS-REx spacecraft. This image was taken just hours after the spacecraft completed its Earth Gravity Assist at a range of approximately 106,000 miles (170,000 kilometers). MapCam is part of the OSIRIS-REx Camera Suite (OCAMS) operated by the University of Arizona. Visible in this image are the Pacific Ocean and several familiar landmasses, including Australia in the lower left, and Baja California and the southwestern United States in the upper right. The dark vertical streaks at the top of the image are caused by short exposure times (less than three milliseconds). Short exposure times are required for imaging an object as bright as Earth, but are not anticipated for an object as dark as the asteroid Bennu, which the camera was designed to image. Date Taken: Sept. 22, 2017",
          Phases = {
            {
              Name = "Upcoming Gravity Assist", TimeRange = { Start = "2017 JAN 22 15:00:00", End = "2017 SEP 22 15:00:00" }
            },
            {
              Name = "Gravity Assist", TimeRange = { Start = "2017 SEP 22 15:00:00", End = "2017 SEP 22 21:00:00" }
            }
          }
        }
      }
    },
    {
      Name = "Asteroid Operations",
      Phases = {
        -- Nested Levels from [3]
        {
          Name = "Approach",
          Description = "Approach Phase began on August 17, 2018, when the spacecraft was still about 1.2 million miles (two million km) away from Bennu, and it continued until the spacecraft arrived at the asteroid on December 3, 2018. The primary goals of Approach were to visually locate Bennu for the first time, survey the surrounding area for potential hazards, and collect enough imagery of Bennu for scientists to generate a detailed shape model of the asteroid, assign a coordinate system, and understand its spin state.",
          TimeRange = { Start = "2018-AUG-17 00:00:00.000", End = "2018-DEC-31 01:34:21.183" },
          Image = "https://www.nasa.gov/sites/default/files/styles/full_width_feature/public/thumbnails/image/lbt-orex-1049-loop-gif.gif",
          Phases = {
            {
              Name = "Dust Plume Search Observation",
              Description = "Search for dust and gas plumes originating from the asteroid surface, and characterize their source regions and column densities. Information on the presence and location of dust and gas plumes is needed to assess safety, understand the geologic and dynamic history of the asteroid, and inform sample-site selection.",
              TimeRange = { Start = "2018-SEP-11 21:31:01.183", End = "2018-SEP-12 02:18:41.183" },
              Image = "https://www.asteroidmission.org/wp-content/uploads/2018/09/MapCamDustSearch-1.jpg"
            },
            {
              Name = "Light Curve",
              TimeRange = { Start = "2018-OCT-09 21:50:48.182", End = "2018-OCT-10 02:33:16.183" }
            },
            {
              Name = "Natural Satellite Search",
              TimeRange = { Start = "2018-OCT-26 19:38:30.183", End = "2018-OCT-27 00:22:34.183" }
            },
            {
              Name = "Phase Function",
              TimeRange = { Start = "2018-OCT-12 21:42:26.183", End = "2018-OCT-13 02:24:54.183" }
            },
            {
              Name = "Shape Model",
              TimeRange = { Start = "2018-NOV-09 11:02:59.183", End = "2018-NOV-16 15:51:33.183" }
            },
            {
              Name = "Shape Model Forced 4x4",
              TimeRange = { Start = "2018-NOV-17 11:03:54.183", End = "2018-NOV-17 15:51:34.183" }
            },
            {
              Name = "Spectral Map",
              TimeRange = { Start = "2018-OCT-30 20:44:53.183", End = "2018-OCT-31 01:34:21.183" }
            }
          }
        },
        {
          Name = "Preliminary Survey",
          Description = "Preliminary Survey Phase began with the spacecraft's arrival at Bennu on December 3, 2018, and marked the first time that the OSIRIS-REx spacecraft operated around the asteroid. The spacecraft made a total of five passes over the north pole, equator, and south pole at a range of 4.3 miles (7 km). The primary science goals of Preliminary Survey were to estimate Bennu's mass, refine the asteroid's spin state model, and generate a global shape model at a resolution of 75-cm.",
          Image = "https://www.asteroidmission.org/wp-content/uploads/2018/05/Prelim-Survey-for-Web.jpg",
          Phases = {
            {
              Name = "MapCamOLA Phase 1",
              TimeRange = { Start = "2018-NOV-20 01:13:12.183", End = "2018-NOV-20 06:13:04.183" }
            },
            {
              Name = "OLA Phase 1",
              TimeRange = { Start = "2018-NOV-19 22:30:00.184", End = "2018-NOV-19 23:19:28.183" }
            },
            {
              Name = "OLA Phase 2",
              TimeRange = { Start = "2018-NOV-23 22:19:34.184", End = "2018-NOV-23 23:19:26.183" }
            },
            {
              Name = "OLA Phase 3",
              TimeRange = { Start = "2018-NOV-24 00:48:38.184", End = "2018-NOV-24 01:38:06.184" }
            },
            {
              Name = "OLA Phase 4",
              TimeRange = { Start = "2018-NOV-27 22:29:58.184", End = "2018-NOV-27 23:19:26.183" }
            },
            {
              Name = "PolyCam Phase 1",
              TimeRange = { Start = "2018-NOV-19 12:00:33.183", End = "2018-NOV-19 16:46:25.183" }
            },
            {
              Name = "PolyCam Phase 2",
              TimeRange = { Start = "2018-NOV-20 07:10:26.183", End = "2018-NOV-20 12:10:18.183" }
            },
            {
              Name = "PolyCam Phase 3",
              TimeRange = { Start = "2018-NOV-23 11:51:29.184", End = "2018-NOV-23 16:51:21.184" }
            },
            {
              Name = "PolyCam Phase 4",
              TimeRange = { Start = "2018-NOV-24 07:17:39.184", End = "2018-NOV-24 12:03:31.184" }
            },
            {
              Name = "PolyCam Phase 5",
              TimeRange = { Start = "2018-NOV-27 12:00:20.184", End = "2018-NOV-27 16:46:12.184" }
            },
            {
              Name = "PolyCam Phase 6",
              TimeRange = { Start = "2018-NOV-28 07:10:35.183", End = "2018-NOV-28 12:10:27.183" }
            }
          }
        },
        {
          Name = "Detailed Survey",
          Phases = {
            {
              Name = "Baseball Diamond Phase 1",
              TimeRange = { Start = "2019-JAN-13 18:59:31.195", End = "2019-JAN-13 23:59:29.179" }
            },
            {
              Name = "Baseball Diamond Phase 2",
              TimeRange = { Start = "2019-JAN-14 16:56:01.185", End = "2019-JAN-14 21:55:58.219" }
            },
            {
              Name = "Baseball Diamond Phase 3",
              TimeRange = { Start = "2019-JAN-20 18:59:15.211", End = "2019-JAN-20 23:59:13.195" }
            },
            {
              Name = "Baseball Diamond Phase 4",
              TimeRange = { Start = "2019-JAN-21 19:26:47.179", End = "2019-JAN-22 00:26:44.213" }
            },
            {
              Name = "EquatorialStations Phase 1",
              TimeRange = { Start = "2019-JAN-27 10:36:24.185", End = "2019-JAN-27 15:20:28.185" }
            },
            {
              Name = "EquatorialStations Phase 2",
              TimeRange = { Start = "2019-FEB-03 10:35:30.185", End = "2019-FEB-03 15:21:22.185" }
            },
            {
              Name = "EquatorialStations Phase 3",
              TimeRange = { Start = "2019-FEB-10 10:51:50.185", End = "2019-FEB-10 15:51:42.185" }
            },
            {
              Name = "EquatorialStations Phase 4",
              TimeRange = { Start = "2019-FEB-17 10:29:11.186", End = "2019-FEB-17 15:29:03.186" }
            },
            {
              Name = "EquatorialStations Phase 5",
              TimeRange = { Start = "2019-FEB-24 10:08:28.186", End = "2019-FEB-24 15:08:20.185" }
            },
            {
              Name = "EquatorialStations Phase 6",
              TimeRange = { Start = "2019-MAR-03 09:52:58.186", End = "2019-MAR-03 14:42:26.186" }
            },
            {
              Name = "EquatorialStations Phase 7",
              TimeRange = { Start = "2019-MAR-10 09:57:47.186", End = "2019-MAR-10 14:36:33.186" }
            },
            {
              Name = "Plume Search Phase 1",
              TimeRange = { Start = "2019-JAN-28 10:34:36.185", End = "2019-JAN-28 15:22:16.185" }
            },
            {
              Name = "Plume Search Phase 2",
              TimeRange = { Start = "2019-FEB-18 10:29:11.186", End = "2019-FEB-18 15:29:03.186" }
            }
          }
        },
        {
          Name = "Orbital B",
          Description = "At the end of Detailed Survey, the spacecraft entered a close orbit - with a radius of 0.6 miles (1 km) - around Bennu to begin Orbital B Phase. This phase broke the record OSIRIS-REx set in Orbital A for the closest that a spacecraft has ever orbited around a small body. The primary science activities for this phase were the global mapping of Bennu, the development of shape modeling based on OLA data, and the execution of a Radio Science experiment. These data were used to evaluate potential sample collection sites for three key elements: safety, sampleability and science value.  Orbital B concluded with the team narrowing in on a primary and a back-up sample site.",
          Image = "https://www.asteroidmission.org/wp-content/uploads/2018/05/Orbital-B-for-Web.jpg",
          Phases = {
            {
              Name = "Candidate Sample Site Phase 1",
              TimeRange = { Start = "2019-APR-08 10:35:27.186", End = "2019-APR-08 15:22:06.186" }
            },
            {
              Name = "Candidate Sample Site Phase 2",
              TimeRange = { Start = "2019-APR-08 16:16:06.186", End = "2019-APR-11 10:38:58.186" }
            },
            {
              Name = "Candidate Sample Site Phase 3",
              TimeRange = { Start = "2019-APR-22 17:51:23.186", End = "2019-APR-29 19:41:03.186" }
            }
          }
        },
        {
          Name = "Recon",
          Phases = {
            {
              Name = "225m Sortie",
              Phases = {
                {
                  Name = "0° Latitude",
                  TimeRange = { Start = "2019-MAY-25 03:50:31.195", End = "2019-MAY-25 04:32:17.227" }
                },
                {
                  Name = "-20° Latitude",
                  TimeRange = { Start = "2019-MAY-25 03:50:48.216", End = "2019-MAY-25 04:37:10.209" }
                },
                {
                  Name = "-40° Latitude",
                  TimeRange = { Start = "2019-MAY-25 04:02:43.176", End = "2019-MAY-25 04:54:41.179" }
                },
                {
                  Name = "-60° Latitude",
                  TimeRange = { Start = "2019-MAY-25 04:21:46.161", End = "2019-MAY-25 05:18:44.232" }
                }
              }
            },
            {
              Name = "525m Sortie",
              Phases = {
                {
                  Name = "0° Latitude",
                  TimeRange = { Start = "2019-MAY-25 04:06:39.220", End = "2019-MAY-25 04:44:17.198" }
                },
                {
                  Name = "-40° Latitude",
                  TimeRange = { Start = "2019-MAY-25 04:11:39.201", End = "2019-MAY-25 04:49:37.224" }
                },
                {
                  Name = "Case 5 Nominal Profile",
                  TimeRange = { Start = "2019-MAY-25 03:01:50.184", End = "2019-MAY-25 06:38:50.232" }
                },
                {
                  Name = "Case 8 Nominal Profile",
                  TimeRange = { Start = "2019-MAY-25 03:01:50.184", End = "2019-MAY-25 06:38:50.232" }
                }
              }
            }
          }
        }
      }
  -- End of [3]
    },
    {
      Name = "Backup Time",
      TimeRange = { Start = "2020 JAN 01 00:00:00", End = "2021 JAN 01 00:00:00" }
    },
    {
      Name = "Return Cruise",
      TimeRange = { Start = "2021 JAN 01 00:00:00", End = "2023 SEP 20 00:00:00"}
    }
  -- Not too interesting in terms of space visualization --> out commented
  -- { Name = "Sample Analysis",             TimeRange = { Start = "2023 JAN 01 00:00:00", End = "2025 JUN 01 00:00:00" } },

  -- End of [1]
  }
}


asset.onInitialize(function()
  openspace.loadMission(Mission)
end)

asset.onDeinitialize(function()
  openspace.unloadMission(Mission.Name)
end)
