From 2cd5e8a047b07977a40e614a51bc2a08f245dd65 Mon Sep 17 00:00:00 2001 From: shoulinwei Date: Fri, 29 Dec 2023 16:43:03 +0800 Subject: [PATCH] retrieve catalog columns --- csst_dfs_api/facility/level2.py | 11 +++++ tests/facility/test_facility_level2.py | 54 +++++++++++++--------- tests/facility/test_facility_level2type.py | 34 +++++++------- 3 files changed, 60 insertions(+), 39 deletions(-) diff --git a/csst_dfs_api/facility/level2.py b/csst_dfs_api/facility/level2.py index bde568d..f20298d 100644 --- a/csst_dfs_api/facility/level2.py +++ b/csst_dfs_api/facility/level2.py @@ -55,6 +55,17 @@ class Level2DataApi(object): ''' return self.stub.coord_cond_sql(**kwargs) + def catalog_columns(self, **kwargs): + ''' retrieve columns data type + + :param kwargs: Parameter dictionary, key items support: + data_type: [str] + columns: [list], list of str + + :returns: csst_dfs_common.models.Result + ''' + return self.stub.catalog_columns(**kwargs) + def find_existed_brick_ids(self, **kwargs): ''' retrieve existed brick_ids in the catalog with data_type :param kwargs: diff --git a/tests/facility/test_facility_level2.py b/tests/facility/test_facility_level2.py index da9552f..4a8ee97 100644 --- a/tests/facility/test_facility_level2.py +++ b/tests/facility/test_facility_level2.py @@ -15,42 +15,50 @@ class Level2DataTestCase(unittest.TestCase): print('find:', recs) def test_find_existed_brick_ids(self): - recs = self.api.find_existed_brick_ids(data_type = "csst-msc-l1-phot") + recs = self.api.find_existed_brick_ids(data_type = "csst-msc-l1-mbi-cat") print('find_existed_brick_ids:', recs) def test_catalog_query(self): result = self.api.catalog_query( - sql = 'select x,y,A,B,PA,AB,E from csst_msc_l1_phot', + sql = 'select x,y,A,B,PA,AB,E from csst_msc_l1_mbi_cat', limit = 2) print(result) if result.success and result['totalCount'] > 0: dt = to_fits_table(result) dt.pprint() - # def test_get(self): - # rec = self.api.get(id = 1) - # print('get:', rec) + def test_coord_cond_sql(self): + result = self.api.coord_cond_sql(data_type="csst-msc-l1-mbi-cat", ra = 120, dec = 40, radius = 0.5) + print(result) + + def test_catalog_column(self): + result = self.api.catalog_columns(data_type="csst-msc-l1-mbi-cat", columns = ['RA', 'DEC']) + print(result) + + def test_get(self): + rec = self.api.get(id = 1) + print('get:', rec) - # def test_update_proc_status(self): - # rec = self.api.update_proc_status(id = 1, status = 4) - # print('update_proc_status:', rec) + def test_update_proc_status(self): + rec = self.api.update_proc_status(id = 1, status = 4) + print('update_proc_status:', rec) - # def test_update_qc2_status(self): - # rec = self.api.update_qc2_status(id = 1, status = 7) - # print('update_qc2_status:', rec) + def test_update_qc2_status(self): + rec = self.api.update_qc2_status(id = 1, status = 7) + print('update_qc2_status:', rec) - # def test_write(self): - # rec = self.api.write( - # level1_id= 1, - # module_id = 'MSC', - # data_type = "csst-msc-l1-phot", - # prc_status = 3, - # prc_time = '2021-10-22 11:12:13', - # filename = "CSST_MSC_MS_SCIE_20240821005429_20240821005659_10160000004_12_L1_V01_CAT.fits", - # file_path = "/opt/temp/csst/msc/L2/CSST_MSC_MS_SCIE_20240821005429_20240821005659_10160000004_12_L1_V01_CAT.fits", - # pipeline_id = "P1" - # ) - # print('write:', rec) + def test_write(self): + rec = self.api.write( + level0_id= '1016000000412', + module_id = 'MSC', + data_type = "csst-msc-l1-mbi-cat", + prc_status = 3, + prc_time = '2021-10-22 11:12:13', + filename = "CSST_MSC_MS_SCIE_20240821023334_20240821023604_10160000011_19_L1_V01_CAT.fits", + file_path = "/opt/temp/csst/msc/L2/CSST_MSC_MS_SCIE_20240821023334_20240821023604_10160000011_19_L1_V01_CAT.fits", + pipeline_id = "csst-msc-l1-mbi-cat" + ) + print('write:', rec) # rec = self.api.write( # level1_id= 1, # module_id = 'MSC', diff --git a/tests/facility/test_facility_level2type.py b/tests/facility/test_facility_level2type.py index dee67b8..2e24988 100644 --- a/tests/facility/test_facility_level2type.py +++ b/tests/facility/test_facility_level2type.py @@ -11,35 +11,37 @@ class Level2TypeTestCase(unittest.TestCase): def test_find(self): recs = self.api.find( module_id='MSC', - data_type='csst-msc-l1-phot' + data_type='csst-msc-l1-mbi-cat' ) print('find:', recs) def test_get(self): - rec = self.api.get(data_type = 'csst-msc-l1-phot') + rec = self.api.get(data_type = 'csst-msc-l1-mbi-cat') print('get:', rec) def test_update_import_status(self): - rec = self.api.update_import_status(data_type = 'csst-msc-l1-phot', status = 4) + rec = self.api.update_import_status(data_type = 'csst-msc-l1-mbi-cat', status = 4) print('update_import_status:', rec) def test_write(self): rec = self.api.write( - data_type = "csst-msc-l1-phot", + data_type = "csst-msc-l1-mbi-cat", module_id = "MSC", key_column = "ID", hdu_index = 1, - demo_filename = "CSST_MSC_MS_SCIE_20240821005429_20240821005659_10160000004_12_L1_V01_CAT.fits", - demo_file_path = "/Users/wsl/temp/csst/msc/L2/CSST_MSC_MS_SCIE_20240821005429_20240821005659_10160000004_12_L1_V01_CAT.fits", + demo_filename = "CSST_MSC_MS_SCIE_20240821023334_20240821023604_10160000011_19_L1_V01_CAT.fits", + demo_file_path = "/Users/wsl/temp/csst/msc/L2/CSST_MSC_MS_SCIE_20240821023334_20240821023604_10160000011_19_L1_V01_CAT.fits", ra_column = "RA", dec_column = "DEC") - rec = self.api.write( - data_type = "csst-msc-xcat", - module_id = "MSC", - key_column = "PhotoObjID", - hdu_index = 1, - demo_filename = "MSC_MS_XCAT_BRICK_156958.fits", - demo_file_path = "/Users/wsl/temp/csst/msc/L2/MSC_MS_XCAT_BRICK_156958.fits", - ra_column = "RA_r", - dec_column = "DEC_r") - print('write:', rec) \ No newline at end of file + print("write :", rec) + + # rec = self.api.write( + # data_type = "csst-msc-xcat", + # module_id = "MSC", + # key_column = "PhotoObjID", + # hdu_index = 1, + # demo_filename = "MSC_MS_XCAT_BRICK_156958.fits", + # demo_file_path = "/Users/wsl/temp/csst/msc/L2/MSC_MS_XCAT_BRICK_156958.fits", + # ra_column = "RA_r", + # dec_column = "DEC_r") + # print('write:', rec) \ No newline at end of file -- GitLab