test_facility_level1.py 2.23 KB
Newer Older
Wei Shoulin's avatar
c3  
Wei Shoulin committed
1
2
3
4
import os
import unittest
from astropy.io import fits

Wei Shoulin's avatar
Wei Shoulin committed
5
from csst_dfs_api.facility.level1 import Level1DataApi
Wei Shoulin's avatar
c3  
Wei Shoulin committed
6

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

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

Wei Shoulin's avatar
Wei Shoulin committed
12
13
14
15
16
17
    # def test_find(self):
    #     recs = self.api.find(
    #         level0_id='10000010101',
    #         module_id = "MSC",
    #         create_time = ("2024-01-01 11:12:13","2024-06-08 11:12:13"))
    #     print('find:', recs)
Wei Shoulin's avatar
c3  
Wei Shoulin committed
18

Wei Shoulin's avatar
Wei Shoulin committed
19
20
21
22
23
24
25
26
27
    # def test_find_by_ids(self):
    #     recs = self.api.find_by_ids(
    #         module_id = "MSC",
    #         ids=[16]
    #     )
    #     print('find_by_ids:', recs)

    def test_find_refs_by_ids(self):
        recs = self.api.find_refs_by_ids(
Wei Shoulin's avatar
C9    
Wei Shoulin committed
28
            ids=[16]
Wei Shoulin's avatar
Wei Shoulin committed
29
        )
Wei Shoulin's avatar
Wei Shoulin committed
30
        print('test_find_refs_by_ids:', recs)
Wei Shoulin's avatar
Wei Shoulin committed
31

Wei Shoulin's avatar
C9    
Wei Shoulin committed
32
33
34
35
36
37
38
39
40
41
42
43
44
    def test_find_by_brick_ids(self):
        recs = self.api.find_by_brick_ids(
            brick_ids=[1,2,3,4]
        )
        print('find_by_brick_ids:', recs)

    def test_sls_find_by_qc1_status(self):
        recs = self.api.sls_find_by_qc1_status(
            qc1_status = 1,
            limit = 1
        )
        print('sls_find_by_qc1_status:', recs)

Wei Shoulin's avatar
c3  
Wei Shoulin committed
45
    def test_get(self):
Wei Shoulin's avatar
Wei Shoulin committed
46
        rec = self.api.get(id = 16)
Wei Shoulin's avatar
c3  
Wei Shoulin committed
47
48
49
50
51
52
53
54
55
56
57
        print('get:', rec)

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

    def test_update_qc1_status(self):
        rec = self.api.update_qc1_status(id = 2, status = 7)
        print('update_qc1_status:', rec)

    def test_write(self):
Wei Shoulin's avatar
Wei Shoulin committed
58
        rec = self.api.write(
Wei Shoulin's avatar
Wei Shoulin committed
59
            level0_id = '10000010101', 
Wei Shoulin's avatar
Wei Shoulin committed
60
            module_id = "MSC",
Wei Shoulin's avatar
C9    
Wei Shoulin committed
61
            file_type = "SCIE",
Wei Shoulin's avatar
c3  
Wei Shoulin committed
62
            prc_status = 3,
Wei Shoulin's avatar
Wei Shoulin committed
63
            prc_time = '2021-10-22 11:12:13',
Wei Shoulin's avatar
Wei Shoulin committed
64
65
            filename = "CSST_MSC_MS_SCI_20270810142128_20270810142358_100000101_20_img_L1.fits",
            file_path = "/opt/temp/csst/CSST_MSC_MS_SCI_20270810142128_20270810142358_100000101_20_img_L1.fits",
Wei Shoulin's avatar
Wei Shoulin committed
66
            pipeline_id = "P1",
Wei Shoulin's avatar
C9    
Wei Shoulin committed
67
            build_id = 123,
Wei Shoulin's avatar
l1 refs    
Wei Shoulin committed
68
69
70
            refs = [{'file_type':'dark', 'id': 'csst_msc_dark_001.rmap'},
                {'file_type':'bias', 'id': 'csst_msc_bias_001.rmap'}, 
                {'file_type':'flat', 'id': 'csst_msc_flat_001.rmap'}]
Wei Shoulin's avatar
C9    
Wei Shoulin committed
71
        )
Wei Shoulin's avatar
c3  
Wei Shoulin committed
72
        print('write:', rec)