Skip to content

Commit

Permalink
Update high-level docs example
Browse files Browse the repository at this point in the history
  • Loading branch information
adl1995 committed Jul 25, 2017
1 parent c15092b commit 55aa6e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
8 changes: 3 additions & 5 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,18 @@ To make a sky image with the `hips` package, follow the following three steps:


3. Call the `~hips.make_sky_image` function to fetch the HiPS data
and draw it, returning the sky image pixel data as a Numpy array::
and draw it, returning an object of `~hips.HipsDrawResult`::

from hips import make_sky_image

data = make_sky_image(geometry, hips_survey, 'fits')
result = make_sky_image(geometry, hips_survey, 'fits')


That's it. Go ahead and try it out for your favourite sky region and survey.

Now you can then save the sky image to local disk e.g. FITS file format::

from astropy.io import fits
hdu = fits.PrimaryHDU(data=data, header=geometry.fits_header)
hdu.writeto('my_image.fits')
result.write_image('my_image.fits')

or plot and analyse the sky image however you like.

Expand Down
3 changes: 2 additions & 1 deletion hips/draw/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def tiles(self) -> List[HipsTile]:

@property
def result(self) -> 'HipsDrawResult':
"""Return an object of `~hips.HipsDrawResult` class"""
return HipsDrawResult(self.image, self.geometry, self.tile_format)

def warp_image(self, tile: HipsTile) -> np.ndarray:
Expand Down Expand Up @@ -219,7 +220,7 @@ def write_image(self, filename: str) -> None:
Filename
"""
if self.tile_format == 'fits':
hdu = fits.PrimaryHDU(self.image)
hdu = fits.PrimaryHDU(data=self.image, header=self.geometry.fits_header)
hdu.writeto(filename)
else:
image = Image.fromarray(self.image)
Expand Down
2 changes: 1 addition & 1 deletion hips/draw/tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_make_sky_image(pars):
assert_allclose(np.sum(result.image), pars['data_sum'])
assert_allclose(result.image[200, 994], pars['data_1'])
assert_allclose(result.image[200, 995], pars['data_2'])
# result.write_image('test.' + pars['file_format'])
result.write_image('test.' + pars['file_format'])
assert repr(result) == pars['repr']

@remote_data
Expand Down

0 comments on commit 55aa6e0

Please sign in to comment.