5.3.8.1. gemini_application.wims.co2_corrosion

CO2 corrosion analysis application with caliper log processing and model optimization.

Classes

CO2CorrosionApplication()

Class for CO2 Corrosion application.

class gemini_application.wims.co2_corrosion.CO2CorrosionApplication[source]

Bases: ApplicationAbstract

Class for CO2 Corrosion application.

Initialize CO2 corrosion application.

add_corrosion_columns(df)[source]

Add corrosion columns to dataframe.

calculate()[source]

Execute main calculation pipeline.

coarsen_timeseries_by_change_point(df1, df2, df3, value_col='value', pen=3, plot=False)[source]

Coarsen a time series by detecting segments where the values do not change much.

Parameters:
  • df (pd.DataFrame) – DataFrame with a DateTime index.

  • value_col (str) – The column name containing the values to analyze.

  • pen (float or int) – Penalty parameter for the PELT change-point detection algorithm.

  • plot (bool) – If True, plot the original time series with detected change points.

Returns:

A DataFrame with columns [‘start_date’, ‘end_date’,

’mean_value’] for each segment.

Return type:

pd.DataFrame

get_caliper_logs()[source]

Get caliper logs data.

get_corrosion_rate_from_logs()[source]

Compute measured corrosion based on log scenarios.

Scenarios:
  • No logs => ‘calculation not possible’

  • 1 log => compare that log to well tally ID at baseline date

  • 2+ logs => compare each log to the previous one (chronologically)

get_corrosion_rate_from_models_segmented()[source]

Compute modelled corrosion in multiple intervals.

  • Baseline date -> 1st log date

  • 1st log date -> 2nd log date

  • 2nd log date -> 3rd log date

  • etc.

For each interval, we:

  1. Filter the flow/pressure/temp data to [start_date, end_date)

  2. Compute partial corrosion with a pairwise approach

  3. Convert the sum of partial corrosion to [mm/year] over that interval

  4. Store in a new column in self.outputs['modelledCorrosionRate']

get_data()[source]

Load data if available.

get_gas_analysis_data()[source]

Get gas analysis data.

get_prod_data_validation()[source]

Read monthly production data from Excel file for validation purposes.

get_production_data()[source]

Get production data.

get_remaining_days_to_min_thickness(min_remaining_thickness_mm)[source]

Compute remaining days until remaining thickness reaches the minimum.

Uses the latest (by date) corrosion rate and remaining thickness: - Latest corrosion rate: last interval in measuredCorrosionRate (chronologically). - Latest remaining thickness: last log date column in remainingThicknessAtLogDate.

Formula: days = (remaining_thickness_mm - min_remaining_thickness_mm) / (corrosion_rate_mm_per_year) * 365.25

Output: self.outputs[“remainingDaysToMinThickness”] DataFrame with columns Joint No. and “Remaining days to min. thickness [days]”.

get_remaining_thickness_at_log_dates()[source]

Compute remaining wall thickness [mm] at each log date.

For each processed log (sorted by date), remaining thickness at that date is (OD - Max. ID) from well tally and log, converted to mm. Output: self.outputs[“remainingThicknessAtLogDate”] DataFrame with columns Joint No. and one column per log date: “Remaining thickness [mm] (YYYY-MM-DD)”.

get_water_analysis_data()[source]

Get water analysis data.

inches_to_meters(inches)[source]

Convert inches to meters.

init_parameters(corrosion_model_name='DLD')[source]

Initialize models parameters. Tally from well parameter first, then tally folder.

optimize_models()[source]

Optimize the corrosion models to fit the observed data.

predict_corrosion_rate()[source]

Predict corrosion rate.

process_caliper_logs()[source]

Build processed caliper logs for each log.

If no logs, or only one, we’ll handle in get_corrosion_rate_from_logs.