UCS2014 commited on
Commit
a289c00
·
verified ·
1 Parent(s): f44f6f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -10
app.py CHANGED
@@ -20,7 +20,7 @@ from sklearn.metrics import mean_squared_error, mean_absolute_error
20
  # Constants (GR)
21
  # =========================
22
  APP_NAME = "ST_Log_GR"
23
- TAGLINE = "Real-Time Gamma Ray Prediction Using Drilling Data"
24
 
25
  FEATURES = ["GPM", "SPP", "RPM", "WOB", "T", "ROP"]
26
 
@@ -525,25 +525,48 @@ def track_plot(df, include_actual=True, pred_col="GR_Pred", actual_col="GR"):
525
  return fig
526
 
527
 
528
- # ---------- Preview modal (matplotlib) ----------
529
  def preview_tracks(df: pd.DataFrame, cols: list[str]):
 
530
  cols = [c for c in cols if c in df.columns]
531
  n = len(cols)
532
  if n == 0:
533
  fig, ax = plt.subplots(figsize=(4, 2))
534
- ax.text(0.5,0.5,"No selected columns",ha="center",va="center"); ax.axis("off")
535
  return fig
536
- fig, axes = plt.subplots(1, n, figsize=(2.2*n, 7.0), sharey=True, dpi=100)
537
- if n == 1: axes = [axes]
538
- idx = np.arange(1, len(df) + 1)
 
 
 
 
 
 
 
 
 
 
 
 
539
  for ax, col in zip(axes, cols):
540
- ax.plot(df[col], idx, '-', lw=1.4, color="#333")
541
- ax.set_xlabel(col); ax.xaxis.set_label_position('top'); ax.xaxis.tick_top(); ax.invert_yaxis()
 
 
 
 
 
 
 
542
  ax.grid(True, linestyle=":", alpha=0.3)
543
- for s in ax.spines.values(): s.set_visible(True)
544
- axes[0].set_ylabel("Point Index")
 
 
545
  return fig
546
 
 
547
  # Modal wrapper (Streamlit compatibility)
548
  try:
549
  dialog = st.dialog
 
20
  # Constants (GR)
21
  # =========================
22
  APP_NAME = "ST_Log_GR"
23
+ TAGLINE = "Real-Time Gamma Ray Prediction"
24
 
25
  FEATURES = ["GPM", "SPP", "RPM", "WOB", "T", "ROP"]
26
 
 
525
  return fig
526
 
527
 
528
+ # ---------- Preview modal (matplotlib) — y-axis reversed ----------
529
  def preview_tracks(df: pd.DataFrame, cols: list[str]):
530
+ # keep only columns that exist
531
  cols = [c for c in cols if c in df.columns]
532
  n = len(cols)
533
  if n == 0:
534
  fig, ax = plt.subplots(figsize=(4, 2))
535
+ ax.text(0.5, 0.5, "No selected columns", ha="center", va="center"); ax.axis("off")
536
  return fig
537
+
538
+ # use Depth if present, else 1..N
539
+ depth_col = next((c for c in df.columns if 'depth' in str(c).lower()), None)
540
+ if depth_col is not None:
541
+ y = pd.Series(df[depth_col], dtype=float)
542
+ ylab = depth_col
543
+ else:
544
+ y = pd.Series(np.arange(1, len(df) + 1), dtype=float)
545
+ ylab = "Point Index"
546
+
547
+ # IMPORTANT: don't share y so inversion always applies
548
+ fig, axes = plt.subplots(1, n, figsize=(2.4 * n, 7.0), dpi=100, sharey=False)
549
+ if n == 1:
550
+ axes = [axes]
551
+
552
  for ax, col in zip(axes, cols):
553
+ ax.plot(pd.to_numeric(df[col], errors="coerce"), y, '-', lw=1.4, color="#333")
554
+ ax.set_xlabel(col)
555
+ ax.xaxis.set_label_position('top')
556
+ ax.xaxis.tick_top()
557
+
558
+ # Reverse y-axis universally: shallow at top, deep at bottom
559
+ ax.set_ylim(float(y.min()), float(y.max()))
560
+ ax.invert_yaxis()
561
+
562
  ax.grid(True, linestyle=":", alpha=0.3)
563
+ for s in ax.spines.values():
564
+ s.set_visible(True)
565
+
566
+ axes[0].set_ylabel(ylab)
567
  return fig
568
 
569
+
570
  # Modal wrapper (Streamlit compatibility)
571
  try:
572
  dialog = st.dialog