-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add class HipsTileMeta and update test case
- Loading branch information
Showing
6 changed files
with
113 additions
and
63 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
# Licensed under a 3-clause BSD style license - see LICENSE.rst | ||
from astropy.tests.helper import remote_data | ||
|
||
from ..tile import HipsTile | ||
from ..tile_meta import HipsTileMeta | ||
|
||
|
||
class TestHipsTile: | ||
def setup(self): | ||
self.hips_tile_meta_fits = HipsTileMeta(order=6, ipix=30889, format='fits') | ||
self.hips_tile_meta_jpg = HipsTileMeta(order=6, ipix=30889, format='jpg') | ||
|
||
@remote_data | ||
def test_fetch_read_write(self): | ||
fits_tile = HipsTile.fetch(self.hips_tile_meta_fits, | ||
'http://alasky.unistra.fr/2MASS/H/Norder6/Dir30000/Npix30889.fits') | ||
jpg_tile = HipsTile.fetch(self.hips_tile_meta_jpg, | ||
'http://alasky.unistra.fr/2MASS/H/Norder6/Dir30000/Npix30889.jpg') | ||
|
||
data_precomp = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1] | ||
assert fits_tile.data.shape == (512, 512) | ||
assert jpg_tile.data.shape == (512, 512, 3) | ||
assert list(fits_tile.data[510][:12]) == data_precomp | ||
|
||
jpg_tile.write('Npix30889.jpg') | ||
fits_tile.write('Npix30889.fits') | ||
|
||
fits_tile = HipsTile.read(self.hips_tile_meta_fits, 'Npix30889.fits') | ||
jpg_tile = HipsTile.read(self.hips_tile_meta_jpg, 'Npix30889.jpg') | ||
|
||
@remote_data | ||
def test_fetch(): | ||
fits_tile = HipsTile.fetch('fits', 'http://alasky.unistra.fr/2MASS/H/Norder6/Dir30000/Npix30889.fits') | ||
jpg_tile = HipsTile.fetch('jpg', 'http://alasky.unistra.fr/2MASS/H/Norder6/Dir30000/Npix30889.jpg') | ||
|
||
shape_fits_precomp = (512, 512) | ||
shape_jpg_precomp = (512, 512, 3) | ||
data_precomp = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1] | ||
assert fits_tile.data.shape == shape_fits_precomp | ||
assert jpg_tile.data.shape == shape_jpg_precomp | ||
assert list(fits_tile.data[510][:12]) == data_precomp | ||
|
||
def test_read_write(): | ||
fits_tile = HipsTile.read('fits', 'Npix30889.fits') | ||
jpg_tile = HipsTile.read('jpg', 'Npix30889.jpg') | ||
|
||
shape_fits_precomp = (512, 512) | ||
shape_jpg_precomp = (512, 512, 3) | ||
data_precomp = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1] | ||
assert (fits_tile.data.shape) == shape_fits_precomp | ||
assert (jpg_tile.data.shape) == shape_jpg_precomp | ||
assert list(fits_tile.data[510][:12]) == data_precomp | ||
|
||
fits_tile.write('test_file.fits') | ||
jpg_tile.write('test_file.jpg') | ||
|
||
path_fits = fits_tile.path / 'test_file.fits' | ||
path_jpg = jpg_tile.path / 'test_file.jpg' | ||
assert True == path_fits.is_file() | ||
assert True == path_jpg.is_file() | ||
data_precomp = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1] | ||
assert fits_tile.data.shape == (512, 512) | ||
assert jpg_tile.data.shape == (512, 512, 3) | ||
assert list(fits_tile.data[510][:12]) == data_precomp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Licensed under a 3-clause BSD style license - see LICENSE.rst | ||
|
||
__all__ = [ | ||
'HipsTileMeta', | ||
] | ||
|
||
|
||
class HipsTileMeta: | ||
"""HiPS tile metadata container. | ||
This class stores HiPS tile meta attributes. | ||
Parameters | ||
---------- | ||
order : `int` | ||
Order of HiPS tile | ||
ipix : `int` | ||
Pixel number of HiPS tile | ||
format : `str` | ||
Format of the HiPS tile | ||
tile_width : `int` | ||
HiPS tile width | ||
""" | ||
|
||
def __init__(self, order: int, ipix: int, format: str, tile_width: int = 512) -> None: | ||
self.order = format | ||
self.ipix = ipix | ||
self.format = format | ||
self.tile_width = tile_width |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Licensed under a 3-clause BSD style license - see LICENSE.rst | ||
"""HEALpy wrapper functions. | ||
This module contains wrapper functions around HEALPix utilizing | ||
the healpy library. | ||
""" | ||
|
||
from pathlib import Path | ||
|
||
__all__ = [ | ||
'tile_path', | ||
] | ||
|
||
|
||
def tile_path() -> Path: | ||
"""Return default path of HiPS tile storage.""" | ||
path = Path('hips', 'tiles', 'tests', 'data') | ||
return path |