[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[python #LMS-970136]: Metpy METAR Parsing
- Subject: [python #LMS-970136]: Metpy METAR Parsing
- Date: Sun, 22 Nov 2020 19:47:53 -0700
Greetings!
Apologies on the delayed response.
The problem with those data files from the NOAA FTP are that the lines are
formatted like:
11641TJSJ SJU20201001010516010/01/20 01:05:31 5-MIN TJSJ 010505Z 19006KT
10SM TS SCT030CB SCT044 BKN060 24/22 A2998 -40 87 1100 200/06 RMK AO2 OCNL
LTGIC SW NW TS SW NW MOV NW T02440222 $
The beginning "11641TJSJ SJU20201001010516010/01/20 01:05:31 5-MIN " are part
of standard METAR reports and are what's breaking MetPy's parser. If you want
to use these with MetPy, you can either perform the string manipulation on each
of the lines and pass only the METAR text to
`metpy.io.parse_metar_to_dataframe`:
https://unidata.github.io/MetPy/latest/api/generated/metpy.io.parse_metar_to_dataframe.html#metpy.io.parse_metar_to_dataframe
or reformat the entire file using something like:
with open('64010TJSJ202010.dat', 'rt') as infile, open('metar.txt', 'wt')
as outfile:
for line in infile:
outfile.write(line[53:])
Hope this helps,
Ryan
> I was trying to use a particular module within Metpy to parse
> METARs to aid in research and make METAR data more manageable by turning it
> into csv's. I am aware that Metpy can utilize parse_metar_file to parse
> THREDDS METAR data that you guys host, but I was running into compatibility
> issues when trying to apply it to 5-minute Metar files found on
> NCEI's website (ftp://ftp.ncdc.noaa.gov/pub/data/asos-fivemin/). I am using
> Spyder to write and debug the scripts that I work on, in case that is
> useful information.
>
> Is the parser found within Metpy able to handle different formats?
> Examining the different text files shows they are clearly different, but
> just wanted to make sure. Thanks for your time!
Ticket Details
===================
Ticket ID: LMS-970136
Department: Support Python
Priority: Low
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata
inquiry tracking system and then made publicly available through the web. If
you do not want to have your interactions made available in this way, you must
let us know in each email you send to us.