HipsTile¶
-
class
hips.
HipsTile
(meta: hips.tiles.tile.HipsTileMeta, raw_data: bytes) → None[source]¶ Bases:
object
HiPS tile container.
This class provides methods for fetching, reading, and writing a HiPS tile.
Note
In HiPS, the pixel data is flipped in the y direction for
jpg
andpng
format with respect to FITS. In this package, we handle this by flippingjpg
andpng
data to match thefits
orientation, at the I/O boundary, i.e. infrom_numpy
andto_numpy
.Parameters: meta :
HipsTileMeta
Metadata of HiPS tile
raw_data :
bytes
Raw data (copy of bytes from file)
Examples
Fetch a HiPS tile:
>>> from hips import HipsTile, HipsTileMeta >>> meta = HipsTileMeta(order=6, ipix=30889, file_format='fits') >>> url = 'http://alasky.unistra.fr/2MASS/H/Norder6/Dir30000/Npix30889.fits' >>> tile = HipsTile.fetch(meta, url)
The tile pixel data is available as a Numpy array:
>>> type(tile.data) numpy.ndarray >>> tile.data.shape (512, 512) >>> tile.data.dtype.name int16
Attributes Summary
children
Create four children tiles from parent tile. data
Tile pixel data ( ndarray
).Methods Summary
fetch
((meta: hips.tiles.tile.HipsTileMeta, …)Fetch HiPS tile and load into memory ( HipsTile
).from_numpy
(…)Create a tile from given pixel data. read
((meta: hips.tiles.tile.HipsTileMeta, …)Read HiPS tile data from a directory and load into memory ( HipsTile
).to_numpy
((raw_data: bytes, …)Convert raw image bytes to Numpy array pixel data. write
((filename: str) -> None)Write to file. Attributes Documentation
-
children
¶ Create four children tiles from parent tile.
-
data
¶ Tile pixel data (
ndarray
).This is a cached property, it will only be computed once.
See the
to_numpy
function.
Methods Documentation
-
classmethod
fetch
(meta: hips.tiles.tile.HipsTileMeta, url: str) → hips.tiles.tile.HipsTile[source]¶ Fetch HiPS tile and load into memory (
HipsTile
).Parameters: meta :
HipsTileMeta
Metadata of HiPS tile
url : str
URL containing HiPS tile
-
classmethod
from_numpy
(meta: hips.tiles.tile.HipsTileMeta, data: numpy.ndarray) → hips.tiles.tile.HipsTile[source]¶ Create a tile from given pixel data.
Parameters: meta :
HipsTileMeta
Metadata of HiPS tile
data :
ndarray
Tile pixel data
Returns: tile :
HipsTile
HiPS tile object in the format requested in
meta
.
-
classmethod
read
(meta: hips.tiles.tile.HipsTileMeta, filename: str = None) → hips.tiles.tile.HipsTile[source]¶ Read HiPS tile data from a directory and load into memory (
HipsTile
).Parameters: meta :
HipsTileMeta
Metadata of HiPS tile
filename : str
Filename
-