test_mbi_level2.py 1.73 KB
Newer Older
Wei Shoulin's avatar
level2  
Wei Shoulin committed
1
2
3
import os
import unittest
from astropy.io import fits
Wei Shoulin's avatar
Wei Shoulin committed
4
from csst_dfs_api.common.utils import to_table as to_fits_table
Wei Shoulin's avatar
Wei Shoulin committed
5
from csst_dfs_api.mbi.level2 import Level2DataApi
Wei Shoulin's avatar
level2  
Wei Shoulin committed
6

Wei Shoulin's avatar
Wei Shoulin committed
7
class MBILevel2DataTestCase(unittest.TestCase):
Wei Shoulin's avatar
level2  
Wei Shoulin committed
8
9
10
11

    def setUp(self):
        self.api = Level2DataApi()

Wei Shoulin's avatar
Wei Shoulin committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    def test_find(self):
        recs = self.api.find(
            level1_id=1,
            create_time = ("2022-06-15 11:12:13","2022-06-16 11:12:13"))
        print('find:', recs)

    def test_catalog_query(self):
        result = self.api.catalog_query(
            obs_id = '100000133',
            detector_no = '13',
            ra = 192,
            dec = 26,
            radius = 1,
            limit = 2)
        print(result)
        if result.success and result['totalCount'] > 0:
            dt = to_fits_table(result)
            dt.pprint()
Wei Shoulin's avatar
Wei Shoulin committed
30
31
32
33
34
35
36
37

    def test_catalog_query_file(self):
        result = self.api.catalog_query_file(
            ra = 192,
            dec = 26,
            radius = 1)
        print(result)

Wei Shoulin's avatar
Wei Shoulin committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
    def test_get(self):
        rec = self.api.get(id = 1)
        print('get:', rec)

    def test_update_proc_status(self):
        rec = self.api.update_proc_status(id = 1, status = 4)
        print('update_proc_status:', rec)

    def test_update_qc2_status(self):
        rec = self.api.update_qc2_status(id = 1, status = 7)
        print('update_qc2_status:', rec)

    def test_write(self):
        rec = self.api.write(
            level1_id= 1, 
            data_type = "sci",
            prc_status = 3,
            prc_time = '2021-10-22 11:12:13',
            filename = "MSC_MS_210525120000_100000000_20_cat.fits",
            file_path = "/opt/temp/csst/msc_data/MSC_MS_210525120000_100000000_20_cat.fits"
            )
        print('write:', rec)