pylunar 0.7.4__py3-none-any.whl → 0.9.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.
pylunar/__init__.py CHANGED
@@ -9,6 +9,7 @@
9
9
  # license that can be found in the LICENSE file.
10
10
 
11
11
  __all__ = [
12
+ "AltitudeDict",
12
13
  "__author__",
13
14
  "__email__",
14
15
  "__version__",
@@ -36,6 +37,7 @@ version_info = __version__.split(".")
36
37
  Use this for version comparison.
37
38
  """
38
39
 
40
+ from .altitude_dict import AltitudeDict
39
41
  from .helpers import mjd_to_date_tuple, tuple_to_string
40
42
  from .lunar_feature import LunarFeature
41
43
  from .lunar_feature_container import LunarFeatureContainer
@@ -0,0 +1,56 @@
1
+ # This file is part of pylunar.
2
+ #
3
+ # Developed by Michael Reuter.
4
+ #
5
+ # See the LICENSE file at the top-level directory of this distribution
6
+ # for details of code ownership.
7
+ #
8
+ # Use of this source code is governed by a 3-clause BSD-style
9
+ # license that can be found in the LICENSE file.
10
+
11
+ """Module for the AltitudeDict class."""
12
+
13
+ from __future__ import annotations
14
+
15
+ import sys
16
+
17
+ if sys.version_info >= (3, 10):
18
+ from importlib.resources import files
19
+ else:
20
+ from importlib_resources import files
21
+
22
+ import sqlite3
23
+
24
+ from .lunar_feature import LunarFeature
25
+ from .moon_info import MoonInfo
26
+
27
+ __all__ = ["AltitudeDict"]
28
+
29
+
30
+ class AltitudeDict(dict[str, float]):
31
+ """Dictionary for the Lunar II features requiring solar altitude."""
32
+
33
+ def load(self, moon_info: MoonInfo) -> None:
34
+ """Provide solar altitude for the Lunar II features.
35
+
36
+ Parameters
37
+ ----------
38
+ moon_info : :class:`pylunar.MoonInfo`
39
+ Instance of the Lunar information class.
40
+ """
41
+ features = ["Byrgius A", "Proclus", "Rupes Recta", "Tycho"]
42
+ dbname = str(files("pylunar.data").joinpath("lunar.db"))
43
+ conn = sqlite3.connect(dbname)
44
+ cur = conn.cursor()
45
+
46
+ sql = f"select * from Features where Name in {str(tuple(features))}"
47
+ cur.execute(sql)
48
+
49
+ feature_list = []
50
+ for row in cur:
51
+ feature_list.append(LunarFeature.from_row(row))
52
+
53
+ for feature in sorted(feature_list, key=lambda x: x.name):
54
+ self[feature.name] = moon_info.solar_altitude(feature)
55
+
56
+ cur.close()
pylunar/lunar_feature.py CHANGED
@@ -108,7 +108,7 @@ class LunarFeature:
108
108
 
109
109
  Returns
110
110
  -------
111
- :class:`.LunarFeature`
111
+ :class:`pylunar.LunarFeature`
112
112
  Class initialized from database row.
113
113
  """
114
114
  return cls(*row[1:])
@@ -15,8 +15,8 @@ from __future__ import annotations
15
15
  __all__ = ["LunarFeatureContainer"]
16
16
 
17
17
  import collections
18
+ from collections.abc import Generator
18
19
  import sys
19
- from typing import Generator
20
20
 
21
21
  if sys.version_info >= (3, 10):
22
22
  from importlib.resources import files
@@ -52,7 +52,7 @@ class LunarFeatureContainer:
52
52
 
53
53
  Yields
54
54
  ------
55
- :class:`.LunarFeature`
55
+ :class:`pylunar.LunarFeature`
56
56
  The current lunar feature.
57
57
  """
58
58
  yield from self.features.values()
@@ -72,7 +72,7 @@ class LunarFeatureContainer:
72
72
 
73
73
  Parameters
74
74
  ----------
75
- moon_info : :class:`.MoonInfo`, optional
75
+ moon_info : :class:`pylunar.MoonInfo`, optional
76
76
  Instance of the Lunar information class.
77
77
  limit : int, optional
78
78
  Restrict the number of features read to the given value.
pylunar/moon_info.py CHANGED
@@ -266,7 +266,7 @@ class MoonInfo:
266
266
 
267
267
  Parameters
268
268
  ----------
269
- feature : :class:`.LunarFeature`
269
+ feature : :class:`pylunar.LunarFeature`
270
270
  The lunar feature instance to check.
271
271
 
272
272
  Returns
@@ -291,7 +291,7 @@ class MoonInfo:
291
291
 
292
292
  Parameters
293
293
  ----------
294
- feature : :class:`.LunarFeature`
294
+ feature : :class:`pylunar.LunarFeature`
295
295
  The lunar feature instance to check.
296
296
 
297
297
  Returns
@@ -556,6 +556,29 @@ class MoonInfo:
556
556
 
557
557
  return sorted_times
558
558
 
559
+ def solar_altitude(self, feature: LunarFeature) -> float:
560
+ """Find the altitude of the sun over a given feature.
561
+
562
+ Sunrise is near zero degrees, noon is near 90 degrees and sunset is
563
+ near 180 degrees.
564
+
565
+ Parameters
566
+ ----------
567
+ feature : :class:`pylunar.LunarFeature`
568
+ Feature to calculate solar altitude.
569
+
570
+ Returns
571
+ -------
572
+ float
573
+ Solar altitude over feature in degrees.
574
+ """
575
+ rad_ss_lat = math.radians(self.subsolar_lat())
576
+ rad_feature_lat = math.radians(feature.latitude)
577
+ term1 = math.sin(rad_ss_lat) * math.sin(rad_feature_lat)
578
+ term2a = math.cos(rad_ss_lat) * math.cos(rad_feature_lat)
579
+ term2b = math.sin(math.radians(self.colong() + feature.longitude))
580
+ return math.degrees(math.asin(term1 + term2a * term2b))
581
+
559
582
  def subsolar_lat(self) -> float:
560
583
  """Latitude in degress on the moon where the sun is overhead.
561
584
 
pylunar/pkg_types.py CHANGED
@@ -19,13 +19,13 @@ if sys.version_info >= (3, 10):
19
19
  else:
20
20
  from typing_extensions import TypeAlias
21
21
 
22
- from typing import List, Tuple, Union
22
+ from typing import Union
23
23
 
24
- DateTimeTuple: TypeAlias = Tuple[int, int, int, int, int, Union[int, float]]
25
- MoonPhases: TypeAlias = List[Tuple[str, Union[DateTimeTuple, str]]]
26
- DmsCoordinate: TypeAlias = Tuple[int, int, int]
27
- Range: TypeAlias = Tuple[float, float]
28
- LunarFeatureList: TypeAlias = Tuple[
24
+ DateTimeTuple: TypeAlias = Union[tuple[int, ...], tuple[int, int, int, int, int, float]]
25
+ MoonPhases: TypeAlias = list[tuple[str, Union[DateTimeTuple, str]]]
26
+ DmsCoordinate: TypeAlias = tuple[int, int, int]
27
+ Range: TypeAlias = tuple[float, float]
28
+ LunarFeatureList: TypeAlias = tuple[
29
29
  str, float, float, float, float, float, str, str, str, str, Union[str, None]
30
30
  ]
31
- FeatureRow: TypeAlias = Tuple[int, str, float, float, float, float, float, str, str, str, str, str]
31
+ FeatureRow: TypeAlias = tuple[int, str, float, float, float, float, float, str, str, str, str, str]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylunar
3
- Version: 0.7.4
3
+ Version: 0.9.0
4
4
  Summary: Information for completing the Astronomical League's Lunar and Lunar II observing programs.
5
5
  Author-email: Michael Reuter <mareuternh@gmail.com>
6
6
  Project-URL: Documentation, http://pylunar.readthedocs.io
@@ -10,34 +10,33 @@ Classifier: Intended Audience :: Developers
10
10
  Classifier: License :: OSI Approved :: BSD License
11
11
  Classifier: Natural Language :: English
12
12
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.8
14
13
  Classifier: Programming Language :: Python :: 3.9
15
14
  Classifier: Programming Language :: Python :: 3.10
16
15
  Classifier: Programming Language :: Python :: 3.11
17
16
  Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
18
  Description-Content-Type: text/x-rst
19
19
  License-File: LICENSE
20
20
  License-File: AUTHORS.rst
21
21
  Requires-Dist: ephem==4.1.6
22
- Requires-Dist: pytz==2024.2
23
22
  Requires-Dist: importlib-resources==6.4.5; python_version < "3.10"
24
23
  Requires-Dist: typing-extensions==4.12.2; python_version < "3.10"
25
- Provides-Extra: build
26
- Requires-Dist: build==1.2.2.post1; extra == "build"
27
- Requires-Dist: twine==5.1.1; extra == "build"
24
+ Requires-Dist: pytz==2024.2
28
25
  Provides-Extra: dev
29
26
  Requires-Dist: pylunar[build,docs,lint,test]; extra == "dev"
27
+ Requires-Dist: scriv==1.5.1; extra == "dev"
30
28
  Requires-Dist: tox==4.23.2; extra == "dev"
31
- Provides-Extra: docs
32
- Requires-Dist: sphinx~=7.1; extra == "docs"
33
- Requires-Dist: sphinx-rtd-theme==2.0.0; extra == "docs"
34
- Provides-Extra: lint
35
- Requires-Dist: pre-commit==3.5.0; python_version < "3.9" and extra == "lint"
36
- Requires-Dist: pre-commit==3.8.0; python_version >= "3.9" and extra == "lint"
37
29
  Provides-Extra: test
30
+ Requires-Dist: coverage[toml]==7.6.9; extra == "test"
38
31
  Requires-Dist: pytest==8.3.3; extra == "test"
39
- Requires-Dist: coverage[toml]==7.6.1; python_version < "3.9" and extra == "test"
40
- Requires-Dist: coverage[toml]==7.6.4; python_version >= "3.9" and extra == "test"
32
+ Provides-Extra: lint
33
+ Requires-Dist: pre-commit==4.0.1; extra == "lint"
34
+ Provides-Extra: build
35
+ Requires-Dist: build==1.2.2.post1; extra == "build"
36
+ Requires-Dist: twine==5.1.1; extra == "build"
37
+ Provides-Extra: docs
38
+ Requires-Dist: sphinx~=7.1; extra == "docs"
39
+ Requires-Dist: sphinx_rtd_theme==3.0.2; extra == "docs"
41
40
 
42
41
  =============================
43
42
  Python Lunar
@@ -0,0 +1,14 @@
1
+ pylunar/__init__.py,sha256=1HgvGZdShUOeanMLMf2vNzdtyvcyAGtjvsytGxbaW00,1116
2
+ pylunar/altitude_dict.py,sha256=x0nsR9ZeyyEl10tvSDXSqfUx_4q2hmwckWzEmpjoE7Q,1558
3
+ pylunar/helpers.py,sha256=UgEFvBGGZxTBaKx16-CjOO8hkqPA_GLRZN8SOgshZFs,1327
4
+ pylunar/lunar_feature.py,sha256=cqNFA7ED-u13H1rayo029GrQfPR3g1cYL-m_Q0zYNuQ,5532
5
+ pylunar/lunar_feature_container.py,sha256=ci5MXPLqKhghh3k9HCti5csvkohfu3GV9LHnI6rLio0,2819
6
+ pylunar/moon_info.py,sha256=n9sMgk8lDM18_D6hbC8AG0I9yQ7-FfwwQccah-LrqCs,20833
7
+ pylunar/pkg_types.py,sha256=o5LVdgosUo9Vy6OS2Hi1HkVcgUStlPV-AnEYimyxlIo,972
8
+ pylunar/data/lunar.db,sha256=y2u5wR_DpHjPYH7fuR-T_q0nbPzN1GuP8_OXorjVr14,28672
9
+ pylunar-0.9.0.dist-info/AUTHORS.rst,sha256=mqGQzrJPFGm44DZxZFs0d080QDWXdtfFlv1i_fdJerg,332
10
+ pylunar-0.9.0.dist-info/LICENSE,sha256=EF_CKfNhkKjEynpn9Msb6HaGNIBN9VfeGyrJFJQ5FYk,1479
11
+ pylunar-0.9.0.dist-info/METADATA,sha256=2QqOXzrBsu6onsZzuMbM3ePz8PJZGaGg-JzO_OzEKIo,3064
12
+ pylunar-0.9.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
13
+ pylunar-0.9.0.dist-info/top_level.txt,sha256=vEQZCgYlUuoq6D4q99Kj5fSpNs2Mo-jW8vKV3dnpI-U,8
14
+ pylunar-0.9.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.2.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,13 +0,0 @@
1
- pylunar/__init__.py,sha256=-I-kK_YCtnOkwYPs2Qe9mCaanU5XJLnXxhHzNbKJpAk,1056
2
- pylunar/helpers.py,sha256=UgEFvBGGZxTBaKx16-CjOO8hkqPA_GLRZN8SOgshZFs,1327
3
- pylunar/lunar_feature.py,sha256=7geZ5cY_JPOS3F2Zyr4qutQi_fHzl-wXTCNEy80ox8w,5525
4
- pylunar/lunar_feature_container.py,sha256=ud8-B_CqQ_0x9FSbkj2eHMPRT5PAwSai6D6tU9dGkQY,2796
5
- pylunar/moon_info.py,sha256=fD6r0zcX2Q990zqHpYZt7I14HJOPEZyOBqmJx6FKjxI,19962
6
- pylunar/pkg_types.py,sha256=DbPCc9_kzRuSOxOfeKaLJdWfykdbzRPnOTY-EN2xrsc,973
7
- pylunar/data/lunar.db,sha256=y2u5wR_DpHjPYH7fuR-T_q0nbPzN1GuP8_OXorjVr14,28672
8
- pylunar-0.7.4.dist-info/AUTHORS.rst,sha256=mqGQzrJPFGm44DZxZFs0d080QDWXdtfFlv1i_fdJerg,332
9
- pylunar-0.7.4.dist-info/LICENSE,sha256=EF_CKfNhkKjEynpn9Msb6HaGNIBN9VfeGyrJFJQ5FYk,1479
10
- pylunar-0.7.4.dist-info/METADATA,sha256=KVJo7EM7lIj-W4x0TLY7BwV5JvSQ4-3Wx1qQMmhFxB0,3233
11
- pylunar-0.7.4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
12
- pylunar-0.7.4.dist-info/top_level.txt,sha256=vEQZCgYlUuoq6D4q99Kj5fSpNs2Mo-jW8vKV3dnpI-U,8
13
- pylunar-0.7.4.dist-info/RECORD,,