pyiem.observation module#

A class representing an observation stored in the IEM database

pyiem.observation.get_summary_table(valid)[source]#

Optimize the summary table we potentially use.

Parameters:

valid (datetime with time zone) – Datetime

Returns:

str table to query

pyiem.observation.bounded(val, floor, ceiling)[source]#

Make sure this is not NaN and between some value.

pyiem.observation.summary_update(txn, data)[source]#

Updates the summary table and returns affected rows.

Parameters:
  • txn (psycopg.transaction)

  • data (dict)

Returns:

affected rows count

Return type:

int

class pyiem.observation.Observation(station=None, network=None, valid=None, iemid=None, tzname=None)[source]#

Bases: object

my observation object

Parameters:
load(txn)[source]#

Load the current observation for this site and time

calc()[source]#

Compute things not usually computed

compute_iemid(txn)[source]#

Load in what our metadata is to save future queries

save(txn, force_current_log=False, skip_current=False)[source]#

Save this observation to the database via a psycopg transaction @param txn is a psycopg transaction @param force_current_log boolean - make sure this observation goes to the current_log table in the case that it is old, this allows reprocessing by the METAR ingestor et al @param skip_current boolean - optionally skip updating the current table. This is useful for partial obs @return: boolean if this updated one row each