Created
February 12, 2014 18:19
-
-
Save letmaik/8961443 to your computer and use it in GitHub Desktop.
Query the NSSDC Master Catalog for spacecrafts of certain disciplines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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