Commit 9fea0933 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

major updates

parent 99a15c89
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -2,5 +2,4 @@
omit =
    tests/*
    setup.py
    csst_proto/api.py
    test_codestyle.py

Makefile

0 → 100644
+6 −0
Original line number Diff line number Diff line
install:
	pip install .
	rm -rf build csst_proto.egg-info

uninstall:
	pip uninstall csst_proto -y
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ from astropy.io import fits
# read an L0 image
img = fits.getdata("CSST_MS_SCI_06_L0_img.fits")
# flip the image
img_flipped = flip_image(img=img)
img_flipped = flip_image(image=img)
```

## algorithm description
+8 −2
Original line number Diff line number Diff line
import os
from .flip_image import flip_image, read_default_image
from .demo import demo_function, DemoClass

__version__ = "0.0.1"

PACKAGE_PATH = os.path.dirname(__file__)
__all__ = [
    "flip_image",
    "read_default_image",
    "demo_function",
    "DemoClass",
]

csst_proto/config.py

0 → 100644
+49 −0
Original line number Diff line number Diff line
"""
Identifier:     csst_proto/demo.py
Name:           demo.py
Description:    这个文件包括了一个演示函数和演示类
Author:         Bo Zhang
Created:        2023-10-26
Modified-History:
    2023-10-26, Bo Zhang, add module header
    2023-10-28,
"""

import toml
import os
import pathlib
from typing import Optional

# 如何找到当前.py文件所在的文件夹绝对路径?
# 方法1: 使用 pathlib
# HERE: pathlib.Path = pathlib.Path(__file__).parent.resolve()
# 方法2: 使用 os
HERE: str = os.path.dirname(__file__)


# 这个函数演示了如何利用随包数据
# 当config_path被指定时,会读取指定的config_path
# 当config_path=None时,读取随包数据中的config/default_config.toml
def read_config(config_path: Optional[str] = None):
    """Get config info from a toml file.

    Read a `toml` format config file.
    If `config_path` is specified, read that config.
    Otherwise, read the default config in `config/default_config.toml`.

    Parameters
    ----------
    config_path : Optional[str]
        The config file path.

    Returns
    -------
    dict
        The configuration dictionary.
    """
    # if config_path is specified, use it, otherwise use the default
    if config_path is None:
        config_path: str = os.path.join(HERE, "config", "default_config.toml")
    # read the config file
    config: dict = toml.load(config_path)
    return config
Loading