Skip to content

Commit 76e2787

Browse files
authored
v0.8.2 (#47)
* doc links * comet example * example * info and format * version * readme * hash
1 parent 51ef128 commit 76e2787

18 files changed

+138
-15
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ constellationship.fab
1717
de421.bsp
1818
hip_main.dat
1919
hip8.dat
20+
CometEls.txt
2021

2122
temp*
2223
raw/

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ For a demo of Starplot's zenith plots, check out:
6767
- adjustText
6868

6969
## Coming Soon
70+
- ⚙️ Callables for star sizes/colors/alpha
71+
- ✴️ Custom markers
72+
- 📐 Better DSO outlines
73+
- 🌐 More map projection options
7074
- ⚖️ Better auto font-size adjustment
7175
- ☄️ Better label collision detection and handling
7276

docs/examples.md

+25-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ This page has a few examples to get you familiar with Starplot and how it works.
55
3. [Map of Orion](#map-of-orion)
66
4. [Map of The Pleiades with a Scope Field of View](#map-of-the-pleiades-with-a-scope-field-of-view)
77
5. [Optic plot of The Pleiades with a Refractor Telescope](#optic-plot-of-the-pleiades-with-a-refractor-telescope)
8-
6. [Map plot of The Big Dipper with Custom Markers](#map-of-the-big-dipper-with-custom-markers)
9-
10-
8+
6. [Map of The Big Dipper with Custom Markers](#map-of-the-big-dipper-with-custom-markers)
9+
7. [Map of Hale-Bopp in 1997](#map-of-hale-bopp-in-1997)
1110

1211
## Star Chart for Time/Location
1312
To create a star chart for the sky as seen from [Palomar Mountain](https://en.wikipedia.org/wiki/Palomar_Mountain) in California on July 13, 2023 at 10pm PT:
@@ -57,6 +56,8 @@ The result should look like this:
5756

5857
![map-pleiades-scope](images/example_04.png)
5958

59+
_The solid black circle in this plot is the extent of the Pleiades as defined in [OpenNGC](https://github.com/mattiaverga/OpenNGC)._
60+
6061
!!! tip "Binocular Field of View"
6162

6263
You can also plot a circle showing the field of view of binoculars with the `plot_bino_fov` function:
@@ -89,7 +90,27 @@ Here's a fun one 😃 Let's create a small plot of the big dipper ([Ursa Major](
8990

9091
The result should look like this:
9192

92-
![stars-m45](images/example_06.png)
93+
![map-big-dipper](images/example_06.png)
94+
95+
96+
97+
## Map of Hale-Bopp in 1997
98+
99+
Here's an example that uses [Skyfield](https://rhodesmill.org/skyfield/) to get some data on the comet [Hale-Bopp](https://en.wikipedia.org/wiki/Comet_Hale%E2%80%93Bopp) ☄️ and then uses that data to plot the comet's location in the sky in March and April of 1997 (when the comet was at its brightest in the sky):
100+
101+
!!! note
102+
103+
Skyfield is a required dependency of Starplot (and a very important one!), so if you have Starplot installed, then Skyfield should be installed too.
104+
105+
106+
```python
107+
--8<-- "examples/example_07.py"
108+
```
109+
110+
The result should look like this:
111+
112+
![map-hale-bopp](images/example_07.png)
113+
93114

94115
---
95116

docs/images/example_03.png

0 Bytes
Loading

docs/images/example_04.png

1 Byte
Loading

docs/images/example_05.png

25 Bytes
Loading

docs/images/example_07.png

673 KB
Loading

docs/reference-styling.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ Starplot has a bunch of built-in style extensions (all imported from `starplot.s
178178
options:
179179
show_root_heading: true
180180
show_docstring_attributes: true
181+
separate_signature: true
182+
show_signature_annotations: true
183+
signature_crossrefs: true
181184
members: true
182185

183186

@@ -187,7 +190,6 @@ Starplot has a bunch of built-in style extensions (all imported from `starplot.s
187190
show_root_heading: true
188191
show_docstring_attributes: true
189192

190-
191193
::: starplot.styles.LineStyle
192194
options:
193195
show_root_heading: true

examples/03_map_orion.png

0 Bytes
Loading

examples/04_map_m45_scope.png

1 Byte
Loading

examples/05_optic_m45.png

25 Bytes
Loading

examples/07_map_hale_bopp.png

673 KB
Loading

examples/example_07.py

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
from skyfield.api import load
2+
from skyfield.data import mpc
3+
from skyfield.constants import GM_SUN_Pitjeva_2005_km3_s2 as GM_SUN
4+
5+
from starplot import MapPlot, Projection, SkyObject
6+
from starplot.styles import PlotStyle, extensions
7+
8+
# First, we use Skyfield to get comet data
9+
# Code adapted from: https://rhodesmill.org/skyfield/kepler-orbits.html#comets
10+
with load.open(mpc.COMET_URL) as f:
11+
comets = mpc.load_comets_dataframe(f)
12+
13+
# Keep only the most recent orbit for each comet,
14+
# and index by designation for fast lookup.
15+
comets = (
16+
comets.sort_values("reference")
17+
.groupby("designation", as_index=False)
18+
.last()
19+
.set_index("designation", drop=False)
20+
)
21+
22+
# Find Hale-Bopp
23+
row = comets.loc["C/1995 O1 (Hale-Bopp)"]
24+
25+
ts = load.timescale()
26+
eph = load("de421.bsp")
27+
sun, earth = eph["sun"], eph["earth"]
28+
comet = sun + mpc.comet_orbit(row, ts, GM_SUN)
29+
30+
# Find the RA/DEC of comet for every 4 days starting on March 20, 1997
31+
radecs = []
32+
for day in range(0, 28, 4):
33+
t = ts.utc(1997, 3, 20 + day)
34+
ra, dec, distance = earth.at(t).observe(comet).radec()
35+
radecs.append((t, ra.hours, dec.degrees))
36+
37+
# Now let's plot the data on a map!
38+
style = PlotStyle().extend(
39+
extensions.BLUE_LIGHT,
40+
extensions.MAP,
41+
)
42+
style.legend.location = "lower right"
43+
style.legend.num_columns = 1
44+
45+
p = MapPlot(
46+
projection=Projection.STEREO_NORTH,
47+
# to make plots that are centered around the 0h equinox, you can
48+
# set the max RA to a number over 24 which will determine how
49+
# far past 0h the plot will extend. For example, here we set
50+
# the max RA to 28, so this plot will have an RA extent from 23h to 4h
51+
ra_min=23,
52+
ra_max=28,
53+
dec_min=30,
54+
dec_max=50,
55+
limiting_magnitude=6.2,
56+
style=style,
57+
resolution=2000,
58+
)
59+
60+
for t, ra, dec in radecs:
61+
label = f"{t.utc.month}/{t.utc.day}/{t.utc.year % 100}"
62+
p.plot_object(
63+
SkyObject(
64+
name=label,
65+
legend_label="Hale-Bopp Comet",
66+
ra=ra,
67+
dec=dec,
68+
style={
69+
"marker": {
70+
"size": 12,
71+
"symbol": "o",
72+
"fill": "full",
73+
"color": "#ff6868",
74+
"alpha": 0.8,
75+
"zorder": 4096,
76+
},
77+
"label": {
78+
"font_size": 13,
79+
"font_weight": "bold",
80+
"font_color": "#3c6daa",
81+
"zorder": 4096,
82+
},
83+
},
84+
)
85+
)
86+
87+
# refresh the legend so the Hale-Bopp marker is included
88+
p.refresh_legend()
89+
90+
p.export("07_map_hale_bopp.png", padding=0.2)

examples/examples.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import subprocess
44

5-
for n in range(1, 7):
5+
for n in range(1, 8):
66
subprocess.call(f"python example_{n:02}.py", shell=True)
77
subprocess.call(f"cp {n:02}*.png ../docs/images/example_{n:02}.png", shell=True)
88

scripts/scratchpad.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def test_ex():
658658
from starplot.styles import PlotStyle, extensions, MarkerSymbolEnum
659659

660660
style = PlotStyle().extend(
661-
extensions.MINIMAL,
661+
# extensions.MINIMAL,
662662
extensions.GRAYSCALE,
663663
extensions.MAP,
664664
)
@@ -668,12 +668,12 @@ def test_ex():
668668
# Star sizes are calculated based on their magnitude first,
669669
# but then that result will be multiplied by the star's marker size in the PlotStyle
670670
# so, adjusting the star marker size is a way to make all stars bigger or smaller
671-
style.star.marker.size = 50
671+
style.star.marker.size = 20
672672

673673
p = MapPlot(
674674
projection=Projection.STEREO_NORTH,
675-
ra_min=10.8,
676-
ra_max=14,
675+
ra_min=10,
676+
ra_max=18,
677677
dec_min=48,
678678
dec_max=64,
679679
limiting_magnitude=3.6,
@@ -699,8 +699,8 @@ def test_ex():
699699
# create_map_mercator()
700700
# create_map_stereo_north()
701701
# create_map_stereo_south()
702-
create_map_orion()
703-
create_map_scratch()
702+
# create_map_orion()
703+
# create_map_scratch()
704704
# create_map_sgr()
705705
test_ex()
706706

src/starplot/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Star charts and maps"""
22

3-
__version__ = "0.8.1"
3+
__version__ = "0.8.2"
44

55
from .base import StarPlot # noqa: F401
66
from .zenith import ZenithPlot # noqa: F401

src/starplot/map.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,12 @@ def in_bounds(self, ra: float, dec: float) -> bool:
158158
True if the coordinate is in bounds, otherwise False
159159
160160
"""
161-
return self.ra_min < ra < self.ra_max and self.dec_min < dec < self.dec_max
161+
if self.ra_max < 24:
162+
return self.ra_min < ra < self.ra_max and self.dec_min < dec < self.dec_max
163+
else:
164+
return (
165+
ra > self.ra_min or ra < self.ra_max - 24
166+
) and self.dec_min < dec < self.dec_max
162167

163168
def _latlon_bounds(self):
164169
# convert the RA/DEC bounds to lat/lon bounds

tests/test_map.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_map_plot_wrapping():
226226
resolution=2000,
227227
).export(filename, padding=0.3)
228228

229-
assert dhash(filename) == "1f1e8f4743211117"
229+
assert dhash(filename) == "1f1e0f4743211117"
230230
assert colorhash(filename) == "07000000000"
231231

232232

0 commit comments

Comments
 (0)