File indexing completed on 2024-04-14 03:48:49

0001 #!/usr/bin/python2
0002 # SPDX-License-Identifier: LGPL-2.1-or-later
0003 #
0004 # SPDX-FileCopyrightText: 2012-2014 Rene Kuettner <rene@bitkanal.net>
0005 #
0006 
0007 # Create a Marble Satellite Catalog file with data from various sources.
0008 # See also: https://techbase.kde.org/Projects/Marble/SatelliteCatalogFormat
0009 
0010 from __future__ import print_function
0011 
0012 from lib.SpaceObjectCatalog import (SpaceObject, HorizonsSpaceObject,
0013                                    TASCSpaceObject, SpaceObjectCatalog)
0014 from lib.DataDownloader import DataDownloader
0015 
0016 ####[ Configuration ]#########################################################
0017 
0018 object_catalog_file     = "PlanetarySatellites.xml"
0019 data_file_base_url      = "http://files.kde.org/marble/satellites"
0020 
0021 # define all interesting objects
0022 # FIXME: document possible values
0023 OBJECTS = [
0024     # Mars Express
0025     HorizonsSpaceObject(
0026         name            = 'Mars Express',
0027         horizons_id     = -41,
0028         category        = SpaceObject.CATEGORY_SPACEPROBES,
0029         related_body    = SpaceObject.BODY_MARS,
0030         mission_start   = '2003-12-23 00:00',
0031         ),
0032     # Mars Odyssey
0033     #HorizonsSpaceObject(
0034     #    name            = 'Mars Odyssey',
0035     #    horizons_id     = -53,
0036     #    category        = SpaceObject.CATEGORY_SPACEPROBES,
0037     #    related_body    = SpaceObject.BODY_MARS,
0038     #    mission_start   = '2001-11-02 00:00',
0039     #    ),
0040     # Mars Reconnaisance
0041     #HorizonsSpaceObject(
0042     #    name            = 'Mars Reconnaisance',
0043     #    horizons_id     = -74,
0044     #    category        = SpaceObject.CATEGORY_SPACEPROBES,
0045     #    related_body    = SpaceObject.BODY_MARS,
0046     #    mission_start   = '2005-08-12 11:43',
0047     #    ),
0048     # Maven
0049     HorizonsSpaceObject(
0050         name            = 'Maven',
0051         horizons_id     = -202,
0052         category        = SpaceObject.CATEGORY_SPACEPROBES,
0053         related_body    = SpaceObject.BODY_MARS,
0054         mission_start   = '2013-11-18 18:28',
0055         data_from       = '2014-09-22 04:00'
0056         ),
0057     # Mangalyaan
0058     HorizonsSpaceObject(
0059         name            = 'Mangalyaan',
0060         horizons_id     = -3,
0061         category        = SpaceObject.CATEGORY_SPACEPROBES,
0062         related_body    = SpaceObject.BODY_MARS,
0063         mission_start   = '2013-11-05 09:08',
0064         data_from       = '2014-09-24 09:00'
0065         ),
0066     # Venus Express
0067     HorizonsSpaceObject(
0068         name            = 'Venus Express',
0069         horizons_id     = -248,
0070         category        = SpaceObject.CATEGORY_SPACEPROBES,
0071         related_body    = SpaceObject.BODY_VENUS,
0072         mission_start   = '2006-04-11 00:00',
0073         ),
0074     # Phobos
0075     HorizonsSpaceObject(
0076         name            = 'Phobos',
0077         horizons_id     = 401,
0078         category        = SpaceObject.CATEGORY_MOONS,
0079         related_body    = SpaceObject.BODY_MARS,
0080         ),
0081     # Deimos
0082     HorizonsSpaceObject(
0083         name            = 'Deimos',
0084         horizons_id     = 402,
0085         category        = SpaceObject.CATEGORY_MOONS,
0086         related_body    = SpaceObject.BODY_MARS,
0087         ),
0088     # Smart-1
0089     TASCSpaceObject(
0090         name            = "Smart-1",
0091         tasc_mission    = "SM1",
0092         category        = SpaceObject.CATEGORY_SPACEPROBES,
0093         related_body    = SpaceObject.BODY_MOON,
0094         mission_start   = '2003-09-28 00:00',
0095         mission_end     = '2006-09-03 00:00',
0096         data_for_day    = '2005-02-28 00:00',
0097         ),
0098 ]
0099 
0100 ##############################################################################
0101 
0102 class OrbitDataFetcher(object):
0103 
0104     def __init__(self, object_catalog):
0105         super(OrbitDataFetcher, self).__init__()
0106         self._object_catalog = object_catalog
0107         self._downloader = DataDownloader()
0108 
0109     def fetch(self, objects):
0110         vecs = []
0111         for obj in list(objects):
0112             vecs = self._downloader.download_state_vectors(obj)
0113             if len(vecs) < 1:
0114                 print("No data found! Skipping.")
0115                 continue
0116             self._object_catalog.add(obj, vecs[-1])
0117 
0118 # let's start fetching...
0119 object_catalog = SpaceObjectCatalog(object_catalog_file, data_file_base_url)
0120 orbit_data_fetcher = OrbitDataFetcher(object_catalog)
0121 orbit_data_fetcher.fetch(OBJECTS)
0122 object_catalog.write()