Commit 7dd4c2b8 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

add find refs

parent 882f815a
...@@ -23,7 +23,7 @@ class Level1DataApi(object): ...@@ -23,7 +23,7 @@ class Level1DataApi(object):
filename: [str] filename: [str]
ra_cen: float = None ra_cen: float = None
dec_cen: float = None, dec_cen: float = None,
radius_cen: float = None radius: float = None
pipeline_id: [str] pipeline_id: [str]
build: [int] build: [int]
detector_no: [str] detector_no: [str]
...@@ -44,11 +44,21 @@ class Level1DataApi(object): ...@@ -44,11 +44,21 @@ class Level1DataApi(object):
''' '''
return self.stub.find_by_brick_ids(**kwargs) return self.stub.find_by_brick_ids(**kwargs)
def find_refs_by_ids(self, **kwargs):
''' retrieve level1 reference records by internal level1 ids like [1,2,3,4]
:param kwargs: Parameter dictionary, key items support:
ids: [list]
:returns: csst_dfs_common.models.Result
'''
return self.stub.find_refs_by_ids(**kwargs)
def find_by_ids(self, **kwargs): def find_by_ids(self, **kwargs):
''' retrieve level1 records by internal level1 ids like [1,2,3,4] ''' retrieve level1 records by internal level1 ids like [1,2,3,4]
:param kwargs: Parameter dictionary, key items support: :param kwargs: Parameter dictionary, key items support:
ids: [list] ids: [list],
module_id: [str] like 'MSC'
:returns: csst_dfs_common.models.Result :returns: csst_dfs_common.models.Result
''' '''
return self.stub.find_by_ids(**kwargs) return self.stub.find_by_ids(**kwargs)
...@@ -102,16 +112,16 @@ class Level1DataApi(object): ...@@ -102,16 +112,16 @@ class Level1DataApi(object):
:param kwargs: Parameter dictionary, key items support: :param kwargs: Parameter dictionary, key items support:
level0_id: [str] level0_id: [str]
detector_no: [str]
data_type : [str] data_type : [str]
cor_sci_id : [int]
prc_params : [str]
filename : [str] filename : [str]
file_path : [str] file_path : [str]
prc_status : [int] prc_status : [int]
prc_time : [str] prc_time : [str]
pipeline_id : [str] pipeline_id : [str]
pmapname : [str] pmapname : [str]
build : [str] build : [str],
refs : list[tuple] for example: [('dark', 'csst_msc_dark_001.rmap'), ('bias', 'csst_msc_bias_001.rmap'), ('flat', 'csst_msc_flat_001.rmap')]
:returns: csst_dfs_common.models.Result :returns: csst_dfs_common.models.Result
''' '''
......
...@@ -21,13 +21,15 @@ class Level1DataApi(object): ...@@ -21,13 +21,15 @@ class Level1DataApi(object):
qc1_status : [int] qc1_status : [int]
prc_status : [int] prc_status : [int]
filename: [str] filename: [str]
ra_cen: float = None ra_obj: float = None
dec_cen: float = None, dec_obj: float = None,
radius_cen: float = None radius: float = None
rss_id: [str]
cube_id: [str]
obj_id: [str]
pipeline_id: [str] pipeline_id: [str]
build: [int] build: [int]
detector_no: [str] detector_no: [str]
filter: [str]
object_name: [str] object_name: [str]
limit: limits returns the number of records,default 0:no-limit limit: limits returns the number of records,default 0:no-limit
...@@ -35,15 +37,6 @@ class Level1DataApi(object): ...@@ -35,15 +37,6 @@ class Level1DataApi(object):
''' '''
return self.stub.find(**kwargs) return self.stub.find(**kwargs)
def find_by_brick_ids(self, **kwargs):
''' retrieve level1 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)
def find_by_ids(self, **kwargs): def find_by_ids(self, **kwargs):
''' retrieve level1 records by internal level1 ids like [1,2,3,4] ''' retrieve level1 records by internal level1 ids like [1,2,3,4]
...@@ -52,18 +45,16 @@ class Level1DataApi(object): ...@@ -52,18 +45,16 @@ class Level1DataApi(object):
:returns: csst_dfs_common.models.Result :returns: csst_dfs_common.models.Result
''' '''
return self.stub.find_by_ids(**kwargs) return self.stub.find_by_ids(**kwargs)
def sls_find_by_qc1_status(self, **kwargs): def find_refs_by_ids(self, **kwargs):
''' retrieve level1 records from database ''' retrieve level1 reference records by internal level1 ids like [1,2,3,4]
:param kwargs: Parameter dictionary, key items support: :param kwargs: Parameter dictionary, key items support:
qc1_status : [int], ids: [list]
limit: limits returns the number of records,default 1
:returns: csst_dfs_common.models.Result :returns: csst_dfs_common.models.Result
''' '''
return self.stub.sls_find_by_qc1_status(**kwargs) return self.stub.find_refs_by_ids(**kwargs)
def get(self, **kwargs): def get(self, **kwargs):
''' fetch a record from database ''' fetch a record from database
...@@ -102,16 +93,18 @@ class Level1DataApi(object): ...@@ -102,16 +93,18 @@ class Level1DataApi(object):
:param kwargs: Parameter dictionary, key items support: :param kwargs: Parameter dictionary, key items support:
level0_id: [str] level0_id: [str]
detector_no: [str]
rss_id: [str]
cube_id: [str]
data_type : [str] data_type : [str]
cor_sci_id : [int]
prc_params : [str]
filename : [str] filename : [str]
file_path : [str] file_path : [str]
prc_status : [int] prc_status : [int]
prc_time : [str] prc_time : [str]
pipeline_id : [str] pipeline_id : [str]
pmapname : [str] pmapname : [str]
build : [str] build : [str],
refs : list[tuple] for example: [('dark', 'csst_msc_dark_001.rmap'), ('bias', 'csst_msc_bias_001.rmap'), ('flat', 'csst_msc_flat_001.rmap')]
:returns: csst_dfs_common.models.Result :returns: csst_dfs_common.models.Result
''' '''
......
...@@ -9,19 +9,25 @@ class Level1DataTestCase(unittest.TestCase): ...@@ -9,19 +9,25 @@ class Level1DataTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.api = Level1DataApi() self.api = Level1DataApi()
def test_find(self): # def test_find(self):
recs = self.api.find( # recs = self.api.find(
level0_id='10000010101', # level0_id='10000010101',
module_id = "MSC", # module_id = "MSC",
create_time = ("2024-01-01 11:12:13","2024-06-08 11:12:13")) # create_time = ("2024-01-01 11:12:13","2024-06-08 11:12:13"))
print('find:', recs) # print('find:', recs)
def test_find_by_ids(self): # def test_find_by_ids(self):
recs = self.api.find_by_ids( # recs = self.api.find_by_ids(
module_id = "MSC", # module_id = "MSC",
# ids=[16]
# )
# print('find_by_ids:', recs)
def test_find_refs_by_ids(self):
recs = self.api.find_refs_by_ids(
ids=[16] ids=[16]
) )
print('find_by_ids:', recs) print('test_find_refs_by_ids:', recs)
def test_find_by_brick_ids(self): def test_find_by_brick_ids(self):
recs = self.api.find_by_brick_ids( recs = self.api.find_by_brick_ids(
...@@ -37,7 +43,7 @@ class Level1DataTestCase(unittest.TestCase): ...@@ -37,7 +43,7 @@ class Level1DataTestCase(unittest.TestCase):
print('sls_find_by_qc1_status:', recs) print('sls_find_by_qc1_status:', recs)
def test_get(self): def test_get(self):
rec = self.api.get(id = 2) rec = self.api.get(id = 16)
print('get:', rec) print('get:', rec)
def test_update_proc_status(self): def test_update_proc_status(self):
...@@ -51,6 +57,7 @@ class Level1DataTestCase(unittest.TestCase): ...@@ -51,6 +57,7 @@ class Level1DataTestCase(unittest.TestCase):
def test_write(self): def test_write(self):
rec = self.api.write( rec = self.api.write(
level0_id = '10000010101', level0_id = '10000010101',
module_id = "MSC",
file_type = "SCIE", file_type = "SCIE",
prc_status = 3, prc_status = 3,
prc_time = '2021-10-22 11:12:13', prc_time = '2021-10-22 11:12:13',
...@@ -58,6 +65,6 @@ class Level1DataTestCase(unittest.TestCase): ...@@ -58,6 +65,6 @@ class Level1DataTestCase(unittest.TestCase):
file_path = "/opt/temp/csst/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",
pipeline_id = "P1", pipeline_id = "P1",
build_id = 123, build_id = 123,
refs = [('dark', '1'), ('bias', '2'), ('flat', '3')] refs = {'flat': '3', 'arc': '2', 'bias': '1'}
) )
print('write:', rec) print('write:', rec)
\ No newline at end of file
import os
import unittest
from astropy.io import fits
from csst_dfs_api.ifs.level1 import Level1DataApi
class Level1DataTestCase(unittest.TestCase):
def setUp(self):
self.api = Level1DataApi()
def test_find(self):
recs = self.api.find(
level0_id='10000010101',
module_id = "IFS",
create_time = ("2024-01-01 11:12:13","2024-06-08 11:12:13"))
print('find:', recs)
def test_find_refs_by_ids(self):
recs = self.api.find_refs_by_ids(
ids=[16]
)
print('test_find_refs_by_ids:', recs)
def test_get(self):
rec = self.api.get(id = 2)
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):
rec = self.api.write(
level0_id = '10000010101',
rss_id = "123RSSID",
module_id = "IFS",
file_type = "SCI",
prc_status = 3,
prc_time = '2021-10-22 11:12:13',
filename = "CSST_IFS_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",
pipeline_id = "P1",
build_id = 123,
refs = {'flat': '3', 'arc': '2', 'bias': '1'}
)
print('write:', rec)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment