Spaces:
Runtime error
Runtime error
change to make the perforation more flexiable
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from datetime import datetime
|
|
4 |
from streamlit_ext import download_button as down_btn
|
5 |
|
6 |
|
7 |
-
def generate_perforations(df):
|
8 |
content = "UNITS METRIC\n\n"
|
9 |
|
10 |
# Iterate through unique well names
|
@@ -16,12 +16,37 @@ def generate_perforations(df):
|
|
16 |
|
17 |
# Iterate through rows of the filtered dataframe
|
18 |
for index, row in well_df.iterrows():
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
content += "\n" # Add a newline between well sections
|
27 |
|
@@ -79,7 +104,8 @@ def main():
|
|
79 |
|
80 |
if uploaded_file is not None:
|
81 |
# Read the Excel file
|
82 |
-
df = pd.read_excel(uploaded_file)
|
|
|
83 |
|
84 |
# Create button to begin the process
|
85 |
if st.sidebar.button("Generate"):
|
@@ -89,7 +115,7 @@ def main():
|
|
89 |
# Use a callback to execute actions only when the button is clicked
|
90 |
if st.session_state.get("generate_clicked", False):
|
91 |
# Generate content for perforations.ev and tubing.tub
|
92 |
-
perforations_content = generate_perforations(df)
|
93 |
tubing_content = generate_tubing(df, tubing=tubing)
|
94 |
|
95 |
# Display perforations.ev content
|
|
|
4 |
from streamlit_ext import download_button as down_btn
|
5 |
|
6 |
|
7 |
+
def generate_perforations(df,plug_df):
|
8 |
content = "UNITS METRIC\n\n"
|
9 |
|
10 |
# Iterate through unique well names
|
|
|
16 |
|
17 |
# Iterate through rows of the filtered dataframe
|
18 |
for index, row in well_df.iterrows():
|
19 |
+
if row['type'] == 'p':
|
20 |
+
date = row['date'].strftime('%d/%m/%Y')
|
21 |
+
top = row['top']
|
22 |
+
btm = row['btm']
|
23 |
+
# Write the perforation line to the content
|
24 |
+
content += f'{date} perforation {top} {btm} 0.1905 0 0 0\n'
|
25 |
+
|
26 |
+
if row['type'] == 's':
|
27 |
+
date = row['date'].strftime('%d/%m/%Y')
|
28 |
+
top = row['top']
|
29 |
+
btm = row['btm']
|
30 |
+
# Write the shut-in line to the content
|
31 |
+
content += f'{date} squeeze {top} {btm}\n'
|
32 |
+
|
33 |
+
# Filter the plug dataframe for the current well
|
34 |
+
plug_well_df = plug_df[plug_df['well'] == well_name]
|
35 |
+
|
36 |
+
# Iterate through rows of the filtered plug dataframe
|
37 |
+
for index, plug_row in plug_well_df.iterrows():
|
38 |
+
date = plug_row['date'].strftime('%d/%m/%Y')
|
39 |
+
depth = plug_row['depth']
|
40 |
+
|
41 |
+
# Filter the well dataframe based on the plug depth
|
42 |
+
filtered_well_df = well_df[well_df['top'] >= depth]
|
43 |
+
|
44 |
+
# Iterate through rows of the filtered well dataframe
|
45 |
+
for _, filtered_row in filtered_well_df.iterrows():
|
46 |
+
top = filtered_row['top']
|
47 |
+
btm = filtered_row['btm']
|
48 |
+
# Write the squeeze line to the content
|
49 |
+
content += f'{date} squeeze {top} {btm}\n'
|
50 |
|
51 |
content += "\n" # Add a newline between well sections
|
52 |
|
|
|
104 |
|
105 |
if uploaded_file is not None:
|
106 |
# Read the Excel file
|
107 |
+
df = pd.read_excel(uploaded_file,sheet_name='perforation')
|
108 |
+
plug_df = pd.read_excel(uploaded_file,sheet_name='plugs')
|
109 |
|
110 |
# Create button to begin the process
|
111 |
if st.sidebar.button("Generate"):
|
|
|
115 |
# Use a callback to execute actions only when the button is clicked
|
116 |
if st.session_state.get("generate_clicked", False):
|
117 |
# Generate content for perforations.ev and tubing.tub
|
118 |
+
perforations_content = generate_perforations(df,plug_df)
|
119 |
tubing_content = generate_tubing(df, tubing=tubing)
|
120 |
|
121 |
# Display perforations.ev content
|