Python client library for JMA feed.
Project description
jma-feed
Python client library for JMA feed.
This project was generated with cookiecutter using jacebrowning/template-python.
Setup
Requirements
- Python 3.6+
Installation
Install jma-feed with pip:
$ pip install jma-feed
or directly from the source code:
$ git clone https://github.com/tearoom6/jma-feed.git
$ cd jma-feed
$ python setup.py install
Usage
After installation, the package can imported:
import jma_feed
jma_feed.__version__
Report can be retrieved from Atom feeds:
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)
Report API:
control = report.control
print(control.title)
print(control.date_time)
print(control.status)
print(control.editorial_office)
print(control.publishing_office)
head = report.head
print(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)
for headline_information in head.headline_information_list:
print(headline_information.type)
for item in headline_information.items:
print(item.areas_code_type)
for kind in item.kinds:
print(kind.name)
print(kind.code)
print(kind.condition)
for area in item.areas:
print(area.name)
print(area.code)
body = report.body
# Meteorology
if isinstance(body, jma_feed.ReportBodyMeteorology):
target_area = body.target_area
if target_area:
print(target_area.name)
print(target_area.code)
comment = body.comment
if comment:
for text in comment.texts:
print(text.text)
for notice in body.notices:
print(notice)
for warning in body.warnings:
for item in warning.items:
print(item.change_status)
print(item.full_status)
print(item.editing_mark)
if item.area:
print(item.area.name)
print(item.area.code)
for kind in item.kinds:
print(kind.name)
print(kind.code)
print(kind.status)
print(kind.condition)
for meteorological_info in body.meteorological_infos:
print(meteorological_info.date_time)
print(meteorological_info.duration)
print(meteorological_info.name)
for item in meteorological_info.items:
print(item.change_status)
print(item.full_status)
print(item.editing_mark)
if item.area:
print(item.area.name)
print(item.area.code)
for kind in item.kinds:
print(kind.name)
print(kind.code)
print(kind.status)
print(kind.condition)
for time_series_info in body.time_series_infos:
for time_define in meteorological_info.time_defines:
print(time_define.date_time)
print(time_define.duration)
print(time_define.name)
for item in meteorological_info.items:
print(item.change_status)
print(item.full_status)
print(item.editing_mark)
if item.area:
print(item.area.name)
print(item.area.code)
for kind in item.kinds:
print(kind.name)
print(kind.code)
print(kind.status)
print(kind.condition)
# Seismology
if isinstance(body, jma_feed.ReportBodySeismology):
print(body.naming)
print(body.text)
print(body.next_advisory)
comments = body.comments
if comments and comments.warning_comment:
print(comments.warning_comment.text)
print(comments.warning_comment.code)
print(comments.warning_comment.code_type)
if comments and comments.forecast_comment:
print(comments.forecast_comment.text)
print(comments.forecast_comment.code)
print(comments.forecast_comment.code_type)
if comments and comments.observation_comment:
print(comments.observation_comment.text)
print(comments.observation_comment.code)
print(comments.observation_comment.code_type)
if comments and comments.var_comment:
print(comments.var_comment.text)
print(comments.var_comment.code)
print(comments.var_comment.code_type)
if comments and comments.free_form_comment:
print(comments.free_form_comment)
tsunami = body.tsunami
for earthquake in body.earthquakes:
print(earthquake.origin_time)
print(earthquake.arrival_time)
print(earthquake.condition)
for magnitude in earthquake.magnitudes:
print(magnitude)
hypocenter = earthquake.hypocenter
if hypocenter:
print(hypocenter.source)
if hypocenter.area:
print(hypocenter.area.name)
print(hypocenter.area.code)
print(hypocenter.area.coordinate)
# Volcanology
if isinstance(body, jma_feed.ReportBodyVolcanology):
print(body.notice)
print(body.text)
for volcano_info in body.volcano_infos:
for item in volcano_info.items:
if item.kind:
print(item.kind.name)
print(item.kind.formal_name)
print(item.kind.code)
print(item.kind.condition)
for area in item.areas:
print(area.name)
print(area.code)
print(area.coordinate)
for ash_info in body.ash_infos:
print(ash_info.start_time)
print(ash_info.end_time)
for item in ash_info.items:
if item.kind:
print(item.kind.name)
print(item.kind.formal_name)
print(item.kind.code)
print(item.kind.condition)
for area in item.areas:
print(area.name)
print(area.code)
print(area.coordinate)
Feed API (Low-level 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_TERM
feed = jma_feed.AtomFeed(feed_url)
print(feed.id)
print(feed.title)
print(feed.subtitle)
print(feed.updated)
print(feed.rights)
entries = feed.entries
for entry in entries:
print(entry.id)
print(entry.title)
print(entry.updated)
print(entry.author)
print(entry.content)
print(entry.link)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jma_feed-0.9.0.tar.gz
(19.2 kB
view details)
Built Distribution
jma_feed-0.9.0-py3-none-any.whl
(94.2 kB
view details)
File details
Details for the file jma_feed-0.9.0.tar.gz
.
File metadata
- Download URL: jma_feed-0.9.0.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.11 CPython/3.6.8 Darwin/18.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 789071b7e6e9d7701a2a4e6e844599c9fc18da650eb3b9c20a43596fb4bf9c37 |
|
MD5 | ac69fe955f375981b91f3acb7d26940a |
|
BLAKE2b-256 | cd7984dad438c20a7d5ab2d03a9e212c6c842139fa99cfc1731b8edf67122660 |
File details
Details for the file jma_feed-0.9.0-py3-none-any.whl
.
File metadata
- Download URL: jma_feed-0.9.0-py3-none-any.whl
- Upload date:
- Size: 94.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.11 CPython/3.6.8 Darwin/18.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a33ccbdc9d09505fcfb33c40a17dc2d312b0efbbc208573e255b2fad04447033 |
|
MD5 | 71606444988d7482696e416ba444f487 |
|
BLAKE2b-256 | 867ed488bcbd951b75a1b055c2efd0a55c72818ea82fe97d5bd7627fd7e94b86 |