Commit 8be103c9 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

removed factory.py

parent 40316fdb
......@@ -23,7 +23,7 @@ class CsstData:
_auxdata = OrderedDict()
def __init__(self, primaryHDU, imgHDU, instrument=None, detector=None):
print('create CsstData')
# print('create CsstData')
self._primary_hdu = primaryHDU
self._l0data = imgHDU
self.instrument = instrument
......@@ -60,7 +60,7 @@ class CsstData:
raise CsstException
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):
print('save image data to l2data')
......@@ -83,3 +83,7 @@ class CsstData:
hdulist.writeto(filename)
except Exception as e:
print(e)
def read(self, **kwargs):
""" read data from fits file """
raise NotImplementedError
from .data import CsstMscData, CsstMscImgData
\ No newline at end of file
......@@ -2,7 +2,7 @@ from collections import OrderedDict
import astropy.io.fits as fits
from astropy.io.fits import HDUList, PrimaryHDU, ImageHDU
from astropy.io.fits.header import Header
from ..common.data import CsstData
from ..common.data import CsstData, INSTRUMENT_LIST
__all__ = ["CsstMscData", "CsstMscImgData"]
......@@ -81,12 +81,39 @@ class CsstMscData(CsstData):
class CsstMscImgData(CsstMscData):
def __init__(self, primaryHDU, imgHDU, **kwargs):
print('create CsstMscImgData')
# print('create CsstMscImgData')
super(CsstMscData, self).__init__(primaryHDU, imgHDU, **kwargs)
def __repr__(self):
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():
# fp = MSC_MS_210527171000_100000279_16_raw.fits
......
from collections import OrderedDict
from abc import ABCMeta, abstractmethod
from csst.common.data import CsstData
from enum import Enum
import numpy as np
from ..common.processors import CsstProcStatus, CsstProcessor
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment