Skip to main content

Time-series trend analysis for any parameter (pressure, rate, temperature, etc.)

Project description

onsight_trend

Time-series trend analysis for the oil & gas industry—and beyond.

Analyze pressure, rate, temperature, or any parameter with rolling segmentation, dual-method voting (subtraction + linear regression), and configurable magnitude categories. Built for well performance, process monitoring, and industrial analytics.

Installation

pip install onsight-trend

Quick Start

from onsight_trend import analyze_trend

import pandas as pd
df = pd.read_csv("data.csv")
result = analyze_trend(df)

print(result.direction)    # 'increase', 'decrease', or 'steady'
print(result.magnitude)    # net change in parameter units
print(result.confidence)   # 0-100%

Input Formats

DataFrame with columns:

  • Time: datetime, time, date, or timestamp
  • Parameter: value, parameter, thp, pressure, rate, oil_rate, temperature, flow_rate, etc.—or any numeric column

Series with DatetimeIndex:

series = df.set_index("datetime")["pressure"]
result = analyze_trend(series)

Parameters

analyze_trend(
    data,
    duration_days=7.0,           # analysis window (most recent data)
    magnitude_categories=None,   # custom thresholds (see below)
)

Custom Magnitude Categories

Magnitude categories classify the size of change in your parameter’s units (e.g. psi, bar, stb/d, °C).

Default Categories

Category Range (units)
negligible 0 - 10
small 10 - 50
moderate 50 - 150
large 150 - 300
very_large 300+

How to Change Magnitude Categories

1. Python API—pass a dict

my_categories = {
    "negligible": (0, 15),
    "small": (15, 60),
    "moderate": (60, 200),
    "large": (200, 400),
    "very_large": (400, float("inf")),
}
result = analyze_trend(df, magnitude_categories=my_categories)
print(result.magnitude_category)  # uses your categories

2. Modify defaults and reuse

from onsight_trend import analyze_trend
from onsight_trend.config import DEFAULT_MAGNITUDE_CATEGORIES

# Copy and adjust
my_cats = DEFAULT_MAGNITUDE_CATEGORIES.copy()
my_cats["small"] = (10, 75)
my_cats["moderate"] = (75, 200)

result = analyze_trend(df, magnitude_categories=my_cats)

3. Different units (e.g. oil rate in stb/d)

# For oil rate: 0-100 stb/d = low, 100-500 = medium, 500+ = high
rate_categories = {
    "low": (0, 100),
    "medium": (100, 500),
    "high": (500, float("inf")),
}
result = analyze_trend(rate_df, magnitude_categories=rate_categories)

4. CLI

python -m onsight_trend data.csv -d 7 -m "low:0,25 medium:25,100 high:100,inf"

Format: "name1:min1,max1 name2:min2,max2 ...". Use inf for no upper limit.

Category Rules

  • Categories are checked in order; the first matching range is used.
  • Ranges are [min, max) (inclusive min, exclusive max).
  • Use float("inf") for unbounded upper limits.

Result Attributes

Attribute Type Description
direction str 'increase', 'decrease', 'steady'
magnitude float Net change in parameter units
confidence float Vote confidence 0-100%
magnitude_pct float Percentage change
magnitude_category str Category from your thresholds
start_value float Parameter at start of window
end_value float Parameter at end of window
duration_days float Analysis window length
n_segments int Number of rolling segments (10)

How It Works

  1. Rolling segments: Splits the duration into 10 overlapping segments (60% overlap).
  2. Two methods per segment: Simple subtraction and linear regression.
  3. Voting: Each segment contributes 2 votes; majority direction wins.
  4. Confidence: Percentage of votes for the winning direction.
  5. Magnitude: Net change from first to last point in the window.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onsight_trend-0.1.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onsight_trend-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file onsight_trend-0.1.0.tar.gz.

File metadata

  • Download URL: onsight_trend-0.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for onsight_trend-0.1.0.tar.gz
Algorithm Hash digest
SHA256 24ade8ae7a7969957f9167dad54f7e520db387846ba78e607a521b4f050c72e7
MD5 27a40bec1501469b5c08a414b207af5a
BLAKE2b-256 0421b00ac1b68005ed7a3651473530cf3d6a3482ae18717c446cbf5e8a109dc1

See more details on using hashes here.

File details

Details for the file onsight_trend-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: onsight_trend-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for onsight_trend-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 826811d16d38c4d215b576f5bf31104ca5ed6fe1b1c75e8e87415c64b707d26a
MD5 e61e8baab1b33db0f019cdf5a9f2c3e2
BLAKE2b-256 5236c19daa55cba94efd123a2e0011a2824566b48e8370bb2a447730d7cac960

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page