test_astrometry.py 1.76 KB
Newer Older
Fang Yuedong's avatar
Fang Yuedong committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import unittest
import os
import sys
from astropy.time import Time
from datetime import datetime

from ObservationSim.Astrometry.Astrometry_util import on_orbit_obs_position


class TestAstrometry(unittest.TestCase):
    def __init__(self, methodName='runTest'):
        super(TestAstrometry, self).__init__(methodName)
        # self.dataPath = os.path.join(
        #     os.getenv('UNIT_TEST_DATA_ROOT'), 'csst_msc_sim/csst_fz_msc')

    def test_astrometry_method(self):
        ra_list = [300.061827]
        dec_list = [-60.132741]
        pmra_list = [0.]
        pmdec_list = [0.]
        rv_list = [0.]
        parallax_list = [1e-9]
        sat_x = 5227.7501
        sat_y = -1521.2218
        sat_z = -4007.7662
        sat_vx = 0.13581745522969868
        sat_vy = 7.233066646238058
        sat_vz = -2.5770060087052116
Fang Yuedong's avatar
Fang Yuedong committed
29
30
        dt = datetime.utcfromtimestamp(
            Time(2461865.75468577, format='jd').unix)
Fang Yuedong's avatar
Fang Yuedong committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
        date_str = dt.date().isoformat()
        time_str = dt.time().isoformat()
        ra_arr, dec_arr = on_orbit_obs_position(
            input_ra_list=ra_list,
            input_dec_list=dec_list,
            input_pmra_list=pmra_list,
            input_pmdec_list=pmdec_list,
            input_rv_list=rv_list,
            input_parallax_list=parallax_list,
            input_nstars=len(ra_list),
            input_x=sat_x,
            input_y=sat_y,
            input_z=sat_z,
            input_vx=sat_vx,
            input_vy=sat_vy,
            input_vz=sat_vz,
            input_epoch="J2000",
            input_date_str=date_str,
            input_time_str=time_str
        )
        print(ra_arr[0], dec_arr[0])
        self.assertTrue(ra_arr[0] != ra_list[0])
        self.assertTrue(dec_arr[0] != dec_list[0])


if __name__ == '__main_':
    unittest.main()