starplot 0.20.5__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 (98) hide show
  1. starplot/__init__.py +59 -0
  2. starplot/callables.py +176 -0
  3. starplot/cli.py +29 -0
  4. starplot/config.py +80 -0
  5. starplot/coordinates.py +7 -0
  6. starplot/data/__init__.py +22 -0
  7. starplot/data/catalogs.py +356 -0
  8. starplot/data/constellations.py +71 -0
  9. starplot/data/db.py +33 -0
  10. starplot/data/dsos.py +85 -0
  11. starplot/data/ecliptic.py +201 -0
  12. starplot/data/library/constellation_names.parquet +0 -0
  13. starplot/data/library/dso_names.parquet +0 -0
  14. starplot/data/library/readme.md +1 -0
  15. starplot/data/library/star_designations.parquet +0 -0
  16. starplot/data/stars.py +79 -0
  17. starplot/data/translations.py +408 -0
  18. starplot/data/utils.py +35 -0
  19. starplot/geometry.py +319 -0
  20. starplot/mixins.py +360 -0
  21. starplot/models/__init__.py +21 -0
  22. starplot/models/base.py +77 -0
  23. starplot/models/comet.py +302 -0
  24. starplot/models/constellation.py +151 -0
  25. starplot/models/dso.py +317 -0
  26. starplot/models/milky_way.py +30 -0
  27. starplot/models/moon.py +130 -0
  28. starplot/models/objects.py +29 -0
  29. starplot/models/observer.py +125 -0
  30. starplot/models/optics.py +342 -0
  31. starplot/models/planet.py +137 -0
  32. starplot/models/satellite.py +138 -0
  33. starplot/models/star.py +253 -0
  34. starplot/models/sun.py +62 -0
  35. starplot/plots/__init__.py +7 -0
  36. starplot/plots/base.py +1023 -0
  37. starplot/plots/galaxy.py +372 -0
  38. starplot/plots/horizon.py +543 -0
  39. starplot/plots/map.py +515 -0
  40. starplot/plots/optic.py +469 -0
  41. starplot/plots/zenith.py +217 -0
  42. starplot/plotters/__init__.py +9 -0
  43. starplot/plotters/arrow.py +174 -0
  44. starplot/plotters/constellations.py +298 -0
  45. starplot/plotters/debug.py +21 -0
  46. starplot/plotters/dsos.py +294 -0
  47. starplot/plotters/experimental.py +722 -0
  48. starplot/plotters/gradients.py +153 -0
  49. starplot/plotters/legend.py +253 -0
  50. starplot/plotters/milkyway.py +51 -0
  51. starplot/plotters/stars.py +319 -0
  52. starplot/plotters/text.py +802 -0
  53. starplot/profile.py +16 -0
  54. starplot/projections.py +184 -0
  55. starplot/styles/__init__.py +6 -0
  56. starplot/styles/base.py +1344 -0
  57. starplot/styles/ext/antique.yml +175 -0
  58. starplot/styles/ext/blue_dark.yml +163 -0
  59. starplot/styles/ext/blue_gold.yml +147 -0
  60. starplot/styles/ext/blue_light.yml +123 -0
  61. starplot/styles/ext/blue_medium.yml +142 -0
  62. starplot/styles/ext/blue_night.yml +185 -0
  63. starplot/styles/ext/cb_wong.yml +124 -0
  64. starplot/styles/ext/color_print.yml +111 -0
  65. starplot/styles/ext/gradient_presets.yml +158 -0
  66. starplot/styles/ext/grayscale.yml +94 -0
  67. starplot/styles/ext/grayscale_dark.yml +136 -0
  68. starplot/styles/ext/map.yml +12 -0
  69. starplot/styles/ext/nord.yml +158 -0
  70. starplot/styles/ext/optic.yml +20 -0
  71. starplot/styles/ext/publication.yml +8 -0
  72. starplot/styles/extensions.py +129 -0
  73. starplot/styles/fonts-library/gfs-didot/DESCRIPTION.en_us.html +9 -0
  74. starplot/styles/fonts-library/gfs-didot/GFSDidot-Regular.ttf +0 -0
  75. starplot/styles/fonts-library/gfs-didot/METADATA.pb +16 -0
  76. starplot/styles/fonts-library/gfs-didot/OFL.txt +94 -0
  77. starplot/styles/fonts-library/inter/Inter-Bold.ttf +0 -0
  78. starplot/styles/fonts-library/inter/Inter-BoldItalic.ttf +0 -0
  79. starplot/styles/fonts-library/inter/Inter-ExtraBold.ttf +0 -0
  80. starplot/styles/fonts-library/inter/Inter-ExtraLight.ttf +0 -0
  81. starplot/styles/fonts-library/inter/Inter-ExtraLightItalic.ttf +0 -0
  82. starplot/styles/fonts-library/inter/Inter-Italic.ttf +0 -0
  83. starplot/styles/fonts-library/inter/Inter-Light.ttf +0 -0
  84. starplot/styles/fonts-library/inter/Inter-LightItalic.ttf +0 -0
  85. starplot/styles/fonts-library/inter/Inter-Regular.ttf +0 -0
  86. starplot/styles/fonts-library/inter/Inter-SemiBold.ttf +0 -0
  87. starplot/styles/fonts-library/inter/Inter-SemiBoldItalic.ttf +0 -0
  88. starplot/styles/fonts-library/inter/LICENSE.txt +92 -0
  89. starplot/styles/fonts.py +15 -0
  90. starplot/styles/helpers.py +93 -0
  91. starplot/styles/markers.py +308 -0
  92. starplot/utils.py +169 -0
  93. starplot/warnings.py +21 -0
  94. starplot-0.20.5.dist-info/METADATA +146 -0
  95. starplot-0.20.5.dist-info/RECORD +98 -0
  96. starplot-0.20.5.dist-info/WHEEL +4 -0
  97. starplot-0.20.5.dist-info/entry_points.txt +3 -0
  98. starplot-0.20.5.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,722 @@
1
+ from shapely import MultiPolygon
2
+ from shapely import (
3
+ MultiPoint,
4
+ intersection,
5
+ delaunay_triangles,
6
+ distance,
7
+ )
8
+
9
+ from starplot.data import DataFiles
10
+ from starplot.styles import PathStyle
11
+
12
+
13
+ CONSTELLATION_HIP_IDS = {
14
+ "and": {
15
+ 2912,
16
+ 1473,
17
+ 7607,
18
+ 677,
19
+ 116805,
20
+ 5447,
21
+ 9640,
22
+ 3881,
23
+ 116584,
24
+ 3693,
25
+ 4463,
26
+ 3031,
27
+ 3092,
28
+ 4436,
29
+ 116631,
30
+ 5434,
31
+ 113726,
32
+ },
33
+ "ant": {46515, 51172, 53502},
34
+ "aps": {81065, 72370, 81852, 80047},
35
+ "aql": {
36
+ 97804,
37
+ 95501,
38
+ 93805,
39
+ 97649,
40
+ 99473,
41
+ 93747,
42
+ 98036,
43
+ 96468,
44
+ 93429,
45
+ 93244,
46
+ 97278,
47
+ },
48
+ "aqr": {
49
+ 112961,
50
+ 114724,
51
+ 114341,
52
+ 106278,
53
+ 111497,
54
+ 112716,
55
+ 115438,
56
+ 110960,
57
+ 110672,
58
+ 109074,
59
+ 109139,
60
+ 110003,
61
+ 113136,
62
+ 115033,
63
+ 102618,
64
+ 110395,
65
+ },
66
+ "ara": {85792, 83081, 88714, 85258, 83153, 85267, 82363, 85727},
67
+ "ari": {8832, 13209, 9884, 8903},
68
+ "aur": {24608, 28358, 23015, 28360, 25428, 23767, 23416, 28380, 23453},
69
+ "boo": {
70
+ 70497,
71
+ 71075,
72
+ 69732,
73
+ 69673,
74
+ 74666,
75
+ 72105,
76
+ 69483,
77
+ 71053,
78
+ 67275,
79
+ 73555,
80
+ 71795,
81
+ 67927,
82
+ },
83
+ "cae": {21770, 23595, 21060, 21861},
84
+ "cam": {23040, 23522, 16228, 17959, 29997, 17884, 33694, 22783},
85
+ "cap": {100064, 102978, 106723, 107556, 106985, 105881, 104139, 102485, 100345},
86
+ "car": {
87
+ 54463,
88
+ 42913,
89
+ 52419,
90
+ 50371,
91
+ 53253,
92
+ 30438,
93
+ 38827,
94
+ 41037,
95
+ 39953,
96
+ 50099,
97
+ 45556,
98
+ 45238,
99
+ 51576,
100
+ 54301,
101
+ 54751,
102
+ },
103
+ "cas": {746, 3179, 4427, 8886, 6686},
104
+ "cen": {
105
+ 55425,
106
+ 71683,
107
+ 67464,
108
+ 65936,
109
+ 68245,
110
+ 60823,
111
+ 68002,
112
+ 56243,
113
+ 71352,
114
+ 59449,
115
+ 68282,
116
+ 59196,
117
+ 68933,
118
+ 70090,
119
+ 65109,
120
+ 61789,
121
+ 68702,
122
+ 66657,
123
+ 61932,
124
+ 73334,
125
+ 68862,
126
+ },
127
+ "cep": {
128
+ 109857,
129
+ 101093,
130
+ 105199,
131
+ 106032,
132
+ 110991,
133
+ 112724,
134
+ 109492,
135
+ 102422,
136
+ 116727,
137
+ 107259,
138
+ },
139
+ "cet": {
140
+ 13954,
141
+ 12706,
142
+ 12387,
143
+ 8645,
144
+ 8102,
145
+ 6537,
146
+ 10826,
147
+ 5364,
148
+ 14135,
149
+ 1562,
150
+ 3419,
151
+ 11484,
152
+ 12828,
153
+ },
154
+ "cha": {60000, 58484, 52633, 40702, 51839},
155
+ "cir": {74824, 75323, 71908},
156
+ "cma": {33152, 35904, 33347, 31592, 33160, 33579, 34444, 30324, 34045, 32349},
157
+ "cmi": {36188, 37279},
158
+ "cnc": {44066, 40526, 42806, 42911, 43103},
159
+ "col": {25859, 30277, 28199, 28328, 26634, 27628},
160
+ "com": {64241, 64394, 60742},
161
+ "cra": {93825, 94114, 90982, 94160, 94005},
162
+ "crb": {77512, 76267, 75695, 78159, 76952, 78493, 76127},
163
+ "crt": {57283, 55687, 56633, 53740, 58188, 55282, 55705, 54682},
164
+ "cru": {62434, 59747, 61084, 60718},
165
+ "crv": {60965, 61359, 59316, 59803, 59199},
166
+ "cvn": {63125, 61317},
167
+ "cyg": {100453, 99848, 95947, 97165, 95853, 102098, 103413, 102488, 94779, 104732},
168
+ "del": {102532, 101958, 101769, 102281, 101421},
169
+ "dor": {21281, 23693, 27890, 26069, 19893, 27100},
170
+ "dra": {
171
+ 61281,
172
+ 75458,
173
+ 87585,
174
+ 97433,
175
+ 85829,
176
+ 85670,
177
+ 94376,
178
+ 80331,
179
+ 89937,
180
+ 56211,
181
+ 68756,
182
+ 89908,
183
+ 83895,
184
+ 87833,
185
+ 78527,
186
+ },
187
+ "equ": {104521, 104858, 104987},
188
+ "eri": {
189
+ 21248,
190
+ 19587,
191
+ 13701,
192
+ 11407,
193
+ 21393,
194
+ 15510,
195
+ 13847,
196
+ 16537,
197
+ 7588,
198
+ 18216,
199
+ 12843,
200
+ 9007,
201
+ 20535,
202
+ 17593,
203
+ 14146,
204
+ 23875,
205
+ 21444,
206
+ 12486,
207
+ 20042,
208
+ 17874,
209
+ 22109,
210
+ 17378,
211
+ 12770,
212
+ 16611,
213
+ 16870,
214
+ 18543,
215
+ 18673,
216
+ 15474,
217
+ 17651,
218
+ 12413,
219
+ },
220
+ "for": {13147, 9677, 14879},
221
+ "gem": {
222
+ 31681,
223
+ 36962,
224
+ 37826,
225
+ 30883,
226
+ 34693,
227
+ 30343,
228
+ 34088,
229
+ 32362,
230
+ 37740,
231
+ 36046,
232
+ 29655,
233
+ 36850,
234
+ 35350,
235
+ 32246,
236
+ 28734,
237
+ 33018,
238
+ 35550,
239
+ },
240
+ "gru": {113638, 112623, 109268, 108085, 110997, 109111, 112122},
241
+ "her": {
242
+ 87808,
243
+ 83207,
244
+ 86414,
245
+ 84379,
246
+ 84380,
247
+ 81693,
248
+ 81833,
249
+ 80170,
250
+ 87933,
251
+ 80816,
252
+ 85112,
253
+ 85693,
254
+ 86974,
255
+ 77760,
256
+ 80463,
257
+ 88794,
258
+ 81126,
259
+ 81008,
260
+ 79992,
261
+ 84345,
262
+ 79101,
263
+ },
264
+ "hor": {14240, 12225, 19747, 12484, 12653, 13884},
265
+ "hya": {
266
+ 56343,
267
+ 45336,
268
+ 54682,
269
+ 68895,
270
+ 42402,
271
+ 43813,
272
+ 42799,
273
+ 49841,
274
+ 46390,
275
+ 64962,
276
+ 47431,
277
+ 42313,
278
+ 52943,
279
+ 57936,
280
+ 43234,
281
+ 48356,
282
+ 43109,
283
+ 53740,
284
+ 49402,
285
+ 72571,
286
+ 51069,
287
+ },
288
+ "hyi": {11001, 9236, 2021, 17678},
289
+ "ind": {105319, 101772, 108431, 103227, 102333},
290
+ "lac": {111104, 111169, 111944, 110538, 111022, 110351, 110609, 109937, 109754},
291
+ "leo": {
292
+ 57632,
293
+ 46146,
294
+ 47908,
295
+ 49669,
296
+ 48455,
297
+ 55434,
298
+ 54879,
299
+ 49583,
300
+ 50583,
301
+ 54872,
302
+ 55642,
303
+ 46750,
304
+ 50335,
305
+ },
306
+ "lep": {
307
+ 27072,
308
+ 25985,
309
+ 23685,
310
+ 25606,
311
+ 27654,
312
+ 28103,
313
+ 24327,
314
+ 24845,
315
+ 28910,
316
+ 24305,
317
+ 27288,
318
+ },
319
+ "lib": {74785, 76333, 72622, 73714, 76470, 76600},
320
+ "lmi": {51233, 46952, 53229, 51056, 49593},
321
+ "lup": {75264, 77634, 75141, 76297, 75177, 78384, 71860, 73273, 74395},
322
+ "lyn": {45860, 33449, 30060, 36145, 41075, 45688, 44700, 44248},
323
+ "lyr": {91971, 92420, 93194, 91919, 92791, 91262},
324
+ "men": {23467, 29271},
325
+ "mic": {103738, 105140, 105382, 102831},
326
+ "mon": {32578, 37447, 31978, 31216, 34769, 30419, 30867, 29651, 39863},
327
+ "mus": {61199, 61585, 62322, 57363, 59929, 63613},
328
+ "nor": {80000, 78914, 80582, 78639},
329
+ "oct": {107089, 112405, 70638},
330
+ "oph": {
331
+ 81377,
332
+ 87108,
333
+ 79593,
334
+ 79882,
335
+ 84970,
336
+ 84012,
337
+ 85423,
338
+ 86032,
339
+ 88048,
340
+ 80473,
341
+ 80883,
342
+ 80628,
343
+ 86742,
344
+ 80343,
345
+ 83000,
346
+ 80569,
347
+ 80894,
348
+ },
349
+ "ori": {
350
+ 27913,
351
+ 22797,
352
+ 22549,
353
+ 28716,
354
+ 22957,
355
+ 22449,
356
+ 23607,
357
+ 22845,
358
+ 25281,
359
+ 28614,
360
+ 26311,
361
+ 25930,
362
+ 23123,
363
+ 27989,
364
+ 26207,
365
+ 27366,
366
+ 26727,
367
+ 22509,
368
+ 29038,
369
+ 29426,
370
+ 24436,
371
+ 25336,
372
+ },
373
+ "pav": {
374
+ 92609,
375
+ 105858,
376
+ 88866,
377
+ 99240,
378
+ 100751,
379
+ 91792,
380
+ 86929,
381
+ 90098,
382
+ 93015,
383
+ 102395,
384
+ 98495,
385
+ },
386
+ "peg": {
387
+ 109410,
388
+ 677,
389
+ 113963,
390
+ 112748,
391
+ 109176,
392
+ 1067,
393
+ 107315,
394
+ 109427,
395
+ 112440,
396
+ 113881,
397
+ 107354,
398
+ 112029,
399
+ 112158,
400
+ },
401
+ "per": {
402
+ 8068,
403
+ 19343,
404
+ 14354,
405
+ 17448,
406
+ 14632,
407
+ 18614,
408
+ 18246,
409
+ 14668,
410
+ 17358,
411
+ 13268,
412
+ 13531,
413
+ 19167,
414
+ 18532,
415
+ 19812,
416
+ 20070,
417
+ 12777,
418
+ 14576,
419
+ 15863,
420
+ 14328,
421
+ },
422
+ "phe": {2081, 5348, 7083, 5165, 6867, 765},
423
+ "pic": {27321, 27530, 32607},
424
+ "psa": {109285, 111954, 112948, 111188, 107380, 113368, 107608, 113246},
425
+ "psc": {
426
+ 116928,
427
+ 116771,
428
+ 8198,
429
+ 4906,
430
+ 3786,
431
+ 7884,
432
+ 5742,
433
+ 9487,
434
+ 6193,
435
+ 5586,
436
+ 115830,
437
+ 7097,
438
+ 115738,
439
+ 114971,
440
+ 118268,
441
+ },
442
+ "pup": {
443
+ 35264,
444
+ 39429,
445
+ 31685,
446
+ 30438,
447
+ 39757,
448
+ 37229,
449
+ 37677,
450
+ 39953,
451
+ 36917,
452
+ 38070,
453
+ 38170,
454
+ },
455
+ "pyx": {43409, 42515, 42828, 39429},
456
+ "ret": {17440, 19921, 19780, 18597},
457
+ "scl": {4577, 117452, 115102, 116231},
458
+ "sco": {
459
+ 85696,
460
+ 78401,
461
+ 87073,
462
+ 78820,
463
+ 85927,
464
+ 82729,
465
+ 86670,
466
+ 84143,
467
+ 80112,
468
+ 79374,
469
+ 81266,
470
+ 82514,
471
+ 86228,
472
+ 78104,
473
+ 78265,
474
+ 80763,
475
+ 82396,
476
+ 87261,
477
+ },
478
+ "sct": {90595, 91117, 91726, 92175},
479
+ "ser1": {
480
+ 77450,
481
+ 77516,
482
+ 77070,
483
+ 77233,
484
+ 76852,
485
+ 76276,
486
+ 77622,
487
+ 78072,
488
+ },
489
+ "ser2": {86263, 89962, 88048, 92946},
490
+ "sex": {51437, 49641, 51362, 48437},
491
+ "sge": {98337, 96837, 96757, 97365},
492
+ "sgr": {
493
+ 90496,
494
+ 95168,
495
+ 93506,
496
+ 93864,
497
+ 90185,
498
+ 92041,
499
+ 89931,
500
+ 89642,
501
+ 93085,
502
+ 93683,
503
+ 92855,
504
+ 89341,
505
+ 88635,
506
+ 94141,
507
+ },
508
+ "tau": {
509
+ 18724,
510
+ 20455,
511
+ 20205,
512
+ 21421,
513
+ 26451,
514
+ 16083,
515
+ 25428,
516
+ 16852,
517
+ 20889,
518
+ 18907,
519
+ 15900,
520
+ 20894,
521
+ },
522
+ "tel": {89112, 90422, 90568},
523
+ "tra": {77952, 82273, 74946, 76440},
524
+ "tri": {10064, 8796, 10670},
525
+ "tuc": {110130, 118322, 2484, 114996, 110838, 1599},
526
+ "uma": {
527
+ 46853,
528
+ 54539,
529
+ 46733,
530
+ 58001,
531
+ 53910,
532
+ 55203,
533
+ 54061,
534
+ 55219,
535
+ 44471,
536
+ 57399,
537
+ 48319,
538
+ 50372,
539
+ 44127,
540
+ 65378,
541
+ 67301,
542
+ 41704,
543
+ 62956,
544
+ 50801,
545
+ 59774,
546
+ },
547
+ "umi": {82080, 79822, 11767, 72607, 75097, 85822, 77055},
548
+ "vel": {42913, 48774, 50191, 44816, 39953, 45941, 52727, 46651},
549
+ "vir": {
550
+ 60129,
551
+ 65474,
552
+ 58948,
553
+ 57380,
554
+ 69701,
555
+ 68520,
556
+ 66249,
557
+ 64238,
558
+ 63090,
559
+ 61941,
560
+ 71957,
561
+ 63608,
562
+ 72220,
563
+ 57757,
564
+ },
565
+ "vol": {41312, 34481, 39794, 35228, 44382},
566
+ "vul": {95771, 97886},
567
+ }
568
+
569
+
570
+ class ExperimentalPlotterMixin:
571
+ def _constellation_borders(self):
572
+ from shapely import LineString, MultiLineString
573
+ from shapely.ops import unary_union
574
+ import geopandas as gpd
575
+
576
+ constellation_borders = gpd.read_file(
577
+ DataFiles.CONSTELLATIONS,
578
+ engine="pyogrio",
579
+ use_arrow=True,
580
+ bbox=self._extent_mask(),
581
+ )
582
+
583
+ if constellation_borders.empty:
584
+ return
585
+
586
+ geometries = []
587
+
588
+ for i, constellation in constellation_borders.iterrows():
589
+ geometry_types = constellation.geometry.geom_type
590
+
591
+ # equinox = LineString([[0, 90], [0, -90]])
592
+ """
593
+ Problems:
594
+ - Need to handle multipolygon borders too (SER)
595
+ - Shapely's union doesn't handle geodesy (e.g. TRI + AND)
596
+ - ^^ TRI is plotted with ra < 360, but AND has ra > 360
597
+ - ^^ idea: create union first and then remove duplicate lines?
598
+
599
+ TODO: create new static data file of constellation border lines
600
+ """
601
+
602
+ if "Polygon" in geometry_types and "MultiPolygon" not in geometry_types:
603
+ polygons = [constellation.geometry]
604
+
605
+ elif "MultiPolygon" in geometry_types:
606
+ polygons = constellation.geometry.geoms
607
+
608
+ for p in polygons:
609
+ coords = list(zip(*p.exterior.coords.xy))
610
+ # coords = [(ra * -1, dec) for ra, dec in coords]
611
+
612
+ new_coords = []
613
+
614
+ for i, c in enumerate(coords):
615
+ ra, dec = c
616
+ if i > 0:
617
+ if new_coords[i - 1][0] - ra > 60:
618
+ ra += 360
619
+
620
+ elif ra - new_coords[i - 1][0] > 60:
621
+ new_coords[i - 1][0] += 360
622
+
623
+ new_coords.append([ra, dec])
624
+
625
+ ls = LineString(new_coords)
626
+ geometries.append(ls)
627
+
628
+ mls = MultiLineString(geometries)
629
+ geometries = unary_union(mls)
630
+
631
+ for ls in list(geometries.geoms):
632
+ x, y = ls.xy
633
+
634
+ self.line(zip(x, y), self.style.constellation_borders)
635
+ # x, y = ls.xy
636
+ # newx = [xx * -1 for xx in list(x)]
637
+ # self.ax.plot(
638
+ # # list(x),
639
+ # newx,
640
+ # list(y),
641
+ # # **self._plot_kwargs(),
642
+ # # transform=self._geodetic,
643
+ # transform=self._plate_carree,
644
+ # **style_kwargs,
645
+ # )
646
+
647
+ def _plot_constellation_labels_experimental(
648
+ self,
649
+ style: PathStyle = None,
650
+ label_fn=None,
651
+ ):
652
+ def sorter(g):
653
+ # higher score is better
654
+ d = distance(g.centroid, points_line.centroid)
655
+ # d = distance(g.centroid, constellation.boundary.centroid)
656
+ extent = abs(g.bounds[2] - g.bounds[0])
657
+ area = g.area / constellation.boundary.area
658
+ # return ((extent**3)) * area**2
659
+ # return ((extent**2) - (d/2)) * area**2
660
+ # print(str(extent) + " " + str(area) + " " + str(d))
661
+ return d**2 * -1
662
+ return (extent / 2 + area) - (d / 5)
663
+
664
+ for constellation in self.objects.constellations:
665
+ constellation_stars = [
666
+ s
667
+ for s in self.objects.stars
668
+ if s.constellation_id == constellation.iau_id and s.magnitude < 5
669
+ ]
670
+ constellation_line_stars = [
671
+ s
672
+ for s in self.objects.stars
673
+ if s.constellation_id == constellation.iau_id
674
+ # and s.hip in CONSTELLATION_HIP_IDS[constellation.iau_id]
675
+ ]
676
+ points = MultiPoint([(s.ra, s.dec) for s in constellation_stars])
677
+ points_line = MultiPoint([(s.ra, s.dec) for s in constellation_line_stars])
678
+
679
+ triangles = delaunay_triangles(
680
+ geometry=points,
681
+ tolerance=2,
682
+ )
683
+ print(constellation.name + " " + str(len(triangles.geoms)))
684
+
685
+ polygons = []
686
+ for t in triangles.geoms:
687
+ try:
688
+ inter = intersection(t, constellation.boundary)
689
+ except Exception:
690
+ continue
691
+ if (
692
+ inter.geom_type == "Polygon"
693
+ and len(list(zip(*inter.exterior.coords.xy))) > 2
694
+ ):
695
+ polygons.append(inter)
696
+
697
+ p_by_area = {pg.area: pg for pg in polygons}
698
+ polygons_sorted = [
699
+ p_by_area[k] for k in sorted(p_by_area.keys(), reverse=True)
700
+ ]
701
+
702
+ # sort by combination of horizontal extent and area
703
+ polygons_sorted = sorted(polygons_sorted, key=sorter, reverse=True)
704
+
705
+ if len(polygons_sorted) > 0:
706
+ i = 0
707
+ ra, dec = polygons_sorted[i].centroid.x, polygons_sorted[i].centroid.y
708
+ else:
709
+ ra, dec = constellation.ra, constellation.dec
710
+
711
+ text = label_fn(constellation)
712
+ style = style or self.style.constellation.label
713
+ style.anchor_point = "center"
714
+ self.text(
715
+ text,
716
+ ra,
717
+ dec,
718
+ style,
719
+ area=MultiPolygon(polygons_sorted[:3])
720
+ if len(polygons_sorted)
721
+ else constellation.boundary,
722
+ )