{"componentChunkName":"component---src-templates-mdproject-jsx","path":"/projects/bkv_streamlit_apps","result":{"data":{"allGithubFile":{"nodes":[{"base":"bkv_streamlit_apps.md","relativeDirectory":"projects","childMarkdownRemark":{"id":"4d05dcd4-aac0-55a4-a533-a5264a3e9c78","html":"<h1>BKV Streamlit Apps - BKV Corporation</h1>\n<p>Data Scientist/Developer: Manuel Solalinde <a href=\"mailto:manolosolalinde@gmail.com\">(manolosolalinde@gmail.com)</a></p>\n<p>A single, unified <strong>multi-page Streamlit platform</strong> that bundles a growing collection of reservoir and production engineering tools, each selectable from the sidebar. The apps share one data pipeline — daily production, injection and SCADA sensor data live in <strong>AWS S3</strong> as parquet and are read on demand by well ID — and one deployment, a containerized Streamlit service running on <strong>ECS Fargate</strong>. Heavier batch jobs (per-well report generation) fan out across <strong>parallel Lambda</strong> functions; in-app user documentation is published with <strong>MkDocs</strong>.</p>\n<p>This page covers the engineering toolkit; the platform's flagship optimization app is documented separately:</p>\n<ul>\n<li><strong>Gas Injection Optimization</strong> — a data-driven app that recommends optimal gas-injection rates for gas-lift wells and ranks every injecting well against its recommendation. <a href=\"./bkv_gas_injection.md\">See the dedicated page →</a></li>\n</ul>\n<h2>Applications</h2>\n<ul>\n<li><strong>Resolution Visualizer</strong> — visualizes SCADA sensor reading frequency per well, broken down by day and channel.</li>\n<li><strong>Salt Water Injection</strong> — an infinite-reservoir radial pressure-propagation calculator based on the Theis equation.</li>\n<li><strong>Well Communication</strong> — detects inter-well pressure interference from correlated, detrended gas-production residuals.</li>\n<li><strong>Critical Rate Sensitivities</strong> — computes the minimum gas rate required to lift liquids out of the wellbore.</li>\n<li><strong>CO2 Runtime History</strong> — real-time sensor dashboard for the active CO2 injection sites.</li>\n<li><strong>Horner Plots</strong> — pressure-transient analysis on shut-in data, estimating reservoir permeability.</li>\n<li><strong>Hall Plots</strong> — injection-well performance analysis from cumulative pressure vs. cumulative injected volume.</li>\n</ul>\n<h2>Resolution Visualizer</h2>\n<p>Shows the data-collection frequency (resolution) of a well's SCADA sensor readings, broken down by day and by sensor channel — a quick way to spot logging gaps or changes in sampling rate.</p>\n<ul>\n<li>Paginated well search across SCADA ID, well name, well ID and API number.</li>\n<li>Plotly line chart of resolution (data points ÷ 86,400 s) per day, one trace per channel (line/tubing/casing pressure, gas rate).</li>\n<li>Dashed reference lines at standard measurement intervals (15 s, 30 s, 1 min, 5 min, 15 min, 1–24 h) for easy comparison.</li>\n</ul>\n<h2>Salt Water Injection</h2>\n<p>An <strong>Infinite Reservoir Radial Pressure Propagation Calculator</strong> that models how pressure spreads outward from an injection well into an assumed infinite, homogeneous aquifer using the Theis equation, <code class=\"language-text\">ΔP = (ρ·g·Q / 4πT)·E₁(u)</code>, with the exponential integral evaluated via <code class=\"language-text\">scipy.special.exp1</code>.</p>\n<ul>\n<li>Configurable storativity and transmissivity, each derived from rock/fluid properties or supplied directly via an override.</li>\n<li>Point-pressure readout plus four visualizations: pressure-vs-distance, pressure-vs-time, a distance×time contour, and a spatial plan-view (top-down) map.</li>\n<li>Downloadable CSV of the spatial pressure matrix; all inputs converted to SI internally and reported in both psi and Pa.</li>\n</ul>\n<h2>Well Communication</h2>\n<p>Detects potential pressure communication between wells by correlating their detrended gas-production residuals, exposed through three sub-applications: <strong>Map Selection Analysis</strong> (pick wells on an interactive map and run all pairwise correlations), <strong>Trend Production Analysis</strong> (inspect a single well's decomposition), and <strong>Well Pair Analysis</strong> (compare two wells by well ID).</p>\n<ul>\n<li>7-day centered rolling-median smoothing of daily production.</li>\n<li>Reciprocal decline-curve trend fit (starting 365 days after first production) to isolate residuals.</li>\n<li>Pairwise Pearson correlation with a minimum of 365 overlapping observations; high positive correlation flags likely interference.</li>\n</ul>\n<h2>Critical Rate Sensitivities</h2>\n<p>Calculates the minimum gas flow rate needed to lift liquids out of a wellbore (preventing liquid loading), across three modes: an interactive <strong>Default</strong> sensitivity view, a batch <strong>CRS Report</strong>, and a single-well <strong>Report Preview</strong>.</p>\n<ul>\n<li>2D contour plots of critical rate over a pressure grid versus a chosen sensitivity variable (inclination, specific gravity, bottomhole temperature, or surface tension).</li>\n<li>Turner, Coleman, and Belfroid-Coleman (TNO-Shell, inclination-corrected) velocity models; tubing, casing, or annulus flow paths.</li>\n<li>Batch report fans out <strong>Lambda</strong> functions in parallel across all wells and writes results to S3, with an optional probe point and CSV export.</li>\n</ul>\n<h2>CO2 Runtime History</h2>\n<p>A real-time sensor dashboard for the active CO2 injection sites, remapping raw SCADA tags to human-readable fields.</p>\n<ul>\n<li>Interactive Plotly WebGL chart with four independent stacked Y-axes (temperature, casing pressure, pressure, mass flow rate); legend groups toggle whole sensor categories.</li>\n<li>Adaptive resampling (1 min → 1 day) once a date range grows large, to keep charts interactive, with the active resolution shown above the plot.</li>\n<li>Data-quality warnings for stale sensor fields and a CSV export of the resampled series.</li>\n</ul>\n<h2>Horner Plots</h2>\n<p>Performs pressure-transient analysis on well shut-in data: it auto-detects pressure-drop events, fits a Horner regression, and estimates reservoir permeability.</p>\n<ul>\n<li>CSV upload (resampled to 1-minute data) or S3 source, with automatic drop detection by configurable duration/magnitude thresholds.</li>\n<li>Timeseries view with adjustable baseline / shut-in-start / shut-in-end markers for fine-tuning on 1-minute data.</li>\n<li>Robust <strong>HuberRegressor</strong> fit of <code class=\"language-text\">bhp</code> vs <code class=\"language-text\">ln(t/Δt)</code> extrapolated to infinite shut-in time, yielding slope, perm-thickness (<code class=\"language-text\">kh = 162.6·q/m</code>), and permeability estimate.</li>\n</ul>\n<h2>Hall Plots</h2>\n<p>Analyzes injection-well performance via the Hall method — cumulative pressure differential vs. cumulative injected volume — where slope changes reveal injectivity decline or improvement over time.</p>\n<ul>\n<li>CSV upload or direct S3 load of the CO2 runtime-history parquet; data resampled to daily averages with forward/backward fill.</li>\n<li>Configurable flowing-pressure column, assumed reservoir pressure (Pe), tangent window (n_days), and analysis start date.</li>\n<li>Plotly scatter of cumulative ΔP vs. cumulative flow with a fitted tangent line and shaded slope window; rising slope indicates declining injectivity (potential formation damage).</li>\n</ul>\n<h2>Design decisions &#x26; trade-offs</h2>\n<ul>\n<li><strong>One multi-page Streamlit app</strong> instead of a separate app per tool — shared sidebar navigation, a single deployment to maintain, and a consistent UX across the whole toolkit.</li>\n<li><strong>Read-on-demand S3 parquet by well ID</strong> rather than a pre-built cache or index — prioritizes data freshness and low storage cost over the marginal latency a cache would save.</li>\n<li><strong>Parallel Lambda fan-out for batch reports</strong> (Critical Rate Sensitivities, Gas Injection) instead of synchronous computation — handles per-well parallelization at fleet scale without blocking the interactive app.</li>\n<li><strong>Robust HuberRegressor for Horner-plot fitting</strong> rather than ordinary least squares — tolerates outliers in noisy pressure-transient data for more reliable permeability estimates.</li>\n</ul>\n<h2>Architecture</h2>\n<p>All tools run inside <strong>one</strong> containerized Streamlit application using Streamlit's multi-page architecture — each tool is a numbered page in the sidebar — deployed to <strong>AWS ECS Fargate</strong>. Per-well production, injection and sensor data is stored in <strong>S3</strong> as parquet and read on demand by well ID; batch report generation (Critical Rate Sensitivities, Gas Injection) fans out across <strong>parallel Lambda</strong> functions that write results back to S3, and operator decisions persist in <strong>DynamoDB</strong>. Numerical work is done with <strong>Pandas / NumPy / SciPy</strong> (exponential integral, robust regression) and <strong>Plotly</strong> for interactive visualization, drawing on shared in-house engineering libraries (PVT, critical-rate and reservoir calculations). Infrastructure is managed with <strong>Pulumi</strong>, packaged with <strong>Docker</strong>, and shipped through <strong>GitHub Actions</strong> CI/CD. In-app user documentation is built and served with <strong>MkDocs</strong>.</p>\n<blockquote>\n<p><em>Note: Screenshots and internal application URLs are omitted, as they display proprietary client data. Available on request, subject to client approval.</em></p>\n</blockquote>","frontmatter":{"title":"BKV Streamlit Apps","image_url":"./images/covers/streamlit_apps.png","description":"A multi-page Streamlit platform of reservoir & production engineering tools for gas wells.","technologies":"Python, Streamlit, Plotly, Pandas, NumPy, SciPy (exp1, Huber regression), Scikit-learn, AWS (ECS Fargate, Lambda, S3, DynamoDB, ECR, CloudWatch, Bedrock), Pulumi, Docker, GitHub Actions, Parquet, MkDocs.","date":"2026-05-20T00:00:00.000Z"}},"user":"manolosolalinde","repository":"cv"}]},"site":{"siteMetadata":{"title":"Manuel Solalinde's Portfolio","description":"Manuel Solalinde's Portfolio and Featured Projects","author":"Manuel Solalinde"}}},"pageContext":{"uid":"bkv_streamlit_apps.md","rootQuery":"\n    query mdProjectQuery($uid: String) {\n        allGithubFile(filter: {base: {eq: $uid}, relativeDirectory: {eq: \"projects\"}}) {\n            nodes {\n              base\n              relativeDirectory\n              childMarkdownRemark {\n                id\n                html\n                frontmatter {\n                  title\n                  image_url\n                  description\n                  technologies\n                  date\n                }\n              }\n              user\n              repository\n            }\n        }\n        site {\n            siteMetadata {\n                title\n                description\n                author\n            }\n        }\n    }\n"}},"staticQueryHashes":["3649515864"]}