-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce class HipsDrawResult in simple.py #91
Conversation
This looks good to me. I think you can just continue with this PR for ~ a day, adding more features. I would suggest adding a Another thing I would suggest is to add a
and then change the high-level docs example at https://hips.readthedocs.io/en/latest/getting_started.html to call that
|
@cdeil I just made these updates. Please review. |
55aa6e0
to
f4401da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks mostly good. I left some inline comments.
@adl1995 - Do you want to leave it at that or continue in this PR for a bit?
One thing that I think would be nice would be if there were a result.plot
method that would plot the sky image, using wcsaxes and showing the HEALPix grid, i.e. something that will with one line let people see the result and get some info about the tiles that were drawn.
I guess it would mean that you have to store extra info on the result object about the tiles. You could either do that, or for now just attach the painter
to result
, as a simple way for now to expose all intermediate data to "power users" like us, even though they used the high-level interface to run the example.
hips/draw/tests/test_simple.py
Outdated
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']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When writing files from tests, you should always do it using tmpdir
.
Examples: https://github.com/hipspy/hips/search?utf8=%E2%9C%93&q=tmpdir&type=
hips/draw/simple.py
Outdated
'This class object contains two attributes: image and geometry' | ||
) | ||
|
||
def __repr__(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the common pattern of mentioning the class name in the repr
, like in this example:
Line 99 in fce110c
def __repr__(self): |
hips/draw/simple.py
Outdated
|
||
def __str__(self): | ||
return ( | ||
'This class object contains two attributes: image and geometry' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't useful. The idea of having a separate __str__
is that you give more information.
In this case, it could be something like this:
def __str__(self):
ss = 'HiPS draw result:\n'
ss += 'Sky image: .... infos about sky image pixel data (shape, dtype) ...\n'
ss += f'WCS geometry: {self.geometry}\n'
.... later add more info about number of tiles used and fetched, time to exectute, memory used
... i.e. print out a nice report
return ss
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This info in the high-level section is now a little short, you should give some more infos what people can do with the result
, namely that they can get at the pixel data as a numpy array, the WCS for the image and print out info about the result.
@cdeil I just pushed my latest code. Now there is a method in |
Thanks! (I'll do some small follow-up edits in master later today.) |
As outlined in issue #80, I have added a class
HipsDrawResult
. This still needs more work, currently it only storesimage
andgeometry
.