def test_read_neocp_comet_orbit1(self):

        # Hand-crafted element dictionary from MPC MPES output on 2014-09-26.
        # This test tests long-period comet parsing
        expected = {
                     'name'           : 'CK13A010',
                     'epoch'          : 57000.0,
                     'long_node'      : Angle(degrees=300.9764),
                     'eccentricity'   : 1.000434,
                     'semi_axis'      : None,
                     'mean_anomaly'   : None,
                     'arg_perihelion' : Angle(degrees=2.4226),
                     'inclination'    :  Angle(degrees=129.0428),
                     'MDM'            :  None,
                     'H'              : 8.2,
                     'G'              : 2.4,
                     'n_obs'          : None,
                     'n_nights'       : None,
                     'type'           : 'MPC_COMET'
                   }

        recieved = read_neocp_orbit('test/Comet_SidingSpring.neocp')

        for e in list(expected.keys()):
            assert_equal(expected[e], recieved[e])
    def test_read_neocp_comet_orbit2(self):

        # Hand-crafted element dictionary from MPC MPES output on 2014-09-26.
        # This test tests periodic comet parsing
        expected = {
                     'name'           : '0299P',
                     'epoch'          : 57000.0,
                     'long_node'      : Angle(degrees=271.6800),
                     'eccentricity'   : 0.282122,
                     'semi_axis'      : None,
                     'mean_anomaly'   : None,
                     'arg_perihelion' : Angle(degrees=323.5091),
                     'inclination'    : Angle(degrees=10.4798),
                     'MDM'            : None,
                     'H'              : 11.5,
                     'G'              : 4.00,
                     'n_obs'          : None,
                     'n_nights'       : None,
                     'type'           : 'MPC_COMET'
                   }

        recieved = read_neocp_orbit('test/Comet_299P.neocp')

        for e in list(expected.keys()):
            assert_equal(expected[e], recieved[e])
    def test_read_neocp_orbit5(self):

        # Element dictionary produced by TAL's code from NEOCP orbit file, migrated to
        # rise_set format.
        # This test tests very short orbits from find_orb with an arc length in
        # hours
        expected = {
                     'name'           : 'LSCTLF3',
                     'epoch'          : 57109.0,
                     'mean_anomaly'   : Angle(degrees= 21.73763),
                     'arg_perihelion' : Angle(degrees= 80.02788),
                     'long_node'      : Angle(degrees= 64.35739),
                     'inclination'    : Angle(degrees= 12.17788),
                     'eccentricity'   : 0.3895454,
                     'MDM'            : Angle(degrees=0.21752314),
                     'semi_axis'      : 2.7382037,
                     'H'              : 18.23,
                     'G'              : 0.15,
                     'n_obs'          : 10,
                     'n_oppos'        : 1,
                     'n_nights'       : old_div(13.0,24.0),    # 13.0 hrs->days
                     'reference'      : 'FO 150328',
                     'residual'       : 0.09,
                     'uncertainty'    : 'U',
                   }

        recieved = read_neocp_orbit('test/LSCTLF3_V2.neocp')

        for e in list(expected.keys()):
            assert_equal(expected[e], recieved[e])
    def test_read_neocp_orbit7(self):

        # Element dictionary produced by TAL's code from NEOCP orbit file, migrated to
        # rise_set format.
        # This test tests NEOCP orbits without an uncertainty.
        expected = {
                     'name'           : 'N007rdx',
                     'epoch'          : 57120.0,
                     'mean_anomaly'   : Angle(degrees=119.11683),
                     'arg_perihelion' : Angle(degrees= 75.91136),
                     'long_node'      : Angle(degrees=351.90874),
                     'inclination'    : Angle(degrees=  3.64505),
                     'eccentricity'   : 0.1054741,
                     'MDM'            : Angle(degrees=1.07358714),
                     'semi_axis'      : 0.9445925,
                     'H'              : 21.8,
                     'G'              : 0.15,
                     'n_obs'          : 5,
                     'n_oppos'        : 1,
                     'n_nights'       : 0,
                     'uncertainty'    : 'U',   # No value, assume default
                     'reference'      : '',
                   }

        recieved = read_neocp_orbit('test/N007rdx.neocp')

        for e in list(expected.keys()):
            assert_equal(expected[e], recieved[e])
    def test_read_neocp_orbit4(self):

        # Element dictionary produced by TAL's code from NEOCP orbit file, migrated to
        # rise_set format.
        # This test tests very short orbits from find_orb with an arc length in
        # minutes
        expected = {
                     'name'           : 'LSCTLF3',
                     'epoch'          : 57109.0,
                     'semi_axis'      : 2.2601939,
                     'mean_anomaly'   : Angle(degrees= 23.58746),
                     'arg_perihelion' : Angle(degrees= 75.79622),
                     'long_node'      : Angle(degrees= 69.92181),
                     'inclination'    : Angle(degrees=  9.43941),
                     'eccentricity'   : 0.3369232,
                     'MDM'            : Angle(degrees=0.29005846),
                     'H'              : 18.90,
                     'G'              : 0.15,
                     'n_obs'          : 6,
                     'n_oppos'        : 1,
                     'n_nights'       : old_div(18.8,1440.0),    # 18.8 mins->days
                     'reference'      : 'FO 150328',
                     'residual'       : 0.08,
                     'uncertainty'    : 'U',
                   }

        recieved = read_neocp_orbit('test/LSCTLF3.neocp')

        for e in list(expected.keys()):
            assert_equal(expected[e], recieved[e])
    def test_read_neocp_orbit3(self):

        # Element dictionary produced by TAL's code from NEOCP orbit file, migrated to
        # rise_set format.
        # This test tests multi-opposition orbits
        expected = {
                     'name'           : '00001',
                     'epoch'          : 57200.0,
                     'long_node'      : Angle(degrees=80.3272),
                     'eccentricity'   : 0.0757825,
                     'semi_axis'      : 2.7679724,
                     'mean_anomaly'   : Angle(degrees=138.66222),
                     'arg_perihelion' : Angle(degrees= 72.65410),
                     'inclination'    : Angle(degrees= 10.59230),
                     'MDM'            : Angle(degrees=0.21402349),
                     'H'              :  3.34,
                     'G'              : 0.12,
                     'n_obs'          : 6541,
                     'n_oppos'        : 107,
                     'n_nights'       : '1802-2014',
                     'reference'      : 'MPO328644',
                     'uncertainty'    : '0',
                   }

        recieved = read_neocp_orbit('test/00001_Ceres.neocp')

        for e in list(expected.keys()):
            assert_equal(expected[e], recieved[e])
    def test_read_neocp_orbit2(self):

        # Element dictionary produced by TAL's code from NEOCP orbit file, migrated to
        # rise_set format.
        expected = {
                     'name'           : 'K13TB7L',
                     'epoch'          : 56600.0,
                     'long_node'      : Angle(degrees=3.36296),
                     'eccentricity'   : 0.6898696,
                     'semi_axis'      : 3.6038493,
                     'mean_anomaly'   : Angle(degrees=344.69702),
                     'arg_perihelion' : Angle(degrees=112.20127),
                     'inclination'    : Angle(degrees=9.36592),
                     'MDM'            : Angle(degrees=0.14406356),
                     'H'              : 17.7,
                     'G'              : 0.15,
                     'n_obs'          : 146,
                     'n_oppos'        : 1,
                     'n_nights'       : 67,
                     'reference'      : 'E2013-X58',
                     'uncertainty'    : '3',
                   }

        recieved = read_neocp_orbit('test/2013TL117.neocp')

        for e in list(expected.keys()):
            assert_equal(expected[e], recieved[e])
    def test_read_neocp_orbit1(self):

        # Element dictionary produced by TAL's code from NEOCP orbit file, migrated to
        # rise_set format.
        expected = {
                     'name': 'P109rXK',
                     'epoch': 56620.0,
                     'long_node':  Angle(degrees=224.42273),
                     'eccentricity': 0.5131088,
                     'semi_axis': 2.0773493,
                     'mean_anomaly':  Angle(degrees=322.22271),
                     'arg_perihelion': Angle(degrees=307.96804),
                     'inclination':  Angle(degrees=13.72592),
                     'MDM':  Angle(degrees=0.3291848),
                     'H': 17.5,
                     'G': 0.15,
                     'n_obs': 4,
                     'n_oppos' : 1,
                     'n_nights': 0,
                   }

        recieved = read_neocp_orbit('test/P109rXK.neocp')

        for e in list(expected.keys()):
            assert_equal(expected[e], recieved[e])
    def test_special_neo_target(self):
        window = {
                   'start'    : str_to_dt('2014-07-17 23:00:00'),
                   'end'      : str_to_dt('2014-07-18 11:00:00'),
                 }

        elements = read_neocp_orbit('test/special_neo_target.neocp')

        for x, y in list(elements.items()):
            print(x, y)

        site_filename = 'test/telescopes.dat'
        chunksize = timedelta(minutes=10)

        received = find_moving_object_network_up_intervals(window, elements,
                                                           site_filename, chunksize)

        expected = {
                     '1m0a.doma.elp' : [
                                         (
                                           datetime(2014, 7, 18, 3, 50),
                                           datetime(2014, 7, 18, 9, 10)
                                         )
                                       ],
                     '1m0a.doma.coj' : [
                                         (
                                           datetime(2014, 7, 18, 8, 50),
                                           datetime(2014, 7, 18, 11, 0)
                                         )
                                       ],
                     '1m0a.doma.cpt' : [
                                         (
                                           datetime(2014, 7, 17, 23, 0),
                                           datetime(2014, 7, 18, 3, 10)
                                         )
                                       ],
                     '1m0a.doma.lsc' : [
                                         (
                                           datetime(2014, 7, 17, 23, 30),
                                           datetime(2014, 7, 18, 9, 20)
                                         )
                                       ],
                   }


        for site in list(expected.keys()):
            print(site)
            assert_equal(expected[site], received[site])