Skip to content

Instantly share code, notes, and snippets.

@letmaik
Created February 12, 2014 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save letmaik/8961443 to your computer and use it in GitHub Desktop.
Save letmaik/8961443 to your computer and use it in GitHub Desktop.
Query the NSSDC Master Catalog for spacecrafts of certain disciplines
import urllib
import urllib2
import re
# To NSSDC: Please provide a REST API. Thanks.
class Discipline:
'''
as in http://nssdc.gsfc.nasa.gov/nmc/SpacecraftQuery.jsp form
'''
Astronomy = 'ASNO'
EarthScience = 'ESNO'
PlanetaryScience = 'PSNO'
SolarPhysics = 'SONO'
SpacePhysics = 'SPNO'
HumanCrew = 'HUNO'
LifeScience = 'LSNO'
Microgravity = 'MGNO'
Communications = 'CONO'
Engineering = 'ENNO'
NavigationAndGlobalPositioning = 'NANO'
ResupplyRefurbishmentRepair = 'RENO'
SurveillanceAndOtherMilitary = 'MLNO'
TechnologyApplications = 'TANO'
def getSpacecraftsFromDisciplines(disciplines):
'''
Returns a list of NSSDC IDs of spacecrafts from the given disciplines.
'''
url = 'http://nssdc.gsfc.nasa.gov/nmc/spacecraftSearch.do'
data = urllib.urlencode({'discipline': disciplines}, doseq=True)
content = urllib2.urlopen(url, data).read()
nssdcIds = re.findall(r'id=(\d{4}-\d{3}[A-Z]{1,3})', content)
return nssdcIds
if __name__ == '__main__':
nssdcIds = getSpacecraftsFromDisciplines([Discipline.SpacePhysics, Discipline.EarthScience])
nssdcIdsAfter2000 = filter(lambda nssdcId: int(nssdcId[:4]) >= 2000, nssdcIds)
print nssdcIdsAfter2000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment