这篇文章的目的是展现给读者如何从使用pyearthquake模块美国地质勘探局绘制近期日本地震数据。如果您想了解更多的信息pyearthquakemodule, take a look在这个岗位where I previously used it.pyearthquake被暴露的API一个纯Python模块检索来自数据美国地质勘探局网站从井中MODIS快速反应系统(最近,他们创造了一个单独的项目处理日常日本图像)。
安装pyearthquake
我们需要做的第一件事就是安装Pythonpyearthquakemodule, you can do it usingeasy_install的从setuptools的:
easy_install的pyearthquake
该easy_install的应自动处理所需要的模块,但如果你面对的问题(特别是在Ubuntu与底图,这里是版本要求:matplotlib> = 0.99.0,numpy的> = 1.3.0,PIL>= 1.1.6 andbasemap> = 0.99.4。
检索目录USGS
美国地质勘探局提供后续目录的数据集:
M1 +地震(past hour) –M1 + PAST_HOUR
This is the worldwide catalog with earthquake data from the past hour;
M1 +地震(过去的一天) -M1 + PAST_DAY
这是全球目录从过去一天的地震数据;
M1 +地震(past 7 days) –M1 + PAST_7DAY
这是全球目录与过去7天的地震数据;
这是你如何使用检索任何这些目录pyearthquake:
>>> from pyearthquake import * >>> catalog = usgs.retrieve_catalog("M1+PAST_7DAY") >>> len(catalog) 1179
在这方面,我们有1179incidents withmagnitude 1+从the past 7 days.
现在可以过滤器只与幅度6+,它代表了近期显著地震事件:
>>> mag6_list = [event for event in catalog if float(event["Magnitude"]) >= 6.0] >>> len(mag6_list) 30
我们现在30周,从过去7天的活动6+,让我们打印:
>>>在mag6_list行:...打印行[ “Eqid”],行[ “幅度”],行[ “深度”],...行[ “日期时间”],行[ “深度”],行[ “地区”] ... c0001z5z 6.3 8.70周五,2011年3月11日20时11分22秒UTC 8.70附近本州东海岸,日本c0001z4n 6.6 10.00星期五,2011年3月11日十九时46分49秒UTC 10.00附近本州西海岸,日本c0001z2t 6.1 24.80星期五,2011年3月11日19时02分58秒UTC 24.80附近本州东海岸,日本c0001z2a 6.2 10.00星期五,2011年3月11日18点59分15秒UTC 10.00西临本州海岸,日本c0001yib 6.2 18.90星期五,2011年3月11日15时13分14秒UTC 18.90附近本州东海岸,日本c0001y4u 6.5 11.60星期五,2011年3月11日11时36分39秒UTC 11.60附近的东海岸日本本州(...)
As you can see, almost all last events are earthquakes from the Japan coast. Here, you can extract any individual event and retrieve USGS products like ShakeMaps, etc (see more information in这个帖子on how to fetch and show those USGS products).
事件绘制成图
现在,我们将绘制这些事件到地图(pyearthquake使用matplotlib工具包称为basemap绘制事件到地图):
>>> usgs.plot_events(目录)
“目录”变量是使用USGS之前检索相同的我们M1 + PAST_7DAY目录。
这里是什么什么这个声明将显示:
现在我们可以使用按钮放大到日本, and this is the result:
彩色点是从检索目录的事件,更强烈的颜色越强是地震;看到暗红色的颜色接近成本,该事件是不幸的,灾难性的8.9级大地震摧毁了日本的昨天。
Retrieving near real-time MODIS Rapid Response images
MODIShas processed image subsets of Aqua and Terra satellites. One of these subsets is called“japan”和it has the entire country coverage. Let’s retrieve this MODIS subset and then plot our events in this same map:
>>>进口日期时间>>>现在= datetime.datetime.now()>>> BMAP = modis.get_modis_subset(现为 “日本”,satellite_name = “千佛”,分辨率= “250米”,显示=亚洲金博宝 FALSE)>>> usgs.plot_events(目录,BMAP)
Whatpyearthquake是要在这里做的就是下载(这可能需要一些时间),整个子集250米的分辨率(最好的),解析子集元数据,对齐图像转换成纬度/经度范围的地图,然后绘制事件over this satellite image, so we’ll have the last high resolution satellite images from the Japan together with the earthquake events plot, and here is the result:
And here is the zoom near the coast: