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

add find refs

parent 882f815a
......@@ -23,7 +23,7 @@ class Level1DataApi(object):
filename: [str]
ra_cen: float = None
dec_cen: float = None,
radius_cen: float = None
radius: float = None
pipeline_id: [str]
build: [int]
detector_no: [str]
......@@ -44,11 +44,21 @@ class Level1DataApi(object):
'''
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):
''' retrieve level1 records by internal level1 ids like [1,2,3,4]
:param kwargs: Parameter dictionary, key items support:
ids: [list]
ids: [list],
module_id: [str] like 'MSC'
:returns: csst_dfs_common.models.Result
'''
return self.stub.find_by_ids(**kwargs)
......@@ -102,16 +112,16 @@ class Level1DataApi(object):
:param kwargs: Parameter dictionary, key items support:
level0_id: [str]
detector_no: [str]
data_type : [str]
cor_sci_id : [int]
prc_params : [str]
filename : [str]
file_path : [str]
prc_status : [int]
prc_time : [str]
pipeline_id : [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
'''
......
......@@ -21,13 +21,15 @@ class Level1DataApi(object):
qc1_status : [int]
prc_status : [int]
filename: [str]
ra_cen: float = None
dec_cen: float = None,
radius_cen: float = None
ra_obj: float = None
dec_obj: float = None,
radius: float = None
rss_id: [str]
cube_id: [str]
obj_id: [str]
pipeline_id: [str]
build: [int]
detector_no: [str]
filter: [str]
object_name: [str]
limit: limits returns the number of records,default 0:no-limit
......@@ -35,15 +37,6 @@ class Level1DataApi(object):
'''
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):
''' retrieve level1 records by internal level1 ids like [1,2,3,4]
......@@ -52,18 +45,16 @@ class Level1DataApi(object):
:returns: csst_dfs_common.models.Result
'''
return self.stub.find_by_ids(**kwargs)
def sls_find_by_qc1_status(self, **kwargs):
''' retrieve level1 records from database
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:
qc1_status : [int],
limit: limits returns the number of records,default 1
ids: [list]
: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):
''' fetch a record from database
......@@ -102,16 +93,18 @@ class Level1DataApi(object):
:param kwargs: Parameter dictionary, key items support:
level0_id: [str]
detector_no: [str]
rss_id: [str]
cube_id: [str]
data_type : [str]
cor_sci_id : [int]
prc_params : [str]
filename : [str]
file_path : [str]
prc_status : [int]
prc_time : [str]
pipeline_id : [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
'''
......
......@@ -9,19 +9,25 @@ class Level1DataTestCase(unittest.TestCase):
def setUp(self):
self.api = Level1DataApi()
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)
# 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)
def test_find_by_ids(self):
recs = self.api.find_by_ids(
module_id = "MSC",
# 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(
ids=[16]
)
print('find_by_ids:', recs)
print('test_find_refs_by_ids:', recs)
def test_find_by_brick_ids(self):
recs = self.api.find_by_brick_ids(
......@@ -37,7 +43,7 @@ class Level1DataTestCase(unittest.TestCase):
print('sls_find_by_qc1_status:', recs)
def test_get(self):
rec = self.api.get(id = 2)
rec = self.api.get(id = 16)
print('get:', rec)
def test_update_proc_status(self):
......@@ -51,6 +57,7 @@ class Level1DataTestCase(unittest.TestCase):
def test_write(self):
rec = self.api.write(
level0_id = '10000010101',
module_id = "MSC",
file_type = "SCIE",
prc_status = 3,
prc_time = '2021-10-22 11:12:13',
......@@ -58,6 +65,6 @@ class Level1DataTestCase(unittest.TestCase):
file_path = "/opt/temp/csst/CSST_MSC_MS_SCI_20270810142128_20270810142358_100000101_20_img_L1.fits",
pipeline_id = "P1",
build_id = 123,
refs = [('dark', '1'), ('bias', '2'), ('flat', '3')]
refs = {'flat': '3', 'arc': '2', 'bias': '1'}
)
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