flownet.ert.forward_models._iteration_analytics module

flownet.ert.forward_models._iteration_analytics._load_simulations(runpath: str, ecl_base: str) Tuple[str, Optional[ecl.summary.ecl_sum.EclSum]]

Internal helper function to load simulation results in parallel.

Parameters
  • runpath – Path to where the realization is run.

  • ecl_base – Path to where the realization is run.

Returns

(runpath, EclSum), or (runpath, None) in case of failed simulation (inexistent .UNSMRY file)

flownet.ert.forward_models._iteration_analytics.accuracy_metric(data_reference: pandas.core.frame.DataFrame, data_test: numpy.ndarray, metric: str) float

This function computes a score value based on the specified accuracy metric by calculating discrepancy between columns of two 2D numpy arrays: (1) reference simulation data and (2) ensemble of FlowNet simulations

Parameters
  • data_reference – is the 2D numpy array containing normalized data from reference

  • of (simulation replicated into as many columns as the size of ensemble) –

  • realizations (FlowNet) –

  • data_test – is the 2D numpy array containing normalized data from an ensemble of

  • simulations (FlowNet) –

  • metric – is a string with the name of the metric to be calculated

Returns

A score value reflecting the accuracy of FlowNet simulations in terms of matching data from reference simulation

flownet.ert.forward_models._iteration_analytics.compute_metric_ensemble(obs: numpy.ndarray, list_ensembles: List[numpy.ndarray], metrics: List[str], str_key: str, iteration: int) Dict

Internal helper function to generate dataframe containing selected observations and respective dates

Parameters
  • obs – numpy array containing normalized data from reference simulation

  • simulations (replicated over as many columns as size of ensemble of FlowNet) –

  • list_ensembles – list of ensembles of FlowNet simulations; can be used if

  • loaded (ensembles of multiple AHM iterations are) –

  • metrics – list of accuracy metrics to be computed

  • str_key – name of quantity of interest for accuracy metric calculation

  • iteration – current AHM iteration number

Returns

Dictionary containing values of calculated accuracy metrics for selected quantity of interest for current iteration of AHM

flownet.ert.forward_models._iteration_analytics.filter_dataframe(df_in: pandas.core.frame.DataFrame, key_filter: str, min_value: Any, max_value: Any) pandas.core.frame.DataFrame

This function filters the rows of a Pandas dataframe based on a range of values of a specified column

Parameters
  • df_in – is the Pandas dataframe to be filtered

  • key_filter – is the key of the specified column

  • filtered (for which the dataframe is to be) –

  • min_value – is the minimum value of the range for filtering

  • max_value – is the maximum value of the range for filtering

Returns

A Pandas dataframe containing only values within the specified range for the provided column

flownet.ert.forward_models._iteration_analytics.load_csv_file(csv_file: str, csv_columns: List[str]) pandas.core.frame.DataFrame

Internal helper function to generate dataframe containing selected observations and respective dates

Parameters
  • csv_file – name of CSV file

  • csv_columns – list of names of columns of CSV file

Returns

Pandas dataframe containing data from existing CSV file or empty dataframe with requested columns if CSV file does not exist

flownet.ert.forward_models._iteration_analytics.make_dataframe_simulation_data(mode: str, path: str, eclbase_file: str, keys: List[str], end_date: datetime.datetime) Tuple[pandas.core.frame.DataFrame, str, int]

Internal helper function to generate dataframe containing data from ensemble of simulations from selected simulation keys

Parameters
  • mode – String with mode in which flownet is run: prediction (pred) or assisted hisotory matching (ahm)

  • path – path to folder containing ensemble of simulations

  • eclbase_file – name of simulation case file

  • keys – list of prefix of quantities of interest to be loaded

  • end_date – end date of time period for accuracy analysis

Raises

ValueError – If mode is invalid (not pred or ahm).

Returns

Pandas dataframe contained data from ensemble of simulations iteration: current AHM iteration number nb_real: number of realizations

Return type

df_sim

flownet.ert.forward_models._iteration_analytics.normalize_data(data_opm_reference: numpy.ndarray, data_ensembles_flownet: List[numpy.ndarray]) Tuple[numpy.ndarray, List[numpy.ndarray]]

This function normalizes data from a 2D numpy array containing data from the reference simulation and multiple ensembles of FlowNet simulations, using the MinMaxScaler from sklearn.preprocessing module

Parameters
  • data_opm_reference – is the 2D numpy array containing data from reference

  • of (ensembles of FlowNet simulations; each list entry correspond to the ensemble) –

  • realizations (FlowNet) –

  • data_ensembles_flownet – is a list of 2D numpy arrays containing data from

  • of

  • ES-MDA (a given iteration of) –

Returns

is a normalized 2D numpy array for the reference simulation data norm_data_ensembles_flownet: a list of normalized 2D numpy arrays for the ensembles of FlowNet simulations

Return type

norm_data_opm_reference

flownet.ert.forward_models._iteration_analytics.parse_arguments()
flownet.ert.forward_models._iteration_analytics.prepare_flownet_data(df_flownet: pandas.core.frame.DataFrame, str_key: str, n_real: int) numpy.ndarray

This function extracts data from selected columns of the Pandas dataframe containing data from an ensemble of FlowNet simulations, rearranges it into a matrix of stacked column-vectors preserving the original order, i.e. one column per realization of the ensemble

Parameters
  • df_flownet – is the Pandas dataframe containing data from ensemble of FlowNet simulations

  • str_key – is the string to select columns; column names starting with str_key

  • n_real – is the size of ensemble of FlowNet simulations

Returns

A numpy 2D array [length_data * nb_selected_columns, n_real] containing data from selected columns (i.e., quantity of interest for accuracy metric) for an ensemble of FlowNet simulations in a column-vector. Each column correspond to one realization of the ensemble

flownet.ert.forward_models._iteration_analytics.prepare_opm_reference_data(df_opm: pandas.core.frame.DataFrame, str_key: str, n_real: int) numpy.ndarray

This function extracts data from selected columns of the Pandas dataframe containing data from reference simulation, rearranges it into a stacked column vector preserving the original order and repeats it n_real times to form a matrix for comparison with data from ensemble of n_real FlowNet simulations

Parameters
  • df_opm – is the Pandas dataframe containing data from reference simulation

  • str_key – is the string to select columns; column names starting with str_key

  • n_real – is the size of ensemble of FlowNet simulations

Returns

A numpy 2D array [length_data * nb_selected_columns, n_real] containing data from selected columns (i.e., quantity of interest for accuracy metric) of reference simulation stacked in a column-vector and replicated into n_real columns

flownet.ert.forward_models._iteration_analytics.save_iteration_analytics()

This function is called as a post-simulation workflow in ERT, saving all accuracy metrics of all iterations to a file and plotting evolution of accuracy metrics over iterations. The resulting accuracy metric values are stored in a CSV file in the FlowNet output folder, along with the figures

Parameters

None

Returns

Nothing