diff --git a/docs/source/c8_changes.rst b/docs/source/c8_changes.rst index 54a31d96c52ee922ec4fc8af46e89daedab417e3..22bc49bbee9b1ec614dbf6482ac35a7597d8ecae 100644 --- a/docs/source/c8_changes.rst +++ b/docs/source/c8_changes.rst @@ -28,19 +28,54 @@ Change list .. code-block:: python + import os.path + + import numpy as np + from astropy.io import fits + from astropy import table from csst_common.status import CsstStatus, CsstResult - def base_distortion(input_file, output_file, rc="/path/to/gaia_dr3.fits", **kwargs): -> CsstResult: - """ your docstring here """ - # do your calculation - process(input_file, output_fle) + + def read_data(file_path: str = "/path/to/data") -> np.ndarray: + return fits.getdata(file_path) + + + def _do_step_one(data: np.ndarray) -> np.ndarray: + reduced_data = np.fliplr(data) + return reduced_data + + + def _do_step_two(data: np.ndarray) -> np.ndarray: + reduced_data = np.flipud(data) + return reduced_data + + + def _do_step_three(data: np.ndarray, rc="/path/to/catalog") -> np.ndarray: + trc = table.Table.read(rc) + return data + np.mean(trc["ra"]) + np.mean(trc["dec"]) + + + def base_distortion( + input_file, output_file, rc: str = "/path/to/gaia_dr3.fits", **kwargs + ) -> CsstResult: + """your docstring here""" + # read data + data = read_data(input_file) + # do your algorithm + data = _do_step_one(data) + data = _do_step_two(data) + data = _do_step_three(data, rc=rc) + # write results + hl = fits.HDUList(fits.PrimaryHDU(data=data)) + hl.writeto(output_file, overwrite=True) + assert os.path.exists(output_file) # construct CsstResult result = CsstResult( - status=CsstStatus.PERFECT, - file_list=[output_file, "an additional output file"] + status=CsstStatus.PERFECT, file_list=[output_file, "an additional output file"] ) return result + 导入模块 ---------