Kalman (WRTDS-K)¶
WRTDS-K implementation: AR(1) residual interpolation via Monte Carlo simulation to improve daily concentration and flux estimates between sample dates.
wrtds.kalman
¶
WRTDS-K: Kalman-filter–style AR(1) residual interpolation.
make_augmented_sample(sample, rng=None)
¶
Generate a concentration value for every sample observation.
Uncensored observations use ConcAve directly. For censored
observations a random draw is taken from the truncated log-normal
implied by the cross-validation fit (upper bound = ConcHigh).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Populated sample DataFrame with |
required | |
rng
|
Optional :class: |
None
|
Returns:
| Type | Description |
|---|---|
|
1-D array of |
Source code in wrtds/kalman.py
ar1_conditional_draw(rho, n_gap, e_start, e_end, rng)
¶
Draw AR(1) residuals for the interior of a gap, conditioned on endpoints.
Given standardised residuals at two consecutive sample days separated
by n_gap unsampled days, draw plausible residuals for every
intermediate day using the conditional multivariate normal distribution
implied by an AR(1) covariance structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
AR(1) autocorrelation parameter (0 < rho < 1). |
required | |
n_gap
|
Number of interior (unsampled) days in the gap. |
required | |
e_start
|
Standardised residual at the left endpoint. |
required | |
e_end
|
Standardised residual at the right endpoint. |
required | |
rng
|
:class: |
required |
Returns:
| Type | Description |
|---|---|
|
|
|
|
Returns an empty array when |
Source code in wrtds/kalman.py
wrtds_kalman(daily, sample, surfaces, surface_index, rho=0.9, n_iter=200, seed=None)
¶
Run WRTDS-K (Kalman-style residual interpolation).
Improves daily flux estimates by exploiting the temporal autocorrelation of model residuals between consecutive sample days.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
daily
|
Populated daily DataFrame (must have |
required | |
sample
|
Populated sample DataFrame (must have |
required | |
surfaces
|
3-D surfaces array. |
required | |
surface_index
|
Grid parameters dict. |
required | |
rho
|
AR(1) autocorrelation parameter. |
0.9
|
|
n_iter
|
Number of Monte Carlo iterations. |
200
|
|
seed
|
Optional integer seed for reproducibility. |
None
|
Returns:
| Type | Description |
|---|---|
|
Daily DataFrame with added columns |
Source code in wrtds/kalman.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |