Skip to content

Commit 5249cd2

Browse files
syed-gilanibsipocz
authored andcommitted
added a method to retrieve all searchable columns names and their descriptions for a mission
1 parent 5e3c5dd commit 5249cd2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

astroquery/mast/missions.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
This module contains methods for searching MAST missions.
77
"""
88

9+
import requests
10+
911
import astropy.units as u
1012
import astropy.coordinates as coord
1113

@@ -16,6 +18,8 @@
1618
from astroquery.mast import utils
1719
from astroquery.mast.core import MastQueryWithLogin
1820

21+
from . import conf
22+
1923
__all__ = ['MastMissionsClass', 'MastMissions']
2024

2125

@@ -183,5 +187,28 @@ def query_object_async(self, objectname, radius=3*u.arcmin, **kwargs):
183187

184188
return self.query_region_async(coordinates, radius, **kwargs)
185189

190+
@class_or_instance
191+
def get_column_list(self):
192+
"""
193+
For a mission, return a list of all searchable columns and their descriptions
194+
195+
Returns
196+
-------
197+
json data that contains columns names and their descriptions
198+
"""
199+
200+
url = f"{conf.server}/search/util/api/v0.1/column_list?mission={self.mission}"
201+
202+
try:
203+
results = requests.get(url)
204+
results = results.json()
205+
for result in results:
206+
result.pop('field_name')
207+
result.pop('queryable')
208+
result.pop('indexed')
209+
result.pop('default_output')
210+
return results
211+
except:
212+
raise Exception(f"Error occured while trying to get column list for mission {self.mission}")
186213

187214
MastMissions = MastMissionsClass()

0 commit comments

Comments
 (0)