PPL Parsing
1. pypontem ppl parsing code examples
pplParser: a class which holds the ppl parser functions
Importing ppl parser functionalities
from pypontem.ppl.pplparser import pplParser
Instantiating a ppl parser object with a file path
ppl = pplParser(r"data/example_ppl.ppl")
-
metadata
Extracts metadata from the content stored in the object and returns it as a pandas DataFrame.
metadata = ppl.metadata
print(metadata)
version Input file time project \ 0 OLGA 2015.3.1.142077 sample_file.genkey 24-07-27 11:09:37 title author geometry 0 M
-
branch_names
Extracts and prints the names of all branches in the given ppl file.
branch_names = ppl.branch_names
print(branch_names)
["'FLOWLINE-1'", "'RISER-1'", "'JUMPER-1'", "'WELLBORE-1'", "'RISER-2'", "'JUMPER-2'", "'FLOWLINE-2'", "'FLOWLINE-3'", "'JUMPER-3'", "'WELLBORE-2'", "'WELLBORE-3'", "'FLOWLINE-4' ", "'FLOWLINE-5'", "'JUMPER-4'", "'FLOWLINE-6'", "'SJUMPER-5'", "'TOPSIDES-1'", "'FLOWLINE-7'"]
-
branch_profiles
Extracts and displays elevation for a specific branch or all branches in the file.
branch_profiles = ppl.branch_profiles.get("RISER-1")
print(branch_profiles)
{ 'RISER-1': Lengths_(m) Elevations_(m) Pipe Number
0 0.000000 -1907.133600 32
1 15.849599 -1907.250503 32
2 46.329597 -1907.475316 32
3 104.241594 -1907.902461 32
4 218.541588 -1908.745510 32
5 444.093576 -1910.409127 32
6 566.013569 -1911.308379 32
7 630.021565 -1911.780487 32
8 697.077562 -1912.275076 32
9 764.993399 -1912.776007 32
10 801.569396 -1907.655203 32
11 825.445811 -1904.312396 32
12 867.822789 -1885.132053 32
13 912.710102 -1864.815547 32
14 946.593760 -1840.536385 32
15 979.642878 -1816.855086 32
16 1021.058489 -1783.474780 32
17 1070.651274 -1743.503794 32
18 1126.908798 -1694.459789 32
19 1190.388860 -1639.119263 32
20 1261.601709 -1572.379909 32
21 1361.976293 -1478.310660 32
22 1557.167155 -1288.439196 32
23 1831.815410 -1021.275685 32
24 2076.928651 -778.876791 32
25 2299.674137 -558.598303 32
26 2505.458956 -353.875177 32
27 2660.979205 -199.157295 32
28 2761.951527 -98.705914 32
29 2822.911531 -38.060417 32
30 2854.294656 -6.839281 32
31 2872.582658 11.448721 32
32 2885.517945 24.384008 32}
-
n_vars
Parses the number of variables from a given ppl file.
n_vars = ppl.n_vars
print(n_vars)
477
-
catalog
Extracts variable information from the provided content using a regular expression pattern.
returned_catalog = ppl.catalog
print(returned_catalog.head(5))
varname Locator Type BRANCH out_unit \
0 QLT BOUNDARY: FLOWLINE-1 (M3/S)
1 QG BOUNDARY: FLOWLINE-1 (M3/S)
2 ID BOUNDARY: FLOWLINE-1 (-)
3 GORST BOUNDARY: FLOWLINE-1 (SM3/SM3)
4 QGST BOUNDARY: FLOWLINE-1 (SM3/S)
Description
0 Total liquid volume flow
1 Gas volume flow
2 Flow regime: 1=Stratified, 2=Annular, 3=Slug, 4=Bubble.
3 Gas/oil ratio at standard conditions
4 Gas volume flow at standard conditions
-
search_catalog
Searches for variables containing a keyword in their names within a DataFrame.
search_catalog = ppl.search_catalog('TM')
print(search_catalog.head(5))
varname BRANCH out_unit Description
14 TM FLOWLINE-1 (C) Fluid temperature
44 TM RISER-1 (C) Fluid temperature
77 TM JUMPER-1 (C) Fluid temperature
103 TM WELLBORE-1 (C) Fluid temperature
129 TM RISER-1 (C) Fluid temperature
-
extract_profile
Extracts and processes profiles data from an input matrix, performing unit conversions and time filtering.
1. Extracting profiles from a dataframe created using a csv file
import pandas as pd
input_data = pd.read_csv('data/ppl_matrix.csv')
profiles = ppl.extract_profile(input_data)
print(profiles.head(5))
ID \
Profiles_FLOWLINE-1_ID_m FLOWLINE-1_ID_time_in_h:_0.0_(-)
0 0.00 1.0
1 11.43 1.0
2 22.86 1.0
3 34.29 1.0
4 45.72 1.0
\
FLOWLINE-1_ID_time_in_h:_2.0_(-) Profiles_JUMPER-1_ID_m
0 1.0 0.000
1 1.0 64.160
2 1.0 128.321
3 1.0 192.481
4 1.0 256.641
\
JUMPER-1_ID_time_in_h:_0.0_(-) JUMPER-1_ID_time_in_h:_2.0_(-)
0 1.0 1.0
1 1.0 1.0
2 1.0 1.0
3 1.0 1.0
4 1.0 1.0
\
Profiles_WELLBORE-1_ID_m WELLBORE-1_ID_time_in_h:_0.0_(-)
0 0.00 1.0
1 22.86 2.0
2 53.34 2.0
3 99.06 2.0
4 129.54 2.0
WELLBORE-1_ID_time_in_h:_2.0_(-)
0 1.0
1 2.0
2 2.0
3 2.0
4 2.0
2. Extracting profiles from a dataframe created using a dictionary
matrix = {
"varname":"PT",
"BRANCH":"FLOWLINE-1",
"out_unit":None,
"out_unit_profile":"m",
"time_unit":"h",
"start_time":0,
"end_time":2,
}
matrix_df = pd.DataFrame(matrix, index=[0])profiles = ppl.extract_profile(matrix_df)
print(profiles.head(5))
PT \
Profiles_FLOWLINE-1_PT_m FLOWLINE-1_PT_time_in_h:_0.0_(pa)
0 5.715 18955660.0
1 17.145 18955670.0
2 28.575 18955670.0
3 40.005 18955670.0
4 83.845 18953700.0
FLOWLINE-1_PT_time_in_h:_2.0_(pa)
0 23840660.0
1 23838740.0
2 23836820.0
3 23834900.0
4 23818810.0
-
extract_profiles_join_nodes
Extracts and processes trend data for branches, combining boundary and section data.
1. Joining nodes of extracted profiles from a dataframe created using a csv file
branch_matrix = pd.read_csv('data/branch_matrix.csv')
join_nodes = ppl.extract_profiles_join_nodes(input_data,branch_matrix)
print(join_nodes.head(5))
Profiles_ID_m time_in_h:_0.0_(-) time_in_h:_2.0_(-) 0 0.00 1.0 1.0 1 11.43 1.0 1.0 2 22.86 1.0 1.0 3 34.29 1.0 1.0 4 45.72 1.0 1.0
2. Joining nodes of extracted profiles from a dataframe created using a dictionary
branch_matrix = {
"branch_in":["FLOWLINE-1","JUMPER-1"],
"branch_out":["JUMPER-1","WELLBORE-1"]
}
branch_matrix_df = pd.DataFrame(branch_matrix)joining_nodes = ppl.extract_profiles_join_nodes(input_data,branch_matrix_df)
print(joining_nodes.head(2))
Profiles_PT_m time_in_h:_0.0_(pa) time_in_h:_2.0_(pa) 0 5.715 18955660.0 23840660.0 1 17.145 18955670.0 23838740.0
2. pypontem ppl batch parsing code examples
pplBatchParser: a class to handle batches of ppl files
Note that: ppl batch parsing functionality only works for files of the same batch of simulations with the same branch names and structure, otherwise this will raise an error. for illustration purpose we duplicated the same file
Importing ppl batch parser class
from pypontem.ppl.pplparser import pplBatchParser
Instantiating an object with a list of ppl files
files = [r"data/example_ppl.ppl", r"data/example_ppl.ppl"]
batchppl = pplBatchParser(files)
-
extract_profiles
Function to extract profiles from a batch of ppl files
1. Extracting profiles from a DataFrame created using a csv file.
batchtrends = batchppl.extract_profiles(input_data)
print(batchtrends.head(5))
ID_example_ppl.ppl_x \
Profiles_FLOWLINE-1_ID_m_GV-SC_Feb-26-HOC_2.ppl
0 0.00
1 11.43
2 22.86
3 34.29
4 45.72
\
FLOWLINE-1_ID_time_in_h:_0.0_(-)_example_ppl.ppl
0 1.0
1 1.0
2 1.0
3 1.0
4 1.0
\
FLOWLINE-1_ID_time_in_h:_2.0_(-)_example_ppl.ppl
0 1.0
1 1.0
2 1.0
3 1.0
4 1.0
\
Profiles_JUMPER-1_ID_m_example_ppl.ppl
0 0.000
1 64.160
2 128.321
3 192.481
4 256.641
\
JUMPER-1_ID_time_in_h:_0.0_(-)_example_ppl.ppl
0 1.0
1 1.0
2 1.0
3 1.0
4 1.0
\
JUMPER-1_ID_time_in_h:_2.0_(-)_example_ppl.ppl
0 1.0
1 1.0
2 1.0
3 1.0
4 1.0
\
Profiles_WELLBORE-1_ID_m_example_ppl.ppl
0 0.00
1 22.86
2 53.34
3 99.06
4 129.54
\
WELLBORE-1_ID_time_in_h:_0.0_(-)_example_ppl.ppl
0 1.0
1 2.0
2 2.0
3 2.0
4 2.0
\
WELLBORE-1_ID_time_in_h:_2.0_(-)_example_ppl.ppl
0 1.0
1 2.0
2 2.0
3 2.0
4 2.0
ID_example_ppl.ppl_y \
Profiles_FLOWLINE-1_ID_m_example_ppl.ppl
0 0.00
1 11.43
2 22.86
3 34.29
4 45.72
\
FLOWLINE-1_ID_time_in_h:_0.0_(-)_example_ppl.ppl
0 1.0
1 1.0
2 1.0
3 1.0
4 1.0
\
FLOWLINE-1_ID_time_in_h:_2.0_(-)_example_ppl.ppl
0 1.0
1 1.0
2 1.0
3 1.0
4 1.0
\
Profiles_JUMPER-1_ID_m_example_ppl.ppl
0 0.000
1 64.160
2 128.321
3 192.481
4 256.641
\
JUMPER-1_ID_time_in_h:_0.0_(-)_example_ppl.ppl
0 1.0
1 1.0
2 1.0
3 1.0
4 1.0
\
JUMPER-1_ID_time_in_h:_2.0_(-)_example_ppl.ppl
0 1.0
1 1.0
2 1.0
3 1.0
4 1.0
\
Profiles_WELLBORE-1_ID_m_example_ppl.ppl
0 0.00
1 22.86
2 53.34
3 99.06
4 129.54
\
WELLBORE-1_ID_time_in_h:_0.0_(-)_example_ppl.ppl
0 1.0
1 2.0
2 2.0
3 2.0
4 2.0
WELLBORE-1_ID_time_in_h:_2.0_(-)_example_ppl.ppl
0 1.0
1 2.0
2 2.0
3 2.0
4 2.0
2. Extracting profiles from a DataFrame created using a dictionary.
batchtprofiles = batchppl.extract_profiles(matrix_df)
print(batchtrends.head(5))
PT_example_ppl.ppl_x \
Profiles_FLOWLINE-1_PT_m_example_ppl.ppl
0 5.715
1 17.145
2 28.575
3 40.005
4 83.845
\
FLOWLINE-1_PT_time_in_h:_0.0_(pa)_example_ppl.ppl
0 18955660.0
1 18955670.0
2 18955670.0
3 18955670.0
4 18953700.0
\
FLOWLINE-1_PT_time_in_h:_2.0_(pa)_example_ppl.ppl
0 23840660.0
1 23838740.0
2 23836820.0
3 23834900.0
4 23818810.0
\
Profiles_JUMPER-1_PT_m_example_ppl.ppl
0 2.286
1 7.315
2 12.441
3 17.151
4 22.038
\
JUMPER-1_PT_time_in_h:_0.0_(pa)_example_ppl.ppl
0 19032920.0
1 19053960.0
2 19074470.0
3 19074480.0
4 19074480.0
\
JUMPER-1_PT_time_in_h:_2.0_(pa)_example_ppl.ppl
0 25604460.0
1 25625210.0
2 25645540.0
3 25645550.0
4 25645550.0
\
Profiles_WELLBORE-1_PT_m_example_ppl.ppl
0 11.430
1 38.100
2 76.200
3 114.300
4 145.694
\
WELLBORE-1_PT_time_in_h:_0.0_(pa)_example_ppl.ppl
0 53703490.0
1 53438350.0
2 53059520.0
3 52680650.0
4 52368400.0
\
WELLBORE-1_PT_time_in_h:_2.0_(pa)_example_ppl.ppl
0 53703490.0
1 53438350.0
2 53059520.0
3 52680650.0
4 52368390.0
PT_example_ppl.ppl_y \
Profiles_FLOWLINE-1_PT_m_example_ppl.ppl
0 5.715
1 17.145
2 28.575
3 40.005
4 83.845
\
FLOWLINE-1_PT_time_in_h:_0.0_(pa)_example_ppl.ppl
0 18955660.0
1 18955670.0
2 18955670.0
3 18955670.0
4 18953700.0
\
FLOWLINE-1_PT_time_in_h:_2.0_(pa)_example_ppl.ppl
0 23840660.0
1 23838740.0
2 23836820.0
3 23834900.0
4 23818810.0
\
Profiles_JUMPER-1_PT_m_example_ppl.ppl
0 2.286
1 7.315
2 12.441
3 17.151
4 22.038
\
JUMPER-1_PT_time_in_h:_0.0_(pa)_example_ppl.ppl
0 19032920.0
1 19053960.0
2 19074470.0
3 19074480.0
4 19074480.0
\
JUMPER-1_PT_time_in_h:_2.0_(pa)_example_ppl.ppl
0 25604460.0
1 25625210.0
2 25645540.0
3 25645550.0
4 25645550.0
\
Profiles_WELLBORE-1_PT_m_example_ppl.ppl
0 11.430
1 38.100
2 76.200
3 114.300
4 145.694
\
WELLBORE-1_PT_time_in_h:_0.0_(pa)_example_ppl.ppl
0 53703490.0
1 53438350.0
2 53059520.0
3 52680650.0
4 52368400.0
WELLBORE-1_PT_time_in_h:_2.0_(pa)_example_ppl.ppl
0 53703490.0
1 53438350.0
2 53059520.0
3 52680650.0
4 52368390.0
-
join_batch_nodes
Extracts and processes profiles data for branches, combining boundary and section data from a list of ppl files.
1. Joining nodes of extracted profiles from a dataframe created using a csv file
batch_join_nodes = batchppl.join_batch_nodes(input_data,branch_matrix)
print(batch_join_nodes.head(5))
Profiles_ID_m_example_ppl.ppl_x \ 0 0.00 1 11.43 2 22.86 3 34.29 4 45.72 time_in_h:_0.0_(-)_example_ppl.ppl_x \ 0 1.0 1 1.0 2 1.0 3 1.0 4 1.0 time_in_h:_2.0_(-)_example_ppl2.ppl_x \ 0 1.0 1 1.0 2 1.0 3 1.0 4 1.0 Profiles_ID_m_example_ppl.ppl_y \ 0 0.00 1 11.43 2 22.86 3 34.29 4 45.72 time_in_h:_0.0_(-)_example_ppl.ppl_y \ 0 1.0 1 1.0 2 1.0 3 1.0 4 1.0 time_in_h:_2.0_(-)_example_ppl.ppl_y 0 1.0 1 1.0 2 1.0 3 1.0 4 1.0
2. Joining nodes of extracted profiles from a dataframe created using a dictionary
batch_join_nodes = batchppl.join_batch_nodes(input_data,branch_matrix_df)
print(batch_join_nodes.head(5))
Profiles_PT_m_example_ppl.ppl_x \
0 5.715
1 17.145
2 28.575
3 40.005
4 83.845
time_in_h:_0.0_(pa)_example_ppl.ppl_x \
0 18955660.0
1 18955670.0
2 18955670.0
3 18955670.0
4 18953700.0
time_in_h:_2.0_(pa)_example_ppl.ppl_x \
0 23840660.0
1 23838740.0
2 23836820.0
3 23834900.0
4 23818810.0
Profiles_PT_m_example_ppl.ppl_y \
0 5.715
1 17.145
2 28.575
3 40.005
4 83.845
time_in_h:_0.0_(pa)_example_ppl.ppl_y \
0 18955660.0
1 18955670.0
2 18955670.0
3 18955670.0
4 18953700.0
time_in_h:_2.0_(pa)_example_ppl.ppl_y
0 23840660.0
1 23838740.0
2 23836820.0
3 23834900.0
4 23818810.0