test_ifs_fits.py 1.75 KB
Newer Older
Wei Shoulin's avatar
Wei Shoulin committed
1
import os
Wei Shoulin's avatar
Wei Shoulin committed
2
import unittest
Wei Shoulin's avatar
Wei Shoulin committed
3
from astropy.io import fits
Wei Shoulin's avatar
Wei Shoulin committed
4
5

from csst_dfs_api.ifs import FitsApi
Wei Shoulin's avatar
Wei Shoulin committed
6
from csst_dfs_api.common.delegate import Delegate
Wei Shoulin's avatar
Wei Shoulin committed
7
8
9
10
11
12
class IFSFitsTestCase(unittest.TestCase):

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

    def test_find(self):
Wei Shoulin's avatar
ephem    
Wei Shoulin committed
13
14
15
        # recs = self.api.find(file_name='CCD1_ObsTime_300_ObsNum_7.fits')
        # print('find:', recs)
        # assert len(recs) == 1
Wei Shoulin's avatar
Wei Shoulin committed
16

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
17
        recs = self.api.find(limit=1)
Wei Shoulin's avatar
Wei Shoulin committed
18
        print('find:', recs)
Wei Shoulin's avatar
ephem    
Wei Shoulin committed
19
        # assert len(recs) > 1
Wei Shoulin's avatar
Wei Shoulin committed
20

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
21
22
23
    # def test_read(self):
    #     recs = self.api.find(file_name='CCD1_ObsTime_300_ObsNum_7.fits')
    #     print("The full path: ", os.path.join(self.api.file_prefix, recs[0]['file_path']))
Wei Shoulin's avatar
Wei Shoulin committed
24

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
25
26
27
28
29
30
    #     file_segments = self.api.read(file_path=recs[0]['file_path'])
    #     file_bytes = b''.join(file_segments)
    #     hdul = fits.HDUList.fromstring(file_bytes)
    #     print(hdul.info())
    #     hdr = hdul[0].header
    #     print(repr(hdr))
Wei Shoulin's avatar
Wei Shoulin committed
31

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
32
33
    # def test_update_proc_status(self):
    #     recs = self.api.find(file_name='CCD1_ObsTime_300_ObsNum_7.fits')
Wei Shoulin's avatar
Wei Shoulin committed
34

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
35
    #     self.api.update_proc_status(fits_id=recs[0]['id'],status=1)
Wei Shoulin's avatar
Wei Shoulin committed
36

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
37
38
    #     rec = self.api.get(fits_id=recs[0]['id'])
    #     assert rec['prc_status'] == 1
Wei Shoulin's avatar
Wei Shoulin committed
39

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
40
41
    # def test_update_qc0_status(self):
    #     recs = self.api.find(file_name='CCD1_ObsTime_300_ObsNum_7.fits')
Wei Shoulin's avatar
Wei Shoulin committed
42

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
43
    #     self.api.update_qc0_status(fits_id=recs[0]['id'],status=1)
Wei Shoulin's avatar
Wei Shoulin committed
44

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
45
46
    #     rec = self.api.get(fits_id=recs[0]['id'])
    #     assert rec['qc0_status'] == 1
Wei Shoulin's avatar
Wei Shoulin committed
47

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
48
49
    # def test_write(self):
    #     recs = self.api.write(file_path='/opt/temp/csst_ifs/CCD2_ObsTime_1200_ObsNum_40.fits')
Wei Shoulin's avatar
Wei Shoulin committed
50

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
51
    #     recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits')
Wei Shoulin's avatar
Wei Shoulin committed
52

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
53
    #     rec = self.api.get(fits_id=recs[0]['id'])
Wei Shoulin's avatar
Wei Shoulin committed
54

Wei Shoulin's avatar
ephem    
Wei Shoulin committed
55
    #     print(rec)
Wei Shoulin's avatar
Wei Shoulin committed
56