compass-lib 0.0.2__py3-none-any.whl → 0.0.3__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.
- compass_lib/__init__.py +113 -3
- compass_lib/commands/__init__.py +2 -0
- compass_lib/commands/convert.py +223 -36
- compass_lib/commands/encrypt.py +33 -7
- compass_lib/commands/geojson.py +118 -0
- compass_lib/commands/main.py +1 -1
- compass_lib/constants.py +84 -36
- compass_lib/enums.py +292 -84
- compass_lib/errors.py +86 -0
- compass_lib/geo_utils.py +47 -0
- compass_lib/geojson.py +1024 -0
- compass_lib/interface.py +332 -0
- compass_lib/io.py +246 -0
- compass_lib/models.py +217 -95
- compass_lib/plot/__init__.py +28 -0
- compass_lib/plot/models.py +265 -0
- compass_lib/plot/parser.py +610 -0
- compass_lib/project/__init__.py +36 -0
- compass_lib/project/format.py +158 -0
- compass_lib/project/models.py +494 -0
- compass_lib/project/parser.py +638 -0
- compass_lib/survey/__init__.py +24 -0
- compass_lib/survey/format.py +284 -0
- compass_lib/survey/models.py +160 -0
- compass_lib/survey/parser.py +842 -0
- compass_lib/validation.py +74 -0
- {compass_lib-0.0.2.dist-info → compass_lib-0.0.3.dist-info}/METADATA +8 -11
- compass_lib-0.0.3.dist-info/RECORD +31 -0
- {compass_lib-0.0.2.dist-info → compass_lib-0.0.3.dist-info}/entry_points.txt +2 -1
- compass_lib/encoding.py +0 -27
- compass_lib/parser.py +0 -435
- compass_lib/utils.py +0 -15
- compass_lib-0.0.2.dist-info/RECORD +0 -16
- {compass_lib-0.0.2.dist-info → compass_lib-0.0.3.dist-info}/WHEEL +0 -0
- {compass_lib-0.0.2.dist-info → compass_lib-0.0.3.dist-info}/licenses/LICENSE +0 -0
compass_lib/geo_utils.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import datetime
|
|
4
|
+
|
|
5
|
+
import pyIGRF14 as pyIGRF
|
|
6
|
+
from pydantic import BaseModel
|
|
7
|
+
from pydantic_extra_types.coordinate import Latitude # noqa: TC002
|
|
8
|
+
from pydantic_extra_types.coordinate import Longitude # noqa: TC002
|
|
9
|
+
|
|
10
|
+
from compass_lib.constants import GEOJSON_COORDINATE_PRECISION
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class GeoLocation(BaseModel):
|
|
14
|
+
latitude: Latitude
|
|
15
|
+
longitude: Longitude
|
|
16
|
+
|
|
17
|
+
def as_tuple(self) -> tuple[float, float]:
|
|
18
|
+
"""Return the latitude and longitude as a tuple.
|
|
19
|
+
# RFC 7946: (longitude, latitude)
|
|
20
|
+
"""
|
|
21
|
+
return (
|
|
22
|
+
round(self.longitude, GEOJSON_COORDINATE_PRECISION),
|
|
23
|
+
round(self.latitude, GEOJSON_COORDINATE_PRECISION),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def decimal_year(dt: datetime.datetime) -> float:
|
|
28
|
+
dt_start = datetime.datetime( # noqa: DTZ001
|
|
29
|
+
year=dt.year, month=1, day=1, hour=0, minute=0, second=0
|
|
30
|
+
)
|
|
31
|
+
dt_end = datetime.datetime( # noqa: DTZ001
|
|
32
|
+
year=dt.year + 1, month=1, day=1, hour=0, minute=0, second=0
|
|
33
|
+
)
|
|
34
|
+
return round(
|
|
35
|
+
dt.year + (dt - dt_start).total_seconds() / (dt_end - dt_start).total_seconds(),
|
|
36
|
+
ndigits=2,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_declination(location: GeoLocation, dt: datetime.datetime) -> float:
|
|
41
|
+
declination, _, _, _, _, _, _ = pyIGRF.igrf_value(
|
|
42
|
+
location.latitude,
|
|
43
|
+
location.longitude,
|
|
44
|
+
alt=0.0,
|
|
45
|
+
year=decimal_year(dt),
|
|
46
|
+
)
|
|
47
|
+
return round(declination, 2)
|