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
fb155307
Commit
fb155307
authored
May 07, 2024
by
BO ZHANG
🏀
Browse files
add table utils
parent
86a46ad6
Pipeline
#4374
passed with stage
in 0 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
csst_common/utils/__init__.py
View file @
fb155307
...
...
@@ -12,6 +12,4 @@ Modified-History:
from
._module_docstr
import
ModuleHeader
from
._retry
import
retry
from
.tempfile
import
randfile
from
.table_utils
import
table_to_hdu
,
hdu_to_table
csst_common/utils/table_utils.py
0 → 100644
View file @
fb155307
"""
Identifier: csst_dadel/csst_dadel/utils.py
Name: utils.py
Description: Table utils.
Author: Bo Zhang
Created: 2024-02-18
Modified-History:
2024-02-18, Bo Zhang, implement utils for conversion between Table and BinTableHDU
"""
from
astropy
import
table
from
astropy.io
import
fits
def
table_to_hdu
(
tbl
:
table
.
Table
,
name
:
str
=
""
)
->
fits
.
BinTableHDU
:
"""Convert a table to a BinTableHDU."""
# encode meta
encoded_tbl
=
fits
.
connect
.
_encode_mixins
(
tbl
)
# convert to HDU
hdu
=
fits
.
table_to_hdu
(
encoded_tbl
)
# add HDU name
hdu
.
name
=
name
return
hdu
def
hdu_to_table
(
hdu
:
fits
.
BinTableHDU
)
->
table
.
Table
:
"""Convert a BinTableHDU to a table."""
return
table
.
Table
.
read
(
hdu
)
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