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
1d1cb6d7
Commit
1d1cb6d7
authored
Aug 23, 2022
by
BO ZHANG
🏀
Browse files
major updates
parent
e696cd97
Changes
8
Hide whitespace changes
Inline
Side-by-side
csst_proto/__init__.py
View file @
1d1cb6d7
import
os
from
.top_level_interface
import
*
__version__
=
"0.0.1"
PACKAGE_PATH
=
os
.
path
.
dirname
(
__file__
)
csst_proto/data/data.csv
0 → 100644
View file @
1d1cb6d7
a, b, c
1,2,3
4,5,6
\ No newline at end of file
csst_proto/flip_image.py
View file @
1d1cb6d7
import
numpy
as
np
from
astropy
import
table
from
.
import
PACKAGE_PATH
# the main algorithm
def
flip_image
(
img
:
np
.
ndarray
):
""" flip an input image
This function uses an awesome algorithm to flip an input image.
Parameters
----------
img:
the input image
Returns
-------
the flipped image
"""
try
:
assert
img
.
ndim
==
2
except
AssertionError
:
raise
AssertionError
(
"The input image is {}D not 2D!"
.
format
(
img
.
ndim
))
return
img
[::
-
1
,
::
-
1
]
# a demo on how to package data
def
print_data
():
""" print out data """
fp_data
=
PACKAGE_PATH
+
"/data/data.csv"
data
=
table
.
Table
.
read
(
fp_data
)
print
(
data
)
return
csst_proto/
data/your_data.txt
→
csst_proto/
some_other_modules.py
View file @
1d1cb6d7
File moved
csst_proto/top_level_interface.py
0 → 100644
View file @
1d1cb6d7
from
.flip_image
import
flip_image
,
print_data
__all__
=
[
"flip_image"
,
"print_data"
]
demo/__init__.py
deleted
100644 → 0
View file @
e696cd97
demo/demo_processor
.py
→
examples/how_this_code_will_be_used
.py
View file @
1d1cb6d7
import
joblib
from
astropy.io
import
fits
from
csst.core.processor
import
CsstProcessor
from
csst.msc.data_manager
import
CsstMscDataManager
from
csst_proto
import
flip_image
class
CsstProc
PhotonAbsorption
(
CsstProcessor
):
class
CsstProc
FlipImage
(
CsstProcessor
):
""" This processor absorbs photons """
def
__init__
(
self
,
dm
:
CsstMscDataManager
,
n_jobs
:
int
=
1
):
super
(
CsstProc
PhotonAbsorption
,
self
).
__init__
()
super
(
CsstProc
FlipImage
,
self
).
__init__
()
self
.
dm
=
dm
self
.
n_jobs
=
n_jobs
def
run
(
self
,
debug
=
False
):
def
run
(
self
,
debug
:
bool
=
False
):
""" run this processor
Parameters
----------
debug
debug
:
if True, use debug mode
Returns
-------
"""
joblib
.
Parallel
(
n_jobs
=
self
.
n_jobs
)(
joblib
.
delayed
(
CsstProc
PhotonAbsorption
.
run_one_chip
)(
this_ccd_id
)
img_flipped_list
=
joblib
.
Parallel
(
n_jobs
=
self
.
n_jobs
)(
joblib
.
delayed
(
CsstProc
FlipImage
.
run_one_chip
)(
this_ccd_id
)
for
this_ccd_id
in
self
.
dm
.
target_ccd_ids
)
return
return
img_flipped_list
def
prepare
(
self
,
**
kwargs
):
""" prepare the environment """
...
...
@@ -38,6 +40,14 @@ class CsstProcPhotonAbsorption(CsstProcessor):
return
@
staticmethod
def
run_one_chip
(
ccd_id
):
""" run for one chip """
return
def
run_one_chip
(
dm
,
ccd_id
):
""" run for one chip
this function
"""
# 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
demo/demo
_docstring.py
→
examples/how_to_write
_docstring.py
View file @
1d1cb6d7
import
numpy
as
np
#
this
function
need
to be finished
#
a
function to be finished
def
cos_to_be_finished
(
x
):
# TODO: to be finished
return
...
...
@@ -28,5 +28,3 @@ def cos(x: float = 0.):
"""
return
np
.
cos
(
x
)
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