Spaces:
Sleeping
Sleeping
| 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) | |