Skip to content
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

Error in FITS-cubes.ipynb #463

Closed
embray opened this issue Oct 14, 2020 · 21 comments
Closed

Error in FITS-cubes.ipynb #463

embray opened this issue Oct 14, 2020 · 21 comments

Comments

@embray
Copy link
Member

embray commented Oct 14, 2020

When processing the FITS-cubes.ipynb notebook I'm getting an error from astroquery:

# Query for Herschel data in a 1 degree radius around the SMC
result = ESASky.query_region_maps('SMC', radius=1*u.deg, missions='Herschel')

print(result)
------------------

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-1-3cb6373bfea7> in <module>
      1 # Query for Herschel data in a 1 degree radius around the SMC
----> 2 result = ESASky.query_region_maps('SMC', radius=1*u.deg, missions='Herschel')
      3 
      4 print(result)

~/.virtualenvs/astropy/lib/python3.6/site-packages/astroquery/esasky/core.py in query_region_maps(self, position, radius, missions, get_query_payload, cache)
    236         self._store_query_result_maps(query_result, sanitized_missions,
    237                                       coordinates, sanitized_radius,
--> 238                                       get_query_payload, cache)
    239 
    240         if (get_query_payload):

~/.virtualenvs/astropy/lib/python3.6/site-packages/astroquery/esasky/core.py in _store_query_result_maps(self, query_result, missions, coordinates, radius, get_query_payload, cache)
    768             mission_table = self._query_region_maps(coordinates, radius,
    769                                                     mission, get_query_payload,
--> 770                                                     cache)
    771             if (len(mission_table) > 0):
    772                 query_result[mission.upper()] = mission_table

~/.virtualenvs/astropy/lib/python3.6/site-packages/astroquery/esasky/core.py in _query_region_maps(self, coordinates, radius, observation_name, get_query_payload, cache)
    682         query = (
    683             self._build_observation_query(coordinates, radius,
--> 684                                           self._find_observation_parameters(observation_tap_name)))
    685         request_payload = self._create_request_payload(query)
    686         if (get_query_payload):

~/.virtualenvs/astropy/lib/python3.6/site-packages/astroquery/esasky/core.py in _build_observation_query(self, coordinates, radius, json)
    711         from_query = " FROM {}".format(json[self.__TAP_TABLE_STRING])
    712         if (radiusDeg != 0 or json[self.__IS_SURVEY_MISSION_STRING]):
--> 713             if (json[self.__IS_SURVEY_MISSION_STRING]):
    714                 where_query = (" WHERE 1=CONTAINS(pos, CIRCLE('ICRS', {}, {}, {}));".
    715                                format(ra, dec, radiusDeg))

KeyError: 'isSurveyMission'
KeyError: 'isSurveyMission'

Not sure what that's about or how best to fix it.

@pllim
Copy link
Member

pllim commented Oct 14, 2020

Which astroquery version? Be sure to grab the latest pre-release from PyPI.
pip install astroquery --pre --upgrade

@pllim
Copy link
Member

pllim commented Oct 14, 2020

If you still have problem, could be that API is outdated or something, and try open issue over at astroquery. Hope this helps!

@embray
Copy link
Member Author

embray commented Oct 14, 2020

I didn't get the pre-release. Was using 0.4.1 which was the default from the pip-requirements.txt which specifies astroquery>=0.3.7. This might be a problem related to #445

@pllim
Copy link
Member

pllim commented Oct 14, 2020

Using stable astroquery won't do because they have to fix for upstream changes on demand, so they opted for "rolling release." I would recommend --pre.

@embray
Copy link
Member Author

embray commented Oct 14, 2020

Using the latest pre-release didn't work. The notebook in question was last updated in March 2020 so it shouldn't require the bleeding edge anyways.

@pllim
Copy link
Member

pllim commented Oct 14, 2020

What about dev? (Just in case)

@embray
Copy link
Member Author

embray commented Oct 14, 2020

It looks like it has the same issue. I'll open an issue against astroquery...

@embray
Copy link
Member Author

embray commented Oct 14, 2020

FWIW the issue can be reproduced simply by

>>> from astropy import units as u
>>> from astroquery.esasky import ESASky
>>> ESASky.query_region_maps('SMC', radius=1*u.deg, missions='Herschel')

ISTM some piece of metadata that's expected to exist in the query results does not, and the code doesn't handle it being missing.

@pllim
Copy link
Member

pllim commented Oct 14, 2020

Thanks for checking. :(

@embray
Copy link
Member Author

embray commented Oct 14, 2020

After installing astroquery from source and applying my workaround, the rest of the notebook executes successfully, so we can close this once astropy-tutorials is building with an appropriate version of astroquery.

This was referenced Nov 18, 2020
@adrn adrn closed this as completed in b3254ea Nov 18, 2020
@RobinThomas95
Copy link

Hi, I am encountering the aforementioned issue while using astroquery.ESASky queries. Can you guide me on a possible solution? Thank you

@embray
Copy link
Member Author

embray commented Mar 2, 2021

@RobinThomas95 This is fixed in the development version of astroquery and the relevant issue is here: astropy/astroquery#1856

You can install the latest development version of astroquery if you need this fixed. Will you need help on how to do that?

@RobinThomas95
Copy link

@embray It'd be helpful if you could guide me on how to install the dev version of astroquery, Thank You

@embray
Copy link
Member Author

embray commented Mar 2, 2021

@RobinThomas95 How are you installing astroquery in the first place?

@RobinThomas95
Copy link

@embray I'm using pip install astroquery to install the package

@embray
Copy link
Member Author

embray commented Mar 2, 2021

@RobinThomas95 Ok great, in that case you can pip install --pre astroquery to install the latest pre-release, which I believe includes this fix.

@RobinThomas95
Copy link

@embray Sorry for the late reply. I tried pip installing as you advised, restarted the Jupyter kernel that I'm using and then ran the astroquery. The error still persists.

@pllim
Copy link
Member

pllim commented Mar 3, 2021

Might have to install from source pip install git+https://github.com/astropy/astroquery. Just to be safe, do a pip uninstall astroquery until it complains it cannot find astroquery first before you install from source.

@RobinThomas95
Copy link

@pllim @embray Thank you so much, guys. The solution suggested by @pllim worked out for me. :)

@HugoDelgado
Copy link

Im getting errors trying to install with Conda, pip or even the git source option.

@pllim
Copy link
Member

pllim commented Mar 10, 2021

This particular issue from original post is already resolved. If you encounter problems with our tutorials, please open new issue with all the necessary info (versions, OS, environment, traceback). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants