用于geonet nz quakes feed的异步geojson客户端库。
aio-geojson-geonetnz-quakes的Python项目详细描述
python aio geojson geonetnz地震
此库可方便地异步访问 GeoNet NZ Quakes馈送。
安装
pip install aio-geojson-geonetnz-quakes
用法
有关如何使用此库的示例,请参见下文。在实例化
特定的类-feed或feed管理器-并提供所需的参数,
您可以调用update
来检索提要数据。返回值
将是状态代码和实际数据的元组,形式为
特定于选定源的源条目。
状态代码
- ok:更新进行得很顺利,数据被检索到。图书馆可能仍然 返回空数据,例如因为没有满足筛选条件的条目 标准。
- ok_no_data:更新正常,但未检索到数据,例如 因为服务器指示自上次请求以来没有更新。
- error:更新过程中出错
参数
Parameter | Description |
---|---|
^{ | Coordinates (tuple of latitude/longitude) |
^{ | Request quakes that may have caused shaking greater than or equal to the MMI value in the New Zealand region. Allowable values are -1..8 inclusive. Default: -1 is used for quakes that are too small to calculate a stable MMI value for. |
支持的筛选器
Filter | Description | |
---|---|---|
Radius | ^{ | Radius in kilometers around the home coordinates in which events from feed are included. |
Minimum Magnitude | ^{ | Minimum magnitude as float value. Only events with a magnitude equal or above this value are included. |
Time | ^{ | Time interval; only events with a reported origin time that falls within now and this past time interval are included. |
示例
importasynciofromaiohttpimportClientSessionfromaio_geojson_geonetnz_quakesimportGeonetnzQuakesFeedasyncdefmain()->None:asyncwithClientSession()aswebsession:# Home Coordinates: Latitude: -41.2, Longitude: 174.7# MMI: 2# Filter radius: 200 km# Filter minimum magnitude: 2.5feed=GeonetnzQuakesFeed(websession,(-41.2,174.7),mmi=2,filter_radius=200,filter_minimum_magnitude=2.5)status,entries=awaitfeed.update()print(status)print(entries)asyncio.get_event_loop().run_until_complete(main())
馈送条目属性
每个提要条目都填充有以下属性:
Name | Description | Feed attribute |
---|---|---|
geometry | All geometry details of this entry. | ^{ |
coordinates | Best coordinates (latitude, longitude) of this entry. | ^{ |
external_id | The unique public identifier for this quake. | ^{ |
title | Title of this entry. | ^{ |
attribution | Attribution of the feed. | n/a |
distance_to_home | Distance in km of this entry to the home coordinates. | n/a |
time | The origin time of the quake. | ^{ |
depth | The depth of the quake in km. | ^{ |
magnitude | The summary magnitude for the quake. | ^{ |
locality | Distance and direction to the nearest locality. | ^{ |
mmi | The calculated MMI shaking at the closest locality in the New Zealand region. | ^{ |
quality | The quality of this information: best, good, caution, deleted. | ^{ |
饲料管理器
feed管理器通过通知 feed的使用者关于新的feed条目、更新和删除的条目 与上次源更新相比。
- 如果当前的feed更新是第一个,那么所有feed条目都将是 报告为新的。提要管理器将跟踪所有提要条目' 已成功处理的外部ID。
- 如果当前的feed更新不是第一次更新,那么feed管理器将
生产三套:
- 不在上一个提要更新中但在 当前源更新将报告为新的。
- 在上一个提要更新中仍在 当前源更新将报告为待更新。
- 在上一个提要更新中但不在 当前源更新将被报告为已删除。
- 如果当前更新失败,则前一个更新中处理的所有feed条目 将报告要删除源更新。
从feed成功更新后,feed管理器提供了两个 不同日期:
last_update
将是 饲料如果此库的用户希望 以不同的方式处理源更新中的间歇性错误。last_timestamp
(可选,取决于提要数据)将是最新的 从feed数据中提取的时间戳。 这要求底层的feed数据实际上包含一个合适的 日期。如果此库的用户希望 如果feed条目没有实际更新,则处理方式会有所不同。