jma提要的python客户端库。

jma-feed的Python项目详细描述


JMA馈送

用于JMA feed的python客户端库。

此项目是使用jacebrowning/template-python使用cookiecutter生成的。

Unix Build StatusCoverage StatusScrutinizer Code QualityDocumentation StatusPyPI VersionPyPI License

设置

要求

  • Python3.6+

安装

使用pip安装jma feed:

$ pip install jma-feed

或者直接从源代码:

$ git clone https://github.com/tearoom6/jma-feed.git
$ cd jma-feed
$ python setup.py install

用法

安装后,可以导入包:

importjma_feedjma_feed.__version__

可以从Atom源检索报告:

all_reports=jma_feed.fetch_all_reports(long_term=False)all_meteorology_reports=jma_feed.fetch_all_meteorology_reports(long_term=False)all_seismology_reports=jma_feed.fetch_all_seismology_reports(long_term=False)all_volcanology_reports=jma_feed.fetch_all_volcanology_reports(long_term=False)

报告API:

control=report.controlprint(control.title)print(control.date_time)print(control.status)print(control.editorial_office)print(control.publishing_office)head=report.headprint(head.title)print(head.report_date_time)print(head.target_date_time)print(head.event_id)print(head.info_type)print(head.serial)print(head.info_kind)print(head.info_kind_version)print(head.headline_text)forheadline_informationinhead.headline_information_list:print(headline_information.type)foriteminheadline_information.items:print(item.areas_code_type)forkindinitem.kinds:print(kind.name)print(kind.code)print(kind.condition)forareainitem.areas:print(area.name)print(area.code)body=report.body# Meteorologyifisinstance(body,jma_feed.ReportBodyMeteorology):target_area=body.target_areaiftarget_area:print(target_area.name)print(target_area.code)comment=body.commentifcomment:fortextincomment.texts:print(text.text)fornoticeinbody.notices:print(notice)forwarninginbody.warnings:foriteminwarning.items:print(item.change_status)print(item.full_status)print(item.editing_mark)ifitem.area:print(item.area.name)print(item.area.code)forkindinitem.kinds:print(kind.name)print(kind.code)print(kind.status)print(kind.condition)formeteorological_infoinbody.meteorological_infos:print(meteorological_info.date_time)print(meteorological_info.duration)print(meteorological_info.name)foriteminmeteorological_info.items:print(item.change_status)print(item.full_status)print(item.editing_mark)ifitem.area:print(item.area.name)print(item.area.code)forkindinitem.kinds:print(kind.name)print(kind.code)print(kind.status)print(kind.condition)fortime_series_infoinbody.time_series_infos:fortime_defineinmeteorological_info.time_defines:print(time_define.date_time)print(time_define.duration)print(time_define.name)foriteminmeteorological_info.items:print(item.change_status)print(item.full_status)print(item.editing_mark)ifitem.area:print(item.area.name)print(item.area.code)forkindinitem.kinds:print(kind.name)print(kind.code)print(kind.status)print(kind.condition)# Seismologyifisinstance(body,jma_feed.ReportBodySeismology):print(body.naming)print(body.text)print(body.next_advisory)comments=body.commentsifcommentsandcomments.warning_comment:print(comments.warning_comment.text)print(comments.warning_comment.code)print(comments.warning_comment.code_type)ifcommentsandcomments.forecast_comment:print(comments.forecast_comment.text)print(comments.forecast_comment.code)print(comments.forecast_comment.code_type)ifcommentsandcomments.observation_comment:print(comments.observation_comment.text)print(comments.observation_comment.code)print(comments.observation_comment.code_type)ifcommentsandcomments.var_comment:print(comments.var_comment.text)print(comments.var_comment.code)print(comments.var_comment.code_type)ifcommentsandcomments.free_form_comment:print(comments.free_form_comment)tsunami=body.tsunamiforearthquakeinbody.earthquakes:print(earthquake.origin_time)print(earthquake.arrival_time)print(earthquake.condition)formagnitudeinearthquake.magnitudes:print(magnitude)hypocenter=earthquake.hypocenterifhypocenter:print(hypocenter.source)ifhypocenter.area:print(hypocenter.area.name)print(hypocenter.area.code)print(hypocenter.area.coordinate)# Volcanologyifisinstance(body,jma_feed.ReportBodyVolcanology):print(body.notice)print(body.text)forvolcano_infoinbody.volcano_infos:foriteminvolcano_info.items:ifitem.kind:print(item.kind.name)print(item.kind.formal_name)print(item.kind.code)print(item.kind.condition)forareainitem.areas:print(area.name)print(area.code)print(area.coordinate)forash_infoinbody.ash_infos:print(ash_info.start_time)print(ash_info.end_time)foriteminash_info.items:ifitem.kind:print(item.kind.name)print(item.kind.formal_name)print(item.kind.code)print(item.kind.condition)forareainitem.areas:print(area.name)print(area.code)print(area.coordinate)

馈送API(低级API):

# High-frequency feed# Regular (定時: 気象に関する情報のうち、天気概況など定時に発表されるもの)feed_url=jma_feed.FEED_URL_REGULAR_SHORT_TERM# Extra (随時: 気象に関する情報のうち、警報・注意報など随時発表されるもの)feed_url=jma_feed.FEED_URL_EXTRA_SHORT_TERM# Earthquake/Volcano (地震火山: 地震、火山に関する情報)feed_url=jma_feed.FEED_URL_EQVOL_SHORT_TERM# Others (その他: 上記3種類のいずれにも属さないもの)feed_url=jma_feed.FEED_URL_OTHER_SHORT_TERM# Long-term feed# Regular (定時: 気象に関する情報のうち、天気概況など定時に発表されるもの)feed_url=jma_feed.FEED_URL_REGULAR_LONG_TERM# Extra (随時: 気象に関する情報のうち、警報・注意報など随時発表されるもの)feed_url=jma_feed.FEED_URL_EXTRA_LONG_TERM# Earthquake/Volcano (地震火山: 地震、火山に関する情報)feed_url=jma_feed.FEED_URL_EQVOL_LONG_TERM# Others (その他: 上記3種類のいずれにも属さないもの)feed_url=jma_feed.FEED_URL_OTHER_LONG_TERMfeed=jma_feed.AtomFeed(feed_url)print(feed.id)print(feed.title)print(feed.subtitle)print(feed.updated)print(feed.rights)entries=feed.entriesforentryinentries:print(entry.id)print(entry.title)print(entry.updated)print(entry.author)print(entry.content)print(entry.link)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何将jaxb插件扩展与gradlejaxbplugin一起使用   java Hibernate列表<Object[]>到特定对象   java使用多态性显示arraylist的输出   java水平堆叠卡,带有一定偏移量   java错误:找不到符号方法liesInt()   java客户机/服务器文件收发中的多线程流管理   在java中可以基于访问重载方法吗?   包含空元素的java排序数组   swing Java按钮/网格布局   java BottomNavigationView getmaxitemcount   java空指针异常字符串生成器   java Xamarin升级导致“类文件版本错误52.0,应为50.0”错误   java我正在尝试打印它,而不只是对每一行进行println   Tomcat7中的java是否需要复制上下文。将xml转换为conf/Catalina/locahost以使其生效   带有注入服务的java REST端点在何处引发自定义WebServiceException?   在Java中使用GPS数据   java如何将JFreeChart ChartPanel导出到包含添加的CrosshairOverlay的图像对象?   内置Eclipse期间的Java 8堆栈溢出   java在GWT编译的JavaScript中如何表示BigDecimal