Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
python-metar/sample.py at python-3 · caktus/python-metar · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Uh oh!
There was an error while loading.
Please reload this page
.
caktus
/
python-metar
Public
forked from
python-metar/python-metar
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
python-3
Breadcrumbs
python-metar
/
sample.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
152 lines (132 loc) · 6.1 KB
python-3
Breadcrumbs
python-metar
/
sample.py
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
152 lines (132 loc) · 6.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env python
#
# This is a minimal sample script showing how the individual data
# are accessed from the decoded report. To produce the standard text
# summary of a report, the string() method of the Metar object.
#
# The parsed data are stored as attributes of a Metar object.
# Individual attributes are either strings. instances of one of the
# metar.Datatypes classes, or lists of tuples of these scalars.
# Here's a summary, adapted from the comments in the Metar.Metar.__init__()
# method:
#
# Attribute Comments [data type]
# -------------- --------------------
# code original METAR code [string]
# type METAR (routine) or SPECI (special) [string]
# mod AUTO (automatic) or COR (corrected) [string]
# station_id 4-character ICAO station code [string]
# time observation time [datetime]
# cycle observation cycle (0-23) [int]
# wind_dir wind direction [direction]
# wind_speed wind speed [speed]
# wind_gust wind gust speed [speed]
# wind_dir_from beginning of range for win dir [direction]
# wind_dir_to end of range for wind dir [direction]
# vis visibility [distance]
# vis_dir visibility direction [direction]
# max_vis visibility [distance]
# max_vis_dir visibility direction [direction]
# temp temperature (C) [temperature]
# dewpt dew point (C) [temperature]
# press barometric pressure [pressure]
# runway runway visibility [list of tuples...]
# name [string]
# low [distance]
# high [distance]
# weather present weather [list of tuples...]
# intensity [string]
# description [string]
# precipitation [string]
# obscuration [string]
# other [string]
# recent recent weather [list of tuples...]
# sky sky conditions [list of tuples...]
# cover [string]
# height [distance]
# cloud [string]
# windshear runways w/ wind shear [list of strings]
#
# press_sea_level sea-level pressure [pressure]
# wind_speed_peak peak wind speed in last hour [speed]
# wind_dir_peak direction of peak wind speed in last hour [direction]
# max_temp_6hr max temp in last 6 hours [temperature]
# min_temp_6hr min temp in last 6 hours [temperature]
# max_temp_24hr max temp in last 24 hours [temperature]
# min_temp_24hr min temp in last 24 hours [temperature]
# precip_1hr precipitation over the last hour [precipitation]
# precip_3hr precipitation over the last 3 hours [precipitation]
# precip_6hr precipitation over the last 6 hours [precipitation]
# precip_24hr precipitation over the last 24 hours [precipitation]
#
# _remarks remarks [list of strings]
# _unparsed unparsed remarks [list of strings]
#
# The metar.Datatypes classes (temperature, pressure, precipitation,
# speed, direction) describe an observation and its units. They provide
# value() and string() methods to that return numerical and string
# representations of the data in any of a number of supported units.
#
# (You're going to have to study the source code for more details,
# like the available methods and supported unit conversions for the
# metar.Datatypes objects, etc..)
# In particular, look at the Metar.string()
# method, and the functions it calls.
#
# Feb 4, 2005
# Tom Pollard
#
from
metar
import
Metar
# A sample METAR report
code
=
"METAR KEWR 111851Z VRB03G19KT 2SM R04R/3000VP6000FT TSRA BR FEW015 BKN040CB BKN065 OVC200 22/22 A2987 RMK AO2 PK WND 29028/1817 WSHFT 1812 TSB05RAB22 SLP114 FRQ LTGICCCCG TS OHD AND NW-N-E MOV NE P0013 T02270215"
print
"-----------------------------------------------------------------------"
print
"METAR: "
,
code
print
"-----------------------------------------------------------------------"
# Initialize a Metar object with the coded report
obs
=
Metar
.
Metar
(
code
)
# Print the individual data
# The 'station_id' attribute is a string.
print
"station: %s"
%
obs
.
station_id
if
obs
.
type
:
print
"type: %s"
%
obs
.
report_type
()
# The 'time' attribute is a datetime object
if
obs
.
time
:
print
"time: %s"
%
obs
.
time
.
ctime
()
# The 'temp' and 'dewpt' attributes are temperature objects
if
obs
.
temp
:
print
"temperature: %s"
%
obs
.
temp
.
string
(
"C"
)
if
obs
.
dewpt
:
print
"dew point: %s"
%
obs
.
dewpt
.
string
(
"C"
)
# The wind() method returns a string describing wind observations
# which may include speed, direction, variability and gusts.
if
obs
.
wind_speed
:
print
"wind: %s"
%
obs
.
wind
()
# The peak_wind() method returns a string describing the peak wind
# speed and direction.
if
obs
.
wind_speed_peak
:
print
"wind: %s"
%
obs
.
peak_wind
()
# The visibility() method summarizes the visibility observation.
if
obs
.
vis
:
print
"visibility: %s"
%
obs
.
visibility
()
# The runway_visual_range() method summarizes the runway visibility
# observations.
if
obs
.
runway
:
print
"visual range: %s"
%
obs
.
runway_visual_range
()
# The 'press' attribute is a pressure object.
if
obs
.
press
:
print
"pressure: %s"
%
obs
.
press
.
string
(
"mb"
)
# The 'precip_1hr' attribute is a precipitation object.
if
obs
.
precip_1hr
:
print
"precipitation: %s"
%
obs
.
precip_1hr
.
string
(
"in"
)
# The present_weather() method summarizes the weather description (rain, etc.)
print
"weather: %s"
%
obs
.
present_weather
()
# The sky_conditions() method summarizes the cloud-cover observations.
print
"sky: %s"
%
obs
.
sky_conditions
(
"
\n
"
)
# The remarks() method describes the remark groups that were parsed, but
# are not available directly as Metar attributes. The precipitation,
# min/max temperature and peak wind remarks, for instance, are stored as
# attributes and won't be listed here.
if
obs
.
_remarks
:
print
"remarks:"
print
"- "
+
obs
.
remarks
(
"
\n
- "
)
print
"-----------------------------------------------------------------------
\n
"
You can’t perform that action at this time.