From 430584ea341dac0f27f9042a88e3e7feacd52522 Mon Sep 17 00:00:00 2001 From: BO ZHANG Date: Sat, 28 Oct 2023 11:34:27 +0800 Subject: [PATCH] tweaks --- csst_proto/__init__.py | 11 ++-- csst_proto/api.py | 4 -- examples/how_this_code_will_be_used.py | 71 -------------------------- examples/how_to_write_docstring.py | 43 ---------------- tests/test_demos.py | 12 ----- 5 files changed, 8 insertions(+), 133 deletions(-) delete mode 100644 csst_proto/api.py delete mode 100644 examples/how_this_code_will_be_used.py delete mode 100644 examples/how_to_write_docstring.py delete mode 100644 tests/test_demos.py diff --git a/csst_proto/__init__.py b/csst_proto/__init__.py index 05e62ff..fc76991 100644 --- a/csst_proto/__init__.py +++ b/csst_proto/__init__.py @@ -1,11 +1,16 @@ -from .flip_image import flip_image, read_default_image from .demo import demo_function, DemoClass +from .flip_image import flip_image, read_default_image +from .flip_image_in_parallel import flip_multiple_images_jl, flip_multiple_images_mp +from .config import read_config __version__ = "0.0.1" __all__ = [ - "flip_image", - "read_default_image", "demo_function", "DemoClass", + "flip_image", + "read_default_image", + "flip_multiple_images_jl", + "flip_multiple_images_mp", + "read_config", ] diff --git a/csst_proto/api.py b/csst_proto/api.py deleted file mode 100644 index 127ae1b..0000000 --- a/csst_proto/api.py +++ /dev/null @@ -1,4 +0,0 @@ -from .flip_image import flip_image, read_test_image -from .demo import a_demo_function, ADemoClass - -__all__ = ["flip_image", "read_test_image", "a_demo_function", "ADemoClass"] diff --git a/examples/how_this_code_will_be_used.py b/examples/how_this_code_will_be_used.py deleted file mode 100644 index aa36477..0000000 --- a/examples/how_this_code_will_be_used.py +++ /dev/null @@ -1,71 +0,0 @@ -import joblib -from astropy.io import fits -from csst.core.processor import CsstProcessor -from csst.msc.data_manager import CsstMscDataManager - -from csst_proto.api import flip_image - - -class CsstProcFlipImage(CsstProcessor): - """ This processor flips images """ - - def __init__(self, dm: CsstMscDataManager, n_jobs: int = 1): - """ - - Parameters - ---------- - dm: - csst data manager, used to manage the input/output file paths - n_jobs: - number of jobs launched - """ - super(CsstProcFlipImage, self).__init__() - self.dm = dm - self.n_jobs = n_jobs - - def run(self, debug: bool = False): - """ flip images for all detectors - - Parameters - ---------- - debug: - if True, use debug mode - - Returns - ------- - a list of flipped images - """ - img_flipped_list = joblib.Parallel(n_jobs=self.n_jobs)( - joblib.delayed(CsstProcFlipImage.run_one_detector)(this_ccd_id) - for this_ccd_id in self.dm.target_ccd_ids) - return img_flipped_list - - def prepare(self, **kwargs): - """ prepare the environment """ - return - - def cleanup(self): - """ clean up the environment """ - return - - @staticmethod - def run_one_detector(dm: CsstMscDataManager, ccd_id: int = 6): - """ run for one detector - - Parameters - ---------- - dm: - csst data manager, used to manage the input/output file paths - ccd_id: - detector id - - Returns - ------- - the flipped image - """ - # input file path - fp_input = dm.l1_ccd(ccd_id, post="img.fits") - img_input = fits.getdata(fp_input) - # flip image - img_flipped = flip_image(img_input) - return img_flipped diff --git a/examples/how_to_write_docstring.py b/examples/how_to_write_docstring.py deleted file mode 100644 index 8f75b66..0000000 --- a/examples/how_to_write_docstring.py +++ /dev/null @@ -1,43 +0,0 @@ -import numpy as np - - -# a function to be finished -def cos_to_be_finished(x): - # TODO: to be finished - return - - -# a function with a simple docstring -def _cos(x): - """ this is a cosine function """ - return np.cos(x) - - -# a function with a complete docstring -def cos(x: float = 0.) -> float: - """ cosine function - - Parameters - ---------- - x : float - x values - - Returns - ------- - cos(x) : float - - Examples - -------- - >>> import numpy as np - >>> cos(np.pi) - - Notes - ----- - this function is a warpper of `numpy.cos()` - - Conf - ---- - https://numpydoc.readthedocs.io/en/latest/example.html#example - - """ - return np.cos(x) diff --git a/tests/test_demos.py b/tests/test_demos.py deleted file mode 100644 index c39651d..0000000 --- a/tests/test_demos.py +++ /dev/null @@ -1,12 +0,0 @@ -import unittest - -from csst_proto.api import a_demo_function - - -class TestCaseDemoFunction(unittest.TestCase): - """ test demo function """ - def test_demo_function(self): - # flip test image - self.assertTrue( - a_demo_function(None) == 1 - ) -- GitLab