Pre-Processing Module (Current Version)#

This module contains the pre-processing functions of BuckPy.

class buckpy.buckpy_preprocessing_current.PreProcessor(work_dir, file_name, pipeline, scenario, bl_verbose)[source]#

Bases: object

Class to handle the pre-processing of scenario data for BuckPy simulations. This class reads scenario data from an Excel file, extracts and processes route, pipe, operating, and soil data, and calculates scenario data. It also converts the scenario data and end boundary conditions to NumPy arrays for Monte Carlo simulations and processes post-processing data.

The class includes methods for calculating expanded KP values, creating element arrays, interpolating distributions, and handling various preprocessing tasks.

apply_route_mitigation()[source]#

Function to combine rows from route and mitigation, then sort by KP From.

Parameters:
  • route_df (pandas Dataframe) – Dataframe containing the route data.

  • mitigation_df (pandas Dataframe) – Dataframe containing the mitigation data.

Returns:

route_df – Dataframe containing the combined route and mitigation data, sorted by KP From.

Return type:

pandas Dataframe

apply_route_soil_zoning()[source]#

Function to combine rows from route and soil zoning, then sort by KP From.

Parameters:
  • route_df (pandas Dataframe) – Dataframe containing the route data.

  • soil_zoning_df (pandas Dataframe) – Dataframe containing the soil zoning data.

Returns:

route_df – Dataframe containing the combined route and soil zoning data, sorted by KP From.

Return type:

pandas Dataframe

build_oper_element_kp_array(route_df)[source]#

Function to create element array based on KP, KP TO and element number.

Parameters:

route_df (pandas Dataframe) – Dataframe containing the route data with expanded KP values, calculated lengths, element numbers, and element sizes.

Returns:

elem_array

Return type:

numpy Array

build_oper_kp_mesh_from_route(route_df)[source]#

Function to expand the KP array with 1000 intervals from 1000 to nearest maximum KP.

Parameters:

route_df (pandas Dataframe) – Dataframe containing the route data.

Returns:

route_df – Dataframe containing the route data with expanded KP values, calculated lengths, element numbers, and element sizes.

Return type:

pandas Dataframe

calc_monte_carlo_data()[source]#

Convert the scenario data and end boundary conditions data to NumPy arrays for Monte Carlo simulations.

Parameters:
  • scen_df (pandas.DataFrame) – DataFrame containing the scenario data.

  • route_ends_df (pandas.DataFrame) – DataFrame containing the end boundary conditions data.

Returns:

  • dist_np (numpy.ndarray) – 2D array with probabilistic distributions (rows) along the route mesh (columns).

  • scen_np (numpy.ndarray) – 2D array with scenario properties (rows) along the route mesh (columns).

  • ends_np (numpy.ndarray) – 2D array with end properties (rows) for the ends.

Notes

The arrays have the following row layout (index : meaning):

scen_np: - 0 : KP - 1 : LENGTH - 2 : ROUTE_TYPE - 3 : BEND_RADIUS - 4 : SW_INST - 5 : SW_HT - 6 : SW_OP - 7 : SCHAR_HT - 8 : SCHAR_OP - 9 : SV_HT - 10 : SV_OP - 11 : CBF_RCM - 12 : RLT - 13 : FRF_HT - 14 : FRF_P_OP - 15 : FRF_T_OP - 16 : FRF_OP - 17 : L_BUCKLE_HT - 18 : EAF_BUCKLE_HT - 19 : L_BUCKLE_OP - 20 : EAF_BUCKLE_OP - 21 : SECTION_ID - 22 : SECTION_KP - 23 : SECTION_REF - 24 : MUAX_MEAN - 25 : MULAT_HT_MEAN - 26 : MULAT_OP_MEAN - 27 : HOOS_MEAN

dist_np: - 0 : MUAX_ARRAY - 1 : MUAX_CDF_ARRAY - 2 : MULAT_ARRAY_HT - 3 : MULAT_CDF_ARRAY_HT - 4 : MULAT_ARRAY_OP - 5 : MULAT_CDF_ARRAY_OP - 6 : HOOS_ARRAY - 7 : HOOS_CDF_ARRAY

ends_np: - 0 : ROUTE_TYPE - 1 : KP_FROM - 2 : KP_TO - 3 : REAC_INST - 4 : REAC_HT - 5 : REAC_OP

calc_oper_data()[source]#

Calculate operating data and process it.

Parameters:
  • oper_df (pandas.DataFrame) – DataFrame containing the operating data.

  • route_ends_df (pandas.DataFrame) – DataFrame containing the end boundary conditions.

Returns:

df – DataFrame containing the operating data and calculated operating data.

Return type:

pandas.DataFrame

Notes

This function filters oper_df DataFrame based on loadcase, and “KP To”. It calculates rolling mean and difference, assigns the “Length” column, resets the index, and drops rows with NaN values before returning the preprocessed DataFrame.

calc_pipe_data()[source]#

Calculate properties of pipes.

Parameters:

pipe_df (pandas.DataFrame) – DataFrame containing the pipe data.

Returns:

pipe_df – DataFrame containing the pipe data and calculated pipe properties.

Return type:

pandas.DataFrame

Notes

This function computes the inner diameter (ID), cross-sectional area (As), inner area (Ai), moment of inertia (I), hydrotest characteristic buckling force (SChar HT), and operation characteristic buckling force (SChar OP) of the pipe.

calc_pp_data()[source]#

Calculate post-processing data set for a given layout set.

Parameters:
  • df (pandas.DataFrame) – DataFrame containing post-processing data.

  • np_array (numpy.ndarray) – NumPy array containing pipeline end boundary conditions.

  • pipeline_id (str) – Identifier of the pipeline.

  • layout_set (str) – Identifier of the layout set.

Returns:

df – DataFrame containing calculated post-processing data.

Return type:

pandas.DataFrame

Notes

This function filters the DataFrame based on the layout set. It resets the index, renames columns, and selects relevant columns. Adjusts the last ‘KP_to’ value if it is smaller than the maximum value in np_array. Converts data types of columns to appropriate numeric types.

calc_route_data()[source]#

Extract and process route data for calculations.

Parameters:
  • route_df (pandas.DataFrame) – DataFrame containing route data.

  • mitigation_df (pandas.DataFrame) – DataFrame containing mitigation data.

  • soil_zoning_df (pandas.DataFrame) – DataFrame containing soil zoning data.

Returns:

  • route_df (pandas.DataFrame) – DataFrame containing route data and calculated route data.

  • route_ends_df (pandas.DataFrame) – DataFrame containing end boundary conditions.

Notes

This function extracts route ends and route data based on layout, mitigation, and soil_zoning. It selects specific columns for route ends data. Route Type is converted from string tofloat for numerical representation. Route ends data is converted to a NumPy array for efficient processing.

calc_scenario_data()[source]#

Calculate scenario data based on route, pipe, operating, and soil data.

Parameters:
  • route_df (pandas.DataFrame) – DataFrame containing route data.

  • pipe_df (pandas.DataFrame) – DataFrame containing pipe data.

  • oper_df (pandas.DataFrame) – DataFrame containing operating data.

  • soil_df (pandas.DataFrame) – DataFrame containing soil data.

Returns:

df – DataFrame containing the calculated scenario data.

Return type:

pandas.DataFrame

Notes

This function merges route, pipe, operating, and soil data to compute various scenario parameters. It calculates various attributes such as lognormal distributions, buckling forces, and section counts. The resulting DataFrame includes a subset of calculated columns and is filled with 0 for missing values.

calc_soil_data()[source]#

Calculate soil data and axial and lateral friction factor distributions and assign them to DataFrame columns.

Parameters:

soil_df (pandas.DataFrame) – DataFrame containing soil data.

Returns:

soil_df – DataFrame containing soil data and calculated friction factor distributions.

Return type:

pandas.DataFrame

Notes

This function computes lognormal distributions for axial and lateral friction factors and assigns them to DataFrame columns.

interpolate_oper_profile_on_kp(elem_array)[source]#

Function to interpolate the RLT, pressure and temperature using KP and operating profile.

Parameters:

elem_array (numpy Array) – Array containing the KP values for interpolation.

Returns:

oper_df – Dataframe containing the interpolated RLT, pressure and temperature values based on KP and operating profile.

Return type:

pandas Dataframe

run()[source]#

Import scenario data from an Excel file and preprocess it.

Parameters:
  • work_dir (str) – Directory where the Excel file is located.

  • file_name (str) – Name of the Excel file.

  • pipeline (str) – Identifier of the pipeline.

  • scenario (int) – Identifier of the scenario.

  • bl_verbose (bool, optional) – True if intermediate printouts are required.

Returns:

  • scen_np (numpy.ndarray) – NumPy array containing the scenario data for Monte Carlo simulations.

  • dist_np (numpy.ndarray) – NumPy array containing the distribution data for Monte Carlo simulations.

  • ends_np (numpy.ndarray) – NumPy array containing the end boundary conditions for Monte Carlo simulations.

  • scen_df (pandas.DataFrame) – DataFrame containing the scenario data for deterministic simulations.

  • pp_df (pandas.DataFrame) – DataFrame containing the post-processing data for the scenario.

Notes

This function reads scenario data from an Excel file, extracts and processes route, pipe, operating, and soil data, and calculates scenario data. It also converts the scenario data and end boundary conditions to NumPy arrays for Monte Carlo simulations and processes post-processing data. The function prints out the time taken to create the main dataframe if bl_verbose is set to True.

Parameters:

bl_verbose (boolean, optional) – True if intermediate printouts are required (False by default).

buckpy.buckpy_preprocessing_current.calc_lognorm_hoos(type_elt, length_elt, hoos_mean, hoos_std, length_ref, rcm_charac)[source]#

Compute the parameters of the horizontal out-of-straightness (HOOS) lognormal distribution for different types of elements (e.g., Straight, Bend, Sleeper, RCM). This function takes into account the scaling factor of the HOOS distribution. For RCM, the HOOS factor is not a factor but the critical buckling force.

Parameters:
  • type_elt (str) – Type of the element.

  • length_elt (float) – Length of the element.

  • hoos_mean (float) – Mean of the HOOS distribution.

  • hoos_std (float) – Standard deviation of the HOOS distribution.

  • length_ref (float) – Reference length.

  • rcm_charac (float) – Characteristic buckling force for the Residual Curvature Method (RCM).

Returns:

  • x_range (numpy.ndarray) – An array of values representing the range of the friction factor distribution between probabilities of exceedance between 0.01% and 99.99%.

  • cdf_range (numpy.ndarray) – An array of cumulative density function (CDF) values corresponding to x_range.

Notes

This function computes the parameters of a lognormal distribution for different types of elements such as Straight, Bend, Sleeper, and RCM (Residual Curvature Method). It calculates the cumulative density function (CDF) for the generated range of values based on the HOOS distribution parameters.