NASA API的Python包装器
nasap的Python项目详细描述
纳萨比
nasa.gov API的Python包装器。在
安装
使用nasapy
最容易安装pip
。在
pip install nasapy
也可以将库克隆或下载到您选择的位置,然后使用setup.py
进行安装
根据以下文件:
文件
要求
- Python 3.4+
requests>=2.18
pandas>=0.22.0
- 虽然不是严格要求使用
nasapy
,但是需要pandas库 以数据帧形式返回结果。在
- 虽然不是严格要求使用
教程和深入示例
下面的文章将更深入地探讨nasapy
库的一个方面。在
- Plot Earth Fireball Impacts with nasapy, pandas and folium
- Analyzing the Next Decade of Earth Close-Approaching Objects with nasapy
- Get All NASA Astronomy Pictures of the Day from 2019
示例和用法
虽然没有严格要求开始与NASA API交互,但建议注册 {a17}有一个明显更高的可用接收限制 到演示键选项。许多方法不需要API密钥,但对于那些需要的方法,它通常是一个好的选择 使用提供的API密钥而不是演示密钥。使用接收到的API密钥每小时允许1000个请求,而 演示密钥每小时有30个请求限制,每天有50个请求。在
身份验证
假设在注册后接收到API密钥,初始化Nasa
时会对NASA API进行身份验证
班级。在
nasa=Nasa(key=key)
如果使用演示密钥,则初始化不需要传递任何参数。在
nasa=Nasa()
剩余请求可用
初始化的Nasa
类的limit_remaining
属性允许查看可用请求的数量
剩下的。在
nasa.limit_remaining
示例
下面是一些快速入门的示例。在
当日天文图片# Return today's picture of the daynasa.picture_of_the_day()# Return a previous date's picture of the day with the high-definition URL included.nasa.picture_of_the_day('2019-01-01',hd=True)火星天气
# Return the most recent data for the previous seven Sols (Martian Days)nasa.mars_weather()
小行星馈送
# Get asteroids approaching Earth at the beginning of 2019.nasa.asteroid_feed(start_date='2019-01-01')
获取小行星数据
# Get entire asteroid data set.nasa.get_asteroids()# Get asteroid with ID 3542519nasa.get_asteroids(asteroid_id=3542519)
DONKI(通知、知识和信息空间天气数据库)
# Coronal Mass Ejection Event Data# View data from coronal mass ejection events from the last thirty daysnasa.coronal_mass_ejection()# View all CME events from the beginning of 2019.nasa.coronal_mass_ejection(start_date='2019-01-01',end_date=datetime.datetime.today())# Geomagnetic Storm Event Data# Get geomagnetic storm events from the last thirty days.nasa.geomagnetic_storm()# Solar Flare Event Data # Get solar flare events from May of 2019nasa.solar_flare(start_date='2019-05-01',end_date='2019-05-31')# Solar Energetic Particle Data# Get data from April 2017nasa.solar_energetic_particle(start_date='2017-04-01',end_date='2017-04-30')# Magnetopause Crossing Data# Get data on magnetopause crossing events from 2018 to the current date.nasa.magnetopause_crossing(start_date='2018-01-01')# Radiation Belt Enhancement Data# Get data on radiation belt enhancement events from the last 30 days.nasa.radiation_belt_enhancement()# Hight Speed Stream Data# Get data on hight speed stream events from the beginning of September 2019.nasa.hight_speed_stream()# WSA Enlil-Simulation Data# Get data from the first simulation performed in 2019.wsa=n.wsa_enlil_simulation(start_date='2019-01-01')wsa[0]
EPIC(DSCOVR的地球多色成像相机)
# Get EPIC data from the beginning of 2019.e=nasa.epic(date='2019-01-01')# Print the first resulte[0]
系外行星
# Get all exoplanets data as a pandas DataFrame.exoplanets(return_df=True)# Get all confirmed planets in the Kepler field.exoplanets(where='pl_kepflag=1')# Stars known to host exoplanets as a pandas DataFrame.exoplanets(select='distinct pl_hostname',order='pl_hostname',return_df=True)
给定经纬度的陆地卫星图像
# Get imagery at latitude 1.5, longitude 100.75 and include the computed cloud score calculation.nasa.earth_imagery(lon=100.75,lat=1.5,cloud_score=True)# Get assets available beginning from 2014-02-01 at lat-lon 100.75, 1.5nasa.earth_assets(lat=100.75,lon=1.5,begin_date='2014-02-01')
火星探测器“好奇号”、“发现”号和“勇气号”收集的可用图像数据。
# Return image data collected on Curiosity's 1000th sol.nasa.mars_rover(sol=1000)
访问GeneLab和其他生物信息学数据库
# Find Gene studies in the cgene database related to 'mouse liver'n.genelab_search(term='mouse liver')
# Get all exoplanets data as a pandas DataFrame.exoplanets(return_df=True)# Get all confirmed planets in the Kepler field.exoplanets(where='pl_kepflag=1')# Stars known to host exoplanets as a pandas DataFrame.exoplanets(select='distinct pl_hostname',order='pl_hostname',return_df=True)
给定经纬度的陆地卫星图像
# Get imagery at latitude 1.5, longitude 100.75 and include the computed cloud score calculation.nasa.earth_imagery(lon=100.75,lat=1.5,cloud_score=True)# Get assets available beginning from 2014-02-01 at lat-lon 100.75, 1.5nasa.earth_assets(lat=100.75,lon=1.5,begin_date='2014-02-01')
火星探测器“好奇号”、“发现”号和“勇气号”收集的可用图像数据。
# Return image data collected on Curiosity's 1000th sol.nasa.mars_rover(sol=1000)
访问GeneLab和其他生物信息学数据库
# Find Gene studies in the cgene database related to 'mouse liver'n.genelab_search(term='mouse liver')
以下函数不需要使用API或演示密钥进行身份验证。在
CelesTrak两行元素集记录
# Retrieve available data for a specific satellite ID.tle(satellite_number=43553)
从images.nasa.govAPI
# Search for media related to 'apollo 11' with 'moon landing' in the description of the items.r=media_search(query='apollo 11',description='moon landing')# Print the first returned media item from the resulting collection.r['items'][0]
小行星和彗星在过去和未来接近行星
# Get all close-approach object data in the year 2019 with a maximum approach distance of 0.01AU.close_approach(date_min='2019-01-01',date_max='2019-12-31',dist_max=0.01)# Get close-approach data for asteroid 433 Eros within 0.2AU from the years 1900 to 2100.close_approach(des='433',date_min='1900-01-01',date_max='2100-01-01',dist_max=0.2)# Return close-approach data from the beginning of 2000 to the beginning of 2020 as a pandas DataFrame.close_approach(date_min='2000-01-01',date_max='2020-01-01',return_df=True)
美国政府传感器报告的火球大气影响数据
# Get all available data in reverse chronological ordern=fireballs()# Return the earlieset recordfireballs(limit=1)# Get data from the beginning of 2019fireballs(date_min='2019-01-01')# Return fireball data from the beginning of the millennium to the beginning of 2020 as a pandas DataFrame.fireballs(date_min='2000-01-01',date_max='2020-01-01',return_df=True)
喷气推进实验室/太阳系动力学小天体任务设计套件API
# Search for mission design data for SPK-ID 2000433r=mission_design(spk=2000433)# Print the object data from the returned dictionary object.r['object']
获取近地天体人类太空飞行可接近目标的数据
^{pr21}$从美国宇航局近地天体研究中心(CNEOS)侦察系统获取数据
# Get all available summary data.scout()# Return all summary data as a pandas DataFrame.scout(return_df=True)# Return data and plot files for a specific object by its temporary designation. Note the object may no longer# exist in the current databasescout(tdes='P20UvyK')# Get ephemeris data for a specific object at the current time with a Field of View diameter of 5 arc-minutes# with a limiting V-magnitude of 23.1.scout(tdes='P20UvyK',fov_diam=5,fov_vmag=23.1)
从近地天体研究中心(CNEOS)哨兵系统获取数据
# Get summary data for available sentry objects.sentry()# Get summary data as a pandas DataFramesentry(return_df=True)# Get data for a specific Sentry object by its designation.sentry(des=99942)# Get data for objects removed from the Sentry system.sentry(removed=1)
其他函数示例
获取儒略和修改的儒略日期
# Return the modified Julian Date for the current time.julian_date()# Return the non-modified Julian Date for the current time.julian_date(modified=False)# Get the modified Julian Date for 2019-01-01 at midnight.julian_date(year=2019)
许可证
麻省理工学院
- 项目
标签: