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
71e23c8d
Commit
71e23c8d
authored
Oct 22, 2025
by
BO ZHANG
🏀
Browse files
add fits_open to be compatible with s3
parent
931e0ded
Pipeline
#10781
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
csst_common/io.py
View file @
71e23c8d
...
...
@@ -12,18 +12,30 @@ Modified-History:
2025-08-05, Bo Zhang, added generate_meta
"""
import
os
import
json
import
bisect
import
json
import
os
import
uuid
import
warnings
from
copy
import
deepcopy
from
typing
import
Optional
,
Any
import
uuid
from
typing
import
Optional
from
astropy.io
import
fits
from
csst_fs.s3_config
import
load_s3_options
from
.time
import
now
s3_options
=
load_s3_options
()
def
fits_open
(
name
,
**
kwargs
)
->
fits
.
HDUList
:
if
name
.
startswith
(
"s3://"
):
# read fits file from s3
return
fits
.
open
(
name
,
use_fsspec
=
True
,
fsspec_kwargs
=
s3_options
,
**
kwargs
)
else
:
# read fits file from local
return
fits
.
open
(
name
,
**
kwargs
)
# meta字段和默认值
REQUIRED_KEYS_IN_META
=
dict
(
...
...
tests/test_
fits_header_ops
.py
→
tests/test_
io
.py
View file @
71e23c8d
...
...
@@ -21,6 +21,7 @@ from csst_common.io import (
generate_meta
,
append_meta
,
extract_meta
,
fits_open
,
)
...
...
@@ -141,3 +142,7 @@ class TestFitsHeaderOps(unittest.TestCase):
self
.
assertIn
(
"META"
,
set
(
hdulist
[
0
].
header
.
keys
()))
meta
=
extract_meta
(
hdulist
)
self
.
assertEqual
(
meta
[
"obs_id"
],
"123456"
)
def
test_fits_open
(
self
):
hl
=
fits_open
(
"/nfsdata/share/pipeline-unittest/csst_common/test_fits/hl.fits"
)
self
.
assertTrue
(
isinstance
(
hl
,
fits
.
HDUList
))
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