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

ESASky.query_region_maps: expected property missing from Herschel data #1856

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

ESASky.query_region_maps: expected property missing from Herschel data #1856

embray opened this issue Oct 14, 2020 · 4 comments

Comments

@embray
Copy link
Member

embray commented Oct 14, 2020

The following example results in an exception, KeyError: 'isSurveyMission':

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

It seems the expected property isSurveyMission is not present in the JSON response. I was able to work around it like so, but I don't know if it's the most responsible solution:

diff --git a/astroquery/esasky/core.py b/astroquery/esasky/core.py
index cc630509..cc72e7c3 100644
--- a/astroquery/esasky/core.py
+++ b/astroquery/esasky/core.py
@@ -709,8 +709,8 @@ class ESASkyClass(BaseQuery):
                                         for entry in metadata])
 
         from_query = " FROM {}".format(json[self.__TAP_TABLE_STRING])
-        if (radiusDeg != 0 or json[self.__IS_SURVEY_MISSION_STRING]):
-            if (json[self.__IS_SURVEY_MISSION_STRING]):
+        if (radiusDeg != 0 or json.get(self.__IS_SURVEY_MISSION_STRING, False)):
+            if (json.get(self.__IS_SURVEY_MISSION_STRING, False)):
                 where_query = (" WHERE 1=CONTAINS(pos, CIRCLE('ICRS', {}, {}, {}));".
                                format(ra, dec, radiusDeg))
             else:

After I apply this fix I get:

WARNING: W50: None:37:0: W50: Invalid unit string 'microns' [astropy.io.votable.tree]
WARNING: W50: None:43:0: W50: Invalid unit string 'seconds' [astropy.io.votable.tree]
Out[3]: 
TableList with 1 tables:
	'0:HERSCHEL' with 12 column(s) and 28 row(s) 

which seems reasonable (the VOTable warnings are no surprise I suppose :)

Originally reported at astropy/astropy-tutorials#463

@pllim
Copy link
Member

pllim commented Oct 14, 2020

#1446 says maybe @imbasimba can advise?

the VOTable warnings are no surprise I suppose

Yeah... 😬

@imbasimba
Copy link
Contributor

Thanks for reporting this. We have changed the jsons slightly in the latest release of ESASky & forgot to properly change the astroquery module. I'll fix it today.

Cheers,
Henrik

@imbasimba
Copy link
Contributor

Fixed in this PR #1858

Cheers,
Henrik

@HugoDelgado
Copy link

I had trouble updating to the latest versions of astroquery in my Mac through Conda. Apparently my Mac has several directories for python. Your solution was the easiest and worked. Thanks

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

No branches or pull requests

5 participants