level0.py 2.88 KB
Newer Older
Wei Shoulin's avatar
c3  
Wei Shoulin committed
1
2
3
4
5
6
7
8

from ..common.delegate import Delegate

class Level0DataApi(object):
    """
    Level 0 Data Operation API
    """
    def __init__(self):
Wei Shoulin's avatar
Wei Shoulin committed
9
        self.pymodule = Delegate().load(sub_module = "facility")
Wei Shoulin's avatar
c3  
Wei Shoulin committed
10
11
12
13
14
        self.stub = getattr(self.pymodule, "Level0DataApi")()
        
    def find(self, **kwargs):
        ''' retrieve level0 records from database

Wei Shoulin's avatar
docs    
Wei Shoulin committed
15
        :param kwargs: Parameter dictionary, key items support:
Wei Shoulin's avatar
Wei Shoulin committed
16
            obs_id: [str]
Wei Shoulin's avatar
c3  
Wei Shoulin committed
17
18
19
20
21
            detector_no: [str]
            obs_type: [str]
            obs_time : (start, end),
            qc0_status : [int],
            prc_status : [int],
Wei Shoulin's avatar
Wei Shoulin committed
22
23
24
25
            file_name: [str],
            ra_obj: [float],
            dec_obj: [float],
            radius: [float],
Wei Shoulin's avatar
Wei Shoulin committed
26
27
            object_name: [str],
            version: [str],
Wei Shoulin's avatar
c3  
Wei Shoulin committed
28
            limit: limits returns the number of records,default 0:no-limit
Wei Shoulin's avatar
docs    
Wei Shoulin committed
29
30
        
        :returns: csst_dfs_common.models.Result
Wei Shoulin's avatar
c3  
Wei Shoulin committed
31
32
33
        '''
        return self.stub.find(**kwargs)

Wei Shoulin's avatar
hstdm    
Wei Shoulin committed
34
35
36
37
38
39
40
41
42
    def find_by_brick_ids(self, **kwargs):
        ''' retrieve level0 records by brick_ids like [1,2,3,4]

        :param kwargs: Parameter dictionary, key items support:
            brick_ids: [list]
        :returns: csst_dfs_common.models.Result
        '''
        return self.stub.find_by_brick_ids(**kwargs)
        
Wei Shoulin's avatar
c3  
Wei Shoulin committed
43
44
45
    def get(self, **kwargs):
        '''  fetch a record from database

Wei Shoulin's avatar
docs    
Wei Shoulin committed
46
        :param kwargs: Parameter dictionary, key items support:
Wei Shoulin's avatar
Wei Shoulin committed
47
48
            id : [int],
            level0_id: [str]
Wei Shoulin's avatar
Wei Shoulin committed
49
            obs_type: [str]
Wei Shoulin's avatar
docs    
Wei Shoulin committed
50
51
        
        :returns: csst_dfs_common.models.Result
Wei Shoulin's avatar
c3  
Wei Shoulin committed
52
53
54
55
56
57
        '''
        return self.stub.get(**kwargs)

    def update_proc_status(self, **kwargs):
        ''' update the status of reduction

Wei Shoulin's avatar
docs    
Wei Shoulin committed
58
        :param kwargs: Parameter dictionary, key items support:
Wei Shoulin's avatar
Wei Shoulin committed
59
60
            id : [int],
            level0_id: [str],
Wei Shoulin's avatar
Wei Shoulin committed
61
            obs_type: [str],
Wei Shoulin's avatar
c3  
Wei Shoulin committed
62
            status : [int]
Wei Shoulin's avatar
docs    
Wei Shoulin committed
63
64
        
        :returns: csst_dfs_common.models.Result            
Wei Shoulin's avatar
c3  
Wei Shoulin committed
65
66
67
68
69
70
        '''
        return self.stub.update_proc_status(**kwargs)

    def update_qc0_status(self, **kwargs):
        ''' update the status of QC0
        
Wei Shoulin's avatar
docs    
Wei Shoulin committed
71
        :param kwargs: Parameter dictionary, key items support:
Wei Shoulin's avatar
Wei Shoulin committed
72
73
            id : [int],
            level0_id: [str],
Wei Shoulin's avatar
Wei Shoulin committed
74
            obs_type: [str],
Wei Shoulin's avatar
c3  
Wei Shoulin committed
75
            status : [int]
Wei Shoulin's avatar
docs    
Wei Shoulin committed
76
77
        
        :returns: csst_dfs_common.models.Result            
Wei Shoulin's avatar
c3  
Wei Shoulin committed
78
79
80
81
82
83
        '''        
        return self.stub.update_qc0_status(**kwargs)    

    def write(self, **kwargs):
        ''' insert a level0 data record into database
 
Wei Shoulin's avatar
docs    
Wei Shoulin committed
84
        :param kwargs: Parameter dictionary, key items support:
Wei Shoulin's avatar
Wei Shoulin committed
85
86
87
88
89
90
91
            obs_id = [str],
            detector_no = [str],
            obs_type = [str],    
            obs_time = [str],
            exp_time = [int],
            detector_status_id = [int],
            filename = [str],
Wei Shoulin's avatar
c3  
Wei Shoulin committed
92
            file_path = [str]
Wei Shoulin's avatar
docs    
Wei Shoulin committed
93
94
        
        :returns: csst_dfs_common.models.Result
Wei Shoulin's avatar
c3  
Wei Shoulin committed
95
96
97
        '''  
        return self.stub.write(**kwargs)