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
Bo Zhang
csst
Commits
8be103c9
Commit
8be103c9
authored
Mar 02, 2022
by
BO ZHANG
🏀
Browse files
removed factory.py
parent
40316fdb
Changes
4
Show whitespace changes
Inline
Side-by-side
csst/common/data.py
View file @
8be103c9
...
@@ -23,7 +23,7 @@ class CsstData:
...
@@ -23,7 +23,7 @@ class CsstData:
_auxdata
=
OrderedDict
()
_auxdata
=
OrderedDict
()
def
__init__
(
self
,
primaryHDU
,
imgHDU
,
instrument
=
None
,
detector
=
None
):
def
__init__
(
self
,
primaryHDU
,
imgHDU
,
instrument
=
None
,
detector
=
None
):
print
(
'create CsstData'
)
#
print('create CsstData')
self
.
_primary_hdu
=
primaryHDU
self
.
_primary_hdu
=
primaryHDU
self
.
_l0data
=
imgHDU
self
.
_l0data
=
imgHDU
self
.
instrument
=
instrument
self
.
instrument
=
instrument
...
@@ -60,7 +60,7 @@ class CsstData:
...
@@ -60,7 +60,7 @@ class CsstData:
raise
CsstException
raise
CsstException
def
set_l1keyword
(
self
,
key
,
value
):
def
set_l1keyword
(
self
,
key
,
value
):
print
(
'check out whether '
+
key
+
" is a valid key and "
+
value
+
" is valid value"
)
raise
NotImplementedError
(
'check out whether '
+
key
+
" is a valid key and "
+
value
+
" is valid value"
)
def
set_l1data
(
self
,
img
):
def
set_l1data
(
self
,
img
):
print
(
'save image data to l2data'
)
print
(
'save image data to l2data'
)
...
@@ -83,3 +83,7 @@ class CsstData:
...
@@ -83,3 +83,7 @@ class CsstData:
hdulist
.
writeto
(
filename
)
hdulist
.
writeto
(
filename
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
print
(
e
)
def
read
(
self
,
**
kwargs
):
""" read data from fits file """
raise
NotImplementedError
csst/msc/__init__.py
View file @
8be103c9
from
.data
import
CsstMscData
,
CsstMscImgData
\ No newline at end of file
csst/msc/
msc
data.py
→
csst/msc/data.py
View file @
8be103c9
...
@@ -2,7 +2,7 @@ from collections import OrderedDict
...
@@ -2,7 +2,7 @@ from collections import OrderedDict
import
astropy.io.fits
as
fits
import
astropy.io.fits
as
fits
from
astropy.io.fits
import
HDUList
,
PrimaryHDU
,
ImageHDU
from
astropy.io.fits
import
HDUList
,
PrimaryHDU
,
ImageHDU
from
astropy.io.fits.header
import
Header
from
astropy.io.fits.header
import
Header
from
..common.data
import
CsstData
from
..common.data
import
CsstData
,
INSTRUMENT_LIST
__all__
=
[
"CsstMscData"
,
"CsstMscImgData"
]
__all__
=
[
"CsstMscData"
,
"CsstMscImgData"
]
...
@@ -81,12 +81,39 @@ class CsstMscData(CsstData):
...
@@ -81,12 +81,39 @@ class CsstMscData(CsstData):
class
CsstMscImgData
(
CsstMscData
):
class
CsstMscImgData
(
CsstMscData
):
def
__init__
(
self
,
primaryHDU
,
imgHDU
,
**
kwargs
):
def
__init__
(
self
,
primaryHDU
,
imgHDU
,
**
kwargs
):
print
(
'create CsstMscImgData'
)
#
print('create CsstMscImgData')
super
(
CsstMscData
,
self
).
__init__
(
primaryHDU
,
imgHDU
,
**
kwargs
)
super
(
CsstMscData
,
self
).
__init__
(
primaryHDU
,
imgHDU
,
**
kwargs
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
"<CsstMscImgData: {} {}>"
.
format
(
self
.
instrument
,
self
.
detector
)
return
"<CsstMscImgData: {} {}>"
.
format
(
self
.
instrument
,
self
.
detector
)
@
staticmethod
def
read
(
fitsfilename
):
""" create CSST Data instances
Parameters
----------
fitsfilename:
the file name of fits files
Returns
-------
"""
try
:
hl
=
fits
.
open
(
fitsfilename
)
instrument
=
hl
[
0
].
header
.
get
(
'INSTRUME'
)
# strip or not?
detector
=
hl
[
0
].
header
.
get
(
'DETECTOR'
)
# strip or not?
print
(
"@CsstMscImgData: reading data {} ..."
.
format
(
fitsfilename
))
assert
instrument
in
INSTRUMENT_LIST
if
instrument
==
'MSC'
and
6
<=
int
(
detector
[
3
:
5
])
<=
25
:
# multi-band imaging
data
=
CsstMscImgData
(
hl
[
0
],
hl
[
1
],
instrument
=
instrument
,
detector
=
detector
)
return
data
except
Exception
as
e
:
print
(
e
)
# def test():
# def test():
# fp = MSC_MS_210527171000_100000279_16_raw.fits
# fp = MSC_MS_210527171000_100000279_16_raw.fits
...
...
csst/msc/instrument.py
View file @
8be103c9
from
collections
import
OrderedDict
from
collections
import
OrderedDict
from
abc
import
ABCMeta
,
abstractmethod
from
abc
import
ABCMeta
,
abstractmethod
from
csst.common.data
import
CsstData
from
enum
import
Enum
from
enum
import
Enum
import
numpy
as
np
import
numpy
as
np
from
..common.processors
import
CsstProcStatus
,
CsstProcessor
from
..common.processors
import
CsstProcStatus
,
CsstProcessor
...
...
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