Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-pipeline
csst_proto
Commits
3ca6e260
Commit
3ca6e260
authored
Sep 14, 2023
by
BO ZHANG
🏀
Browse files
update example API
parent
37b1bc15
Pipeline
#1205
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
docs/source/c8_changes.rst
View file @
3ca6e260
...
...
@@ -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
导入模块
---------
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment