-
-
Notifications
You must be signed in to change notification settings - Fork 425
Esasky #758
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
Esasky #758
Conversation
…gion in catalogs.
…mments, added basic tests
…ted minor errors in comments.
keflavich
left a comment
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.
I've left a series of mostly stylistic comments. The module is looking very nearly complete, though a few more tests would probably be helpful.
The most important changes for getting this merged into astroquery is to fix the issues related to testing, since right now the tests will not work properly.
This is looking great!
astroquery/esasky/core.py
Outdated
| """ | ||
| return self._json_object_field_to_list(self._get_catalogs_json(cache = True), self.__MISSION_STRING) | ||
|
|
||
| def query_object_maps(self, position, missions = __ALL_STRING, get_query_payload = False, cache = True): |
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.
Minor style comments:
- in function definitions, we prefer not to have spaces surrounding
=signs. - when possible, try to wrap lines at <= 80 characters.
astroquery/esasky/core.py
Outdated
| query_region_maps("265.05, 69.0", 14*u.arcmin, "Herschel") | ||
| query_region_maps("265.05, 69.0", ["Herschel", "HST"]) | ||
| """ | ||
| sanatized_position = self._sanatize_input_position(position) |
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.
spelling: sanitize
astroquery/esasky/core.py
Outdated
|
|
||
| self._store_query_result_maps(query_result, sanatized_missions, coordinates, sanatized_radius, get_query_payload, cache) | ||
|
|
||
| if(get_query_payload): |
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.
parentheses aren't necessary here, but they're acceptable. Please add a space between if and (
astroquery/esasky/core.py
Outdated
| maps[query_mission] = self._get_maps_for_mission(sanatized_query_table_list[query_mission], query_mission, download_folder, cache) | ||
| break | ||
| if(len(sanatized_query_table_list) > 0): | ||
| print("Maps available at %s" %os.path.abspath(download_folder)) |
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.
Use log.info instead of print here (it gives users finer-tuned control over the code's verbosity)
astroquery/esasky/core.py
Outdated
|
|
||
| maps = dict() | ||
|
|
||
| map_query_result = self.query_region_maps(sanatized_position, sanatized_radius, sanatized_missions, False) |
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.
it would be helpful for readability to specify these as keywords, at least for the last parameter (what is being set to False here? Hard to tell without scrolling through the code)
astroquery/esasky/tests/test_maps.py
Outdated
| @@ -0,0 +1,23 @@ | |||
| from astroquery.esasky import ESASky | |||
| import astropy.units as u | |||
| from astropy.coordinates import SkyCoord | |||
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 is a good interactive test but the tests below should all be put into some function def test_something so that it's not called at import time and is run when we run overall tests
docs/esasky/esasky.rst
Outdated
| a choice of catalogs or missions. | ||
|
|
||
| Get the available catalog names | ||
| ------------------- |
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.
number of dashes should match number of characters in previous line
docs/esasky/esasky.rst
Outdated
| --------------- | ||
|
|
||
| There are two query objects methods in this module query_object_catalogs | ||
| and query_object_maps. They both work in exactly the same way except |
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.
surround function names in backticks (or maybe double backticks... I can never remember sphinx syntax exactly. One or the other will still do something neat....)
docs/esasky/esasky.rst
Outdated
| .. code-block:: python | ||
| >>> from astroquery.esasky import ESASky | ||
| >>> import astropy.units as u |
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.
spacing problem here (too many tabs/spaces)
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.
also, you're not using units in this example
docs/esasky/esasky.rst
Outdated
|
|
||
| .. code-block:: python | ||
| >>> for table_name in result.keys(): |
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.
.keys() is not needed here
…and explicit print for integral fetching
… now returns a HDUList
|
To run tests locally, use |
| # similarly fill in tests for each of the methods | ||
| # look at tests in existing modules for more examples | ||
|
|
||
| def test_esasky_query_region_maps_invalid_position(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.
since this is not in a class, self should not be given as an input parameter. I'm not really sure what's going on in this code (where is assertRaises defined?), but it causes the following exceptions:
https://travis-ci.org/astropy/astroquery/jobs/165599483#L1212
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.
ah, this should be in a class that inherits from python's unittest.TestCase
astroquery/esasky/core.py
Outdated
| import tempfile | ||
| import tarfile | ||
| import sys | ||
| from __future__ import print_function |
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.
Thanks! I was just about to report this.
|
@imbasimba - This looks very nice, thank you for adding esasky to astroquery. |
docs/esasky/esasky.rst
Outdated
| Query an object | ||
| --------------- | ||
|
|
||
| There are two query objects methods in this module :meth:`~query_object_catalogs` |
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.
A minor comment, just for information: Full path is needed to resolve these method names as links in the docs, e.g. ~astroquery.esasky.ESASkyClass.query_object_catalogs. There are quite a few other cases below, too.
However it's not important at all at the moment, and I plan to go through the whole of astroquery to fix these cases.
|
Great! |
|
@imbasimba - The coverage failure is a red herring, so this looks good to me as is. However I'll leave the final word and honour of merging to @keflavich as he did all the review. |
|
|
||
| def test_esasky_query_region_maps(self): | ||
| result = esasky.core.ESASkyClass().query_region_maps("M51", "5 arcmin") | ||
| assert isinstance(result, Table) |
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.
In these 4 tests, this should be isinstance(result, TableList) (which also requires that TableList be imported above)
|
I found one more small bug when running the remote-tests. Fix that, then I'll merge. |
First implementation of ESASky module