aeclipseuse0_2.py

Created by steveg1cmz

Created on October 12, 2023

3.83 KB

Uses aeclipse. Illustrates usage.


"""Astronomy: Eclipse Use.

Illustrates how to use Astronomy:Eclipse.
Includes example calls (but not expected values).

Note that sometimes you have to search a month earlier to get the expected event.
And sometimes use koffset=-0.5 not 0.5.

Note: Calculations are geocentric (not specific to a particular lat/long).

"""
__version__="0.2"

criduse="Astronomy:Eclipse Use V"+__version__+"""
© 2023 SteveG1CMZ"""

#customise
showme=True
lines=True #print several lines in eprint

#user prompts
#whats may need editing on ascii platforms
whats="magnitude γ[M M\' F Ω F1]JDE:" #&mins
koffs="type[0:solar, +-0.5:lunar]?"
yyyys="YYYY.?"
OKK="[OK/EXE]" #OK keys

intro=__name__+""":
Illustrates use of aeclipse module.
"""
#end custom

try: 
  from aeclipse import *
  #from time import *
except:
  print(criduse)
  print(intro)
  print(__name__+""":
Requires aeclipse module.
  """)
  showme=False
  
#may need editing on ascii platforms
symbols="ФЭΔΣΩαβγδεζηθλμπρσω" #for reference
menutext="""menu:
0:?: help (.: exit)
1: eclipse
3: calendar
5: example
choice?"""+OKK
#also #7: test data

helptext="""
YYYY.: decimal year, eg 2023+10/12
itsa: type of eclipse
DT: DateTime may be rounded to minutes
magnitude of eclipse: fraction
gamma: how central is the eclipse:
JDE: peak time of eclipse
(modify by ΔT for UTC, ~2mins)
mins: semidurations may be rounded to mins
"""
#[may be: in case aeclipse rounding is changed]

def help():
  print(helptext)
  
def eprint(details):
  if details==None: return
  if details[0]==None:
    return
  if not(lines):
    #print(whats)
    print(details)
  else: 
    print(whats)
    for item in details:
      print(item)
      
def menu(text):
  return (input(text))
  
def eclipsesjm():
  #52=54 eclipses examples
  lines=True #display several lines
  #solar
  print("a:")
  eprint(eclipse(1993+5/12,0)) #52=54.a
  print("b:")
  eprint(eclipse(2009+7/12,0)) #52=54.b
  #lunar
  #NB Some seem better with -0.5 some with 0.5
  #perhaps I need to tweak rounding
  print("c:")
  eprint(eclipse(1973.5,-0.5)) #52=54.c
  print("d:")
  eprint(eclipse(1997+9/12,-0.5)) #52=54.d

def eclipsesjmsolar():
  #52=54 eclipses more examples
  #just dates and types
  print("seven non-central solars:")
  print("one miscategorised (noted by jm)")
  #sleep(2)
  print(eclipse(1950+3/12,0))
  print(eclipse(1957+4/12,0)) #miscategorised
  #(lists as central coz GAMMA 0.9966 is in reality 0.9990)
  print(eclipse(1957+10/12,0))
  print(eclipse(1967+10/12,0)) #November
  print(eclipse(2014+4/12,0))
  print(eclipse(2043+4/12,0))
  print(eclipse(2043+9/12,0)) #October
  
def eclipsesjmmore():
  #affected by accuracy of jm algorithm
  print(eclipse(1935+1/12,0))
  print(eclipse(1957+4/12,0))
  print(eclipse(1890+11/12,0.5)) #k=-1349.5
  
def calendar(yyyy=None,koff=None):
  """year calendar (real)
  year.: calendar (real)
  koff: offset (0 solar, -0.5 or 0.5 lunar)
  """
  if yyyy==None: 
    yyyy=eval(str(input(yyyys)))
  if koff==None:
    koff=eval(str(input(koffs)))
  print("Calendar:",yyyy,koff)
  for ii in range (12):
    i=float(ii)
    details=eclipse(yyyy+(i/12),koff)
    eprint(details)

def tests():
  eclipsesjm()
  eclipsesjmsolar()
  #eclipsesjmmore()

if showme or __name__=="__main__":
  print(criduse)
  
  while True:
    choice=menu(menutext)
    if choice==".": return 
    if choice=="0" or choice=="?": help()
  
    if choice=="1": #eclipse
      #print("Eclipse")
      lines=True
      yyyy=eval(str(input(yyyys)))
      koff=eval(str(input(koffs)))
      eprint(eclipse(yyyy,koff))
    
    if choice=="3": #calendar
      #print("Calendar")
      lines=True
      calendar(None,None)
    
    if choice=="7": #tests
      tests()
      
    if choice=="5": #example
      print("Example:")
      lines=True
      eprint(eclipse(2023+10/12,0)) #solar
      eprint(eclipse(2023+10/12,0.5)) #lunar
    #if choice=="e":
    #  print("e")
    
  #ends

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.