Commit 1a81229e authored by Yi Hu's avatar Yi Hu
Browse files

修改: README.md

	修改:     crmask.py
                   修改注释格式,sphinx生成文档不报警
parent b5906fa8
...@@ -60,4 +60,4 @@ If you would like use the native training model of deepCR, which are obtained fr ...@@ -60,4 +60,4 @@ If you would like use the native training model of deepCR, which are obtained fr
# Bugs # Bugs
Please contact **_HU Yi_** (huyi.naoc@gmail.com) to report bugs. Bugs can be reported and filed at https://csst-tb.bao.ac.cn/code/huyi/csst-commom-crmask/-/issues. Alternatively, you can contact **_HU Yi_** (huyi.naoc@gmail.com) to report bugs.
...@@ -23,51 +23,51 @@ from astropy.nddata import CCDData ...@@ -23,51 +23,51 @@ from astropy.nddata import CCDData
from pathlib import Path from pathlib import Path
import ccdproc import ccdproc
import datetime import datetime
import sys import sys
__all__ = ['CRMask'] __all__ = ['CRMask']
class CRMask: class CRMask:
def __init__(self, obj, flag = None, mask = None, clean = None, sky = None, save_flag = True, update_flag = True, save_name = None, flag_suffix = 'flg', clean_suffix = 'crclean', append_flag = False, mask_suffix = 'crmask', model = 'deepCR', fill_flag = True, fill_method = 'inpainting', gpu_flag = False, config_path = 'crmask.ini', **kwargs): def __init__(self, obj, flag = None, mask = None, clean = None, sky = None, save_flag = True, update_flag = True, save_name = None, flag_suffix = 'flg', clean_suffix = 'crclean', append_flag = False, mask_suffix = 'crmask', model = 'deepCR', fill_flag = True, fill_method = 'inpainting', gpu_flag = False, config_path = 'crmask.ini', **kwargs):
""" """
Instantiation of CRMask with specified model configuration. Instantiation of CRMask with specified model configuration.
Parameters
---------- Parameters
obj : string, Path, astropy.io.fits.HDUList, numpy.ndarray, astropy.nddata.CCDData or list of string __________
if model is ``deepCR``, ``lacosmic``, obj is input image to be cosmic-ray masked
if model is ``deepCR_train``, obj is input training and validating images obj : string, Path, astropy.io.fits.HDUList, numpy.ndarray, astropy.nddata.CCDData or list of string
flag : (optional) string, Path, astropy.io.fits.HDUList, numpy.ndarray or astropy.nddata.CCDData if model is ``deepCR``, ``lacosmic``, obj is input image to be cosmic-ray masked, if model is ``deepCR_train``, obj is input training and validating images
flag image(s), default is None flag : (optional) string, Path, astropy.io.fits.HDUList, numpy.ndarray or astropy.nddata.CCDData
mask : (optional) string or list of string flag image(s), default is None
mask image(s), default is None, necessary when model is ``deepCR_train`` or ``benchmark``, otherwise, let it alone mask : (optional) string or list of string
sky : (optional) string or list of string mask image(s), default is None, necessary when model is ``deepCR_train`` or ``benchmark``, otherwise, let it alone
sky image(s), default is None, optional when model is ``deepCR_train``, otherwise, let it alone sky : (optional) string or list of string
save_flag : (optional) boolean sky image(s), default is None, optional when model is ``deepCR_train``, otherwise, let it alone
whether save CR mask (and cleaned) image, default is True save_flag : (optional) boolean
update_flag : (optional) boolean whether save CR mask (and cleaned) image, default is True
whether update flag image, default is True update_flag : (optional) boolean
save_name : (optional) string whether update flag image, default is True
output mask, cleaned and flag filename. default is None. If save_name is None, use the filename as the input. And if save_flag is True, save_name is None, and obj is a numpy.ndarray or a astropy.nddata.CCDData, cr_mask will raise a ValueError exception save_name : (optional) string
flag_suffix : (optional) string output mask, cleaned and flag filename. default is None. If save_name is None, use the filename as the input. And if save_flag is True, save_name is None, and obj is a numpy.ndarray or a astropy.nddata.CCDData, cr_mask will raise a ValueError exception
suffix name of flag file, if flag is a numpy.ndarray or a astropy.nddata.CCDData, default is ``flg`` flag_suffix : (optional) string
mask_suffix : (optional) string suffix name of flag file, if flag is a numpy.ndarray or a astropy.nddata.CCDData, default is ``flg``
suffix name of mask file, default is ``crmask`` mask_suffix : (optional) string
clean_suffix : (optional) string suffix name of mask file, default is ``crmask``
suffix name of cleaned file, default is ``crclean`` clean_suffix : (optional) string
model : (optional) string suffix name of cleaned file, default is ``crclean``
model type, can be ``deepCR``, ``lacosmic``, ``deepCR_train`` or ``benchmark`` default is ``deepCR`` model : (optional) string
fill_flag : (optional) boolean model type, can be ``deepCR``, ``lacosmic``, ``deepCR_train`` or ``benchmark`` default is ``deepCR``
whehter generate cleaned image, default is True fill_flag : (optional) boolean
fill_method : (optional) string whehter generate cleaned image, default is True
fill method for CR contaminated pixel, can be ``inpainting``, ``meanmask``, ``meanmed``, default is ``inpainting`` fill_method : (optional) string
gpu_flag : (optional) boolean fill method for CR contaminated pixel, can be ``inpainting``, ``meanmask``, ``meanmed``, default is ``inpainting``
whether use GPU, default is False gpu_flag : (optional) boolean
config_path : (optional) string whether use GPU, default is False
configuration file path, default is ``./crmask.ini`` config_path : (optional) string
configuration file path, default is ``./crmask.ini``
""" """
self.model = model self.model = model
if model == 'deepCR_train': if model == 'deepCR_train':
self.image_sets = obj self.image_sets = obj
...@@ -440,18 +440,19 @@ class CRMask: ...@@ -440,18 +440,19 @@ class CRMask:
def cr_mask(self): def cr_mask(self):
""" """
Cosmic ray detection and mask. Cosmic ray detection and mask.
Returns Returns
------- -------
masked : numpy.ndarray masked : numpy.ndarray
cosmic ray masked image. cosmic ray masked image.
cleaned : numpy.ndarray, optional cleaned : numpy.ndarray, optional
Only returned if `fill_flag` is True Only returned if `fill_flag` is True
cosmic ray cleaned image. cosmic ray cleaned image.
Examples
------- Examples
--------
>>> from crmask import CRMask >>> from crmask import CRMask
>>> crobj = CRMask('xxxx.fits', 'deepCR') >>> crobj = CRMask('xxxx.fits', 'deepCR')
>>> crobj.cr_mask() >>> crobj.cr_mask()
...@@ -710,21 +711,44 @@ class CRMask: ...@@ -710,21 +711,44 @@ class CRMask:
def cr_train(self): def cr_train(self):
""" """
Training models, only support ``deepCR_train``. It will generate pytorch's *.pth file. Training models, only support ``deepCR_train``. It will generate pytorch's \*.pth file. The train is very painful and time consuming, do NOT use it in pipelines.
The train is very painful and time consuming, do NOT use it in pipelines.
Returns Returns
------- -------
No returns No returns
Examples Examples
------- --------
>>> from crmask import CRMask >>> from crmask import CRMask
>>> imglist = ['MSC_MS_210525170000_100000010_23_sci.fits', 'MSC_MS_210525171000_100000011_23_sci.fits', 'MSC_MS_210525172000_100000012_23_sci.fits', 'MSC_MS_210525173000_100000013_23_sci.fits', 'MSC_MS_210525174000_100000014_23_sci.fits', 'MSC_MS_210525175000_100000015_23_sci.fits', 'MSC_MS_210525180000_100000016_23_sci.fits', 'MSC_MS_210525181000_100000017_23_sci.fits', 'MSC_MS_210525182000_100000018_23_sci.fits', 'MSC_MS_210525183000_100000019_23_sci.fits'] >>> imglist = [
>>> masklist = ['MSC_CRM_210525170000_100000010_23_raw.fits', 'MSC_CRM_210525171000_100000011_23_raw.fits', 'MSC_CRM_210525172000_100000012_23_raw.fits', 'MSC_CRM_210525173000_100000013_23_raw.fits', 'MSC_CRM_210525174000_100000014_23_raw.fits', 'MSC_CRM_210525175000_100000015_23_raw.fits', 'MSC_CRM_210525180000_100000016_23_raw.fits', 'MSC_CRM_210525181000_100000017_23_raw.fits', 'MSC_CRM_210525182000_100000018_23_raw.fits', 'MSC_CRM_210525183000_100000019_23_raw.fits'] >>> 'MSC_MS_210525170000_100000010_23_sci.fits',
>>> trainobj = CRMask(imglist, mask = masklist, model = 'deepCR_train') >>> 'MSC_MS_210525171000_100000011_23_sci.fits',
>>> 'MSC_MS_210525172000_100000012_23_sci.fits',
>>> 'MSC_MS_210525173000_100000013_23_sci.fits',
>>> 'MSC_MS_210525174000_100000014_23_sci.fits',
>>> 'MSC_MS_210525175000_100000015_23_sci.fits',
>>> 'MSC_MS_210525180000_100000016_23_sci.fits',
>>> 'MSC_MS_210525181000_100000017_23_sci.fits',
>>> 'MSC_MS_210525182000_100000018_23_sci.fits',
>>> 'MSC_MS_210525183000_100000019_23_sci.fits'
>>> ]
>>> masklist = [
>>> 'MSC_CRM_210525170000_100000010_23_raw.fits',
>>> 'MSC_CRM_210525171000_100000011_23_raw.fits',
>>> 'MSC_CRM_210525172000_100000012_23_raw.fits',
>>> 'MSC_CRM_210525173000_100000013_23_raw.fits',
>>> 'MSC_CRM_210525174000_100000014_23_raw.fits',
>>> 'MSC_CRM_210525175000_100000015_23_raw.fits',
>>> 'MSC_CRM_210525180000_100000016_23_raw.fits',
>>> 'MSC_CRM_210525181000_100000017_23_raw.fits',
>>> 'MSC_CRM_210525182000_100000018_23_raw.fits',
>>> 'MSC_CRM_210525183000_100000019_23_raw.fits'
>>> ]
>>> trainobj = CRMask(imglist, mask = masklist,
>>> model = 'deepCR_train')
>>> trainobj.cr_train() >>> trainobj.cr_train()
""" """
if self.model == 'deepCR_train': if self.model == 'deepCR_train':
CRMask.cr_train_deepCR(self) CRMask.cr_train_deepCR(self)
else: else:
......
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