diff --git a/.gitignore b/.gitignore index b5e68f2744e03963a1856c67d147c6c678d8d751..64784986e2143b8e277695b416643bf0e6676039 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ test_reports.xml **/.eggs **/_version.py +examples/test.py diff --git a/csst_dfs_api/common/constants.py b/csst_dfs_api/common/constants.py index 4807dcd3d9cde6378d022163b34c8c9c7d4c5521..ed7c3fcd2700ae680368a91faf32e4c89b2185eb 100644 --- a/csst_dfs_api/common/constants.py +++ b/csst_dfs_api/common/constants.py @@ -1,2 +1,11 @@ MODE_LOCAL = 'local' -MODE_CLUSTER = 'cluster' \ No newline at end of file +MODE_CLUSTER = 'cluster' + + +MODULE_MSC = "MSC" +MODULE_IFS = "IFS" +MODULE_MCI = "MCI" +MODULE_CPIC = "CPIC" +MODULE_HSTDM = "HSTDM" + +MODULE_IDS = [MODULE_MSC, MODULE_IFS, MODULE_MCI, MODULE_CPIC, MODULE_HSTDM] diff --git a/csst_dfs_api/cpic/__init__.py b/csst_dfs_api/cpic/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/csst_dfs_api/facility/__init__.py b/csst_dfs_api/facility/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..4a31a70cbda269bff6b387fe339d379ccdcf6ef9 --- /dev/null +++ b/csst_dfs_api/facility/__init__.py @@ -0,0 +1,5 @@ +from .calmerge import CalMergeApi +from .detector import DetectorApi +from .level0 import Level0DataApi +from .level0prc import Level0PrcApi +from .observation import ObservationApi \ No newline at end of file diff --git a/csst_dfs_api/facility/calmerge.py b/csst_dfs_api/facility/calmerge.py new file mode 100644 index 0000000000000000000000000000000000000000..9eaf08a5e17c88bc37ef779338e100acc13cec58 --- /dev/null +++ b/csst_dfs_api/facility/calmerge.py @@ -0,0 +1,77 @@ + +from ..common.delegate import Delegate + +class CalMergeApi(object): + """ + Level 0 Data Operation API + """ + def __init__(self): + self.pymodule = Delegate().load(sub_module = "facility") + self.stub = getattr(self.pymodule, "CalMergeApi")() + + def find(self, **kwargs): + ''' retrieve calibration merge records from database + + parameter kwargs: + detector_no: [str] + ref_type: [str] + obs_time: (start,end) + qc1_status : [int] + prc_status : [int] + file_name: [str] + limit: limits returns the number of records,default 0:no-limit + + return: csst_dfs_common.models.Result + ''' + return self.stub.find(**kwargs) + + def get(self, **kwargs): + ''' fetch a record from database + + parameter kwargs: + id : [int] + + return csst_dfs_common.models.Result + ''' + return self.stub.get(**kwargs) + + def update_proc_status(self, **kwargs): + ''' update the status of reduction + + parameter kwargs: + id : [int], + status : [int] + + return csst_dfs_common.models.Result + ''' + return self.stub.update_proc_status(**kwargs) + + def update_qc1_status(self, **kwargs): + ''' update the status of reduction + + parameter kwargs: + id : [int], + status : [int] + + return csst_dfs_common.models.Result + ''' + return self.stub.update_qc1_status(**kwargs) + + def write(self, **kwargs): + ''' insert a calibration merge record into database + + parameter kwargs: + id : [int] + detector_no : [str] + ref_type : [str] + obs_time : [str] + exp_time : [float] + prc_status : [int] + prc_time : [str] + filename : [str] + file_path : [str] + level0_ids : [list] + return csst_dfs_common.models.Result + ''' + return self.stub.write(**kwargs) + diff --git a/csst_dfs_api/facility/detector.py b/csst_dfs_api/facility/detector.py new file mode 100644 index 0000000000000000000000000000000000000000..004290538f0dd03773c473c9dd0b1c1fea5dacf4 --- /dev/null +++ b/csst_dfs_api/facility/detector.py @@ -0,0 +1,98 @@ +from ..common.delegate import Delegate + +class DetectorApi(object): + """ + Detector Operation Class + """ + def __init__(self): + self.pymodule = Delegate().load(sub_module = "facility") + self.stub = getattr(self.pymodule, "DetectorApi")() + + def find(self, **kwargs): + ''' retrieve detector records from database + + parameter kwargs: + module_id: [str] + key: [str] + + return: csst_dfs_common.models.Result + ''' + return self.stub.find(**kwargs) + + def get(self, **kwargs): + ''' fetch a record from database + + parameter kwargs: + no : [str] + + return csst_dfs_common.models.Result + ''' + return self.stub.get(**kwargs) + + def update(self, **kwargs): + ''' update a detector by no + + parameter kwargs: + no : [str], + detector_name : [str], + module_id : [str], + filter_id : [str] + + return csst_dfs_common.models.Result + ''' + return self.stub.update(**kwargs) + + def delete(self, **kwargs): + ''' delete a detector by no + + parameter kwargs: + no : [str] + + return csst_dfs_common.models.Result + ''' + return self.stub.delete(**kwargs) + + def write(self, **kwargs): + ''' insert a detector record into database + + parameter kwargs: + no : [str], + detector_name : [str], + module_id : [str], + filter_id : [str] + return csst_dfs_common.models.Result + ''' + return self.stub.write(**kwargs) + + def find_status(self, **kwargs): + ''' retrieve a detector status's from database + + parameter kwargs: + detector_no: [str] + status_occur_time: (begin,end) + limit: limits returns the number of records,default 0:no-limit + + return: csst_dfs_common.models.Result + ''' + return self.stub.find_status(**kwargs) + + def get_status(self, **kwargs): + ''' fetch a record from database + + parameter kwargs: + id : [int] + + return csst_dfs_common.models.Result + ''' + return self.stub.get_status(**kwargs) + + def write_status(self, **kwargs): + ''' insert a detector status into database + + parameter kwargs: + detector_no : [str], + status : [str], + status_time : [str] + return csst_dfs_common.models.Result + ''' + return self.stub.write_status(**kwargs) \ No newline at end of file diff --git a/csst_dfs_api/facility/level0.py b/csst_dfs_api/facility/level0.py new file mode 100644 index 0000000000000000000000000000000000000000..296687e6053248613adad900d3c53354af5a66e7 --- /dev/null +++ b/csst_dfs_api/facility/level0.py @@ -0,0 +1,72 @@ + +from ..common.delegate import Delegate + +class Level0DataApi(object): + """ + Level 0 Data Operation API + """ + def __init__(self): + self.pymodule = Delegate().load(sub_module = "facility") + self.stub = getattr(self.pymodule, "Level0DataApi")() + + def find(self, **kwargs): + ''' retrieve level0 records from database + + parameter kwargs: + obs_id: [int] + detector_no: [str] + obs_type: [str] + obs_time : (start, end), + qc0_status : [int], + prc_status : [int], + file_name: [str] + limit: limits returns the number of records,default 0:no-limit + + return: csst_dfs_common.models.Result + ''' + return self.stub.find(**kwargs) + + def get(self, **kwargs): + ''' fetch a record from database + + parameter kwargs: + fits_id : [int] + + return csst_dfs_common.models.Result + ''' + return self.stub.get(**kwargs) + + def update_proc_status(self, **kwargs): + ''' update the status of reduction + + parameter kwargs: + fits_id : [int], + status : [int] + ''' + return self.stub.update_proc_status(**kwargs) + + def update_qc0_status(self, **kwargs): + ''' update the status of QC0 + + parameter kwargs: + fits_id : [int], + status : [int] + ''' + return self.stub.update_qc0_status(**kwargs) + + def write(self, **kwargs): + ''' insert a level0 data record into database + + parameter kwargs: + obs_id = [int] + detector_no = [str] + obs_type = [str] + obs_time = [str] + exp_time = [int] + detector_status_id = [int] + filename = [str] + file_path = [str] + return: csst_dfs_common.models.Result + ''' + return self.stub.write(**kwargs) + diff --git a/csst_dfs_api/facility/level0prc.py b/csst_dfs_api/facility/level0prc.py new file mode 100644 index 0000000000000000000000000000000000000000..eec1e62a804dabeecccd63466323c1572e84458c --- /dev/null +++ b/csst_dfs_api/facility/level0prc.py @@ -0,0 +1,50 @@ + +from ..common.delegate import Delegate + +class Level0PrcApi(object): + """ + Level 0 Data Operation API + """ + def __init__(self): + self.pymodule = Delegate().load(sub_module = "facility") + self.stub = getattr(self.pymodule, "Level0PrcApi")() + + def find(self, **kwargs): + ''' retrieve level0 procedure records from database + + parameter kwargs: + level0_id: [int] + pipeline_id: [str] + prc_module: [str] + prc_status : [int] + + return: csst_dfs_common.models.Result + ''' + return self.stub.find(**kwargs) + + def update_proc_status(self, **kwargs): + ''' update the status of reduction + + parameter kwargs: + id : [int], + status : [int] + + return csst_dfs_common.models.Result + ''' + return self.stub.update_proc_status(**kwargs) + + def write(self, **kwargs): + ''' insert a level0 procedure record into database + + parameter kwargs: + level0_id : [int] + pipeline_id : [str] + prc_module : [str] + params_id : [str] + prc_status : [int] + prc_time : [str] + file_path : [str] + return csst_dfs_common.models.Result + ''' + return self.stub.write(**kwargs) + diff --git a/csst_dfs_api/facility/observation.py b/csst_dfs_api/facility/observation.py new file mode 100644 index 0000000000000000000000000000000000000000..0e5e40342821d0dd9e4251ce03bb7e1db9c8ce35 --- /dev/null +++ b/csst_dfs_api/facility/observation.py @@ -0,0 +1,74 @@ + +from ..common.delegate import Delegate + +class ObservationApi(object): + """ + Observation Operation Class + """ + def __init__(self): + self.pymodule = Delegate().load(sub_module = "facility") + self.stub = getattr(self.pymodule, "ObservationApi")() + + def find(self, **kwargs): + ''' retrieve exposure records from database + + parameter kwargs: + module_id: [str] + obs_type: [str] + obs_time : (start, end), + qc0_status : [int], + prc_status : [int], + limit: limits returns the number of records,default 0:no-limit + + return: csst_dfs_common.models.Result + ''' + return self.stub.find(**kwargs) + + def get(self, **kwargs): + ''' fetch a record from database + + parameter kwargs: + obs_id = [int] + + return: csst_dfs_common.models.Result + ''' + return self.stub.get(**kwargs) + + + def update_proc_status(self, **kwargs): + ''' update the status of reduction + + parameter kwargs: + obs_id = [int], + status = [int] + + return: csst_dfs_common.models.Result + ''' + return self.stub.update_proc_status(**kwargs) + + def update_qc0_status(self, **kwargs): + ''' update the status of QC0 + + parameter kwargs: + obs_id = [int], + status = [int] + + return: csst_dfs_common.models.Result + ''' + return self.stub.update_qc0_status(**kwargs) + + def write(self, **kwargs): + ''' insert a observational record into database + + parameter kwargs: + obs_time = [str] + exp_time = [float] + module_id = [str] + obs_type = [str] + facility_status_id = [int] + module_status_id = [int] + + return: csst_dfs_common.models.Result + ''' + return self.stub.write(**kwargs) + diff --git a/csst_dfs_api/hstdm/__init__.py b/csst_dfs_api/hstdm/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/csst_dfs_api/ifs/__init__.py b/csst_dfs_api/ifs/__init__.py index 043a0f51eb7d45d6cbca896a2edca64038614ffd..1fd02d8db240adc400354f658c3ba6f2c9941ae5 100644 --- a/csst_dfs_api/ifs/__init__.py +++ b/csst_dfs_api/ifs/__init__.py @@ -1,4 +1 @@ -from .fits import FitsApi -from .reffits import RefFitsApi -from .result0 import Result0Api -from .result1 import Result1Api \ No newline at end of file +from .level1 import Level1DataApi \ No newline at end of file diff --git a/csst_dfs_api/ifs/fits.py b/csst_dfs_api/ifs/fits.py deleted file mode 100644 index 7cf05133aaa2d1499b5f8830d038784964abac13..0000000000000000000000000000000000000000 --- a/csst_dfs_api/ifs/fits.py +++ /dev/null @@ -1,75 +0,0 @@ - -from ..common.delegate import Delegate - -class FitsApi(object): - """ - Raw Fits Operation Class of IFS - """ - def __init__(self, sub_system="ifs"): - self.sub_system = sub_system - self.module = Delegate().load(sub_module = "ifs") - self.stub = getattr(self.module, "FitsApi")() - - def find(self, **kwargs): - ''' - parameter kwargs: - obs_time = [int], - file_name = [str], - exp_time = (start, end), - ccd_num = [int], - qc0_status = [int], - prc_status = [int], - limit: limits returns the number of records - - return: csst_dfs_common.models.Result - ''' - return self.stub.find(**kwargs) - - def get(self, **kwargs): - ''' query database, return a record as dict - - parameter kwargs: - fits_id = [int] - - return dict or None - ''' - return self.stub.get(**kwargs) - - def read(self, **kwargs): - ''' yield bytes of fits file - - parameter kwargs: - fits_id = [int], - file_path = [str], - chunk_size = [int] default 20480 - - yield bytes of fits file - ''' - return self.stub.read(**kwargs) - - def update_proc_status(self, **kwargs): - ''' update the status of reduction - - parameter kwargs: - fits_id = [int], - status = [int] - ''' - return self.stub.update_proc_status(**kwargs) - - def update_qc0_status(self, **kwargs): - ''' update the status of reduction - - parameter kwargs: - fits_id = [int], - status = [int] - ''' - return self.stub.update_qc0_status(**kwargs) - - def write(self, **kwargs): - ''' copy a local file to file storage, then reduce the header of fits file and insert a record into database - - parameter kwargs: - file_path = [str] - ''' - return self.stub.write(**kwargs) - diff --git a/csst_dfs_api/ifs/level1.py b/csst_dfs_api/ifs/level1.py new file mode 100644 index 0000000000000000000000000000000000000000..14332d0cbfeff4e13ed43bdce7d0793e16070281 --- /dev/null +++ b/csst_dfs_api/ifs/level1.py @@ -0,0 +1,85 @@ + +from ..common.delegate import Delegate + +class Level1DataApi(object): + """ + Level1 Data Operation Class + """ + def __init__(self): + self.pymodule = Delegate().load(sub_module = "ifs") + self.stub = getattr(self.pymodule, "Level1DataApi")() + + def find(self, **kwargs): + ''' retrieve level1 records from database + + parameter kwargs: + raw_id: [int] + data_type: [str] + obs_type: [str] + create_time : (start, end), + qc1_status : [int], + prc_status : [int], + filename: [str] + limit: limits returns the number of records,default 0:no-limit + + return: csst_dfs_common.models.Result + ''' + return self.stub.find(**kwargs) + + def get(self, **kwargs): + ''' fetch a record from database + + parameter kwargs: + id : [int] + + return csst_dfs_common.models.Result + ''' + return self.stub.get(**kwargs) + + + def update_proc_status(self, **kwargs): + ''' update the status of reduction + + parameter kwargs: + id = [int], + status = [int] + + return: csst_dfs_common.models.Result + ''' + return self.stub.update_proc_status(**kwargs) + + def update_qc1_status(self, **kwargs): + ''' update the status of QC0 + + parameter kwargs: + id = [int], + status = [int] + + return: csst_dfs_common.models.Result + ''' + return self.stub.update_qc1_status(**kwargs) + + def write(self, **kwargs): + ''' insert a level1 record into database + + parameter kwargs: + raw_id : [int] + data_type : [str] + cor_sci_id : [int] + prc_params : [str] + flat_id : [int] + dark_id : [int] + bias_id : [int] + lamp_id : [int] + arc_id : [int] + sky_id : [int] + filename : [str] + file_path : [str] + prc_status : [int] + prc_time : [str] + pipeline_id : [str] + + return csst_dfs_common.models.Result + ''' + return self.stub.write(**kwargs) + diff --git a/csst_dfs_api/ifs/reffits.py b/csst_dfs_api/ifs/reffits.py deleted file mode 100644 index 91f3e77c7806399e9c0699712318be624c9daa6c..0000000000000000000000000000000000000000 --- a/csst_dfs_api/ifs/reffits.py +++ /dev/null @@ -1,74 +0,0 @@ - -from ..common.delegate import Delegate - -class RefFitsApi(object): - """ - Reference Fits Operation Class of IFS - """ - REF_FITS_BIAS = "bias" - REF_FITS_FLAT = "flat" - REF_FITS_DARK = "dark" - REF_FITS_SKY = "sky" - REF_FITS_ARC = "arc" - - REF_FITS_TYPES = [REF_FITS_BIAS, REF_FITS_FLAT, REF_FITS_DARK, REF_FITS_SKY, REF_FITS_ARC] - - def __init__(self, sub_system="ifs"): - self.sub_system = sub_system - self.module = Delegate().load(sub_module = "ifs") - self.stub = getattr(self.module, "RefFitsApi")() - self.file_prefix = self.stub.root_dir - - def find(self, **kwargs): - ''' - parameter kwargs: - obs_time = [int], - file_name = [str], - exp_time = (start, end), - ccd_num = [int], - status = [int], - ref_type = [str] - - return list of reference's files records - ''' - return self.stub.find(**kwargs) - - def get(self, **kwargs): - ''' query database, return a record as dict - - parameter kwargs: - fits_id = [int] - - return dict or None - ''' - return self.stub.get(**kwargs) - - def read(self, **kwargs): - ''' yield bytes of fits file - - parameter kwargs: - fits_id = [int], - file_path = [str], - chunk_size = [int] default 20480 - - yield bytes of fits file - ''' - return self.stub.read(**kwargs) - - def update_status(self, **kwargs): - ''' update the status of reduction - - parameter kwargs: - fits_id = [int], - status = [int] - ''' - return self.stub.update_status(**kwargs) - - def write(self, **kwargs): - ''' copy a local file to file storage, then reduce the header of fits file and insert a record into database - - parameter kwargs: - file_path = [str] - ''' - return self.stub.write(**kwargs) - diff --git a/csst_dfs_api/ifs/result0.py b/csst_dfs_api/ifs/result0.py deleted file mode 100644 index 9413e7588484e2181ec0ad4205c15d50e6153bec..0000000000000000000000000000000000000000 --- a/csst_dfs_api/ifs/result0.py +++ /dev/null @@ -1,56 +0,0 @@ - -from ..common.delegate import Delegate - -class Result0Api(object): - """ - Level 0 Operation Class of IFS - """ - def __init__(self, sub_system="ifs"): - self.sub_system = sub_system - self.module = Delegate().load(sub_module = "ifs") - self.stub = getattr(self.module, "Result0Api")() - self.file_prefix = self.stub.root_dir - - def find(self, **kwargs): - ''' - parameter kwargs: - raw_id = [int], - file_name = [str], - proc_type = [str] - - return list of level 0 record - ''' - return self.stub.find(**kwargs) - - def get(self, **kwargs): - ''' query database, return a record as dict - - parameter kwargs: - fits_id = [int] - - return dict or None - ''' - return self.stub.get(**kwargs) - - def read(self, **kwargs): - ''' yield bytes of fits file - - parameter kwargs: - fits_id = [int], - file_path = [str], - chunk_size = [int] default 20480 - - yield bytes of fits file - ''' - return self.stub.read(**kwargs) - - def write(self, **kwargs): - ''' copy a local level 0 file to file storage, and insert a record into database - - parameter kwargs: - raw_id = [int], - file_path = [str], - proc_type = [str] - ''' - return self.stub.write(**kwargs) - diff --git a/csst_dfs_api/ifs/result1.py b/csst_dfs_api/ifs/result1.py deleted file mode 100644 index ecd7a5e26bf4d92b7d496b5ec35270936db810ee..0000000000000000000000000000000000000000 --- a/csst_dfs_api/ifs/result1.py +++ /dev/null @@ -1,55 +0,0 @@ - -from ..common.delegate import Delegate - -class Result1Api(object): - """ - Level 1 Operation Class of IFS - """ - def __init__(self, sub_system="ifs"): - self.sub_system = sub_system - self.module = Delegate().load(sub_module = "ifs") - self.stub = getattr(self.module, "Result1Api")() - self.file_prefix = self.stub.root_dir - - def find(self, **kwargs): - ''' - parameter kwargs: - file_name = [str], - proc_type = [str] - - return list of level 1 record - ''' - return self.stub.find(**kwargs) - - def get(self, **kwargs): - ''' query database, return a record as dict - - parameter kwargs: - fits_id = [int] - - return dict or None - ''' - return self.stub.get(**kwargs) - - def read(self, **kwargs): - ''' yield bytes of fits file - - parameter kwargs: - fits_id = [int], - file_path = [str], - chunk_size = [int] default 20480 - - yield bytes of fits file - ''' - return self.stub.read(**kwargs) - - def write(self, **kwargs): - ''' copy a local level 1 file to file storage, and insert a record into database - - parameter kwargs: - file_path = [str], - proc_type = [str], - result0_ids = [list] - ''' - return self.stub.write(**kwargs) - diff --git a/csst_dfs_api/mci/__init__.py b/csst_dfs_api/mci/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/csst_dfs_api/msc/__init__.py b/csst_dfs_api/msc/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1fd02d8db240adc400354f658c3ba6f2c9941ae5 --- /dev/null +++ b/csst_dfs_api/msc/__init__.py @@ -0,0 +1 @@ +from .level1 import Level1DataApi \ No newline at end of file diff --git a/csst_dfs_api/msc/level1.py b/csst_dfs_api/msc/level1.py new file mode 100644 index 0000000000000000000000000000000000000000..3a2529e9d003bf49e1e2268f660ca8ddea967366 --- /dev/null +++ b/csst_dfs_api/msc/level1.py @@ -0,0 +1,82 @@ + +from ..common.delegate import Delegate + +class Level1DataApi(object): + """ + Level1 Data Operation Class + """ + def __init__(self): + self.pymodule = Delegate().load(sub_module = "msc") + self.stub = getattr(self.pymodule, "Level1DataApi")() + + def find(self, **kwargs): + ''' retrieve level1 records from database + + parameter kwargs: + raw_id: [int] + data_type: [str] + obs_type: [str] + create_time : (start, end), + qc1_status : [int], + prc_status : [int], + filename: [str] + limit: limits returns the number of records,default 0:no-limit + + return: csst_dfs_common.models.Result + ''' + return self.stub.find(**kwargs) + + def get(self, **kwargs): + ''' fetch a record from database + + parameter kwargs: + id : [int] + + return csst_dfs_common.models.Result + ''' + return self.stub.get(**kwargs) + + + def update_proc_status(self, **kwargs): + ''' update the status of reduction + + parameter kwargs: + id = [int], + status = [int] + + return: csst_dfs_common.models.Result + ''' + return self.stub.update_proc_status(**kwargs) + + def update_qc1_status(self, **kwargs): + ''' update the status of QC0 + + parameter kwargs: + id = [int], + status = [int] + + return: csst_dfs_common.models.Result + ''' + return self.stub.update_qc1_status(**kwargs) + + def write(self, **kwargs): + ''' insert a level1 record into database + + parameter kwargs: + raw_id : [int] + data_type : [str] + cor_sci_id : [int] + prc_params : [str] + flat_id : [int] + dark_id : [int] + bias_id : [int] + filename : [str] + file_path : [str] + prc_status : [int] + prc_time : [str] + pipeline_id : [str] + + return csst_dfs_common.models.Result + ''' + return self.stub.write(**kwargs) + diff --git a/tests/test_common_catalog.py b/tests/test_common_catalog.py index ab870791740ac024eda15c360663fcda5ac13bfc..0d7267090adc101100a4add2bc00a6bd8e087c1a 100644 --- a/tests/test_common_catalog.py +++ b/tests/test_common_catalog.py @@ -9,6 +9,15 @@ class CommonCatalogTestCase(unittest.TestCase): def setUp(self): self.api = CatalogApi() - def test_gaia3_query(self): - result = self.api.gaia3_query(ra=160, dec=-17, radius=0.2, min_mag=-1, max_mag=-1, obstime = -1, limit = 2) + def test_catalog_query(self): + result = self.api.catalog_query( + ra=160, + dec=-17, + radius=0.2, + catalog_name='gaia3', + min_mag=-1, + max_mag=-1, + obstime = -1, + limit = 2 + ) print('return:', result) diff --git a/tests/test_facility_cal_merge.py b/tests/test_facility_cal_merge.py new file mode 100644 index 0000000000000000000000000000000000000000..b682170d6268c87a01be55044cc66dd7e89319f7 --- /dev/null +++ b/tests/test_facility_cal_merge.py @@ -0,0 +1,40 @@ +import os +import unittest +from astropy.io import fits + +from csst_dfs_api.facility.calmerge import CalMergeApi + +class CalMergeApiTestCase(unittest.TestCase): + + def setUp(self): + self.api = CalMergeApi() + + def test_find(self): + recs = self.api.find(detector_no='CCD01', + ref_type = "bias", + obs_time = ("2021-06-01 11:12:13","2021-06-08 11:12:13")) + print('find:', recs) + + def test_get(self): + rec = self.api.get(id = 3) + print('get:', rec) + + def test_update_proc_status(self): + rec = self.api.update_proc_status(id = 3, status = 1) + print('update_proc_status:', rec) + + def test_update_qc1_status(self): + rec = self.api.update_qc1_status(id = 3, status = 2) + print('update_qc1_status:', rec) + + def test_write(self): + rec = self.api.write(detector_no='CCD01', + ref_type = "bias", + obs_time = "2021-06-04 11:12:13", + exp_time = 150, + filename = "/opt/dddasd.params", + file_path = "/opt/dddasd.fits", + prc_status = 3, + prc_time = '2021-06-04 11:12:13', + level0_ids = [1,2,3,4]) + print('write:', rec) \ No newline at end of file diff --git a/tests/test_facility_detector.py b/tests/test_facility_detector.py new file mode 100644 index 0000000000000000000000000000000000000000..1be9223a45ad0bc46f0587a168e863c4a7dd2a86 --- /dev/null +++ b/tests/test_facility_detector.py @@ -0,0 +1,45 @@ +import unittest + +from csst_dfs_api.facility.detector import DetectorApi + +class DetectorApiTestCase(unittest.TestCase): + + def setUp(self): + self.api = DetectorApi() + + def test_find(self): + recs = self.api.find(module_id = 'MSC', key = 'CCD') + print('find:', recs) + + def test_get(self): + rec = self.api.get(no = 'CCD01') + print('get:', rec) + + def test_write(self): + rec = self.api.write(no = 'CCD02', + detector_name = 'CCD02', + module_id = 'MSC', + filter_id='f2') + print('write:', rec) + + def test_update(self): + rec = self.api.update(no = 'CCD01', filter_id = 'f1') + print('update:', rec) + + def test_delete(self): + rec = self.api.delete(no = 'CCD01') + print('delete:', rec) + + def test_find_status(self): + recs = self.api.find_status(detector_no = 'CCD01', + status_occur_time = ('2021-06-02','2021-06-08'), + limit = 0) + print('find status:', recs) + + def test_get_status(self): + rec = self.api.get_status(id = 2) + print('get status:', rec) + + def test_write_status(self): + rec = self.api.write_status(detector_no = 'CCD01', status = '{........}',status_time='2021-06-05 12:12:13') + print('write status:', rec) \ No newline at end of file diff --git a/tests/test_facility_level0.py b/tests/test_facility_level0.py new file mode 100644 index 0000000000000000000000000000000000000000..68208dd99bf4a490f674997acf9e7143a982b6c2 --- /dev/null +++ b/tests/test_facility_level0.py @@ -0,0 +1,38 @@ +import os +import unittest +from astropy.io import fits + +from csst_dfs_api.facility.level0 import Level0DataApi + +class Level0DataTestCase(unittest.TestCase): + + def setUp(self): + self.api = Level0DataApi() + + def test_find(self): + recs = self.api.find(obs_id = 9, obs_type = 'sci', limit = 0) + print('find:', recs) + + def test_get(self): + rec = self.api.get(fits_id = 100) + print('get:', rec) + + def test_update_proc_status(self): + rec = self.api.update_proc_status(fits_id = 100, status = 6) + print('update_proc_status:', rec) + + def test_update_qc0_status(self): + rec = self.api.update_qc0_status(fits_id = 100, status = 7) + print('update_qc0_status:', rec) + + def test_write(self): + rec = self.api.write( + obs_id = 13, + detector_no = "CCD01", + obs_type = "sci", + obs_time = "2021-06-06 11:12:13", + exp_time = 150, + detector_status_id = 3, + filename = "MSC_00001234", + file_path = "/opt/MSC_00001234.fits") + print('write:', rec) \ No newline at end of file diff --git a/tests/test_facility_level0_prc.py b/tests/test_facility_level0_prc.py new file mode 100644 index 0000000000000000000000000000000000000000..9b1fa78935d9035365f7b3dcf628714e3c90b779 --- /dev/null +++ b/tests/test_facility_level0_prc.py @@ -0,0 +1,28 @@ +import os +import unittest +from astropy.io import fits + +from csst_dfs_api.facility.level0prc import Level0PrcApi + +class Level0PrcTestCase(unittest.TestCase): + + def setUp(self): + self.api = Level0PrcApi() + + def test_find(self): + recs = self.api.find(level0_id=134) + print('find:', recs) + + def test_update_proc_status(self): + rec = self.api.update_proc_status(id = 8, status = 4) + print('update_proc_status:', rec) + + def test_write(self): + rec = self.api.write(level0_id=134, + pipeline_id = "P1", + prc_module = "QC0", + params_id = "/opt/dddasd.params", + prc_status = 3, + prc_time = '2021-06-04 11:12:13', + file_path = "/opt/dddasd.header") + print('write:', rec) \ No newline at end of file diff --git a/tests/test_facility_observation.py b/tests/test_facility_observation.py new file mode 100644 index 0000000000000000000000000000000000000000..1aa4d43cbc000892be875cb3ae8519ad19d494b8 --- /dev/null +++ b/tests/test_facility_observation.py @@ -0,0 +1,36 @@ +import os +import unittest +from astropy.io import fits + +from csst_dfs_api.facility.observation import ObservationApi + +class FacilityObservationTestCase(unittest.TestCase): + + def setUp(self): + self.api = ObservationApi() + + def test_find(self): + recs = self.api.find(module_id="MSC",limit = 0) + print('find:', recs) + + def test_get(self): + rec = self.api.get(obs_id=9) + print('get:', rec) + + def test_update_proc_status(self): + rec = self.api.update_proc_status(obs_id = 9, status = 3, ) + print('update_proc_status:', rec) + + def test_update_qc0_status(self): + rec = self.api.update_qc0_status(obs_id = 9, status = 3, ) + print('update_qc0_status:', rec) + + def test_write(self): + rec = self.api.write( + obs_time = "2021-06-06 11:12:13", + exp_time = 150, + module_id = "MSC", + obs_type = "sci", + facility_status_id = 3, + module_status_id = 3) + print('write:', rec) \ No newline at end of file diff --git a/tests/test_ifs_fits.py b/tests/test_ifs_fits.py deleted file mode 100644 index 177098a69da99d28c689f0cf538f5eae25645a59..0000000000000000000000000000000000000000 --- a/tests/test_ifs_fits.py +++ /dev/null @@ -1,56 +0,0 @@ -import os -import unittest -from astropy.io import fits - -from csst_dfs_api.ifs import FitsApi -from csst_dfs_api.common.delegate import Delegate -class IFSFitsTestCase(unittest.TestCase): - - def setUp(self): - self.api = FitsApi() - - def test_find(self): - # recs = self.api.find(file_name='CCD1_ObsTime_300_ObsNum_7.fits') - # print('find:', recs) - # assert len(recs) == 1 - - recs = self.api.find(limit=1) - print('find:', recs) - # assert len(recs) > 1 - - # 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'])) - - # 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)) - - # def test_update_proc_status(self): - # recs = self.api.find(file_name='CCD1_ObsTime_300_ObsNum_7.fits') - - # self.api.update_proc_status(fits_id=recs[0]['id'],status=1) - - # rec = self.api.get(fits_id=recs[0]['id']) - # assert rec['prc_status'] == 1 - - # def test_update_qc0_status(self): - # recs = self.api.find(file_name='CCD1_ObsTime_300_ObsNum_7.fits') - - # self.api.update_qc0_status(fits_id=recs[0]['id'],status=1) - - # rec = self.api.get(fits_id=recs[0]['id']) - # assert rec['qc0_status'] == 1 - - # def test_write(self): - # recs = self.api.write(file_path='/opt/temp/csst_ifs/CCD2_ObsTime_1200_ObsNum_40.fits') - - # recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits') - - # rec = self.api.get(fits_id=recs[0]['id']) - - # print(rec) - \ No newline at end of file diff --git a/tests/test_ifs_level1.py b/tests/test_ifs_level1.py new file mode 100644 index 0000000000000000000000000000000000000000..9d10000a26c114b447e24e4075f4680e7e04b21d --- /dev/null +++ b/tests/test_ifs_level1.py @@ -0,0 +1,45 @@ +import os +import unittest +from astropy.io import fits + +from csst_dfs_api.ifs.level1 import Level1DataApi + +class IFSLevel1DataTestCase(unittest.TestCase): + + def setUp(self): + self.api = Level1DataApi() + + def test_find(self): + recs = self.api.find(raw_id=1, + create_time = ("2021-06-01 11:12:13","2021-06-08 11:12:13")) + print('find:', 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(raw_id=12, + data_type = "sci", + cor_sci_id = 2, + prc_params = "/opt/dddasd.params", + flat_id = 1, + dark_id = 2, + bias_id = 3, + lamp_id = 4, + arc_id = 5, + sky_id = 6, + prc_status = 3, + prc_time = '2021-06-05 11:12:13', + filename = "dddasd", + file_path = "/opt/dddasd.fits", + pipeline_id = "P2") + print('write:', rec) \ No newline at end of file diff --git a/tests/test_ifs_refs.py b/tests/test_ifs_refs.py deleted file mode 100644 index 36d2ea01964e91375d871c6a8fdfecfac99f23d0..0000000000000000000000000000000000000000 --- a/tests/test_ifs_refs.py +++ /dev/null @@ -1,43 +0,0 @@ -import os -import unittest -from astropy.io import fits - -from csst_dfs_api.ifs import RefFitsApi - -class IFSFitsTestCase(unittest.TestCase): - - def setUp(self): - self.api = RefFitsApi() - - def test_find(self): - recs = self.api.find(exp_time=('2021-03-24 10:14:56', '2021-03-24 10:15:56'), ref_type=RefFitsApi.REF_FITS_FLAT) - print('find:', recs) - # assert len(recs) > 1 - - # recs = self.api.find() - # print('=' * 80) - # print('find:', recs) - # assert len(recs) > 1 - - # def test_read(self): - # recs = self.api.find(file_name='CCD2_Flat_img.fits') - # print("The full path: ", os.path.join(self.api.file_prefix, recs[0]['file_path'])) - - # 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)) - - # def test_update_status(self): - # recs = self.api.find(file_name='CCD2_Flat_img.fits') - # self.api.update_status(fits_id=recs[0]['id'],status=1) - # rec = self.api.get(fits_id=recs[0]['id']) - # assert rec['status'] == 1 - - # def test_write(self): - # recs = self.api.write(file_path='/opt/temp/csst_ifs/CCD3_Flat_img.fits') - # recs = self.api.find(file_name='CCD3_Flat_img.fits') - # rec = self.api.get(fits_id=recs[0]['id']) - # print(rec) diff --git a/tests/test_ifs_result0.py b/tests/test_ifs_result0.py deleted file mode 100644 index 10c95b03bc06ebe1bf8ffa086a472f909a862c73..0000000000000000000000000000000000000000 --- a/tests/test_ifs_result0.py +++ /dev/null @@ -1,40 +0,0 @@ -import os -import unittest -from astropy.io import fits - -from csst_dfs_api.ifs import Result0Api - -class IFSResult0TestCase(unittest.TestCase): - - def setUp(self): - self.api = Result0Api() - - def test_find(self): - recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits') - print('find:', recs) - - recs = self.api.find() - print('find:', recs) - - def test_read(self): - recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits') - print("The full path: ", os.path.join(self.api.file_prefix, recs[0]['file_path'])) - - 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)) - - def test_write(self): - self.api.write(raw_id = 1, - file_path='/opt/temp/csst_ifs/CCD2_ObsTime_1200_ObsNum_40.fits', - proc_type = 'default') - - recs = self.api.find(raw_id=1) - print() - print(recs) - print("="*80) - recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits') - print(recs) diff --git a/tests/test_ifs_result1.py b/tests/test_ifs_result1.py deleted file mode 100644 index 5b536f9a7fd3ff8856ff566cd409eee220ef3745..0000000000000000000000000000000000000000 --- a/tests/test_ifs_result1.py +++ /dev/null @@ -1,42 +0,0 @@ -import os -import unittest -from astropy.io import fits - -from csst_dfs_api.ifs import Result1Api - -class IFSResult1TestCase(unittest.TestCase): - - def setUp(self): - self.api = Result1Api() - - def test_find(self): - recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits') - print('find:', recs) - - recs = self.api.find() - print('find:', recs) - - def test_read(self): - recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits') - print("The full path: ", os.path.join(self.api.file_prefix, recs[0]['file_path'])) - - rec, result0s = self.api.get(fits_id=recs[0]['id']) - print(result0s) - file_segments = self.api.read(file_path=rec['file_path']) - file_bytes = b''.join(file_segments) - hdul = fits.HDUList.fromstring(file_bytes) - print(hdul.info()) - hdr = hdul[0].header - print(repr(hdr)) - - def test_write(self): - self.api.write(result0_ids = [1,2,3,4], - file_path='/opt/temp/csst_ifs/CCD2_ObsTime_1200_ObsNum_40.fits', - proc_type = 'default') - - recs = self.api.find(raw_id=1) - print() - print(recs) - print("="*80) - recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits') - print(recs) diff --git a/tests/test_msc_level1.py b/tests/test_msc_level1.py new file mode 100644 index 0000000000000000000000000000000000000000..e5a7b8828b7060d5344b881033e32ef028ee85c8 --- /dev/null +++ b/tests/test_msc_level1.py @@ -0,0 +1,42 @@ +import os +import unittest +from astropy.io import fits + +from csst_dfs_api.msc.level1 import Level1DataApi + +class MSCLevel1DataTestCase(unittest.TestCase): + + def setUp(self): + self.api = Level1DataApi() + + def test_find(self): + recs = self.api.find(raw_id=1, + create_time = ("2021-06-01 11:12:13","2021-06-08 11:12:13")) + print('find:', 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(raw_id=1, + data_type = "sci", + cor_sci_id = 1, + prc_params = "/opt/dddasd.params", + flat_id = 1, + dark_id = 2, + bias_id = 3, + prc_status = 3, + prc_time = '2021-06-04 11:12:13', + filename = "dddasd", + file_path = "/opt/dddasd.fits", + pipeline_id = "P1") + print('write:', rec) \ No newline at end of file