Spaces:
Sleeping
Sleeping
File size: 2,021 Bytes
46e770f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | """Seed database with sample Niger Delta production data."""
import numpy as np
from datetime import datetime, timedelta
from app.core.database import insert_production
OMLS = ["OML-14","OML-18","OML-22","OML-29","OML-58"]
FIELDS = {"OML-14":["Obagi","Erema"],"OML-18":["Nembe Creek","Cough Creek"],
"OML-22":["Odidi","Batton"],"OML-29":["Agbada","Agbada West"],"OML-58":["Akri","Ogoda"]}
WELL_PREFIX = {"OML-14":"OBG","OML-18":"NCR","OML-22":"ODD","OML-29":"AGB","OML-58":"AKR"}
def seed_production(days: int = 30):
np.random.seed(42)
records = 0
for oml in OMLS:
for field in FIELDS[oml]:
for w in range(4):
wid = f"{WELL_PREFIX[oml]}-{w+1:02d}"
base_oil = np.random.uniform(500, 4000)
base_gas = base_oil * np.random.uniform(0.3, 1.2) / 1000
base_wc = np.random.uniform(20, 80)
for d in range(days):
date = (datetime.now() - timedelta(days=days-d)).strftime("%Y-%m-%d")
decline = 1 - (d * 0.001)
noise = np.random.uniform(0.92, 1.08)
status = np.random.choice(["active","active","active","active","shut-in"], p=[0.9,0.025,0.025,0.025,0.025])
insert_production({
"oml_id": oml, "well_id": wid, "field_name": field,
"oil_rate_bpd": round(base_oil * decline * noise, 1) if status == "active" else 0,
"gas_rate_mmscfd": round(base_gas * decline * noise, 3) if status == "active" else 0,
"water_cut_pct": round(base_wc + d * 0.1 + np.random.uniform(-2, 2), 1),
"wellhead_pressure_psi": round(np.random.uniform(800, 3000), 0),
"temperature_f": round(np.random.uniform(120, 220), 1),
"status": status, "record_date": date
})
records += 1
return records
|