diff --git a/test/test_fits.py b/test/test_fits.py index 12e2daf5aba4e40392af5e9021e751367607a86a..7d916bd1418b02ee18941492c5e9d3fe7e9167ce 100644 --- a/test/test_fits.py +++ b/test/test_fits.py @@ -1,18 +1,12 @@ 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) +