pyiem.nws package

Subpackages

Submodules

pyiem.nws.bufkit module

A BUFKIT File Reader.

pyiem.nws.bufkit.read_bufkit(mixedobj)

Read a BUFKIT file and return two pandas dataframes.

The first dataframe is the sounding values with a column called STIM, which can be joined against the index of the station_dataframe.

Parameters:

mixedobj (str or filelike) – What to read.

Returns:

(profile_dataframe, station_dataframe)

pyiem.nws.gini module

Processing of GINI formatted data found on NOAAPORT

class pyiem.nws.gini.GINIZFile(fobj)

Bases: object

Deal with compressed GINI files, which are the standard on NOAAPORT

archive_filename()

Return a filename for this product, we’ll use the format {SOURCE}_{SECTOR}_{CHANNEL}_{VALID}.png

awips_grid()

Return the awips grid number based on the WMO header

current_filename()

Return a filename for this product, we’ll use the format {SOURCE}_{SECTOR}_{CHANNEL}_{VALID}.png

get_bird()

Return a string label for this satellite

get_channel()

Return the channel.

get_sector()

Return the sector.

init_llc()

Initialize Lambert Conic Comformal

init_mercator()

Compute mercator projection stuff

init_projection()

Setup Grid and projection details

init_stereo()

Compute Polar Stereographic

read_header(hdata)

read the header!

pyiem.nws.gini.get_ir_ramp()

Return a np 256x3 array of colors to use for IR

pyiem.nws.gini.int24(data)

Convert to int.

pyiem.nws.gini.uint24(data)

convert three byte data that represents an unsigned int

pyiem.nws.hvtec module

Process HVTEC encoding.

class pyiem.nws.hvtec.HVTEC(tokens, nwsli_provider=None)

Bases: object

Hydro VTEC.

pyiem.nws.hvtec.contime(s)

Process a string into time.

pyiem.nws.hvtec.parse(text, nwsli_provider=None, tp=None)

Return list of HVTEC entries found within text.

Parameters:
  • text (str) – String to look for HVTEC tokens within.

  • nwsli_provider (dict) – Provider of metadata.

  • tp (TextProduct) – TextProduct instance used for provider and warnings.

Returns:

list(HVTEC)

pyiem.nws.lsr module

The Atomic Local Storm Report … Report

class pyiem.nws.lsr.LSR

Bases: object

Represents a single Local Storm Report within the LSRProduct

assign_timezone(tz, z)

retroactive assignment of timezone, so to improve attrs

consume_magnitude(text)

Convert LSR magnitude text into something atomic

get_dbtype()

Return the typecode used in the database for this event type

get_jabbers(uri)

Return a Jabber formatted message tuple.

get_lat()

Return the LSR latitude.

get_lon()

Return the LSR longitude.

mag_string()

Return a string representing the magnitude and units

sql(txn)

Provided a database transaction object, persist this LSR

pyiem.nws.nwsli module

National Weather Service Location Idenitifiers (NWSLI)

A class to store metadata associated with a NWSLI entry.

class pyiem.nws.nwsli.NWSLI(identifier, name=None, wfos=None, lon=0, lat=0)

Bases: object

National Weather Service Location Idenitifiers (NWSLI)

get_name()

Return the name of this NWSLI, uses self.id if name is unset

Returns:

the name of this site

Return type:

str

pyiem.nws.product module

Base Class encapsulating a NWS Text Product

class pyiem.nws.product.TextProduct(text, utcnow=None, ugc_provider: UGCProvider | dict | None = None, nwsli_provider=None, parse_segments=True)

Bases: WMOProduct

class representing a NWS Text Product

get_affected_wfos()

Based on the ugc_provider, figure out which WFOs are impacted by this product

get_channels()

Return a list of channels

get_jabbers(uri, _uri2=None)

Return a tuple of jabber messages [(plain, html, xtra_dict)]

Parameters:

uri (str) – the base URI to use to construct links

Returns:

[(str, str, dict)]

get_main_headline(default='')

Return a string for the main headline, if it exists

get_nicedate()

Nicely format the issuance time of this product

get_product_id()

Get an identifier of this product used by the IEM

get_signature() str | None

Attempt to glean the free form text that is a signature.

is_correction()

Is this product a correction?

Sadly, this is not as easy as it should be. It turns out that some products do not have a proper correction mechanism, so offices will just brute force in a note into the MND header. So we have to do some further checking…

Returns:

Is this product a correction?

Return type:

bool

is_resent()

Check to see if this product is a …RESENT product

parse_afos()

Figure out what the AFOS PIL is

parse_attn_rfc()

Figure out which RFCs this product is seeking attention

parse_attn_wfo()

Figure out which WFOs this product is seeking attention

parse_segments()

Split the product by its $$

suv_iter()

Yield [(segment, ugcs, vtec)] combos found in product.

class pyiem.nws.product.TextProductSegment(text, tp: TextProduct)

Bases: object

A segment of a Text Product

get_affected_wfos() list[str]

Based on the ugc_provider, figure out which WFOs are impacted by this product segment

get_hvtec_cause()

Return the first hvtec cause entry, if it exists

get_hvtec_nwsli()

Return the first hvtec NWSLI entry, if it exists

get_hvtec_record()

Return the first hvtec record entry, if it exists

get_hvtec_severity()

Return the first hvtec severity entry, if it exists

get_ugcs_list()

Helper to return a list useful for SQL.

get_ugcs_tuple()

Helper to return a tuple useful for SQL.

parse_headlines()

Find headlines in this segment

process_bullets()

Figure out the bulleted segments

process_latlon()

Parse the segment looking for the ‘standard’ LAT…LON encoding

process_tags()

Find various tags in this segment

process_time_mot_loc()

Try to parse the TIME…MOT…LOC

special_tags_to_text()

Convert the special tags into a nice text

Special search the product for special text

pyiem.nws.product.checker(lon, lat, strdata)

make sure our values are within physical bounds

pyiem.nws.product.damage_survey_pns(prod, data)

Glean out things, hopefully.

pyiem.nws.product.date_tokens2datetime(tokens)

Convert tokens from MND regex to a valid time, if possible.

Returns:

3-4 char timezone string tz (datetime.timezone): of this product utcvalid (datetimetz): of this product

Return type:

z (str)

pyiem.nws.product.qc_is_emergency(seg)

Belt + Suspenders check that this segment is an emergency.

pyiem.nws.product.str2polygon(strdata)

Convert some string data into a polygon

pyiem.nws.ugc module

Something to store UGC information!

class pyiem.nws.ugc.UGC(state, geoclass, number, name=None, wfos=None)

Bases: object

Representation of a single UGC

class pyiem.nws.ugc.UGCProvider(legacy_dict=None, pgconn=None, valid=None)

Bases: object

Wrapper around dataframe to provide UGC information.

get(key: str | UGC, is_firewx=False) UGC

Return what this provider knows about a given UGC.

The complication is that we always want something, either a newly created UGC instance or a new one materialized by the internal dataframe stored metadata.

Parameters:
  • key (str or UGC) – the UGC to lookup

  • is_firewx (bool) – is this a fire weather product, so firewx zones

Returns:

UGC instance

pyiem.nws.ugc.parse(text: str, valid: datetime, ugc_provider: UGCProvider | None = None, is_firewx: bool = False) tuple[list[UGC], datetime | None]

Return UGC list and expiration time.

Parameters:
  • text (str) – text to parse.

  • valid (datetime) – the text product’s valid time.

  • ugc_provider (UGCProvider) – what will generate UGC instances for us.

  • is_firewx (bool) – is this product a fire weather product.

pyiem.nws.ugc.str2time(text, valid)

Convert a string that is the UGC product expiration to a valid datetime @param text string to convert @param valid datetime instance

pyiem.nws.ugc.ugcs_to_text(ugcs)

Convert a list of UGC objects to a textual string

pyiem.nws.vtec module

Support NWS VTEC encoding

class pyiem.nws.vtec.VTEC(tokens)

Bases: object

A single VTEC encoding instance

get_action_string()

Return the action string

get_begin_string(prod)

Return an appropriate beginning string for this VTEC

get_end_string(prod)

Return an appropriate end string for this VTEC

get_id(year)

Return a custom string identifier for this VTEC product

This is used by the Live client

get_ps_string()

Return the combination of Phenomena + Significance as string

product_string()

Return the combination of action and phenomena+significance

s2()

Return a commonly used string representation.

s3()

Return a commonly used string representation.

url(year)

Generate a VTEC url string needed

pyiem.nws.vtec.contime(text)

Convert text into a UTC datetime.

pyiem.nws.vtec.get_action_string(action)

Return the action string

pyiem.nws.vtec.get_ps_string(phenomena, significance)

Return the combination of Phenomena + Significance as string

pyiem.nws.vtec.parse(text)

I look for and return vtec objects as I find them

Module contents

NWS specific codes

A collection of codes to support the processing of NWS products and NWS terminology.