Gaussian Plume
Gaussian Plume module.
The class for the Gaussian Plume dispersion model used in pyELQ.
The Mathematics of Atmospheric Dispersion Modeling, John M. Stockie, DOI. 10.1137/10080991X
GaussianPlume
dataclass
Defines the Gaussian plume dispersion model class.
Attributes:
Name | Type | Description |
---|---|---|
source_map |
Sourcemap
|
SourceMap object used for the dispersion model |
source_half_width |
float
|
Source half width (radius) to be used in the Gaussian plume model (in meters) |
minimum_contribution |
float
|
All elements in the Gaussian plume coupling smaller than this number will be set to 0. Helps to speed up matrix multiplications/matrix inverses, also helps with stability |
Source code in src/pyelq/dispersion_model/gaussian_plume.py
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 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 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 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
|
compute_coupling(sensor_object, meteorology_object, gas_object=None, output_stacked=False, run_interpolation=True)
Top level function to calculate the Gaussian plume coupling.
Calculates the coupling for either a single sensor object or a dictionary of sensor objects.
When both a SensorGroup and a MeteorologyGroup have been passed in, we assume they are consistent and contain exactly the same keys for each item in both groups. Also assuming interpolation has been performed and time axes are consistent, so we set run_interpolation to False
When you input a SensorGroup and a single Meteorology object we convert this object into a dictionary, so we don't have to duplicate the same code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
Union[SensorGroup, Sensor]
|
Single sensor object or SensorGroup object which is used in the calculation of the plume coupling. |
required |
meteorology_object
|
Union[MeteorologyGroup, Meteorology]
|
Meteorology object or MeteorologyGroup object which is used in the calculation of the plume coupling. |
required |
gas_object
|
GasSpecies
|
Optional input, a gas species object to correctly calculate the gas density which is used in the conversion of the units of the Gaussian plume coupling |
None
|
output_stacked
|
bool
|
if true outputs as stacked np.array across sensors if not outputs as dict |
False
|
run_interpolation
|
bool
|
logical indicating whether interpolation of the meteorological data to the sensor/source is required. Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
plume_coupling |
Union[list, ndarray, dict]
|
List of arrays, single array or dictionary containing the plume coupling in hr/kg. When a single source object is passed in as input this function returns a list or an array depending on the sensor type. If a dictionary of sensor objects is passed in as input and output_stacked=False this function returns a dictionary consistent with the input dictionary keys, containing the corresponding plume coupling outputs for each sensor. If a dictionary of sensor objects is passed in as input and output_stacked=True this function returns a np.array containing the stacked coupling matrices. |
Source code in src/pyelq/dispersion_model/gaussian_plume.py
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 |
|
compute_coupling_single_sensor(sensor_object, meteorology, gas_object=None, run_interpolation=True)
Wrapper function to compute the gaussian plume coupling for a single sensor.
Wrapper is used to identify specific cases and calculate the Gaussian plume coupling accordingly.
When the sensor object contains the source_on attribute we set all coupling values to 0 for observations for which source_on is False. Making sure the source_on is column array, aligning with the 1st dimension (nof_observations) of the plume coupling array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
Sensor
|
Single sensor object which is used in the calculation of the plume coupling |
required |
meteorology
|
Meteorology
|
Meteorology object which is used in the calculation of the plume coupling |
required |
gas_object
|
GasSpecies
|
Optionally input a gas species object to correctly calculate the gas density which is used in the conversion of the units of the Gaussian plume coupling |
None
|
run_interpolation
|
bool
|
logical indicating whether interpolation of the meteorological data to the sensor/source is required. Default passed from compute_coupling. |
True
|
Returns:
Name | Type | Description |
---|---|---|
plume_coupling |
Union[list, ndarray]
|
List of arrays or single array containing the plume coupling in 1e6*[hr/kg]. Entries of the list are per source in the case of a satellite sensor, if a single array is returned the coupling for each observation (first dimension) to each source (second dimension) is provided. |
Source code in src/pyelq/dispersion_model/gaussian_plume.py
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 |
|
compute_coupling_array(sensor_x, sensor_y, sensor_z, source_z, wind_speed, theta, wind_turbulence_horizontal, wind_turbulence_vertical, gas_density)
Compute the Gaussian plume coupling.
Most low level function to calculate the Gaussian plume coupling. Assuming input shapes are consistent but no checking is done on this.
Setting sigma_vert to 1e-16 when it is identically zero (distance_x == 0) so we don't get a divide by 0 error all the time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_x
|
ndarray
|
sensor x location relative to source [m]. |
required |
sensor_y
|
ndarray
|
sensor y location relative to source [m]. |
required |
sensor_z
|
ndarray
|
sensor z location relative to ground height [m]. |
required |
source_z
|
ndarray
|
source z location relative to ground height [m]. |
required |
wind_speed
|
ndarray
|
wind speed at source locations in [m/s]. |
required |
theta
|
ndarray
|
Mathematical wind direction at source locations [radians]: calculated as np.arctan2(v_component_wind, u_component_wind). |
required |
wind_turbulence_horizontal
|
ndarray
|
Horizontal wind turbulence [deg]. |
required |
wind_turbulence_vertical
|
ndarray
|
Vertical wind turbulence [deg]. |
required |
gas_density
|
Union[float, ndarray]
|
Gas density to use in coupling calculation [kg/m^3]. |
required |
Returns:
Name | Type | Description |
---|---|---|
plume_coupling |
ndarray
|
Gaussian plume coupling in (1e6)*[hr/kg]: gives concentrations in [ppm] when multiplied by sources in [kg/hr]. |
Source code in src/pyelq/dispersion_model/gaussian_plume.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 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 |
|
calculate_gas_density(meteorology, sensor_object, gas_object)
Helper function to calculate the gas density using ideal gas law.
https://en.wikipedia.org/wiki/Ideal_gas
When a gas object is passed as input we calculate the density according to that gas. We check if the meteorology object has a temperature and/or pressure value and use those accordingly. Otherwise, we use Standard Temperature and Pressure (STP).
We interpolate the temperature and pressure values to the source locations/times such that this is consistent with the other calculations, i.e. we only do spatial interpolation when the sensor is a Satellite object and temporal interpolation otherwise.
When no gas_object is passed in we just set the gas density value to 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
meteorology
|
Meteorology
|
Meteorology object potentially containing temperature or pressure values |
required |
sensor_object
|
Sensor
|
Sensor object containing information about where to interpolate to |
required |
gas_object
|
Union[GasSpecies, None]
|
Gas species object which actually calculates the correct density |
required |
Returns:
Name | Type | Description |
---|---|---|
gas_density |
ndarray
|
Numpy array of shape [1 x nof_sources] (Satellite sensor) or [nof_observations x 1] (otherwise) containing the gas density values to use |
Source code in src/pyelq/dispersion_model/gaussian_plume.py
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 |
|
interpolate_all_meteorology(sensor_object, meteorology, gas_object, run_interpolation)
Function which carries out interpolation of all meteorological information.
The flag run_interpolation determines whether the interpolation should be carried out. If this is set to be False, the meteorological parameters are simply set to the values stored on the meteorology object (i.e. we assume that the meteorology has already been interpolated). This functionality is required to avoid wasted computation in the case of e.g. a reversible jump run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
Sensor
|
object containing locations/times onto which met information should be interpolated. |
required |
meteorology
|
Meteorology
|
object containing meteorology information for interpolation. |
required |
gas_object
|
GasSpecies
|
object containing gas information. |
required |
run_interpolation
|
bool
|
logical indicating whether the meteorology information needs to be interpolated. |
required |
Returns:
Name | Type | Description |
---|---|---|
gas_density |
ndarray
|
numpy array of shape [n_data x 1] of gas densities. |
u_interpolated |
ndarray
|
numpy array of shape [n_data x 1] of northerly wind components. |
v_interpolated |
ndarray
|
numpy array of shape [n_data x 1] of easterly wind components. |
wind_turbulence_horizontal |
ndarray
|
numpy array of shape [n_data x 1] of horizontal turbulence parameters. |
wind_turbulence_vertical |
ndarray
|
numpy array of shape [n_data x 1] of vertical turbulence parameters. |
Source code in src/pyelq/dispersion_model/gaussian_plume.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
interpolate_meteorology(meteorology, variable_name, sensor_object)
Helper function to interpolate meteorology variables.
This function interpolates meteorological variables to times in Sensor or Sources in sourcemap. It also calculates the wind speed and mathematical angle between the u- and v-components which in turn gets used in the calculation of the Gaussian plume.
When the input sensor object is a Satellite type we use spatial interpolation using the interpolation method from the coordinate system class as this takes care of the coordinate systems. When the input sensor object is of another time we use temporal interpolation (assumption is spatial uniformity for all observations over a small(er) area).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
meteorology
|
Meteorology
|
Meteorology object containing u- and v-components of wind including their spatial location |
required |
variable_name
|
str
|
String name of an attribute in the meteorology input object which needs to be interpolated |
required |
sensor_object
|
Sensor
|
Sensor object containing information about where to interpolate to |
required |
Returns:
Name | Type | Description |
---|---|---|
variable_interpolated |
ndarray
|
Interpolated values |
Source code in src/pyelq/dispersion_model/gaussian_plume.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
|
compute_coupling_satellite(sensor_object, wind_speed, theta, wind_turbulence_horizontal, wind_turbulence_vertical, gas_density)
Compute Gaussian plume coupling for satellite sensor.
When the sensor is a Satellite object we calculate the plume coupling per source. Given the large number of sources and the possibility of using the inclusion radius and inclusion indices here and validity of a local ENU system over large distances we loop over each source and calculate the coupling on a per-source basis.
If source_map.inclusion_n_obs is None, we do not do any filtering on observations and we want to include all observations in the plume coupling calculations.
All np.ndarray inputs should have a shape of [1 x nof_sources]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
Sensor
|
Sensor object used in plume coupling calculation |
required |
wind_speed
|
ndarray
|
Wind speed [m/s] |
required |
theta
|
ndarray
|
Mathematical angle between the u- and v-components of wind [radians] |
required |
wind_turbulence_horizontal
|
ndarray
|
Parameter of the wind stability in horizontal direction [deg] |
required |
wind_turbulence_vertical
|
ndarray
|
Parameter of the wind stability in vertical direction [deg] |
required |
gas_density
|
ndarray
|
(np.ndarray): Numpy array containing the gas density values to use [kg/m^3] |
required |
Returns:
Name | Type | Description |
---|---|---|
plume_coupling |
list
|
List of Gaussian plume coupling 1e6*[hr/kg] arrays. The list has a length of nof_sources, each array has the shape [nof_observations x 1] or [inclusion_n_obs x 1] when inclusion_idx is used. |
Source code in src/pyelq/dispersion_model/gaussian_plume.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
|
compute_coupling_ground(sensor_object, wind_speed, theta, wind_turbulence_horizontal, wind_turbulence_vertical, gas_density)
Compute Gaussian plume coupling for a ground sensor.
If the source map is already defined as ENU the reference location is maintained but the sensor is checked to make sure the same reference location is used. Otherwise, when converting to ENU object for the sensor observations we use a single source and altitude 0 as the reference location. This way our ENU system is a system w.r.t. ground level which is required for the current implementation of the actual coupling calculation.
When the sensor is a Beam object we calculate the plume coupling for all sources to all beam knot locations at once in the same ENU coordinate system and finally averaged over the beam knots to get the final output.
In general, we calculate the coupling from all sources to all sensor observation locations. In order to achieve this we input the sensor array as column and source array as row vector in calculating relative x etc., with the beam knot locations being the third dimension. When the sensor is a single point Sensor or a Drone sensor we effectively have one beam knot, making the mean operation at the end effectively a reshape operation which gets rid of the third dimension.
All np.ndarray inputs should have a shape of [nof_observations x 1]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_object
|
Sensor
|
Sensor object used in plume coupling calculation |
required |
wind_speed
|
ndarray
|
Wind speed [m/s] |
required |
theta
|
ndarray
|
Mathematical angle between the u- and v-components of wind [radians] |
required |
wind_turbulence_horizontal
|
ndarray
|
Parameter of the wind stability in horizontal direction [deg] |
required |
wind_turbulence_vertical
|
ndarray
|
Parameter of the wind stability in vertical direction [deg] |
required |
gas_density
|
ndarray
|
(np.ndarray): Numpy array containing the gas density values to use [kg/m^3] |
required |
Returns:
Name | Type | Description |
---|---|---|
plume_coupling |
ndarray
|
Gaussian plume coupling 1e6*[hr/kg] array. The array has the shape [nof_observations x nof_sources] |
Source code in src/pyelq/dispersion_model/gaussian_plume.py
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 |
|
compute_coverage(couplings, threshold_function, coverage_threshold=6, **kwargs)
staticmethod
Returns a logical vector that indicates which sources in the couplings are, or are not, within the coverage.
The 'coverage' is the area inside which all sources are well covered by wind data. E.g. If wind exclusively blows towards East, then all sources to the East of any sensor are 'invisible', and are not within the coverage.
Couplings are returned in hr/kg. Some threshold function defines the largest allowed coupling value. This is used to calculate estimated emission rates in kg/hr. Any emissions which are greater than the value of 'coverage_threshold' are defined as not within the coverage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
couplings
|
ndarray
|
Array of coupling values. Dimensions: n_datapoints x n_sources. |
required |
threshold_function
|
Callable
|
Callable function which returns some single value that defines the maximum or 'threshold' coupling. For example: np.quantile(., q=0.95) |
required |
coverage_threshold
|
float
|
The threshold value of the estimated emission rate which is considered to be within the coverage. Defaults to 6 kg/hr. |
6
|
kwargs
|
dict
|
Keyword arguments required for the threshold function. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
coverage |
Union[ndarray, dict]
|
A logical array specifying which sources are within the coverage. |
Source code in src/pyelq/dispersion_model/gaussian_plume.py
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
|