pyelq 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyelq/__init__.py +19 -0
- pyelq/component/__init__.py +6 -0
- pyelq/component/background.py +391 -0
- pyelq/component/component.py +79 -0
- pyelq/component/error_model.py +327 -0
- pyelq/component/offset.py +183 -0
- pyelq/component/source_model.py +875 -0
- pyelq/coordinate_system.py +598 -0
- pyelq/data_access/__init__.py +5 -0
- pyelq/data_access/data_access.py +104 -0
- pyelq/dispersion_model/__init__.py +5 -0
- pyelq/dispersion_model/gaussian_plume.py +625 -0
- pyelq/dlm.py +497 -0
- pyelq/gas_species.py +232 -0
- pyelq/meteorology.py +387 -0
- pyelq/model.py +209 -0
- pyelq/plotting/__init__.py +5 -0
- pyelq/plotting/plot.py +1183 -0
- pyelq/preprocessing.py +262 -0
- pyelq/sensor/__init__.py +5 -0
- pyelq/sensor/beam.py +55 -0
- pyelq/sensor/satellite.py +59 -0
- pyelq/sensor/sensor.py +241 -0
- pyelq/source_map.py +115 -0
- pyelq/support_functions/__init__.py +5 -0
- pyelq/support_functions/post_processing.py +377 -0
- pyelq/support_functions/spatio_temporal_interpolation.py +229 -0
- pyelq-1.1.0.dist-info/LICENSE.md +202 -0
- pyelq-1.1.0.dist-info/LICENSES/Apache-2.0.txt +73 -0
- pyelq-1.1.0.dist-info/METADATA +127 -0
- pyelq-1.1.0.dist-info/RECORD +32 -0
- pyelq-1.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2024 Shell Global Solutions International B.V. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
# -*- coding: utf-8 -*-
|
|
6
|
+
"""Data access module.
|
|
7
|
+
|
|
8
|
+
Superclass containing some common attributes and helper functions used in multiple data access classes
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import datetime as dt
|
|
13
|
+
from abc import ABC, abstractmethod
|
|
14
|
+
from dataclasses import dataclass
|
|
15
|
+
from typing import Any, Union
|
|
16
|
+
|
|
17
|
+
import pandas as pd
|
|
18
|
+
|
|
19
|
+
from pyelq.meteorology import Meteorology, MeteorologyGroup
|
|
20
|
+
from pyelq.sensor.sensor import Sensor, SensorGroup
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class DataAccess(ABC):
|
|
25
|
+
"""DataAccess superclass containing some common attributes and functionalities.
|
|
26
|
+
|
|
27
|
+
This superclass is used to show the type of methods to implement when creating a new data access class. The data
|
|
28
|
+
access classes are used to convert raw data into well-defined classes and objects which can be used by the rest of
|
|
29
|
+
the package.
|
|
30
|
+
|
|
31
|
+
Attributes:
|
|
32
|
+
latitude_bounds (tuple, optional): Tuple specifying (latitude_min, latitude_max)
|
|
33
|
+
longitude_bounds (tuple, optional): Tuple specifying (longitude_min, longitude_max)
|
|
34
|
+
date_bounds (tuple, optional): Tuple specifying (datetime_min, datetime_max)
|
|
35
|
+
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
latitude_bounds: tuple = (None, None)
|
|
39
|
+
longitude_bounds: tuple = (None, None)
|
|
40
|
+
date_bounds: tuple = (None, None)
|
|
41
|
+
|
|
42
|
+
@abstractmethod
|
|
43
|
+
def to_sensor(self, *args: Any, **kwargs: dict) -> Union[Sensor, SensorGroup]:
|
|
44
|
+
"""Abstract method to convert raw data into a Sensor or SensorGroup object.
|
|
45
|
+
|
|
46
|
+
This method should be implemented to convert the raw data into a Sensor or SensorGroup object.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
*args (Any): Variable length argument list of any type.
|
|
50
|
+
**kwargs (dict): Arbitrary keyword arguments
|
|
51
|
+
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
@abstractmethod
|
|
55
|
+
def to_meteorology(self, *args: Any, **kwargs: dict) -> Union[Meteorology, MeteorologyGroup]:
|
|
56
|
+
"""Abstract method to convert raw data into a Meteorology or MeteorologyGroup object.
|
|
57
|
+
|
|
58
|
+
This method should be implemented to convert the raw data into a Meteorology or MeteorologyGroup object.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
*args (Any): Variable length argument list of any type.
|
|
62
|
+
**kwargs (dict): Arbitrary keyword arguments
|
|
63
|
+
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
def _query_aoi(self, data: pd.DataFrame) -> pd.DataFrame:
|
|
67
|
+
"""Helper function to perform area of interest query on data.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
data (pd.Dataframe): Pandas dataframe to perform the query on
|
|
71
|
+
|
|
72
|
+
"""
|
|
73
|
+
aoi_query_string = ""
|
|
74
|
+
if self.latitude_bounds[0] is not None:
|
|
75
|
+
aoi_query_string += f" & latitude>={self.latitude_bounds[0]}"
|
|
76
|
+
if self.latitude_bounds[1] is not None:
|
|
77
|
+
aoi_query_string += f" & latitude<={self.latitude_bounds[1]}"
|
|
78
|
+
if self.longitude_bounds[0] is not None:
|
|
79
|
+
aoi_query_string += f" & longitude>={self.longitude_bounds[0]}"
|
|
80
|
+
if self.longitude_bounds[1] is not None:
|
|
81
|
+
aoi_query_string += f" & longitude<={self.longitude_bounds[1]}"
|
|
82
|
+
if len(aoi_query_string) > 0:
|
|
83
|
+
aoi_query_string = aoi_query_string[3:]
|
|
84
|
+
return data.query(aoi_query_string).copy()
|
|
85
|
+
return data
|
|
86
|
+
|
|
87
|
+
def _query_time(self, data: pd.DataFrame) -> pd.DataFrame:
|
|
88
|
+
"""Helper function to perform time query on data.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
data (pd.Dataframe): Pandas dataframe to perform the query on
|
|
92
|
+
|
|
93
|
+
"""
|
|
94
|
+
time_query_string = ""
|
|
95
|
+
if self.date_bounds[0] is not None:
|
|
96
|
+
timestamp_min = dt.datetime.timestamp(self.date_bounds[0])
|
|
97
|
+
time_query_string += f" & timestamp>={timestamp_min}"
|
|
98
|
+
if self.date_bounds[1] is not None:
|
|
99
|
+
timestamp_max = dt.datetime.timestamp(self.date_bounds[1])
|
|
100
|
+
time_query_string += f" & timestamp<={timestamp_max}"
|
|
101
|
+
if len(time_query_string) > 0:
|
|
102
|
+
time_query_string = time_query_string[3:]
|
|
103
|
+
return data.query(time_query_string).copy()
|
|
104
|
+
return data
|