Error Model
Error model module.
ErrorModel
dataclass
Bases: Component
Measurement precision model component for the model.
Attributes:
Name | Type | Description |
---|---|---|
n_sensor |
int
|
number of sensors in the sensor object used for analysis. |
precision_index |
ndarray
|
index mapping precision parameters onto observations. Will be set up differently for different model types. |
precision_parameter |
Parameter
|
parameter object which constructs the full measurement error precision matrix from the components stored in state. Will be passed to the distribution for the observed when the full model is constructed. |
prior_precision_shape |
Union[ndarray, float]
|
prior shape parameters for the precision model. Set up differently per model type. |
prior_precision_rate |
Union[ndarray, float]
|
prior rate parameters for the precision model. Set up differently per model type. |
initial_precision |
Union[ndarray, float]
|
initial value for the precision to be passed to the analysis routine. Set up differently per model type. |
precision |
ndarray
|
array of sampled measurement error precision values, populated in self.from_mcmc() after the MCMC run is completed. |
Source code in src/pyelq/component/error_model.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
initialise(sensor_object, meteorology=None, gas_species=None)
Take data inputs and extract relevant properties.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
SensorGroup
|
sensor data. |
required |
meteorology
|
MeteorologyGroup
|
meteorology data. Defaults to None. |
None
|
gas_species
|
GasSpecies
|
gas species information. Defaults to None. |
None
|
Source code in src/pyelq/component/error_model.py
55 56 57 58 59 60 61 62 63 64 65 66 |
|
make_model(model=None)
Take model list and append new elements from current model component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
list
|
Current list of model elements. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
model output list. |
Source code in src/pyelq/component/error_model.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
make_sampler(model, sampler_list=None)
Take sampler list and append new elements from current model component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Model
|
Full model list of distributions. |
required |
sampler_list
|
list
|
Current list of samplers. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
sampler output list. |
Source code in src/pyelq/component/error_model.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
make_state(state=None)
Take state dictionary and append initial values from model component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
dict
|
current state vector. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
current state vector with components added. |
Source code in src/pyelq/component/error_model.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
from_mcmc(store)
Extract results of mcmc from mcmc.store and attach to components.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
store
|
dict
|
mcmc result dictionary. |
required |
Source code in src/pyelq/component/error_model.py
117 118 119 120 121 122 123 124 |
|
BySensor
dataclass
Bases: ErrorModel
Version of measurement precision where each sensor object has a different precision.
Attributes:
Name | Type | Description |
---|---|---|
prior_precision_shape |
Union[ndarray, float]
|
prior shape parameters for the precision model, can be specified either as a float or as a (nof_sensors, ) np.ndarray: a float specification will result in the same parameter value for each sensor. Defaults to 1e-3. |
prior_precision_rate |
Union[ndarray, float]
|
prior rate parameters for the precision model, can be specified either as a float or as a (nof_sensors, ) np.ndarray: a float specification will result in the same parameter value for each sensor. Defaults to 1e-3. |
initial_precision |
Union[ndarray, float]
|
initial value for the precision parameters, can be specified either as a float or as a (nof_sensors, ) np.ndarray: a float specification will result in the same parameter value for each sensor. Defaults to 1. |
precision_index |
ndarray
|
index mapping precision parameters onto observations. Parameters 1:n_sensor are mapped as the measurement error precisions of the corresponding sensors. |
precision_parameter |
MixtureParameterMatrix
|
parameter specification for this model, maps the current value of the parameter in the state dict onto the concentration data precisions. |
Source code in src/pyelq/component/error_model.py
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 |
|
initialise(sensor_object, meteorology=None, gas_species=None)
Set up the error model using sensor properties.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
SensorGroup
|
sensor data. |
required |
meteorology
|
MeteorologyGroup
|
meteorology data. Defaults to None. |
None
|
gas_species
|
GasSpecies
|
gas species information. Defaults to None. |
None
|
Source code in src/pyelq/component/error_model.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
plot_iterations(plot, sensor_object, burn_in_value)
Plots the error model values for every sensor with respect to the MCMC iterations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
Union[SensorGroup, Sensor]
|
Sensor object associated with the error_model |
required |
burn_in_value
|
int
|
Burn in value to show in plot. |
required |
plot
|
Plot
|
Plot object to which this figure will be added in the figure dictionary |
required |
Returns:
Name | Type | Description |
---|---|---|
plot |
Plot
|
Plot object to which this figure is added in the figure dictionary with key 'error_model_iterations' |
Source code in src/pyelq/component/error_model.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
plot_distributions(plot, sensor_object, burn_in_value)
Plots the distribution of the error model values after the burn in for every sensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
Union[SensorGroup, Sensor]
|
Sensor object associated with the error_model |
required |
burn_in_value
|
int
|
Burn in value to show in plot. |
required |
plot
|
Plot
|
Plot object to which this figure will be added in the figure dictionary |
required |
Returns:
Name | Type | Description |
---|---|---|
plot |
Plot
|
Plot object to which this figure is added in the figure dictionary with key 'error_model_distributions' |
Source code in src/pyelq/component/error_model.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
ByRelease
dataclass
Bases: ErrorModel
ByRelease error model, special case of the measurement precision model.
Version of the measurement precision model where each sensor object has a different precision, and there are different precisions for periods inside and outside controlled release periods. For all parameters: the first element corresponds to the case where the sources are OFF; the second element corresponds to the case where the sources are ON.
Attributes:
Name | Type | Description |
---|---|---|
prior_precision_shape |
ndarray
|
prior shape parameters for the precision model, can be specified either as a (2, 1) np.ndarray or as a (2, nof_sensors) np.ndarray: the former specification will result in the same prior specification for the off/on precisions for each sensor. Defaults to np.array([1e-3, 1e-3]). |
prior_precision_rate |
ndarray
|
prior rate parameters for the precision model, can be specified either as a (2, 1) np.ndarray or as a (2, nof_sensors) np.ndarray: the former specification will result in the same prior specification for the off/on precisions for each sensor. Defaults to np.array([1e-3, 1e-3]). |
initial_precision |
ndarray
|
initial value for the precision parameters, can be specified either as a (2, 1) np.ndarray or as a (2, nof_sensors) np.ndarray: the former specification will result in the same prior specification for the off/on precisions for each sensor. Defaults to np.array([1.0, 1.0]). |
precision_index |
ndarray
|
index mapping precision parameters onto observations. Parameters 1:n_sensor are mapped onto each sensor for the periods where the sources are OFF; parameters (n_sensor + 1):(2 * n_sensor) are mapped onto each sensor for the periods where the sources are ON. |
precision_parameter |
MixtureParameterMatrix
|
parameter specification for this model, maps the current value of the parameter in the state dict onto the concentration data precisions. |
Source code in src/pyelq/component/error_model.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
|
initialise(sensor_object, meteorology=None, gas_species=None)
Set up the error model using sensor properties.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
SensorGroup
|
sensor data. |
required |
meteorology
|
MeteorologyGroup
|
meteorology data. Defaults to None. |
None
|
gas_species
|
GasSpecies
|
gas species information. Defaults to None. |
None
|
Source code in src/pyelq/component/error_model.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
plot_iterations(plot, sensor_object, burn_in_value)
Plot the estimated error model parameters against iterations of the MCMC chain.
Works by simply creating a separate plot for each of the two categories of precision parameter (when the sources are on/off). Creates a BySensor() object for each of the off/on precision cases, and then makes a call to its plot function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
Union[SensorGroup, Sensor]
|
Sensor object associated with the error_model |
required |
burn_in_value
|
int
|
Burn in value to show in plot. |
required |
plot
|
Plot
|
Plot object to which this figure will be added in the figure dictionary |
required |
Returns:
Name | Type | Description |
---|---|---|
plot |
Plot
|
Plot object to which this figure is added in the figure dictionary with key 'error_model_iterations' |
Source code in src/pyelq/component/error_model.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
plot_distributions(plot, sensor_object, burn_in_value)
Plot the estimated distributions of error model parameters.
Works by simply creating a separate plot for each of the two categories of precision parameter (when the sources are off/on). Creates a BySensor() object for each of the off/on precision cases, and then makes a call to its plot function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
Union[SensorGroup, Sensor]
|
Sensor object associated with the error_model |
required |
burn_in_value
|
int
|
Burn in value to show in plot. |
required |
plot
|
Plot
|
Plot object to which this figure will be added in the figure dictionary |
required |
Returns:
Name | Type | Description |
---|---|---|
plot |
Plot
|
Plot object to which this figure is added in the figure dictionary with key 'error_model_distributions' |
Source code in src/pyelq/component/error_model.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
|