Skip to content

Conversation

@imbasimba
Copy link
Contributor

@imbasimba imbasimba commented Sep 29, 2016

First implementation of ESASky module

Copy link
Contributor

@keflavich keflavich left a 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!

"""
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):
Copy link
Contributor

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.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling: sanitize


self._store_query_result_maps(query_result, sanatized_missions, coordinates, sanatized_radius, get_query_payload, cache)

if(get_query_payload):
Copy link
Contributor

@keflavich keflavich Oct 4, 2016

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 (

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))
Copy link
Contributor

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)


maps = dict()

map_query_result = self.query_region_maps(sanatized_position, sanatized_radius, sanatized_missions, False)
Copy link
Contributor

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)

@@ -0,0 +1,23 @@
from astroquery.esasky import ESASky
import astropy.units as u
from astropy.coordinates import SkyCoord
Copy link
Contributor

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

a choice of catalogs or missions.

Get the available catalog names
-------------------
Copy link
Contributor

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

---------------

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
Copy link
Contributor

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....)

.. code-block:: python
>>> from astroquery.esasky import ESASky
>>> import astropy.units as u
Copy link
Contributor

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)

Copy link
Contributor

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


.. code-block:: python
>>> for table_name in result.keys():
Copy link
Contributor

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

@keflavich
Copy link
Contributor

To run tests locally, use python setup.py test -P esasky. It reveals a few failures I'll try to help correct.

# 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):
Copy link
Contributor

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

Copy link
Contributor

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

import tempfile
import tarfile
import sys
from __future__ import print_function
Copy link
Contributor

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.

@bsipocz
Copy link
Member

bsipocz commented Oct 10, 2016

@imbasimba - This looks very nice, thank you for adding esasky to astroquery.

Query an object
---------------

There are two query objects methods in this module :meth:`~query_object_catalogs`
Copy link
Member

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.

@imbasimba
Copy link
Contributor Author

imbasimba commented Oct 10, 2016

Great!
@keflavich @bsipocz - Is there anything else that needs to be done before we can merge this pull request?

@bsipocz
Copy link
Member

bsipocz commented Oct 10, 2016

@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)
Copy link
Contributor

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)

@keflavich
Copy link
Contributor

I found one more small bug when running the remote-tests. Fix that, then I'll merge.

@keflavich keflavich merged commit d8ab59d into astropy:master Oct 10, 2016
@bsipocz bsipocz modified the milestone: 0.3.3 Nov 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants