ScottSturdivant / rpi_metar

METAR LED Display for a Raspberry Pi
MIT License
26 stars 16 forks source link

Detect TS only in body of METAR #9

Closed peepsnet closed 5 years ago

peepsnet commented 5 years ago

The code for checking if a metar contains any TS is missing one qualifyer.

TS can appear alone in a metar:

KPBI 011956Z 14015KT 10SM TS SCT027CB SCT090 BKN250 32/21 A2991 RMK AO2 LTG DSNT N TSB56 OCNL LTGICCC NW-N TS NW-N MOV SE T03220206

This line does not detect that TS by itself

https://github.com/ScottSturdivant/rpi_metar/blob/7b67181c3d5b59ead807a4c06cb7fc9f8293a5bb/rpi_metar/airports.py#L88

I propose the line be:

self.thunderstorms = any(word in metar['raw_text'] for word in ['TSRA', 'VCTS', 'TS ']) and self.category != wx.FlightCategory.OFF

By adding the "TS "(with a space) you will catch all the TS in the body of the metar

thommo17 commented 5 years ago

Will this also capture METARs with a heavy (+) symbol? eg. +TSRA

peepsnet commented 5 years ago

Will this also capture METARs with a heavy (+) symbol? eg. +TSRA

Yes. The function

word in metar['raw_text'] for word in ['TSRA', 'VCTS', 'TS ']

will find any instance of the options: TSRA or VCTS or TS

ScottSturdivant commented 5 years ago

Agreed that it'd be nice to search for "TS" as a weather modifier. This particular modification however would match too much - for instance, the ICAO of KSTS would always match, regardless of their weather conditions.

Would you be able to convert it into something more strict?

Thanks for working on it!

peepsnet commented 5 years ago

That is why I asked to match "TS " (Notice the space after TS).

More strict would be " TS "(a space on each side)

I am using the modified code with success

ScottSturdivant commented 5 years ago

KSTS 021853Z VRB04KT 10SM SCT026 17/12 A2989 RMK AO2 SLP115 T01670122 would still get matched with the trailing space.

Are there other modifiers that get combined with TS? I'm afraid that " TS " might then miss something like "TSSH". Maybe the best search would be for TS anywhere in the body that's NOT the first word (the ICAO code)?

peepsnet commented 5 years ago

Well... According to this page: http://moratech.com/aviation/metar-class/metar-pg9-ww.html#DECODE

Any time thunderstorms are mentioned it is the leading letters in the identifier except for VCTS

So... ' TS', '+TS', '-TS', 'VCTS' would find all the variables... but it would also match:

TSB25RAB25

but that would always exist after RMK if you delete the first 4 chars and everything after RMK then all that is left would be current weather data. Then that var could be searched for ' TS', '+TS', '-TS', 'VCTS'

Any value there??

ScottSturdivant commented 5 years ago

What do you think about this regex that looks for TS between the ICAO and RMK (if it exists)? That way it won't match any remarks about a TS having ended.

peepsnet commented 5 years ago

What do you think about this regex that looks for TS between the ICAO and RMK (if it exists)? That way it won't match any remarks about a TS having ended.

Looks good. The only thing left is to release it on the world and wait to be proven wrong! :)

ScottSturdivant commented 5 years ago

@peepsnet, did you want to update your PR to go with the regex approach from #9, or would you prefer I just make the change and close this PR?

ScottSturdivant commented 5 years ago

Fixed this in f9f549e, closing.