src.utils.snowflake

Module Contents

src.utils.snowflake.logger[source]
src.utils.snowflake.config[source]
src.utils.snowflake.channel_like = register://electricity/0/activepower/%?avg=15[source]
src.utils.snowflake.column_details =[source]

(BOXID VARCHAR(50), L VARCHAR(5), YEAR NUMBER(4), WEEK NUMBER(2), PROCESSED_ON TIMESTAMP_TZ, MAX DOUBLE, MIN DOUBLE)

src.utils.snowflake.format_connection(name)[source]

Get (connection) details in the right format for different tables.

Parameters
namename of the different sources
Returns
Connection
src.utils.snowflake.read_meta(boxid=None)[source]

Read meta preprocess of DALI box.

Parameters
boxidlist

ID of DALI box to read. None results in all available preprocess of DALI boxes that have nominal power specified.

Returns
pd.DataFrame with metadata.
src.utils.snowflake.make_week_extremes_query(boxid=None, last_processed=dt.datetime(2001, 1, 1))[source]

Build the query to request week extremes.

Parameters
boxidlist

If not None: select specific boxes.

last_processed: datetime

Date to determine week extremes from. Cuts are always made on the last monday.

Returns
str

Query string.

src.utils.snowflake.create_table_query(query)[source]

Make query to create or replace table and insert preprocess of select query.

Parameters
querystr

Select query to be used.

Returns
str

New query

src.utils.snowflake.insert_table_query(query)[source]

Make query to insert preprocess of select query in an existing table.

Parameters
querystr

Select query to be used.

Returns
str

New query

src.utils.snowflake.create_week_extremes()[source]

Execute query to create whole new table of week extremes asynchroniously.

src.utils.snowflake.get_last_processed_time()[source]

Retrieve last time table update has been done.

Returns
datetime

Last processing time.

src.utils.snowflake.update_week_extremes()[source]

Update week extremes from last processing time upt o last monday.

src.utils.snowflake.read_week_extremes(boxid=None, L=None)[source]

Read week extremes for a DALI box and phase.

Parameters
boxid: list

If not None: A list with DALI box IDs to read.

L: str

The phases to retrieve (sumli, L1, L2, L3)

Returns
pd.DataFrame

Week extremes.

src.utils.snowflake.clear_forecasts()[source]

Clear the table with forecasts.

Returns
None
src.utils.snowflake.clear_forecast_meta()[source]

Clear the table with forecast metadata.

Returns
None
src.utils.snowflake.write_forecasts(df)[source]

Write results into the Snowflake database.

Parameters
df: pd.DataFrame

Results to write.

Returns
None
src.utils.snowflake.write_forecast_meta(df)[source]

Write assessment of forecast on capacity to forecast metadata table in Snowflake.

Parameters
df: pd.DataFrame

Assessment results.

Returns
None
src.utils.snowflake.read_forecasts(boxid=None)[source]

Read forecasts for Snowflake database.

Parameters
boxid: str

Boxid of a DALI box. If not provided or None, all forecast are loaded.

Returns
pd.DataFrame

DataFrame with forecasts.

src.utils.snowflake.read_forecast_meta()[source]

Read assessment of forecasts.

Returns
pd.DataFrame

Results of he assessment of all DALI box forecasts.

src.utils.snowflake.get_forecasted_boxids()[source]

Get the boxids for boxes that are already forecasted.

(Should be adapted when multiple forecasts (done on different dates) are present in database).

Returns
pd.DataFrame

Unique boxids.