-
Notifications
You must be signed in to change notification settings - Fork 3
/
skycalcgui.py
executable file
·3064 lines (2554 loc) · 103 KB
/
skycalcgui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# skycalcgui.py - a GUI version of skycalc which can display
# a map of the sky built with PGPLOT graphics.
#
# copyright John Thorstensen, Dartmouth College, 2005 January.
#
# Anyone may use this program for non-commercial purposes,
# and copy it and alter it as they like, but this banner must
# be preserved, and my name must be preserved in window titles,
# i.e. proper credit must be given.
import sys
import string
import _skysub
from cooclasses import *
from Tkinter import *
from tkFileDialog import askopenfilename
from copy import deepcopy
# from pyraf import iraf # this breaks the connection between the main
# window and its variables. Too bad!
# from iraf import imred,specred,splot
import os
infields = ('objname','RA','dec','equinox','date','time','Time is:',\
'timestep','obs_name','longit','lat', \
'stdz', 'use_dst', 'zone_name', 'zone_abbrev', \
'elevsea','elevhoriz', 'siteabbrev')
# 0 = objname,
# 1 = RA; 2 = dec; 3 = equinox; date = 4, time = 5,
# Time is: = 6, timestep = 7,
# 8 = obs_name, 9 = longit, 10 = lat, 11 = stdz, 12 = use_dst,
# 13 = zone_name, 14 = zone_abbrev,
# 15 = elevsea, 16 = elevhoriz, 17 = siteabbrev
# These are all in text-entry widgets EXCEPT:
# - 'Time is:' is controlled by a radio button
# - site_abbrev is controlled by a separate radio-button panel
outfields = ('sidereal','ha','airmass','alt_az','parallactic','jd', \
'sunradec','sunaltaz','ztwilight','moonphase','moonradec','moonaltaz', \
'illumfrac','lunsky','moon-obj ang.','baryjd','baryvcor','constel',
'planet_proxim')
# 0 = sidereal; 1 = ha; 2 = airmass; 3 = alt_az; 4 = parallactic;
# 5 = jd; 6 = sunradec; 7 = sunaltaz; 8 = ztwilight;
# 9 = moonphase; 10 = moonradec; 11 = moonaltaz; 12 = illumfrac;
# 13 = lunsky; 14 = moon-obj angle; 15 = baryjd; 16 = baryvcor
# 17 = constel; 18 = planet proximity flag
almfields = ('Sunset','Twilight Ends','Night center','Twilight Begins','Sunrise',\
'Moon:','Moon:')
# 0 = sunset, 1 = eve twi, 3 = night center, 4 = morn. twilight, 5 = sunrise,
# 6, 7 = moon rise and/or set in time order.
coofields = ('Current RA:','Current dec:','equinox:',
'Proper motion','PM is:','input epoch','RA (pm only)',
'Dec (pm only)','equinox:',
'Ecliptic latitude','Ecliptic longitude','Galactic latitude',
'Galactic longitude','parallax factors')
# 0, 1, 2 -> Current RA, dec, and equinox
# 3 -> proper motion (two fields)
# 4 -> 1 = proper motion is dX/dt, 0 = proper motion is dalpha/dt
# 5 -> actual epoch of input coords
# 6, 7, 8 -> PM adjusted RA, and dec, and input equinox repeated
# 9, 10 -> ecliptic latitude and longitude
# 11, 12 -> Galactic latitude and longitude
# 13 -> parallax factors in X and Y
helptext = """
GENERAL
This program computes astronomical circumstances, given
the target's celestial location, the date and time, and
the site parameters. The graphical user interface (GUI)
is a front end for routines taken from the text-based
'skycalc' program. The program is intended for users
who are familiar with the concepts involved; it is
not intended as a tutorial on time-and-the-sky.
Most input parameters are read from the fields in the
left-hand column of the main window. Parameters which
can be straightforwardly used as input are rendered in
white. All the output parameters are refreshed whenever
a calculation is made.
At startup, the program sets the input date and time using
the computer's clock, and sets the coordinates to the
zenith at the default site (presently Kitt Peak).
MAKING COMPUTATION HAPPEN
You can refresh all the output fields by:
(a) Typing a carriage return in an input field;
(b) Stepping the time forward or backward with
the left and right arrow keys (or a carriage
return in the "timestep" field;
(c) Pressing 'Refresh output', 'Set to now',
or 'UT <-> Local'. This last converts the
input time format but leaves the time unchanged;
(d) Selecting a new object from the (optional) target
list menu;
(e) Selecting a new site from the site menu.
SPECIFYING A SITE
The site menu has parameters for several major
observatories. But note:
- If you want a site NOT on the menu, you must first
select "Other (allow user entries)" on the site menu.
Otherwise, the site parameters are overwritten when you
refresh. Site parameters are rendered with a slight
pink tinge to draw attention to this distinction.
Once you've done this, simply enter your site's
parameters. NOTE: the longitude units default to HMS
positive westward, which is NOT STANDARD. You can
specify units and direction explicitly, for example
"-111 36.9 d e" will enter Kitt Peak's longitude
in the form used in the "Astronomical Almanac".
LOADING TARGETS BY NAME FROM A LIST
It can be very handy to select objects by name from an
(optional) object list. To do this, prepare a file with
one object per line in this form:
name_no_blanks rahh mm ss decdd mm ss equinox
for example,
4U2129+47 21 29 36.2 47 04 08 1950
The 'read object list' button will pop up the list.
Select the object by double-clicking on its name.
The "dismiss" button clears the list and destroys
the window. You can load multiple target lists;
dismissing a list dismisses only the objects on that
list. Overlapping names are checked for and handled.
WHAT'S WITH THE COLORS?
Data fields which can be used for input are rendered
in off-white. Pale pink is for site parameters, which
can be adjusted when the site menu enables it.
Other than that, color is used to draw attention to
various conditions:
- yellow, orange, red : these indicate increasingly
problematic conditions (twilight, hour angle,
airmass, or proximity to the moon). The Reference
Manual gives details. For the moon, these colors are
used when the moon is < 25 degrees from the
input position (i.e., it means the moon's proximity
may be a problem).
- Light blue means daylight for the sun. For the moon it
signals that the moonlight prediction is between non-
negligible and fairly strong. It is only used when the
moon is more than 25 degrees from the object.
- Light purple is used to flag quite bright moonlight (more
than 19.5 V mag per square arcsec) at angles more than
25 degrees from the moon.
The reason for not using yellow, orange, and red in
these moonlit conditions is to reserve these colors for
when the moon is close to the object -- easy to overlook
in planning. Since the sky is always bright around full moon,
using red for the ordinary bright sky would be "crying wolf".
STUFF TO KEEP IN MIND:
- If a window has a "Hide" button, use it when you want
to close the window. Windows with "Hide" buttons have
processes which are always running, and killing the window
destroys the process.
- For most windows, if they get "buried alive" behind
another window, clicking their button on the main window
will raise them. Exceptions are object lists and text
output windows, for which you can have more than one at
a time.
- The Hourly Airmass window has a "Dump to file" button,
which appends a text version of the information to a
text file called "skycalc.out". The file will appear
in whatever directory the program started in, probably
your top directory if you launched with a pull-down menu.
- The "Step time" button advances the input time by the
"timestep" parameter and refreshes the output. Left
and Right arrow keys typed anywhere in the main window
move the time backward and forward. Typing a carriage
return into the "timestep" field also advances the time.
A variety of units are recognized for the timestep:
5 s - 5 seconds
10 m - 10 minutes [minutes are the default]
1.5 h - an hour and a half
2 d - 2 days
1 t - 1 sidereal day, think "transit" for mnemonic
2 w - 2 weeks
1 l - one lunation (mean synodic month). This is
useful for examining conditions at e.g. successive
new moon dates. The jump is 29.53 days.
- The "Time is: UT Local" radiobuttons affect how the
input time is interpreted when the computation is done.
Switching this doesn't have any effect until the output is
refreshed. Switching this and refreshing will change the
output values, unless UT and local time are identical.
The "UT <-> local" button, by contrast, converts the
input time fields to the SAME time in the other system
(and switches the radiobutton so the change will stick).
The output is refreshed, but nothing should change (except
for tiny roundoff effects, e.g. azimuth at zenith).
- The "objname" field is updated when an object is loaded
from the menu, or you can change it by hand. It is not
changed automatically when you change the RA and dec;
in that case it's up to you to change it. If you do have
an object list loaded, you can enter an object's name
in this field to load its coordinates if it's easier than
finding it on the list and double-clicking.
- You can input RA, dec, etc. with or without colons (":")
separating the field, or as decimal hours or degrees.
If there are two or more fields the input is interepreted
as sexigesimal (i.e., 60-based like HH MM SS). If you
enter a negative dec, you must not leave any space between
the minus sign and the first digit of the degrees.
You can enter RA as degrees, minutes, and seconds, or as
decimal degrees, if you put a "d" at the end, separated by
a space, e.g. "275.3828 d" or "275 22 58 d".
- Entering a jd in the "jd" field and hitting return will
set the time to agree with the entered JD. This is a
rare exception to the distinction between input and
output variables. The field is whitened for this reason.
OTHER WINDOWS ...
- The "Nightly almanac" window displays times of sunrise
and -set, twilight, and moonrise and set.
- The "Alt. Coords" window displays current coords and
optionally computes a proper motion correction. See
the reference manual for details.
- The 'Planets' window gives low-precision planetary positions.
- The 'Text Tasks' window handles several calculations which
can produce tables, including seasonal observability and
generating ephemerides for periodic phenomena (e.g. binary
star eclipses).
MORE INFORMATION
If you want more detail, pop up the Reference Manual
window. It has detailed descriptions of the various
fields, explains the warning color scheme, and so on.
There is also a cursory HTML manual, and a very detailed
manual for the text-based skycalc program, which shares
much code with this version.
OTHER FORMS OF THIS PROGRAM
This program encapsulates some of the most widely-used
functionality of the text-based "skycalc" program. Many
features have been left out; if you need some other
time-and-the-sky calculation, it may be in skycalc.
LEGALITIES.
This program is copyright 2005, by the author, John
Thorstensen (Dartmouth College). Permission is hereby
granted for all non-profit use, especially educational
and scientific users. I do ask that my credit line
remain prominently displayed.
Portions of the interface code are adapted from
"Programming Python" by Mark Lutz (O'Reilly).
There are no warranties of any kind.
John Thorstensen, Dartmouth College
john dot thorstensen at dartmouth dot edu
"""
referenceman = """
---- REFERENCE MANUAL ----
ALL THE FIELDS:
--- INPUT VARIABLES ---
objname - Used to label text-file output and for the
user's benifit. Loads automatically when objects are
double-clicked on the object list, or can be set by
hand. When an object list has been loaded, you can
fetch an object's coordinates by entering its name here
with a carriage return; if the object isn't on the list, a
"NOT FOUND" will appear in the objname field.
RA - Right ascension, defaults to hours, minutes, and
seconds. Fields can be delineated by spaces or colons.
You can also enter plain decimal hours. If there are
two fields or more, it is interpreted as HH:MM:SS.
You can enter RA in degrees if you put a " d" (space
and d) at the end of the input, e.g. "275.3828 d" or
"275 22 58.1 d"
dec - Declination, generally in degrees, minutes, and
seconds separated by colons or spaces. The same input
apply as for RA. For negative declinations there cannot
be any space between the negative sign and the first
digit of the degrees.
equinox - The equinox (often incorrectly called "epoch")
of the input coordinates, in decimal years. One special
hook -- if you enter "date", the equinox is forced to
agree with the date and time (will change the direction
of the input coordinates, unless they're already in the
equinox of date). This feature enables a
backdoor computation of the Julian epoch (which is
2000.0 + the number of 365.25 day intervals since
J2000 = JD 2451545.0).
date - The input date as year, month, day. The day of
the week is not used on input, but when a refresh happens
it is forced to agree with the year, month, and day.
The month can be specified as e.g. "Apr", "April", or
"4". Dates outside of the range 1901 to 2099 are rejected.
time - The time in hours, minutes, and seconds. The same
formats are acceptable here as for RA and dec, e.g.
17 32 33, 17:32:33, 17.53, 17:32, and so on. However,
entering e.g. "3.25" for 3:15 will truncate to
"3 00 00".
NOTE ON DAYLIGHT SAVINGS TIME: If the "use_dst" flag
lower down is not zero, local time will be interpreted
as daylight savings when it is in effect. See the
notes on the "use_dst" flag below.
Time is: - A button which controls whether the input time
will be interpreted as local time or UT. Changing this
does not cause a refresh. Use the control button
"UT <-> local" to convert the time and switch the input
values to specify the same actual time in the other system.
timestep - How far to step the time when the "Step the time"
button is pressed, a right- or left-arrow key is pressed,
or when a carriage return is typed in this particular input
field. Note that typing a left-arrow key will step the
time backward, and a right-arrow key will step the time
forward.
Default units are minutes. You can specify the unit by
leaving a space and entering the unit explicitly, e.g.
"1.5 h". The units recognized are:
s seconds
m minutes
h hours
d days
t sidereal days (mnemonic: successive Transits).
w weeks
l lunations (29.5307 d)
Only the first character of the units field is used, and
case is ignored.
The "lunation" option makes it easy to step through and
look at circumstances for a given target on successive
bright or dark runs on the Hourly Airmass display.
-- SITE PARAMETERS --
Selecting an observatory on the site menu sets the site
parameters and refreshes the output.
The site paramters are reloaded from the observatory menu
every time the output is refreshed, UNLESS the last item on
the menu, "Other", is selected. If "Other" is selected
the user is free to adjust the values by hand, for example to
compute for a site which isn't on the menu, and the user-
entered values will not immediately be overwritten. The
parameters are:
obs_name - The name of the observatory, for your information.
longit - The observatory longitude as hours, minutes, and
seconds WEST, which are also the default input units.
To specify a longitude in another system you need to
specify the UNIT (d or h) and the POSITIVE DIRECTION
(e or w) explicitly, for example as
-111 37.0 d e
For -111 degrees, 37.0 minutes east longitude (which is
Kitt Peak). The input format is fairly flexible - the
direction can be left out (defaults to W), decimals
can be used in any field, colons can be used, and so on.
If the direction is specified, it must be in the last field.
lat - The latitude in degrees, minutes, and seconds.
stdz - Offset between local standard time and UT, in hours,
positive westward.
use_dst - A flag controlling whether daylight savings time
will be used. Note that the 1-hour DST offset is applied
AUTOMATICALLY based on a limited number of prescriptions
for the dates the time changes. These are specified by
integer codes:
0 - Standard time in use all year.
Positive number codes are used in the northern hemisphere:
1 - United States convention (last Sunday in April,
last Sunday
2 - Spanish convention.
Negative number codes are used for the southern hemisphere:
-1 - Chilean convention
-2 - Australian convention.
Around the hour the time switches between daylight and
standard, some deeply confusing ambiguities occur. If this
is a problem you can always switch to UT input to avoid
these issues; alternately, enable site parameter changes
on the site menu (last button), then manually set
use_dst to zero, to force the use of standard time.
Careful examination of the times in the Hourly Airmass
table may help clear up confusion.
zone_name - The name of the time zone, for your information
only.
zone_abbrev - The 1-character abbreviation, which may be used
in the future to label output.
elevsea - The elevation of the observatory above sea level,
in meters. Used when the spatial location of the
site must be known precisely (e.g., lunar parallax).
elevhoriz - The elevation of the observatory above the
terrain forming its horizon, in meters. Used to adjust
rise and set times for the sun and moon to account for
the depression of the horizon.
-- OUTPUT VARIABLES ---
These are all refreshed when calculations occur.
Changing them by hand has no effect.
sidereal - The local mean sidereal time, in hours,
minutes, and seconds.
ha - The hour angle in hours, minutes, and seconds. This
is adjusted to be in the range -12 to +12 hours.
airmass - The airmass. If the zenith distance is less
than 85 degrees, this is computed from a polynomial
approximation (it's a real airmass, not secant z).
For zenith distance > 85 degrees "> 10" is output,
and for zenith distances > 90 degrees this lists
"(Down)". Color is used to alert the user of possibly
problematic conditions:
Yellow - airmass 2 to 3
Orange - airmass 3 to 4
Red - airmass greater than 4, or down.
alt_az - The altitude above the horizon, and the azimuth
(measured from north through east), in degrees.
parallactic - The parallactic angle (crudely, position
angle of "straight up"), in degrees. The 180-degree
opposite is also given. The parallactic angle is
important because it is the direction along which
atmospheric refraction and dispersion act. See
A. Filippenko, 1982, PASP, 94, 715 for more detail.
jd - The Julian Day number of the input date and time.
One can use this as an INPUT field by entering
a jd and hitting carriage return ("Enter"), which
forces the date and time to agree with the given JD.
Julian dates outside of 1901 to 1899 are rejected,
because of the calendrical limitations of the program.
Times and dates are passed internally in the program
as JDs. The numerical resolution of the double-precision
floating point value is typically a few milliseconds.
sunradec - The RA and dec of the sun. The equinox of the
coordinates is that of the input time. Accuracy is
around 1 arcsecond. The RA and dec are "topocentric",
i.e., corrected for the observer's location with respect
to the earth's center.
sunaltz - Altitude and azimuth of the sun in degrees.
ztwilight - If during twilight (sun angle between 0 and
-18 degrees), this field displays a rough estimate of how
bright the twilight is at the zenith. It is
approximately how many more magnitudes of surface
brightness there are compared to the dark night sky,
as measured in blue light. When the sun's altitude is
outside this range, it displays "No twilight" or "Daytime".
Color is used for warnings. Light blue indicates that
the sun is up (so the sky is blue). Different levels of
twilight are flagged as follows:
0 to 4 mag: yellow
4 to 8 mag: orange
8 and more: red
moonphase - A verbal description of the moon phase.
moonradec - RA and dec of the moon. The coordinates are
in the equinox of the input date. The coordinates
do account for the huge horizontal parallax of the moon,
i.e. you should see the center of the moon if you aim
at them. Accuracy is a few arcseconds.
moonaltaz - Altitude and azimuth of the moon, in degrees.
illumfrac - The fraction of the moon's visible face which is
illuminated. If the moon is down, you're informed of this
here.
lunsky - If the moon and the object are both up and the sun
is more than 12 degrees below the horizon, this field gives
an estimate of the moon's contribution to the sky brightness
at the specified celestial location and time, in V magnitudes
per square arcsec. This is computed using the prescription of
Krisciunas and Schaefer, 1991, PASP, 103, 1033.
Color is used as follows:
- If the sun is higher than -12 degrees altitude, the
field is not colored in, since twilight will usually
be a more important consideration.
- If the position is within 10 degrees of the moon
the field is colored red. Even if the moon is not
bright this can cause special difficulties because
of reflections and so on.
- If the position is more than 25 degrees from the moon,
the following color scheme is used:
- light blue: 19.5 to 21.5 mag per sq. arcsec
- light purple : brighter than 19.5 mag per square
arcsec.
(The blue color appears when the moon roughly doubles
the sky brightness).
- Between 10 and 25 degrees from the moon, warning colors are
as follows:
yellow : 19.5 to 21.5 mag per square arcsec
orange : 18 to 19.5 mag per square arcsec
red : Brighter than 18th.
Note that this scheme preserves the yellow-orange-red colors
to warn of PROXIMITY TO THE MOON, which is easily overlooked
in planning. Using the same scheme at greater moon-object
separations would de-value their alarm value (i.e., it
would be "crying wolf"). It's always bright at full moon!
moon-obj ang. - Angle subtended by the moon and the object,
in degrees. Color is used as above to warn of proximity.
baryjd - The barycentric Julian Day. This is the time at
which the light from an event observed in this direction
and at this time will arrive at the solar system center of
mass, or barycenter. The barycenter is always close to the
sun, so it's nearly the same as the heliocentric Julian date,
but the barycenter is a more nearly inertial frame. Accuracy
is around 1/10 of a second. The barycentric time correction
(i.e., amount added to the JD) is also displayed, in brackets.
baryvcor - The amount to add to an observed radial velocity
to correct it to the solar system barycenter. Accuracy is
around 0.01 km/s.
constel - The constellation of the input coordinates, given by
the standard 3-letter code. This is from a prescription
invented by Barry Rappaport and Nancy Roman (see Roman,
1987, PASP, 99, 695) and coded in C by Francois Ochsenbein
of CDS, Strasbourg and used with his permission.
planet_prox - This item prints the name(s) of any planet(s)
within 1 degree of the target. If there is a planet, the
box is colored orange to attract the user's attention.
THE HOURLY AIRMASS WINDOW
This window is popped up on startup, since it is especially
useful. It gives the circumstances for the specified oject,
every hour, on the hour, through the night.
If the input time is before noon, data for the previous night
are displayed, and if it is after noon, the next night is
displayed. The output starts the first hour that the sun is
less than 8 degrees above the horizon, and ends when the sun
rises above 8 degrees, or when all the rows are filled.
Enough rows are given to accomodate a quite long night.
Columns are as follows:
Local - Local time and date, using daylight savings if it
is in effect.
UT - The universal time, in hours and minutes. Note that
the UT date is not displayed, and may disagree with the local
date.
LST - The local sidereal time.
HA - The hour angle. If this is greater than 6 hours, it is
flagged as orange since some telescope mounts are constrained
to less than 6 hours.
Airmass - The airmass. The warning colors are used the same
as described earlier.
moonalt - The altitude of the moon. The warning color scheme
is the same as described earlier; the proximity to the moon
and lunar sky brightness are not displayed, but are computed
internally and used to set the warning colors. When the moon
is down, dashes are printed and the warning colors are not
used (the object's position must be above the horizon for the
lunar sky brightness calculation to be valid).
sunalt - The altitude of the sun. The warning color scheme
is the same as described earlier. When there is no twilight,
dashes are printed.
Two buttons appear at the bottom of the display:
The "Dump to file" button - This appends a version of the
hourly airmass information to a file named 'skycalc.out',
creating the file if it doesn't exist. The output is labeled
with the "objname" field and the coordinates are also
given. The file is closed after each "Dump to file" so
it can be accessed while the sky calculator windows are
still up.
The "Hide" button hides (withdraws) the window. NOTE that
closing the window with window manager's button may destroy
the process, in which case you can't get it back.
THE NIGHTLY ALMANAC WINDOW
This is hidden at startup but can be popped up using a button
in the main window.
This window displays the time of sunset and sunrise, twilight,
night center, and moon rise and set. For times before
noon the previous night is displayed, for times after noon
the next night.
Times are local, and are adjusted for daylight savings if it
is selected and in effect. Rising and setting times for the
sun and moon should apply to the upper limb and are adjusted
for the horizon depression using the "elevhoriz" parameter.
Moon rise and set are presented in the order they occur.
They are only given if they occur within about 12 hours of
night center. Dashes may be printed if the time of moonrise
or moonset is around mid-day; the criterion used is
imperfect so not too much should be read into this.
Note that if daylight savings time is used, there is some
confusion and ambiguity on the night it switches, especially
on the return to standard time (when the local time is
double-valued for an hour). Correlating the nightly almanac
with the Hourly Airmass window should clarify ambiguities.
The "Hide" button withdraws the window without destroying
the process; the window can be popped up again with the
"Show nightly almanac" button.
THE ALT COORDS WINDOW
This is hidden at startup and popped up by a button if
desired. It displays several other forms of coordinates
not available in the other windows. Proper motion can
be applied in this window. Note, however, that values
displayed in the other windows aside from this one
are not updated for proper motion (though they are
precessed properly); the proper motion corrections
are local to this window only. The proper motion
corrections are not fully rigorous and break down
at the poles.
There are three new INPUT variables in this window:
Proper motion: - Two numbers separated by whitespace
giving the proper motion in milliarcsec/yr. The
interpretation of these is controlled by the radiobutton
just below, which is
PM is: - There are three choices for interpreting the
pair of proper motion numbers.
dX/dt : The first number is the annual eastward proper
motion at the object's location - it's how fast
an object will appear to move on a set of images.
d(alpha)/dt : The first number is the annual change in
the object's right ascension (thus an object
near the pole will tend to have a large number
in the first field, since a small motion there
projects to a large arc at the equator). This
is the convention used in the UCAC2.
(For both of these, the second number is the proper motion
in dec, which is uncomplicated.)
mu/theta : The first number is the total proper motion
in mas/yr, and the second is the position angle
of the proper motion in degrees (i.e. 0 = due
north, 90 = due east, and so on).
input epoch - When proper motions are involved we need to
distinguish the "epoch" from the "equinox". The
"equinox" is the date of the coordinate system -- it
defines the pole and equinox used to set up RA and dec.
The "epoch" is the date that the star is at the input
position. Thus if the position of a moving star were
measured in 1980 and that position were precessed forward
to the J2000 coordinate system, the epoch of the position
would be 1980 and the equinox would be 2000.
Whenever the window is refreshed, these three input values
are read and used, together with input values from the main
window, to compute the following:
Current RA -- RA for the date and time specified in the main
window, updated for precession and proper motion (if any).
The precession routine is a rigorous matrix formulation,
using the IAU 1976 formulae, which are now superseded but
which are accurate enough for nearly all optical-astronomy
purposes.
Current dec -- same, for declination
equinox -- the equinox of these coordinates, i.e. the current
time expressed as decimal years. Technically this is the
'julian epoch', which is 2000 + (jd - J2000) / 365.25, where
J2000 is 2451545.0.
[The next three fields are INPUT fields described earlier, and
are omitted from this list of outputs.]
RA (pm only). -- The input RA taken from the main window, updated
for proper motion but left in the equinox of the input
coordinates.
dec -- same, but now the dec.
equinox -- the equinox of these coordinates, which will always be
identical to the input coordinates' equinox.
Ecliptic latitude -- Ecliptic latitude, in degrees.
Ecliptic longitude -- Ecliptic longitude, in degrees.
Galactic latitude -- Galactic latitude, in degrees. The
routine which computes the Galactic coordinates conforms
to the IAU definition, which is based in the RA and dec
for 1950; coordinates are internally precessed to 1950
before the transformation into Galactic.
Galactic longitude -- Galactic longitude in degrees.
There is a special hook here -- if you enter Galactic
coordinates with a carriage return, the position in the
main window is set to agree with the Galactic coordinates.
Thus the program can serve as a Galactic-to-equatorial
converter.
As usual, the "Hide" button takes the window down so that
it can still be brought back up.
THE PLANETS WINDOW
This prints low-precision coordinates of the planets. The
inner planets are the best, better than an arcmin, and then
the outer planets become worse. Coordinates are in the epoch
of date. If a planet is computed to lie within 1 degree of
the input coordinates from the main window, its line is
colored in orange to alert the reader.
Tabulated in the window are:
Name - name of the planet (duh).
RA - Right ascension in the epoch of date.
Dec - Declination in the epoch of date.
HA - Hour angle.
airmass - airmass, if less than 10.
proximity - Angular separation between the planet and the
coordinates of the object, in decimal degrees.
Again, there is a "Hide" button to put the window away.
THE SITE WINDOW
This is used to select an observatory. The window is
displayed when the program starts up.
The behavior is less than optimal and may be improved in
subsequent releases. Every time the output is refreshed,
the variable set by this window is read and the site
parameters are set to the standard values for the
selected site. This reloading is passed over ONLY
if you select the last button on the menu, labeled
"Other (allow user entries)". Thus if you want to
customize your site by entering its parameters by hand,
you must first select the last button on the site menu.
If you don't, the first time you refresh the output,
the fields you've entered will revert to the standard
values for the selected site.
Other sites can be added in the source code if needed -
just use the existing sites as a guide.
The "Hide" button withdraws the menu window without
destroying it. The "Show site menu" button in the
main window pops the menu back up.
THE OBJECT LIST WINDOW
The "Read object list" button lets you load an object
list using a file-selection dialog. The object list
needs to have one object per line in the format:
name_no_blanks rahh mm ss decdd mm ss equinox
For example:
4U2129+47 21 29 36.2 47 04 08 1950
The list is free-format, but whitespace (not colons) must
be used to delineate fields. A little window pops up,
and double-clicking a name sets the name, RA, dec, and
equinox.
You can open more than one list at a time, which appear
in separate windows. If identically-named objects
appear on more than one list, the object's name will
be bracketed by vertical bars on the second list.
Buttons control the order in which the list is presented:
- in the original order it was read from the file
- alphabetically
- ordered by RA
- ordered by proximity to the current coordinates
(e.g. "I need something nearby!, or "I remember
vaguely where this is but don't remember what
I named it", or you can set to the zenith and
get objects sorted by airmass, etc.)
BUGS, UNIMPLIMENTED FEATURES etc. --
- There are some unresolved issues around reporting
phenomena at very high latitudes, especially moonrise
and moonset. At temperate latitudes it seems fine.
- Eclipses are not taken into account in the lunar sky
brightness calculations.
For more detail on the algorithms used, see the skycalc
documentation.
"""
# Some utility routines adapted from Mark Lutz' *Programming Python*,
# published by O'Reilly.
# Adapted from Mark Lutz' "Programming in Python", O'Reilly
class ScrolledList(Frame) :
def __init__(self, options, parent=None, kill=1) :
Frame.__init__(self,parent)
self.pack(expand=YES, fill=BOTH)
self.makeWidgets(options)
self.val = 0
self.onepass = kill
def handleList(self,event) :
index = self.listbox.curselection()
self.val = self.listbox.get(index)
# if self.onepass == 1:
# self.quit() # kill box after any selection.
def makeWidgets(self,options) :
sbar = Scrollbar(self)
list = Listbox(self,relief=SUNKEN)
sbar.config(command=list.yview)
list.config(yscrollcommand=sbar.set)
sbar.pack(side=RIGHT, fill=Y)
list.pack(side=LEFT,expand=YES, fill=BOTH)
pos = 0
# print "options %s" % options
for label in options:
# print "label %s" % label
list.insert(pos,label)
pos = pos + 1
list.bind('<Double-1>', self.handleList)
self.listbox=list
self.sb = sbar
# Largely from Lutz' Programming Python book, with some
# enhancements I added.
class ScrolledText(Frame) :
def __init__(self, parent = None, text = '', file = None, width=80, height=24) :
Frame.__init__(self, parent) # make me expendable
self.pack(expand = YES, fill=BOTH)
self.makewidgets(width=width, height=height)
self.settext(text,file)
def makewidgets(self,width=80,height=24) :
sbar = Scrollbar(self)
text = Text(self, relief = SUNKEN,width=width,height=height,
bg="#330066",fg="yellow",font="7x13")
sbar.config(command=text.yview) # xlink sbar and text
text.config(yscrollcommand=sbar.set) # each moves the other
sbar.pack(side=LEFT, fill=Y)
text.pack(side=LEFT, expand=YES, fill=BOTH)
self.text = text
def settext(self, text='', file = None) :
if file:
text = open(file, 'r').read()
self.text.delete('1.0',END) # delete current text
self.text.insert('1.0',text) # add at line 1, col 0
self.text.mark_set(INSERT, '1.0')
self.text.focus() # save user a click
def gettext(self) :
return self.text.get('1.0', END+'-1c')
def getsel(self) :
return self.text.selection_get()
def appendline(self,line='\n',maxlines = 10000) :
self.text.insert(END,line + "\n")
if float(self.text.index(END)) > maxlines :
#print maxlines, self.text.index(END), \
# self.text.index(END) > float(maxlines)
self.text.delete('1.0','2.0')
self.text.see(END)
def erasetext(self) :
self.text.delete('1.0',END)
def dumptext(self,filename) :
# outstuff = self.text.selection_get()
outf = open(filename,"a")
outf.write(self.gettext())
outf.close()
# quitter widget is a direct copy of Lutz' routine, except without the
# __name__ == '__main__' trick.
#############################################
# a quit button that verifies exit requests;
# to reuse, attach an instance to other guis
#############################################
from Tkinter import * # get widget classes
from tkMessageBox import askokcancel # get canned std dialog
class Quitter(Frame): # subclass our GUI
def __init__(self, parent=None): # constructor method
Frame.__init__(self, parent)
self.pack()
# widget = Button(self, text='Quit', command=self.quit, bg="#ffaa75")
widget = Button(self, text='Quit', command=self.quit)
widget.pack(expand=YES, fill=BOTH, side=LEFT)
def quit(self):
ans = askokcancel('Verify exit', "Really quit?")
if ans: Frame.quit(self)
# if __name__ == '__main__': Quitter().mainloop()