Surfaces¶
Surface grid computation and interpolation: builds the 3-D concentration surface array and provides vectorised bilinear interpolation for daily estimation.
wrtds.surfaces
¶
Surface grid estimation and bilinear interpolation for WRTDS.
compute_surface_index(sample)
¶
Compute the surface grid parameters from sample data.
The grid spans the range of observed log-discharge and decimal year, with fixed resolution: 14 log-Q levels and time steps of 1/16 year (~23 days).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Populated sample DataFrame (must have |
required |
Returns:
| Type | Description |
|---|---|
|
Dict with keys: |
|
|
|
|
|
|
Source code in wrtds/surfaces.py
estimate_surfaces(sample, surface_index, window_y=7.0, window_q=2.0, window_s=0.5, min_num_obs=100, min_num_uncen=50, edge_adjust=True)
¶
Fit the censored regression at every grid point to build the surfaces array.
This is the main computational bottleneck of WRTDS: one MLE solve per grid point, typically ~7 000 total (14 log-Q levels x ~500 time steps).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Populated sample DataFrame with |
required | |
surface_index
|
Grid parameters from :func: |
required | |
window_y
|
Time half-window in years. |
7.0
|
|
window_q
|
Discharge half-window in log units. |
2.0
|
|
window_s
|
Season half-window in fraction of year. |
0.5
|
|
min_num_obs
|
Minimum observations with nonzero weight. |
100
|
|
min_num_uncen
|
Minimum uncensored observations with nonzero weight. |
50
|
|
edge_adjust
|
Expand time window near record edges. |
True
|
Returns:
| Type | Description |
|---|---|
|
3-D numpy array of shape |
|
|
|
Source code in wrtds/surfaces.py
make_interpolator(surfaces, surface_index, layer=2)
¶
Create a RegularGridInterpolator for one surface layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
surfaces
|
3-D array |
required | |
surface_index
|
Grid parameters dict. |
required | |
layer
|
Which layer to interpolate (0=yHat, 1=SE, 2=ConcHat). |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
class: |
|
|
Out-of-range queries are clamped to the nearest grid boundary. |
Source code in wrtds/surfaces.py
interpolate_surface(surfaces, surface_index, logq, dec_year, layer=2)
¶
Vectorised bilinear interpolation on a surface layer.
Queries are clamped to the grid boundaries before interpolation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
surfaces
|
3-D array |
required | |
surface_index
|
Grid parameters dict. |
required | |
logq
|
Log-discharge value(s). |
required | |
dec_year
|
Decimal year value(s). |
required | |
layer
|
Which layer (0=yHat, 1=SE, 2=ConcHat). |
2
|
Returns:
| Type | Description |
|---|---|
|
Array of interpolated values (same shape as inputs). |