File size: 7,049 Bytes
052f08d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import pandas as pd
import streamlit as st
from mLogsFunctions.fx import *
from mLogsFunctions import *

def subtab21(df, well_names):
    col1, col2 = st.columns([1,8])
    if "method_eda" not in st.session_state:
        st.session_state.method_eda:str = "Single Well"
        st.session_state.well_eda:str = well_names[0]
    with col1:
        st.radio("",
                key="method_eda",
                options=["All Wells", "Single Well"])
        st.radio("WELL",
                key="well_eda",
                options=well_names)
    with col2:
        st.write('Data Description:')
        if st.session_state.method_eda == "All Wells":
            st.dataframe(df.describe(),width=1400, height=300)
        elif st.session_state.method_eda == "Single Well":
            df_single_w = df[df.WELL == st.session_state.well_eda]
            st.dataframe(df_single_w.describe(),width=1400, height=300)
        else:
            pass
        
def subtab22(df,):
    def missing_count(df):
        missing = df.isnull().sum()*100/df.isnull().sum().sum()
        missing = missing[missing >= 0].reset_index()
        missing.columns = ['Columns', 'Count missing (%)']
        return missing
    
    mt1, mt2, mt3 = st.columns(3)
    
    with mt1:
        st.caption("Missing data rate of whole wells")
        st.write(missing_bar(missing_count(df), "ALL WELLS"))
        for i, w in enumerate(df.WELL.unique()):
            if i%3 == 0:
                st.caption(f"Missing data rate of {w}")
                st.write(missing_bar(missing_count(well_filter(df, w)), f"WELL {w}"))
    with mt2:
        for i, w in enumerate(df.WELL.unique()):
            if i%3 == 1:
                st.caption(f"Missing data rate of {w}")
                st.write(missing_bar(missing_count(well_filter(df, w)), f"WELL {w}"))
    with mt3:
        for i, w in enumerate(df.WELL.unique()):
            if i%3 == 2:
                st.caption(f"Missing data rate of {w}")
                st.write(missing_bar(missing_count(well_filter(df, w)), f"WELL {w}"))

def subtab23(df, curves):
    mb1, mb2, mb3 = st.columns(3)
    for i, c in enumerate(curves):
        if i%3 == 0:
            with mb1:
                st.caption(f"Distribution of {c}")
                st.write(missing_box(df, c))
        if i%3 == 1:
            with mb2:
                st.caption(f"Distribution of {c}")
                st.write(missing_box(df, c))
        if i%3 == 2:
            with mb3:
                st.caption(f"Distribution of {c}")
                st.write(missing_box(df, c))
        
def subtab24(df, curves):
    #Histogram Line----------------------------------------------------------------
    h1, h2, h3 = st.columns(3)
    for i, c in enumerate(curves):
        if i%3 == 0:
            with h1:
                hist_line_plot(df,c)
        if i%3 == 1:
            with h2:
                hist_line_plot(df,c)
        if i%3 == 2:
            with h3:
                hist_line_plot(df,c)
        
def subtab25(df, curves):
    #CrossPlot---------------------------------------------------------------- 
    pair_curv = [(a, b) for idx, a in enumerate(curves) for b in curves[idx + 1:]]
    cp0, cp1, cp2, cp3, cp4 = st.columns(5)
    for i, c in enumerate(pair_curv):
        if i%5 == 0:
            with cp0:
                crossplot(df, pair_curv[i][0], pair_curv[i][1])
        if i%5 == 1:
            with cp1:
                crossplot(df, pair_curv[i][0], pair_curv[i][1])
        if i%5 == 2:
            with cp2:
                crossplot(df, pair_curv[i][0], pair_curv[i][1])
        if i%5 == 3:
            with cp3:
                crossplot(df, pair_curv[i][0], pair_curv[i][1])
        if i%5 == 4:
            with cp4:
                crossplot(df, pair_curv[i][0], pair_curv[i][1])
            
def subtab26(df, curves):
    #Pairpot----------------------------------------------------------------
    _p1, _p2, _p3 = st.columns([2,2,2])
    if "pair_opt" not in st.session_state:
        st.session_state.pair_opt:str = "ALL WELLS"
        st.session_state.color_pair:str = "WELL"
        st.session_state.well_pair:str = list(df.WELL.unique())[0]
    with _p1:
        pair_opt_ = st.radio("Displayed objects", key="pair_opt", options=["ALL WELLS", "SINGLE WELL"], horizontal=True)
    with _p2:
        well_pair_ = st.selectbox("WELL", key="well_pair", options=list(df.WELL.unique()))
    with _p3:
        colorp_ = st.selectbox("COLOR", key="color_pair", options=columns_list(df))
    if pair_opt_ == "ALL WELLS":
        st.write(pairplot(df, curves, curves, colorp_))
    elif pair_opt_ == "SINGLE WELL":
        st.write(pairplot(df[df["WELL"]==well_pair_], curves, curves, colorp_))
    else:
        st.write("Undefined Error!")
        
def scatterPoint3D(df,):
    #3D Plotly----------------------------------------------------------------
    wells_ = list(df.WELL.unique())
    curvs_ = columns_list(df, no_well=True)
    colors_ = columns_list(df)
    sizes_ = ["WELL", "FRACTURE_INTENSITY", "DEPTH", None]
    symbols_ = ["WELL", "FRACTURE_INTENSITY", None]
    
    if "well_3d" not in st.session_state:
        st.session_state.w_opt:str = "ALL WELLS"
        st.session_state.well_3d:str = wells_[0]
        st.session_state.x_3d:str = curvs_[0]
        st.session_state.y_3d:str = curvs_[0]
        st.session_state.z_3d:str = curvs_[0]
        st.session_state.color_3d:str = "WELL"
        st.session_state.size_3d:str = "DEPTH"
        st.session_state.symbol_3d:str = "WELL"
        
    p1_, p2_ = st.columns([1,7])
    with p1_:
        w_opt = st.radio("DisplayType", key="w_opt", options=["ALL WELLS", "SINGLE WELL"])
        well_ = st.selectbox("WELL", key="well_3d", options=wells_)
        x_ = st.selectbox("X", key="x_3d", options=curvs_)
        y_ = st.selectbox("Y", key="y_3d", options=curvs_)
        z_ = st.selectbox("Z", key="z_3d", options=curvs_)
        color_ = st.selectbox("COLOR", key="color_3d", options=colors_)
        size_ = st.selectbox("SIZE", key="size_3d", options=sizes_)
        symbol_ = st.selectbox("SYMBOL", key="symbol_3d", options=symbols_)
    with p2_:
        log_x, log_y, log_z = [False, False, False]
        if x_ in ["LLD", "LLS"]:
            log_x = True
        if y_ in ["LLD", "LLS"]:
            log_y = True
        if z_ in ["LLD", "LLS"]:
            log_z = True
        if w_opt == "ALL WELLS":
            plotly_3d(df, x_, y_, z_, color_, size_, symbol_, log_x, log_y, log_z)
        else:
            df_3d_plt = df[df["WELL"]==well_]
            plotly_3d(df_3d_plt, x_, y_, z_, color_, size_, symbol_, log_x, log_y, log_z)
            
                
def stViewCurves(df):
    _w = st.selectbox(label='Select WELL', options=list(df.WELL.unique()), key='w_plot')
    if st.session_state.w_plot is not None:
        df_plot = df[df['WELL']== _w]
    _c = st.multiselect("Select curves for plotting:", key="curv_plt", options=columns_list(df, no_depth=True, no_well=True))
    if len(_c) != 0:
        view_curves(df_plot, curves=_c)