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-dfs
csst-dfs-commons
Commits
8b09e30e
Commit
8b09e30e
authored
Oct 28, 2024
by
Wei Shoulin
Browse files
add test
parent
b29c39d3
Pipeline
#7160
passed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
test/test_fits.py
View file @
8b09e30e
import
unittest
from
astropy.io
import
fits
from
csst_dfs_commons.utils.fits
import
get_header_value
,
get_healpix_id
,
get_healpix_ids
,
hdul_of_healpix_ids
from
csst_dfs_commons.utils.fits
import
get_header_value
,
get_healpix_id
,
get_healpix_ids
class
CommonFitsTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
pass
def
test_hdul_of_healpix_ids
(
self
):
# hdul = fits.open()
# r = hdul_of_healpix_ids(id = 1)
pass
def
test_get_header_value
(
self
):
# cat_image_file = ""
# hdul = fits.open(cat_image_file)
...
...
@@ -22,4 +16,23 @@ class CommonFitsTestCase(unittest.TestCase):
# hdul.close()
pass
def
test_healpix_id
(
self
):
assert
get_healpix_id
(
169.44857011771074
,
-
22.386716001490132
)
==
402272
assert
get_healpix_id
(
169.4589413632046
,
-
22.33955353764225
)
==
402275
assert
get_healpix_id
(
169.48469002849907
,
-
22.286516726694472
)
==
402275
assert
get_healpix_id
(
169.4108965845783
,
-
22.393670092820404
)
==
402272
assert
get_healpix_id
(
169.43237517250446
,
-
22.3422045639634
)
==
402274
assert
get_healpix_id
(
169.4201458422564
,
-
22.35046889102491
)
==
402274
assert
get_healpix_id
(
169.4246373742319
,
-
22.31984666676682
)
==
402275
assert
get_healpix_id
(
169.45647029099555
,
-
22.23815703367434
)
==
402275
assert
get_healpix_id
(
169.40007432226554
,
-
22.34302561078609
)
==
402274
assert
get_healpix_id
(
169.43318631346764
,
-
22.258275712920017
)
==
402275
assert
get_healpix_id
(
207.37598395996824
,
-
59.699973553678625
)
==
667401
cat_image_file
=
"/Users/wsl/temp/csst/CSST_MSC_MS_SCI_20270810142128_20270810142358_100000101_01_L0_1.fits"
with
fits
.
open
(
cat_image_file
)
as
hdul
:
print
(
type
((
hdul
[
0
].
header
[
'RA_OBJ'
])))
hpix
=
get_healpix_id
(
hdul
[
0
].
header
[
'RA_OBJ'
],
hdul
[
0
].
header
[
'DEC_OBJ'
])
print
(
int
(
hpix
),
hpix
)
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