frflib.forecast_methods.forecast_wf
Forecast Workflow module
Module containing the workflow object and related methods.
Workflow are the core orchestrating object of FRFLib, organizing the data distribution and sequentiation of work to all chosen Forecasters
Classes
ForecastWF |
Functions
|
function that return the list of fluid forecasted by the method |
|
check that a list of conditions is validated by a given parameters set |
|
reformulate dataset from asset model to phaser format |
|
Run a manual parameter initializer workflow |
|
Return the list of the wells which started after the bt_date. for the blind test they are assumed as new wells |
|
For a given fluid, return the parameters of the forecast : score, method, parameters, method_category |
Module Contents
- class frflib.forecast_methods.forecast_wf.ForecastWF(field_data, wf_param, forecast_list, wells_for=None)
ForecastWF
Object in charge of instantiating, running and saving all forecast methods in a workflow.
- Parameters:
field_data (InputData) – Field data
wf_param (dict) – workflow parameters, dictionary containing all forecast parameters, including forecast mode
forecast_list (List[dict]) – list of dictionary with forecaster to be called in the workflow by order with their parameters
If running in ‘blind_test’ mode, it will realize a forecast on the last ‘blind_test_duration’ month of data.
If running in ‘forecast’ mode, it will forecast for ‘forecast_period’ months
the forecast modes and parameters are defined in the wf_param dictionary argument
- Workflow parameters:
name (str): name of the forecast
forecast_fluids (List[str]): list of fluids to be forecasted (e.g. [‘oil’, ‘water’])
forecast_period (int) : number of month to forecast from data last date
forecast_mode (str): mode of forecast, ‘blind_test’ or ‘forecast’
blind_test_duraion (int): if in forecast_mode, number of month to remove from data
eco_cut_off (float): Value under which to close a well
max_bsw (float): ratio between water and liquid under which to close a well
max_liq_rate_stbd: maximum liquid constraint
max_gas_rate_mscfd: maximum gas constraint
short_term_forecast_adjustment: number of month to join data to trend
uptime_selection: uptime hypothesis (‘constant_value’ or ‘average_uptime’)
constant_value: if uptime is ‘constant_value’, value to consider for uptime
period_for_avg_months : if uptime is average_uptime, number of previous month to consider in average
abandonned_wells (int): number of month without production to consider a well closed
- Example of Workflow execution ::
>>> general_forecast_params = { >>> 'forecast_name': 'wf_exponential', >>> 'forecast_end_date': "01/01/2040", >>> 'forecast_fluids': ['oil', 'water'], >>> 'forecast_mode': 'blind_test', >>> 'abandonned_wells': 12, >>> 'uptime_selection': 'constant_value', >>> 'constant_value': 1.0, >>> 'short_term_forecast_adjustment': 24, >>> 'blind_test_duration': 48, >>> 'max_liq_from_history': True >>> } >>> param_list = [ >>> {'forecaster_name': 'dca_oil', >>> 'methods': 'exponential', >>> 'fluid': 'oil'}, >>> { >>> 'type': 'analog_wells_oil', >>> 'fluid': 'oil', >>> 'learn_x': 'cum_active_days', >>> }, >>> {'type':'log_fo_fit', >>> 'fluid': 'water', >>> }] >>> # Execution >>> ForecastWF.execute(data, general_forecast_params, param_list, nproc=12)
- classmethod get_forecaster_form_dict(*args) collections.OrderedDict
- Abstractmethod:
Returns the class required parameters description for generating a form
- Returns:
method parameters dictionary
- Return type:
OrderedDict
- classmethod get_forecaster_form(*args) frflib.forecast_tools.forecaster_param.ForecasterParam
- Abstractmethod:
Returns the form for class required parameters setting
- Returns:
Forecaster Parameter object
- Return type:
- classmethod execute(field_data, wf_params, forecast_list, nproc=1, wells_for=None, taskobj=None, df_scenario=None)
Creates a workflow and run it.
It is the main designated interface to create and run new workflows
- Parameters:
wells_for –
field_data (InputData) – Field data
wf_params (dict) – workflow parameters
forecast_list (List[dict]) – list of dictionaries containing forecaster names and parameters to execute
nproc (int) – number of process available (default 1)
df_scenario – scenario - only for new wells
taskobj – for frf web app
- update_manual(manual_param)
Update a workflow with manual parameters
- Parameters:
manual_param – manual parameters for wells to update
- Type:
dict
- enrich_data()
function that recompute enriched data (data + forecast as a dataframe) This is function is usefull as the enriched data is not stored in the hdf wf file
- Returns:
- post_process()
post process the workflow so far mainly - complete with wells no producing / not forecasted / new wells for blind test
- Returns:
- get_well_forecast(wellname: str)
Returns the forecast of a well
- Parameters:
wellname –
- Returns:
DataFrame with all forecasted data for this well
- Return type:
pd.DataFrame
- get_well_forecast_param(wellname: str, fluid: str) dict
Returns the parameters of a forecaster
- Parameters:
wellname –
fluid –
- Returns:
parameters of the forecaster for given well and fluid
- get_forecast_plot_data_json() dict
generate json for FRF front to plot forecast data
- Returns:
forecast json
- Return type:
dict
- get_param_value(fluid: str, param_list=None, **kwargs) pandas.DataFrame
extract values of a list of parameters for all possible well
- Parameters:
fluid (str) – fluid to look parameter for
param_list (list) – list of parameters to extract
- Returns:
Dataframe of parameters
- Return type:
pd.DataFrame
- get_well_fit(fluid: str, wellname: str) pandas.Series
returns the fit of a well and fluid
- Parameters:
fluid – fluid of the fit
wellname – name of the well
- Returns:
Fit series indexed by date
- Return type:
pd.Series
- get_all_fit()
- Returns:
a dataframe with all fits
- Return type:
pd.DataFrame
- get_all_forecast(well_list=None, method=None)
obtain all the valid forecast for the field or a well list
- Parameters:
well_list – list of wells to fetch info from
method (str) – if not None, give only forecast of this method
- Returns:
Dataframe with all forecasts
- Return type:
pd.DataFrame
- get_phaser_format(last_date_forecast=None)
Extract forecast and format them in a phaser-format-compatible dataframe
- Parameters:
last_date_forecast (datetime) – last date of the forecast to extract
- get_sum_forecast(well_list=None, df_forecast=None)
give the sum of the forecast for a well list or a field
- Parameters:
well_list – list of wells
df_forecast – if forecast has been extracted it can be given to avoid re-extraction of the data
- Returns:
aggregated dataframe
- Return type:
pd.DataFrame
- get_well_num_per_fmethod(fluid, well_list=None)
function that allows to get the number of well per method forecast
- Parameters:
well_list – list of wells
fluid – considerd fluid
- Returns:
dataframe with methods vs number of wells
- get_closed_wells()
simple function which return the closed wells in the worflow
- Returns:
list - closed wells
- blind_test_results(fluid: str = 'oil', compute_r2=True, only_forecasted=False)
generate results of blind tests - store internally in self.bt_results and return a dataframe
- Parameters:
fluid – fluid to consider
- Returns:
dataframe with well by well comparison for the blind test
- Return type:
pd.DataFrame
- save_to_hdf(path: str)
Save workflow in a hdf file
- Parameters:
path (str) – path of the file
- classmethod load_from_hdf(path: str, field: frflib.data_class.input_data.InputData | str)
Load data from a HDF and instantiate a new workflow
- Parameters:
path (str) – path to file
field (InputData or string) – field dataset or path to data file
- Returns:
Loaded workflow
- Return type:
- plot_well_num_per_fmethod(fluid, well_list=None)
function that plots the number of well per method forecast
- Parameters:
well_list – list of wells
fluid – considerd fluid
- Returns:
pie chart
- compare_blind_test(other, fluid='oil', well_list=None)
make a comparison scatter plot to compare forecasted values with another forecast
- bt_get_worst_off(fluid, well_number, error='absolute', worst=True)
get the worst performing well during a blind test
- Parameters:
fluid –
well_number –
error –
worst –
- Returns:
- export_to_df(export_type='frf_format', aggregation_cat='wellname')
extract results, transform them in export format and aggregate them
- Parameters:
export_type – ‘frf_format’ or ‘phaser_format’
aggregation_cat – category in df_static to aggregate against
- Returns:
dataframe with results in asked format
- detail_export()
Export details about the parameters of each forecaster
- Returns:
Dictionary of dataframes, first one is “summary”, the rest is one dataframe for each forecaster
- cut_like_wf(another: ForecastWF) None
Cut forecasts to keep only fluids and end_date such as defined in another workflow Works only for forecasts in forecast mode
- Parameters:
another – Model workflow to mimic
- cut_forecasts_to_end()
cut forecasts to match required end date
- get_result_summary(fluid=None, include_stat=False, results_only=False)
function that gives a dataframe summary of the results of the workflow main data are the parameters and the ultimate cumulative per fluid
- Parameters:
fluid – oil water gas liquid
include_stat – bool - if true will concat the df with static data and production ind
- Results_only:
if false give the parameters of the forecast
- Returns:
dataframe
- __repr__()
Return repr(self).
- classmethod get_f_methods_fluid(method_name)
function that return the list of fluid forecasted by the method
- classmethod get_f_methods_default_param(method, field_data=None)
return default parameter of the method
- Parameters:
method – method name
- Returns:
dictionary of default parameters
- classmethod get_available_f_methods(fluid_list, available_ux=True)
function that given the list of the fluid selected will give the available forecast methods in frflib
:param available_ux if true show only list of method validated for UX :return: dictionary with method_name : method name : method :rtype: dict
- classmethod get_f_methods(method_name)
function that return the object forecast method with the given name
- Returns:
Forecaster object
- Return type:
AbstractForecast
- classmethod get_f_methods_form_dict(method_name, field_data=None)
function that return the dictionary necessary to build the form for the given forecast name
See also
forecast_methods.abstract_forecast.AbstractForecast.get_forecaster_form_dict()
- classmethod get_f_methods_form(method_name, field_data=None)
function that return the dictionary necessary to build the form for the given forecast name
- setup_blindtest(bt_duration=None, new_wells_split=1)
allow to setup the main parameters for the blnd test (the input_data,the bt_data for comparison purposes the new wells list and the bt_start up It allows to run for both existing and new wells
:param data : (input_data) the dataset for the workflow :param bt_duration: (int) duration of the bt in months :param existing_tag: :param new_well_split: (float) - between 0 and 1 allows a subset selection for the new wells
- Returns:
enriched_data: (input_data) - subset of field data bt_data: (input_data) - subset of field data dt_bt_start: (date) blind test date start new_wells: (set) new wells set
- get_fluid_dict()
function that return a dictionary of fluids and variables available in the forecast
- Returns:
- frflib.forecast_methods.forecast_wf.get_f_methods_conditions(method_name)
function that return the list of fluid forecasted by the method
- frflib.forecast_methods.forecast_wf.valid_forecaster_params(forecast_params, verbose=False)
check that a list of conditions is validated by a given parameters set
- frflib.forecast_methods.forecast_wf.naming_phaser(df)
reformulate dataset from asset model to phaser format
- frflib.forecast_methods.forecast_wf.compute_init_manual(data: frflib.data_class.input_data.InputData, nproc=1, duration=LONG_DURATION, forecast_parameters=None) ForecastWF
Run a manual parameter initializer workflow
- Parameters:
data – Field data to compute initialization for
nproc (int) – number of processes to use (default 1)
duration (int) – number of months to forecast if no forecast parameters specified (default to 480)
forecast_parameters (dict) – forecast parameters to use (default is None).
- Returns:
workflow executed with ManualInitializer
- Return type:
- frflib.forecast_methods.forecast_wf.get_new_wells_list(df_dynamic, bt_date)
Return the list of the wells which started after the bt_date. for the blind test they are assumed as new wells and therefore not treated
- Parameters:
df_dynamic – dynamic dataframe
bt_date – pd.datetime
- Returns:
set of new wells
- frflib.forecast_methods.forecast_wf.extract_wf_parameters(dict_wf_param: dict, dict_wlist_fmethod: dict, fluid: str, fluid_list: List[str], main_fluid: str) pandas.DataFrame
For a given fluid, return the parameters of the forecast : score, method, parameters, method_category Wells not forecasted are return with score=0 and empty parameters If fluid is not forecasted return the parameters of main fluid (ex : liquid)