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_common
Commits
920d289c
Commit
920d289c
authored
Dec 16, 2023
by
BO ZHANG
🏀
Browse files
add type annotation
parent
aa18ce37
Pipeline
#2437
failed with stage
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
csst_common/io.py
View file @
920d289c
...
@@ -6,10 +6,12 @@ Author: Bo Zhang
...
@@ -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
...
@@ -86,7 +88,34 @@ def append_header(
...
@@ -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
:
...
...
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