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, ortimestamp - 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
- Rolling segments: Splits the duration into 10 overlapping segments (60% overlap).
- Two methods per segment: Simple subtraction and linear regression.
- Voting: Each segment contributes 2 votes; majority direction wins.
- Confidence: Percentage of votes for the winning direction.
- Magnitude: Net change from first to last point in the window.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24ade8ae7a7969957f9167dad54f7e520db387846ba78e607a521b4f050c72e7
|
|
| MD5 |
27a40bec1501469b5c08a414b207af5a
|
|
| BLAKE2b-256 |
0421b00ac1b68005ed7a3651473530cf3d6a3482ae18717c446cbf5e8a109dc1
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
826811d16d38c4d215b576f5bf31104ca5ed6fe1b1c75e8e87415c64b707d26a
|
|
| MD5 |
e61e8baab1b33db0f019cdf5a9f2c3e2
|
|
| BLAKE2b-256 |
5236c19daa55cba94efd123a2e0011a2824566b48e8370bb2a447730d7cac960
|