Commit 2cd5e8a0 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

retrieve catalog columns

parent 8d848a98
...@@ -55,6 +55,17 @@ class Level2DataApi(object): ...@@ -55,6 +55,17 @@ class Level2DataApi(object):
''' '''
return self.stub.coord_cond_sql(**kwargs) 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): def find_existed_brick_ids(self, **kwargs):
''' retrieve existed brick_ids in the catalog with data_type ''' retrieve existed brick_ids in the catalog with data_type
:param kwargs: :param kwargs:
......
...@@ -15,42 +15,50 @@ class Level2DataTestCase(unittest.TestCase): ...@@ -15,42 +15,50 @@ class Level2DataTestCase(unittest.TestCase):
print('find:', recs) print('find:', recs)
def test_find_existed_brick_ids(self): 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) print('find_existed_brick_ids:', recs)
def test_catalog_query(self): def test_catalog_query(self):
result = self.api.catalog_query( 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) limit = 2)
print(result) print(result)
if result.success and result['totalCount'] > 0: if result.success and result['totalCount'] > 0:
dt = to_fits_table(result) dt = to_fits_table(result)
dt.pprint() dt.pprint()
# def test_get(self): def test_coord_cond_sql(self):
# rec = self.api.get(id = 1) result = self.api.coord_cond_sql(data_type="csst-msc-l1-mbi-cat", ra = 120, dec = 40, radius = 0.5)
# print('get:', rec) 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): def test_update_proc_status(self):
# rec = self.api.update_proc_status(id = 1, status = 4) rec = self.api.update_proc_status(id = 1, status = 4)
# print('update_proc_status:', rec) print('update_proc_status:', rec)
# def test_update_qc2_status(self): def test_update_qc2_status(self):
# rec = self.api.update_qc2_status(id = 1, status = 7) rec = self.api.update_qc2_status(id = 1, status = 7)
# print('update_qc2_status:', rec) print('update_qc2_status:', rec)
# def test_write(self): def test_write(self):
# rec = self.api.write( rec = self.api.write(
# level1_id= 1, level0_id= '1016000000412',
# module_id = 'MSC', module_id = 'MSC',
# data_type = "csst-msc-l1-phot", data_type = "csst-msc-l1-mbi-cat",
# prc_status = 3, prc_status = 3,
# prc_time = '2021-10-22 11:12:13', prc_time = '2021-10-22 11:12:13',
# filename = "CSST_MSC_MS_SCIE_20240821005429_20240821005659_10160000004_12_L1_V01_CAT.fits", filename = "CSST_MSC_MS_SCIE_20240821023334_20240821023604_10160000011_19_L1_V01_CAT.fits",
# file_path = "/opt/temp/csst/msc/L2/CSST_MSC_MS_SCIE_20240821005429_20240821005659_10160000004_12_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 = "P1" pipeline_id = "csst-msc-l1-mbi-cat"
# ) )
# print('write:', rec) print('write:', rec)
# rec = self.api.write( # rec = self.api.write(
# level1_id= 1, # level1_id= 1,
# module_id = 'MSC', # module_id = 'MSC',
......
...@@ -11,35 +11,37 @@ class Level2TypeTestCase(unittest.TestCase): ...@@ -11,35 +11,37 @@ class Level2TypeTestCase(unittest.TestCase):
def test_find(self): def test_find(self):
recs = self.api.find( recs = self.api.find(
module_id='MSC', module_id='MSC',
data_type='csst-msc-l1-phot' data_type='csst-msc-l1-mbi-cat'
) )
print('find:', recs) print('find:', recs)
def test_get(self): 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) print('get:', rec)
def test_update_import_status(self): 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) print('update_import_status:', rec)
def test_write(self): def test_write(self):
rec = self.api.write( rec = self.api.write(
data_type = "csst-msc-l1-phot", data_type = "csst-msc-l1-mbi-cat",
module_id = "MSC", module_id = "MSC",
key_column = "ID", key_column = "ID",
hdu_index = 1, hdu_index = 1,
demo_filename = "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_20240821005429_20240821005659_10160000004_12_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", ra_column = "RA",
dec_column = "DEC") dec_column = "DEC")
rec = self.api.write( print("write :", rec)
data_type = "csst-msc-xcat",
module_id = "MSC", # rec = self.api.write(
key_column = "PhotoObjID", # data_type = "csst-msc-xcat",
hdu_index = 1, # module_id = "MSC",
demo_filename = "MSC_MS_XCAT_BRICK_156958.fits", # key_column = "PhotoObjID",
demo_file_path = "/Users/wsl/temp/csst/msc/L2/MSC_MS_XCAT_BRICK_156958.fits", # hdu_index = 1,
ra_column = "RA_r", # demo_filename = "MSC_MS_XCAT_BRICK_156958.fits",
dec_column = "DEC_r") # demo_file_path = "/Users/wsl/temp/csst/msc/L2/MSC_MS_XCAT_BRICK_156958.fits",
print('write:', rec) # ra_column = "RA_r",
\ No newline at end of file # dec_column = "DEC_r")
# 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