expreccs.utils.reg_sit_given_decks module#

Create a site deck with boundary pressures projected from existing decks.

The module reads regional and site OPM outputs, identifies corresponding boundary and regional cells, builds spatial and temporal interpolators, and writes BCCON, BCPROP, FIPNUM, and OPERNUM include files. Both rectangular and irregular site contours are supported, with optional FIPNUM-zone matching.

class Regional(grid, init, rst, rfip, act, rdays)[source]#

Bases: object

Data required by the Regional workflow.

Attributes:
gridOpmGrid

Grid.

initOpmFile

Init.

rstOpmRestart

Rst.

rfipNDArray

Rfip.

actNDArray

Act.

rdaysNDArray

Rdays.

Parameters:
  • grid (EGrid)

  • init (EclFile)

  • rst (ERst)

  • rfip (NDArray)

  • act (NDArray)

  • rdays (NDArray)

grid: EGrid#
init: EclFile#
rst: ERst#
rfip: NDArray#
act: NDArray#
rdays: NDArray#
class Site(grid, init, rst, sfip, sdata)[source]#

Bases: object

Data required by the Site workflow.

Attributes:
gridOpmGrid

Grid.

initOpmFile

Init.

rstOpmRestart

Rst.

sfipNDArray

Sfip.

sdatastr

Sdata.

Parameters:
  • grid (EGrid)

  • init (EclFile)

  • rst (ERst)

  • sfip (NDArray)

  • sdata (str)

grid: EGrid#
init: EclFile#
rst: ERst#
sfip: NDArray#
sdata: str#
class Config(fol, fsit, explicit, zones, freq, acoeff, boundaries, nonregular)[source]#

Bases: object

Data required by the Config workflow.

Attributes:
folstr

Output folder or model location.

fsitstr

Fsit.

explicitbool

Explicit.

zonesbool

Zones.

freqNDArray

Freq.

acoeffNDArray

Acoeff.

boundarieslist[int]

Boundaries.

nonregularbool

Nonregular.

Parameters:
fol: str#
fsit: str#
explicit: bool#
zones: bool#
freq: NDArray#
acoeff: NDArray#
boundaries: list[int]#
nonregular: bool#
class InterpData(ri, rx, ry, rz, sx, sy, sz, rf, rk, rt, rkg, sf, st, sai, snum)[source]#

Bases: object

Data required by the InterpData workflow.

Attributes:
rilist[NDArray]

Ri.

rxlist[NDArray]

Rx.

rylist[NDArray]

Ry.

rzlist[NDArray]

Rz.

sxlist[list[float]]

Sx.

sylist[list[float]]

Sy.

szlist[list[float]]

Sz.

rflist[NDArray]

Rf.

rklist[NDArray]

Rk.

rtlist[NDArray]

Rt.

rkglist[list[tuple[float, int]]]

Rkg.

sflist[list[int]]

Sf.

stlist[list[float]]

St.

sailist[int]

Sai.

snumlist[int]

Snum.

Parameters:
ri: list[NDArray]#
rx: list[NDArray]#
ry: list[NDArray]#
rz: list[NDArray]#
sx: list[list[float]]#
sy: list[list[float]]#
sz: list[list[float]]#
rf: list[NDArray]#
rk: list[NDArray]#
rt: list[NDArray]#
rkg: list[list[tuple[float, int]]]#
sf: list[list[int]]#
st: list[list[float]]#
sai: list[int]#
snum: list[int]#
class XYMaps(x_i, y_i, z_i, inds, fipr, offset, oprn, rtmin)[source]#

Bases: object

Data required by the XYMaps workflow.

Attributes:
x_iNDArray

X i.

y_iNDArray

Y i.

z_iNDArray

Z i.

indslist[int]

Inds.

fiprNDArray

Fipr.

offsetlist[float]

Offset.

oprnNDArray

Oprn.

rtminfloat

Rtmin.

Parameters:
  • x_i (NDArray)

  • y_i (NDArray)

  • z_i (NDArray)

  • inds (list[int])

  • fipr (NDArray)

  • offset (list[float])

  • oprn (NDArray)

  • rtmin (float)

x_i: NDArray#
y_i: NDArray#
z_i: NDArray#
inds: list[int]#
fipr: NDArray#
offset: list[float]#
oprn: NDArray#
rtmin: float#
class BCCon(coords, sbound, spres, ksfips, stmin, sopn)[source]#

Bases: object

Data required by the BCCon workflow.

Attributes:
coordslist[list[float]]

Coords.

sboundlist[str]

Sbound.

spreslist[float]

Spres.

ksfipslist[int]

Ksfips.

stminfloat

Stmin.

sopnNDArray

Sopn.

Parameters:
coords: list[list[float]]#
sbound: list[str]#
spres: list[float]#
ksfips: list[int]#
stmin: float#
sopn: NDArray#
class Borders(sx, sy, sz, sf, st, sbound, sai)[source]#

Bases: object

Data required by the Borders workflow.

Attributes:
sxlist[list[float]]

Sx.

sylist[list[float]]

Sy.

szlist[list[float]]

Sz.

sflist[list[int]]

Sf.

stlist[list[float]]

St.

sboundlist[str]

Sbound.

sailist[int]

Sai.

Parameters:
sx: list[list[float]]#
sy: list[list[float]]#
sz: list[list[float]]#
sf: list[list[int]]#
st: list[list[float]]#
sbound: list[str]#
sai: list[int]#
class RegionalCells(ri, rx, ry, rz, rf, rt, rk, rkg, sbound)[source]#

Bases: object

Data required by the RegionalCells workflow.

Attributes:
rilist

Ri.

rxlist

Rx.

rylist

Ry.

rzlist

Rz.

rflist[NDArray]

Rf.

rtlist

Rt.

rklist

Rk.

rkglist[list[tuple[float, int]]]

Rkg.

sboundlist[str]

Sbound.

Parameters:
ri: list#
rx: list#
ry: list#
rz: list#
rf: list[NDArray]#
rt: list#
rk: list#
rkg: list[list[tuple[float, int]]]#
sbound: list[str]#
class SiteBorders(spres, sai, sbound, sxn, syn, szn, sfn, stn, sxw, syw, szw, sfw, stw, sxs, syl, szs, sfs, sts, sxe, sye, sze, sfe, ste)[source]#

Bases: object

Data required by the SiteBorders workflow.

Attributes:
spreslist[float]

Spres.

sailist[int]

Sai.

sboundlist[str]

Sbound.

sxnlist[float]

Sxn.

synlist[float]

Syn.

sznlist[float]

Szn.

sfnlist[int]

Sfn.

stnlist[float]

Stn.

sxwlist[float]

Sxw.

sywlist[float]

Syw.

szwlist[float]

Szw.

sfwlist[int]

Sfw.

stwlist[float]

Stw.

sxslist[float]

Sxs.

syllist[float]

Syl.

szslist[float]

Szs.

sfslist[int]

Sfs.

stslist[float]

Sts.

sxelist[float]

Sxe.

syelist[float]

Sye.

szelist[float]

Sze.

sfelist[int]

Sfe.

stelist[float]

Ste.

Parameters:
spres: list[float]#
sai: list[int]#
sbound: list[str]#
sxn: list[float]#
syn: list[float]#
szn: list[float]#
sfn: list[int]#
stn: list[float]#
sxw: list[float]#
syw: list[float]#
szw: list[float]#
sfw: list[int]#
stw: list[float]#
sxs: list[float]#
syl: list[float]#
szs: list[float]#
sfs: list[int]#
sts: list[float]#
sxe: list[float]#
sye: list[float]#
sze: list[float]#
sfe: list[int]#
ste: list[float]#
create_deck(fol, explicit, zones, freq, nonregular, acoeff, boundaries, reg, freg, sit, fsit)[source]#

Project regional pressures and create a boundary-driven site deck.

Parameters:
folstr

Output folder or model location.

explicitbool

Explicit.

zonesbool

Zones.

freqNDArray

Freq.

nonregularbool

Nonregular.

acoeffNDArray

Acoeff.

boundarieslist[int]

Boundaries.

regstr

Reg.

fregstr

Freg.

sitstr

Sit.

fsitstr

Fsit.

Parameters:
Return type:

None

get_xymaps(regional, ufip, zones, coords)[source]#

Collect regional interpolation coordinates around site boundaries.

Parameters:
regionalRegional

Regional.

ufipNDArray

Ufip.

zonesbool

Zones.

coordslist[list[float]]

Coords.

Returns:
XYMaps

Regional interpolation coordinates and metadata.

Parameters:
Return type:

XYMaps

get_bccon(site, regional, boundaries, explicit, boundary, dire, sopn)[source]#

Build boundary connections and interpolation coordinates for an irregular site.

Parameters:
siteSite

Site.

regionalRegional

Regional.

boundarieslist[int]

Boundaries.

explicitbool

Explicit.

boundaryNDArray

Boundary.

direlist[int]

Dire.

sopnNDArray

Sopn.

Returns:
BCCon

Site boundary connections and coordinates.

Parameters:
Return type:

BCCon

site_contour(grid, start)[source]#

Trace the active-cell contour of an irregular site grid.

Parameters:
gridNDArray

Grid.

startlist[int]

Start.

Returns:
tuple[list[list[int]], list[int]]

Boundary cells and corresponding direction codes.

Parameters:
Return type:

tuple[list[list[int]], list[int]]

compact_format_numeric(v)[source]#

Compress consecutive numeric values using OPM repeated-value notation.

Parameters:
vNDArray
Returns:
list[str]

OPM-formatted value groups.

Parameters:

v (NDArray)

Return type:

list[str]

handle_grid_coord(sgrid, rgrid, sinit, rinit)[source]#

Build site bounds and regional cell-center coordinate arrays.

Parameters:
sgridOpmGrid

Sgrid.

rgridOpmGrid

Rgrid.

sinitOpmFile

Sinit.

rinitOpmFile

Rinit.

Returns:
tuple

Region arrays, dimensions, and site bounding polygon.

Parameters:
  • sgrid (EGrid)

  • rgrid (EGrid)

  • sinit (EclFile)

  • rinit (EclFile)

Return type:

tuple[NDArray, NDArray, NDArray, NDArray, NDArray, int, int, list[list[float]]]

add_neigh(gtmp, ijk_n, kval, rgrid, ract, rfip, rnxy, ri, rx, ry, rz, rk, rf, rt, d_z, oprn, n, noise)[source]#

Add one active regional neighbor to an interpolation stencil.

Ignore global indices outside the grid, inactive cells, and active cells already included in the current stencil. For a retained neighbor, append its active index, center coordinates, layer, FIPNUM, and top elevation, then mark its role in the full-grid OPERNUM array.

Parameters:
gtmpint

Global index of the candidate regional neighbor.

ijk_ntuple[int, int, int]

Zero-based I, J, and K indices of the candidate cell.

kvalint

Layer index assigned to the candidate cell.

rgridOpmGrid

Regional grid geometry and active/global index mappings.

ractNDArray

Boolean active-cell mask in global-grid order.

rfipNDArray

Regional FIPNUM values in active-cell order.

rnxyint

Number of cells in one regional xy layer.

rilist[int]

Active regional-cell indices already included in the stencil.

rxlist[float]

Regional cell-center x coordinates to update.

rylist[float]

Regional cell-center y coordinates to update.

rzlist[float]

Regional cell-center z coordinates to update.

rklist[int]

Regional layer indices to update.

rflist[int]

Regional FIPNUM values to update.

rtlist[float]

Regional cell top-face elevations to update.

d_zNDArray

Half-heights of active regional cells.

oprnNDArray

Full-grid OPERNUM values to update.

nint

Site-boundary direction index used to assign OPERNUM.

noisefloat

Small vertical offset used to avoid duplicate interpolation points.

Parameters:
Return type:

None

check_regional_neighbours(rgrid, ract, rfip, rnxy, ri, rx, ry, rz, rk, rf, rt, gind, n, d_z, oprn)[source]#

Add active neighboring regional cells to an interpolation stencil.

Parameters:
rgridOpmGrid

Rgrid.

ractNDArray

Ract.

rfipNDArray

Rfip.

rnxyint

Rnxy.

rilist[int]

Ri.

rxlist[float]

Rx.

rylist[float]

Ry.

rzlist[float]

Rz.

rklist[int]

Rk.

rflist[int]

Rf.

rtlist[float]

Rt.

gindint

Gind.

nint
d_zNDArray

D z.

oprnNDArray

Oprn.

Returns:
NDArray

Updated OPERNUM array.

Parameters:
Return type:

NDArray

find_regional_cells(rgrid, sgrid, sinit, rinit, rfip, zones, borders, ract)[source]#

Find regional interpolation cells for each site border.

Parameters:
rgridOpmGrid

Rgrid.

sgridOpmGrid

Sgrid.

sinitOpmFile

Sinit.

rinitOpmFile

Rinit.

rfipNDArray

Rfip.

zonesbool

Zones.

bordersBorders

Borders.

ractNDArray

Ract.

Returns:
tuple[RegionalCells, list[int]]

Regional interpolation cells and retained site indices.

Parameters:
  • rgrid (EGrid)

  • sgrid (EGrid)

  • sinit (EclFile)

  • rinit (EclFile)

  • rfip (NDArray)

  • zones (bool)

  • borders (Borders)

  • ract (NDArray)

Return type:

tuple[RegionalCells, list[int]]

temporal_interpolation(freq, acoeff, sdays, isdays, rdays, rp, explicit, spres)[source]#

Create site report times and interpolate boundary pressures.

Parameters:
freqNDArray

Freq.

acoeffNDArray

Acoeff.

sdaysNDArray

Sdays.

isdaysNDArray

Isdays.

rdaysNDArray

Rdays.

rplist[list[tuple[int, float]]]

Rp.

explicitbool

Explicit.

spreslist[float]

Spres.

Returns:
tuple[NDArray, NDArray, list[str]]

Site times, time steps, and boundary records.

Parameters:
Return type:

tuple[NDArray, NDArray, list[str]]

update_boundary(key, z_b, sbound, c_c, s_s, rp_out, i, rgrid, sgrid, sopn)[source]#

Store one projected pressure and update its boundary connection.

Append a finite projected pressure to the current restart-step results. At the first restart step, renumber retained one-layer boundary connections and mark their site cells in OPERNUM. If interpolation returns NaN, remove the corresponding connection during the first restart step.

Parameters:
keyint

One-based boundary-connection identifier.

z_bfloat

Interpolated boundary pressure or scalar NumPy result.

sboundlist[str]

Current BCCON records.

c_cint

Counter used to renumber retained one-layer boundary connections.

s_sint

Number of skipped boundary connections since the last retained entry.

rp_outlist[tuple[int, float]]

Projected boundary-pressure pairs for the current restart step.

iint

Regional restart-step index.

rgridOpmGrid

Regional grid used to distinguish one- and multi-layer models.

sgridOpmGrid

Site grid used to map retained BCCON records to global cells.

sopnNDArray

Full-grid site OPERNUM values to update.

Returns:
tuple[list[str], int, int]

Updated BCCON records, retained-connection counter, and skipped counter.

Parameters:
Return type:

tuple[list[str], int, int]

project_pressures(rrst, rgrid, sgrid, data, sbound, ufip, explicit, zones, sopn, i)[source]#

Project one regional restart step onto the site boundary.

Parameters:
rrstOpmRestart

Rrst.

rgridOpmGrid

Rgrid.

sgridOpmGrid

Sgrid.

dataInterpData

Values to plot.

sboundlist[str]

Sbound.

ufipNDArray

Ufip.

explicitbool

Explicit.

zonesbool

Zones.

sopnNDArray

Sopn.

iint

Index of the current quantity, boundary, or report step.

Returns:
tuple[list[tuple[int, float]], list[str]]

Projected pressures and updated boundary definitions.

Parameters:
  • rrst (ERst)

  • rgrid (EGrid)

  • sgrid (EGrid)

  • data (InterpData)

  • sbound (list[str])

  • ufip (NDArray)

  • explicit (bool)

  • zones (bool)

  • sopn (NDArray)

  • i (int)

Return type:

tuple[list[tuple[int, float]], list[str]]

write_files(fol, fsit, freq, ddays, sdata, sbound, sbc, sdays, sopn)[source]#

Write projected deck and boundary-condition include files.

Parameters:
folstr

Output folder or model location.

fsitstr

Fsit.

freqNDArray

Freq.

ddaysNDArray

Ddays.

sdatastr

Sdata.

sboundlist[str]

Sbound.

sbclist[str]

Sbc.

sdaysNDArray

Sdays.

sopnNDArray

Sopn.

Parameters:
  • fol (str)

  • fsit (str)

  • freq (NDArray)

  • ddays (NDArray)

  • sdata (str)

  • sbound (list[str])

  • sbc (list[str])

  • sdays (NDArray)

  • sopn (NDArray)

Return type:

None

find_ij_orientation(sgrid)[source]#

Determine site-grid I and J orientation signs.

Parameters:
sgridOpmGrid

Sgrid.

Returns:
tuple[int, int]

Orientation signs for the J and I axes.

Parameters:

sgrid (EGrid)

Return type:

tuple[int, int]

extract_site_borders(sgrid, sdim, sinit, srst, boundaries, explicit, mly, mlx, sfip)[source]#

Extract active cells and properties along rectangular site borders.

Parameters:
sgridOpmGrid

Sgrid.

sdimNDArray

Sdim.

sinitOpmFile

Sinit.

srstOpmRestart

Srst.

boundarieslist[int]

Boundaries.

explicitbool

Explicit.

mlyint

Mly.

mlxint

Mlx.

sfipNDArray

Sfip.

Returns:
SiteBorders

Extracted site-border coordinates and properties.

Parameters:
  • sgrid (EGrid)

  • sdim (NDArray)

  • sinit (EclFile)

  • srst (ERst)

  • boundaries (list[int])

  • explicit (bool)

  • mly (int)

  • mlx (int)

  • sfip (NDArray)

Return type:

SiteBorders