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
430584ea
Commit
430584ea
authored
Oct 28, 2023
by
BO ZHANG
🏀
Browse files
tweaks
parent
9fea0933
Pipeline
#1424
failed with stage
in 0 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
csst_proto/__init__.py
View file @
430584ea
from
.flip_image
import
flip_image
,
read_default_image
from
.demo
import
demo_function
,
DemoClass
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"
__version__
=
"0.0.1"
__all__
=
[
__all__
=
[
"flip_image"
,
"read_default_image"
,
"demo_function"
,
"demo_function"
,
"DemoClass"
,
"DemoClass"
,
"flip_image"
,
"read_default_image"
,
"flip_multiple_images_jl"
,
"flip_multiple_images_mp"
,
"read_config"
,
]
]
csst_proto/api.py
deleted
100644 → 0
View file @
9fea0933
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"
]
examples/how_this_code_will_be_used.py
deleted
100644 → 0
View file @
9fea0933
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
examples/how_to_write_docstring.py
deleted
100644 → 0
View file @
9fea0933
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
)
tests/test_demos.py
deleted
100644 → 0
View file @
9fea0933
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
)
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