pyiem.nws.products.shef module#

Standard Hydrological Exchange Format (SHEF).

https://www.weather.gov/media/mdl/SHEF_CodeManual_5July2012.pdf

Formats#

.A - single station, multiple parameter .B - multiple station, multiple parameter, header driven .E - single station, single parameter, evenly spaced time series

Implementation Notes#

  • The IEM uses a nomenclature of 0.0001 float value to represent Trace values, not the 0.001 that SHEF does.

  • When DH is blank or DHM, this generates a SHEFElement with a None valid attribute. This is ambiguous behavior to consider further.

Known Limitations#

  • 4.4.4 DIE special end-of-month specifier not implemented

  • 5.1.4 how to handle repeated data not implemented

  • Handle when R is being specified in the AR BR ER

  • 5.1.6 revision of a missing value not implemented

  • 5.2.1 DR codes, DRE end of month not implemented

  • Table 9a D codes not implemented

  • 4.4.1 ugly time logic and DN support

  • Handle UQ variable SSS.SDDD

  • Handle UR (tens of degrees)

pyiem.nws.products.shef.parse_d_wrapper(func)[source]#

Catch exceptions.

pyiem.nws.products.shef.make_date(text, now=None)[source]#

Make the text date unambiguous.

pyiem.nws.products.shef.parse_dc(text, basevalid)[source]#

Convert the DC element into a timestamp.

pyiem.nws.products.shef.parse_dy(text, basevalid)[source]#

Convert the DY element into a timestamp.

pyiem.nws.products.shef.datetime24(dt, replacements)[source]#

Handle the junkiness that is a 24 hour.

pyiem.nws.products.shef.parse_dh(text, valid)[source]#

Inner.

pyiem.nws.products.shef.parse_station_valid(text, utcnow)[source]#

Parse the first token found in a SHEF observation.

Parameters:
  • text (str) – the first part of the string

  • utcnow (datetime) – The default time.

Return type:

str, datetime, datetime, list

pyiem.nws.products.shef.process_di(text)[source]#

Convert a DI value into an interval.

pyiem.nws.products.shef.parse_dm(text, valid)[source]#

Inner.

pyiem.nws.products.shef.parse_dd(text, valid)[source]#

Inner.

pyiem.nws.products.shef.parse_dt(text, valid)[source]#

Inner.

pyiem.nws.products.shef.process_modifiers(text, diction, basevalid)[source]#

Apply modifications based on what the token is telling us.

Parameters:
  • text (str) – Potential new information.

  • diction (SHEFElement) – our current elemenet definition

  • basevalid (datetime) – the base valid in case of relative time.

Return type:

bool for if this text was handled.

pyiem.nws.products.shef.process_message_e(prod, message)[source]#

Process a text string in E SHEF format.

Parameters:
  • prod (SHEFProduct) – the product we are working on.

  • message (str) – The string to parse.

Return type:

List[SHEFElement]

pyiem.nws.products.shef.strip_comments(line)[source]#

Remove comments.

pyiem.nws.products.shef.clean_b_headerline(text)[source]#

Account for invalid encoding. SIGH.

pyiem.nws.products.shef.process_message_b(prod, message)[source]#

Convert the message into an object.

Return type:

List[SHEFElement]

pyiem.nws.products.shef.slash_tokenize(message)[source]#

Carefully discover tokens.

pyiem.nws.products.shef.process_message_a(prod, message)[source]#

Convert the message into an object.

Return type:

List[SHEFElement]

pyiem.nws.products.shef.process_messages(func, prod, messages)[source]#

Safe frontend to do message processing.

Return type:

int

pyiem.nws.products.shef.parse_A(prod)[source]#

Parse A format SHEF data.

Return type:

int

pyiem.nws.products.shef.parse_B(prod)[source]#

Parse B format SHEF data.

Return type:

int

pyiem.nws.products.shef.parse_E(prod)[source]#

Parse E format SHEF data.

Return type:

int

pyiem.nws.products.shef.compute_num_value(element)[source]#

Attempt to make this into a float.

Return type:

bool

class pyiem.nws.products.shef.SHEFProduct(text, utcnow=None, ugc_provider=None, nwsli_provider=None)[source]#

Bases: TextProduct

A single text product containing SHEF encoded data.

pyiem.nws.products.shef.parser(text, utcnow=None, ugc_provider=None, nwsli_provider=None)[source]#

Parser.