The ArtificialFeatures class

class artificial_features.ArtificialFeatures(influxdb_client, forecast_type, cfg, logger)[source]

Bases: object

Class handling the forecasting of features calculated from the other measurements or forecasts (e.g. VOC, Kloten-Luano pressure gradient, specific time slots means, and so on…)

analyze_signal(signal)[source]

Parse the signal codes and send it to the appropriate method for value calculation

Parameters

signal (str) – signal code

Returns

single value of the queried signal

Return type

float

calc_data(query, signal_data, func)[source]
calc_voc_woods(region)[source]

Get values with and without woods emission

calculate_wood_emission(region)[source]

Calculate the VOC emissions from woods, using either forecasted or measured data. Forecasted data are not always available, so sometimes we’re forced to use measured values and infer the future.

Parameters

emissionType (str) – type of emission, either ‘measured’ or ‘forecasted’

Returns

calculated VOC emission value

Return type

float

static create_forecast_chunk_steps_string(start, end)[source]
do_KLO_query(signal_data)[source]

Calculate the pressure gradient between Kloten airport and Lugano to take into account the air current between South and North of Switzerland

Parameters

signal_data (str) – signal code

Returns

single value of the queried signal

Return type

float

do_MAX_query(signal_data, measurement)[source]

Calculate maximum value of all hourly forecasted temperatures

Parameters
  • signal_data (str) – signal code

  • measurement (str) – InfluxDB measurement code

Returns

single value of the queried signal

Return type

float

do_T_2M_query(signal_data, measurement)[source]
do_VOC_query(region)[source]

Get values with and without woods emission

do_mor_eve_query(signal_data, measurement)[source]
do_multiday_query(signal_data, measurement)[source]

Calculate the mean of the last 24, 48 or 72 hourly measurements for all measured signals Special case NOx_12h is also calculated here: MOR: mean value of NOx hourly measurements from 22:00 to 10:00 of previous day (previous afternoon) EVE: mean value of NOx hourly measurements from 22:00 of previous day to 10:00 of present day (present morning)

Parameters
  • signal_data (str) – signal code

  • measurement (str) – InfluxDB measurement code

Returns

single value of the queried signal

Return type

float

do_tot_prec_query(signal_data, measurement)[source]

Sum of the hourly forecasted precipitations for the next 24 hours

do_transf_query(signal_data, measurement)[source]

Maximum value of all hourly forecasted Dew Temperatures, to which we add 20 and cube the obtained value

get_Q_T_forecasted(region)[source]
get_query_value_forecast(measurement, signal_data, steps, func)[source]

Perform a query on forecasted signals using a certain amount of steps forward in time and a data aggregating function, such as mean, max, min or sum. This method is used in most methods except KLO-LUG and past measurements features

Parameters
  • measurement (str) – InfluxDB measurement code

  • signal_data (str) – signal code

  • steps (str) – steps (hours) in the future for the data we’re interested in

  • func (str) – reduction to apply to multiple data (‘min’, ‘max’ or ‘mean’)

Returns

single value of the queried signal

Return type

float

get_query_value_global(signal)[source]

Perform a query on signals who are location independent, i.e. it doesnt matter where they are measured. This method is used for calculating VOC and NOx daily variables in method do_IFEC_query

Parameters

signal (str) – signal code

Returns

single value of the queried signal

Return type

float

get_query_value_measure(measurement, signal_data, start_dt, end_dt, func)[source]

Perform a query on measured signals using a starting and ending time and a data aggregating function

Parameters
  • measurement (str) – InfluxDB measurement code

  • signal_data (str) – signal code

  • start_dt (str) – timestamp, format ‘%Y-%m-%dTHH:MM:SSZ’

  • end_dt (str) – timestamp, format ‘%Y-%m-%dTHH:MM:SSZ’

  • func (str) – reduction to apply to multiple data (‘min’, ‘max’ or ‘mean’)

Returns

single value of the queried signal

Return type

float

measurements_start_end(days)[source]

Create start and end times for the measurement signal queries. To be used in the do_multiday_query method

Parameters

days (int) – number of days back in time

Returns

list of timestamps

Return type

list

set_forecast_day()[source]

Set the day related to the forecast

steps_type_forecast(mor_start, mor_end, eve_start, eve_end)[source]

Create a string for the forward steps in time of a forecast signal query