starplot 0.13.0__py2.py3-none-any.whl → 0.15.0__py2.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.
Files changed (74) hide show
  1. starplot/__init__.py +5 -2
  2. starplot/base.py +311 -197
  3. starplot/cli.py +33 -0
  4. starplot/coordinates.py +6 -0
  5. starplot/data/__init__.py +6 -24
  6. starplot/data/bigsky.py +58 -40
  7. starplot/data/constellation_lines.py +827 -0
  8. starplot/data/constellation_stars.py +1501 -0
  9. starplot/data/constellations.py +600 -27
  10. starplot/data/db.py +17 -0
  11. starplot/data/dsos.py +24 -141
  12. starplot/data/stars.py +45 -24
  13. starplot/geod.py +0 -6
  14. starplot/geometry.py +181 -0
  15. starplot/horizon.py +302 -231
  16. starplot/map.py +100 -463
  17. starplot/mixins.py +75 -14
  18. starplot/models/__init__.py +1 -1
  19. starplot/models/base.py +18 -129
  20. starplot/models/constellation.py +55 -32
  21. starplot/models/dso.py +132 -67
  22. starplot/models/moon.py +57 -78
  23. starplot/models/planet.py +44 -69
  24. starplot/models/star.py +91 -60
  25. starplot/models/sun.py +32 -53
  26. starplot/optic.py +21 -18
  27. starplot/plotters/__init__.py +2 -0
  28. starplot/plotters/constellations.py +342 -0
  29. starplot/plotters/dsos.py +49 -68
  30. starplot/plotters/experimental.py +171 -0
  31. starplot/plotters/milkyway.py +39 -0
  32. starplot/plotters/stars.py +126 -122
  33. starplot/profile.py +16 -0
  34. starplot/settings.py +26 -0
  35. starplot/styles/__init__.py +2 -0
  36. starplot/styles/base.py +56 -34
  37. starplot/styles/ext/antique.yml +11 -9
  38. starplot/styles/ext/blue_dark.yml +8 -10
  39. starplot/styles/ext/blue_gold.yml +135 -0
  40. starplot/styles/ext/blue_light.yml +14 -12
  41. starplot/styles/ext/blue_medium.yml +23 -20
  42. starplot/styles/ext/cb_wong.yml +9 -7
  43. starplot/styles/ext/grayscale.yml +4 -3
  44. starplot/styles/ext/grayscale_dark.yml +7 -5
  45. starplot/styles/ext/map.yml +9 -6
  46. starplot/styles/ext/nord.yml +7 -7
  47. starplot/styles/ext/optic.yml +1 -1
  48. starplot/styles/extensions.py +1 -0
  49. starplot/utils.py +19 -0
  50. starplot/warnings.py +21 -0
  51. {starplot-0.13.0.dist-info → starplot-0.15.0.dist-info}/METADATA +19 -18
  52. starplot-0.15.0.dist-info/RECORD +97 -0
  53. starplot-0.15.0.dist-info/entry_points.txt +3 -0
  54. starplot/data/bayer.py +0 -3499
  55. starplot/data/flamsteed.py +0 -2682
  56. starplot/data/library/constellation_borders_inv.gpkg +0 -0
  57. starplot/data/library/constellation_lines_hips.json +0 -709
  58. starplot/data/library/constellation_lines_inv.gpkg +0 -0
  59. starplot/data/library/constellations.gpkg +0 -0
  60. starplot/data/library/constellations_hip.fab +0 -88
  61. starplot/data/library/milkyway.gpkg +0 -0
  62. starplot/data/library/milkyway_inv.gpkg +0 -0
  63. starplot/data/library/ongc.gpkg.zip +0 -0
  64. starplot/data/library/stars.bigsky.mag11.parquet +0 -0
  65. starplot/data/library/stars.hipparcos.parquet +0 -0
  66. starplot/data/messier.py +0 -111
  67. starplot/data/prep/__init__.py +0 -0
  68. starplot/data/prep/constellations.py +0 -108
  69. starplot/data/prep/dsos.py +0 -299
  70. starplot/data/prep/utils.py +0 -16
  71. starplot/models/geometry.py +0 -44
  72. starplot-0.13.0.dist-info/RECORD +0 -101
  73. {starplot-0.13.0.dist-info → starplot-0.15.0.dist-info}/LICENSE +0 -0
  74. {starplot-0.13.0.dist-info → starplot-0.15.0.dist-info}/WHEEL +0 -0
starplot/cli.py ADDED
@@ -0,0 +1,33 @@
1
+ import sys
2
+
3
+ from starplot.styles import fonts
4
+
5
+ COMMANDS = ["setup"]
6
+
7
+
8
+ def setup(options):
9
+ from starplot import settings
10
+ from starplot.data import db, bigsky
11
+
12
+ print("Installing DuckDB spatial extension...")
13
+
14
+ con = db.connect()
15
+ con.load_extension("spatial")
16
+
17
+ fonts.load()
18
+
19
+ print(f"Installed to: {settings.DUCKDB_EXTENSION_PATH}")
20
+
21
+ if "--install-big-sky" in options:
22
+ bigsky.download_if_not_exists()
23
+ print(f"Big Sky Catalog downloaded and installed to: {settings.DOWNLOAD_PATH}")
24
+
25
+
26
+ def main():
27
+ command = sys.argv[1].lower()
28
+
29
+ if command not in COMMANDS:
30
+ print(f"Unrecognized command: {command}")
31
+
32
+ if command == "setup":
33
+ setup(sys.argv[2:])
@@ -0,0 +1,6 @@
1
+ class CoordinateSystem:
2
+ RA_DEC = "radec"
3
+ AZ_ALT = "azalt"
4
+ AXES = "axes"
5
+ PROJECTED = "projected"
6
+ DISPLAY = "display"
starplot/data/__init__.py CHANGED
@@ -1,31 +1,13 @@
1
- import os
2
-
3
- from enum import Enum
4
- from pathlib import Path
5
-
6
1
  from skyfield.api import Loader
7
2
 
8
- HERE = Path(__file__).resolve().parent
9
- DATA_PATH = HERE / "library"
10
-
11
- load = Loader(DATA_PATH)
3
+ from starplot import settings
12
4
 
5
+ load = Loader(settings.DATA_PATH)
13
6
 
14
- def env(name, default):
15
- return os.environ.get(name) or default
16
7
 
8
+ class DataFiles:
9
+ BIG_SKY = settings.DOWNLOAD_PATH / "bigsky.0.4.0.stars.parquet"
17
10
 
18
- class DataFiles(str, Enum):
19
- # Built-In Files
20
- CONSTELLATION_LINES = DATA_PATH / "constellation_lines_inv.gpkg"
21
- CONSTELLATION_LINES_HIP = DATA_PATH / "constellation_lines_hips.json"
22
- CONSTELLATION_BORDERS = DATA_PATH / "constellation_borders_inv.gpkg"
23
- MILKY_WAY = DATA_PATH / "milkyway.gpkg"
24
- HIPPARCOS = DATA_PATH / "stars.hipparcos.parquet"
25
- BIG_SKY_MAG11 = DATA_PATH / "stars.bigsky.mag11.parquet"
26
- ONGC = DATA_PATH / "ongc.gpkg.zip"
27
- CONSTELLATIONS = DATA_PATH / "constellations.gpkg"
11
+ BIG_SKY_MAG11 = settings.DATA_PATH / "bigsky.0.4.0.stars.mag11.parquet"
28
12
 
29
- # Downloaded Files
30
- _DOWNLOAD_PATH = Path(env("STARPLOT_DOWNLOAD_PATH", str(DATA_PATH)))
31
- BIG_SKY = _DOWNLOAD_PATH / "stars.bigsky.parquet"
13
+ DATABASE = settings.DATA_PATH / "sky.db"
starplot/data/bigsky.py CHANGED
@@ -1,56 +1,58 @@
1
1
  import os
2
+ from pathlib import Path
2
3
 
3
4
  import pandas as pd
4
5
 
5
- from starplot.data import DATA_PATH, DataFiles, utils
6
+ from starplot import settings
7
+ from starplot.data import DataFiles, utils
6
8
 
7
9
 
8
- BIG_SKY_VERSION = "0.1.0"
10
+ BIG_SKY_VERSION = "0.4.0"
11
+ BIG_SKY_FILENAME = f"bigsky.{BIG_SKY_VERSION}.stars.csv.gz"
12
+ BIG_SKY_PQ_FILENAME = f"bigsky.{BIG_SKY_VERSION}.stars.parquet"
9
13
 
10
- BIG_SKY_FILENAME = "bigsky.stars.csv.gz"
14
+ BIG_SKY_MAG11_FILENAME = f"bigsky.{BIG_SKY_VERSION}.stars.mag11.csv.gz"
15
+ BIG_SKY_MAG11_PQ_FILENAME = f"bigsky.{BIG_SKY_VERSION}.stars.mag11.parquet"
11
16
 
12
- BIG_SKY_URL = f"https://github.com/steveberardi/bigsky/releases/download/v{BIG_SKY_VERSION}/{BIG_SKY_FILENAME}"
13
17
 
14
- DOWNLOADED_PATH = DATA_PATH / BIG_SKY_FILENAME
15
-
16
- DIGITS = 4
17
-
18
- BIG_SKY_ASSETS = {
19
- DataFiles.BIG_SKY: "bigsky.stars.csv.gz",
20
- DataFiles.BIG_SKY_MAG11: "bigsky.stars.mag11.csv.gz",
21
- }
22
-
23
-
24
- def url(filename: str, version: str):
18
+ def get_url(version: str = BIG_SKY_VERSION, filename: str = BIG_SKY_FILENAME):
25
19
  return f"https://github.com/steveberardi/bigsky/releases/download/v{version}/{filename}"
26
20
 
27
21
 
28
22
  def download(
29
- filename: str = BIG_SKY_FILENAME,
30
- version: str = BIG_SKY_VERSION,
31
- download_path: str = None,
32
- digits: int = 4,
23
+ url: str = None,
24
+ download_path: str = settings.DOWNLOAD_PATH,
25
+ download_filename: str = BIG_SKY_FILENAME,
26
+ build_file: str = DataFiles.BIG_SKY,
33
27
  ):
34
- download_path = download_path or str(DATA_PATH / filename)
28
+ url = url or get_url()
29
+ download_path = Path(download_path)
30
+
31
+ if not os.path.exists(download_path):
32
+ os.makedirs(download_path)
33
+
34
+ full_download_path = download_path / download_filename
35
35
  utils.download(
36
- url(filename, version),
37
- download_path,
36
+ url,
37
+ full_download_path,
38
38
  "Big Sky Star Catalog",
39
39
  )
40
40
  to_parquet(
41
- download_path,
42
- DataFiles.BIG_SKY,
43
- digits,
41
+ full_download_path,
42
+ build_file,
44
43
  )
45
44
 
46
45
 
47
- def to_parquet(source_path: str, destination_path: str, digits: int = DIGITS):
46
+ def to_parquet(source_path: str, destination_path: str):
47
+ import pyarrow as pa
48
+ import pyarrow.parquet as pq
49
+
48
50
  print("Preparing Big Sky Catalog for Starplot...")
49
51
 
50
52
  df = pd.read_csv(
51
53
  source_path,
52
54
  header=0,
53
- names=[
55
+ usecols=[
54
56
  "tyc_id",
55
57
  "hip_id",
56
58
  "ccdm",
@@ -61,14 +63,11 @@ def to_parquet(source_path: str, destination_path: str, digits: int = DIGITS):
61
63
  "ra_mas_per_year",
62
64
  "dec_mas_per_year",
63
65
  "parallax_mas",
66
+ "constellation",
64
67
  ],
65
68
  compression="gzip",
66
69
  )
67
70
 
68
- df["ra_hours"] = df.apply(
69
- lambda row: round(row.ra_degrees_j2000 / 15, digits), axis=1
70
- )
71
-
72
71
  df = df.assign(epoch_year=2000)
73
72
 
74
73
  df = df.rename(
@@ -79,19 +78,38 @@ def to_parquet(source_path: str, destination_path: str, digits: int = DIGITS):
79
78
  }
80
79
  )
81
80
 
82
- df.to_parquet(destination_path, compression="gzip")
83
-
84
- print(f"Done! {destination_path.value}")
81
+ df = df.sort_values(["magnitude"])
85
82
 
83
+ table = pa.Table.from_pandas(df)
84
+ table = table.drop_columns("__index_level_0__")
86
85
 
87
- def load(path):
88
- if not exists(path):
89
- download(filename=BIG_SKY_ASSETS.get(path))
90
-
91
- df = pd.read_parquet(path)
86
+ pq.write_table(
87
+ table,
88
+ destination_path,
89
+ compression="none",
90
+ sorting_columns=[
91
+ pq.SortingColumn(df.columns.get_loc("magnitude")),
92
+ ],
93
+ )
92
94
 
93
- return df.set_index("tyc_id")
95
+ print(f"Done! {destination_path}")
94
96
 
95
97
 
96
98
  def exists(path) -> bool:
97
99
  return os.path.isfile(path)
100
+
101
+
102
+ def download_if_not_exists(
103
+ filename: str = DataFiles.BIG_SKY,
104
+ url: str = None,
105
+ download_path: str = settings.DOWNLOAD_PATH,
106
+ download_filename: str = BIG_SKY_FILENAME,
107
+ build_file: str = DataFiles.BIG_SKY,
108
+ ):
109
+ if not exists(filename):
110
+ download(
111
+ url=url,
112
+ download_path=download_path,
113
+ download_filename=download_filename,
114
+ build_file=build_file,
115
+ )