The InputsGatherer class

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

Bases: object

Class handling the gathering of the inputs needed by a collection of predictors. There are 3 ways to create a dataframe:

  • Read an existing CSV (see method dataframe_reader)

  • Define a region composed of measurements and forecast stations, define the signals to be used by each station, then create all possible signals in JSON format and finally create the dataframe by querying InfluxDB (see method dataframe_builder_regions)

  • read an existing JSON containing a set of signals and create the dataframe by querying InfluxDB (see method dataframe_builder_custom)

add_input_value(signal, forecast_substitution=False, force_substitution=False)[source]

Add the value related to a given input signal

Parameters

signal (string) – signal code

Returns

query

Return type

string

add_output_value(signal)[source]

Add the value related to a given output signal

Parameters

signal (string) – signal code

Returns

query

Return type

string

artificial_features_forecasted_signals(forecastStation)[source]
build_dataset(name, input_signals)[source]

Build the training dataset given a signal json file in folder “conf/dataset” either from a region or from a custom list

build_global_input_dataset()[source]

Build the dataset

build_meteo_forecast_dataset_for_checking(fw_data)[source]

Build the dataset

calc_data(query, signal_data, func, forecast_substitution, str_steps, str_dt, force_substitution=False)[source]
calc_yesterday_output_daily_values(region, os)[source]

Calc daily data of O3 values related to yesterday

check_inputs_availability()[source]
chunks_forecasted_signals(forecastStation, forecastedSignal)[source]
static create_forecast_chunk_steps_string(chunk, case)[source]
dataframe_builder_custom()[source]
dataframe_builder_regions()[source]
do_chunk_query(signal_data, measurement)[source]
do_copernicus_step_query(signal_data, measurement)[source]
do_daily_query(signal_data, measurement, flag_output_signal=False)[source]
do_forecast_period_query(signal_data, measurement, forecast_substitution, force_substitution=False)[source]
do_forecast_step_query(signal_data, measurement, forecast_substitution, force_substitution=False)[source]
do_forecast_substitution(location, signal, dt_start_meas, dt_end_meas, func_override)[source]
do_hourly_query(signal_data, measurement)[source]
do_moving_average_query(signal_data, measurement)[source]
do_period_query(signal_data, measurement, case)[source]
filter_forecast(sigs_file)[source]
generate_input_signals_codes(region)[source]

Method to generate and save all known signals of a specific region (e.g. Ticino) with defined measuring and forecasting stations

get_location_with_output_signal(region, os)[source]
get_ngb_prediction(region, predictor, case, signal, start_date, end_date)[source]
get_previous_day()[source]
get_target_measure(region, signal, start_date, end_date)[source]
handle_exception_signal(signal_data)[source]
hourly_forecasted_signals(forecastStation, forecastedSignal, start, end, step)[source]
hourly_mean_avgs_measured_signals(measurementStation, measuredSignal, hours_back)[source]
hourly_measured_signals(measurementStation, measuredSignal)[source]
output_folder_creator(dataset_name)[source]

Get the address of the output folder for the current case

past_days_measured_signals_aggregations(measurementStation, measuredSignal, cases=False, agg_func=None)[source]
read_dataset(csv_file)[source]
retrieve_past_mean(code)[source]
static set_MOR_EVE_daytime(forecast_type, dt)[source]
set_forecast_day()[source]

Set the day related to the forecast