Loading csst_common/io.py +31 −2 Original line number Original line Diff line number Diff line Loading @@ -6,10 +6,12 @@ Author: Bo Zhang Created: 2023-12-13 Created: 2023-12-13 Modified-History: Modified-History: 2023-12-10, Bo Zhang, created 2023-12-10, Bo Zhang, created 2023-12-15, Bo Zhang, add verify_checksum and append_header, add module header 2023-12-15, Bo Zhang, added verify_checksum and append_header, add module header 2023-12-16, Bo Zhang, fixed a bug in finding the first key when reformatting """ """ import warnings import warnings from copy import deepcopy from copy import deepcopy from typing import Optional from astropy.io import fits from astropy.io import fits Loading Loading @@ -86,7 +88,34 @@ def append_header( return original_h return original_h def reformat_header(h: fits.Header, strip=True, comment=None): def reformat_header( h: fits.Header, strip: bool = True, comment: Optional[str] = None, ): """ Reformat fits Header. Remove blanks, comments, and history, and add a new comment at the beginning. Parameters ---------- h : fits.Header The original header. strip: bool = True If `True`, strip cards like SIMPLE, BITPIX, etc. so the rest of the header can be used to reconstruct another kind of header. comment: Optional[str] = None The new comment at the beginning. See Also -------- astropy.io.fits.Header.strip() References ---------- https://docs.astropy.org/en/stable/io/fits/api/headers.html#astropy.io.fits.Header.strip """ h_copy = deepcopy(h) h_copy = deepcopy(h) # strip # strip if strip: if strip: Loading Loading
csst_common/io.py +31 −2 Original line number Original line Diff line number Diff line Loading @@ -6,10 +6,12 @@ Author: Bo Zhang Created: 2023-12-13 Created: 2023-12-13 Modified-History: Modified-History: 2023-12-10, Bo Zhang, created 2023-12-10, Bo Zhang, created 2023-12-15, Bo Zhang, add verify_checksum and append_header, add module header 2023-12-15, Bo Zhang, added verify_checksum and append_header, add module header 2023-12-16, Bo Zhang, fixed a bug in finding the first key when reformatting """ """ import warnings import warnings from copy import deepcopy from copy import deepcopy from typing import Optional from astropy.io import fits from astropy.io import fits Loading Loading @@ -86,7 +88,34 @@ def append_header( return original_h return original_h def reformat_header(h: fits.Header, strip=True, comment=None): def reformat_header( h: fits.Header, strip: bool = True, comment: Optional[str] = None, ): """ Reformat fits Header. Remove blanks, comments, and history, and add a new comment at the beginning. Parameters ---------- h : fits.Header The original header. strip: bool = True If `True`, strip cards like SIMPLE, BITPIX, etc. so the rest of the header can be used to reconstruct another kind of header. comment: Optional[str] = None The new comment at the beginning. See Also -------- astropy.io.fits.Header.strip() References ---------- https://docs.astropy.org/en/stable/io/fits/api/headers.html#astropy.io.fits.Header.strip """ h_copy = deepcopy(h) h_copy = deepcopy(h) # strip # strip if strip: if strip: Loading