Astro.com astronomical / astrological calculations

User projects written in or related to FreeBASIC.
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Postby lizard » May 24, 2018 11:30

dodicat wrote:Hi lizard.
Got it working on 64 bit fb, but not on 32 bit fb.

Hi dodicat,
right, i have tested now in windows 10 32 bit. It seems in windows the #define, #ifdefine and #include lines have another behaviour. In FbEdit some are red, others greyed out after a random pattern. Don't know what happens there, because i worked in Linux all the time. Sorry.

latitude and longitude are a bit confusing, is it not declination and hour angle (or right ascension) ?
The longitude bit seems degrees, the latitude bit seems a different unit.

This is described in detail in the programming manual from astro.com mentioned above.

Let me explain it in my own words as far i understood it...

The left two columns are in radians (decimal degrees) showing the longitude (distance on the ecliptic from 0 degree aries). The part left from the point must be divided by 30 to get the sign in which the planet is. The part right from the point must be divided by 60 to get the minutes. The rest must be divided again by 60 to get the seconds, so you end with something like this (example)

Taurus 12° 20' 33'' ( in degrees, minutes and seconds)

Similar with the second column, which shows the latitude. This can be around ~ 23° north or south from the ecliptic. Again the radians must be changed to degrees, minutes and seconds.

The third column shows the distance from earth, in astronomical units (AU), i believe.

The fourth column shows the speed, don`t know which units. :-)
dodicat
Posts: 5024
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Astro.com astronomical / astrological calculations

Postby dodicat » May 24, 2018 12:50

My results

Code: Select all

 
Date (at 0:00 Universal time):             24            5             2018

Planet         Longitude                   Latitude                    Distance                    Speed

Sun            62.79511753919038           5.646607039957745e-005      1.012574016771605           0.9610118839294318
Moon           176.1650919333074           3.763404719037474           0.002539962780624497        13.44366624727041
Mercury        48.00817710029153          -1.504585796249133           1.219779942303076           1.902679000049515
Venus          95.31654371614521           1.708958239297256           1.321741894027001           1.192133833720833
Mars           302.8636735620892          -2.406032084077329           0.667345535607173           0.3416234937903079
Jupiter        226.493394453964            1.239589420596055           4.427141081293557          -0.1180710154986934
Saturn         278.1518732976888           0.8829716391705055          9.222644293294524          -0.05260779808484591
Uranus         30.43450397677699          -0.5254819992339179          20.73497981128271           0.05042219773185641
Neptune        346.3088807792686          -0.9419913249753145          30.16267348201849           0.01395964058890844
Pluto          291.056067377098            0.2451749707781769          32.88498577331953          -0.01420127453026856

Swiss Ephemeris V 2.05.01
 

The declination (~~latitude) of the sun should be about 21 degrees on 24 may 2018.
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Postby lizard » May 24, 2018 13:25

Strange, here all fits in the 1024 pixel width. But thats only in the code tags i suppose.

And i have Swiss Ephemeris 2.07.01 displaying in Linux.

Code: Select all

Sun            62.79511753919038           5.646607039957745e-005


Whats the e-005? Exponent? Have the same here for this date.
dodicat
Posts: 5024
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Astro.com astronomical / astrological calculations

Postby dodicat » May 24, 2018 13:40

I changed to win 10 console, which is by default big enough.
But If your console is too small you can try
width 125,30
(Instead of screenres)
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Postby lizard » May 24, 2018 13:55

I maximized terminal, but with screenres it looks better. :-)

But one thing is obvious, the .bi must have "win/" before them like here:

Code: Select all

#ifdef __FB_WIN32__
   #include once "win/wtypes.bi"
   #include once "win/objbase.bi"
   #include once "win/wincon.bi"
   #include once "win/winbase.bi"
   #include once "crt/io.bi"
   #include once "windows.bi"
#endif
dodicat
Posts: 5024
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Astro.com astronomical / astrological calculations

Postby dodicat » May 24, 2018 14:41

I only went console to copy and paste to the forum.
Does this look right?
The declination of the sun is wrong.
I haven't checked the others.

Code: Select all

' swe_mini.bas   

' minimal program to test the Swiss Ephemeris

#include "swephexp.bi"   
#include "vbcompat.bi"
Dim Shared As long jyear = 2018
Dim Shared As short jday = 24, jmon = 5, p, iflag, iflgret
Dim Shared As double jut = 0.0, tjd, te, x2(6)
Dim shared As zstring * 10 svers
dim shared as zstring * 256 serr

dim as string planets(...) = {"Sun", "Moon ", "Mercury", "Venus", "Mars", _
"Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"}

iflag = SEFLG_SPEED
' we have day, month and year and convert to Julian day number
tjd = swe_julday(jyear,jmon,jday,jut,SE_GREG_CAL)     
 ' #macro hld     
' compute Ephemeris time from Universal time by adding delta_t
te = tjd + swe_deltat(tjd)
'beep


'width 125,30


screenres 1024,768,32
width 1024/8, 768/16
do
dim as string y=format(now,"yyyy mm dd")
jyear=val(mid(y,1,4))
jmon= val(mid(y,6,2))
jday=val(right(y,2))

dim as string h=mid(time,1,2)
dim as string m=mid(time,4,2)
dim as string s=mid(time,7,2)
jut=valint(h)+val(m)/60+val(s)/60/60
tjd = swe_julday(jyear,jmon,jday,jut,SE_GREG_CAL)     
te = tjd + swe_deltat(tjd)
    screenlock
    cls
   
print

print "Date (at ";mid(str(jut),1,6);" Universal time):", jday, jmon, jyear
print
print "Planet         Longitude                   Latitude                    Distance                    Speed"
print
   
' loop over all planets   
for p = SE_SUN to SE_PLUTO
  iflgret = swe_calc(te, p, iflag, @x2(0), serr)
         
' if there is a problem, a negative value is returned and a
' message is in serr       
  if iflgret < 0 then print "Error: ", serr   
         
' print the coordinates     
  print planets(p), x2(0), x2(1), x2(2), x2(3)   
next
'locate 19,5
'print jyear,jmon,(mid(y,6,2)),right(y,2)
'print y
screenunlock
sleep 1,1
loop until len(inkey)
 
' get version
swe_version(svers)
print
print "Swiss Ephemeris V " & svers

swe_close()
'#endmacro
Sleep 
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Postby lizard » May 24, 2018 14:50

lizard wrote:The left two columns are in radians (decimal degrees) showing the longitude (distance on the ecliptic from 0 degree aries). The part left from the point must be divided by 30 to get the sign in which the planet is. The part right from the point must be divided by 60 to get the minutes. The rest must be divided again by 60 to get the seconds, so you end with something like this (example)

Taurus 12° 20' 33'' ( in degrees, minutes and seconds)

No, mistake. It must be multiplied by 60.

Like for sun: Sun 62.79511753919038

62 / 30 = 2 (Gemini)
rest 2 = 2°
0. 79511753919038 * 60 = 47,707052351 = 47'
0,707052351 * 60 = 42,42314106 = 42''

Hope thats right.

Prroofed: Astro.com website says Sun today is on Gemini 2°47'42''
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Postby lizard » May 24, 2018 16:03

You have a old version with include "swephexp.bi" i have replaced again with "swisseph.bi". But sadly this dont work on Win32.

But your example works here.
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Postby lizard » May 24, 2018 16:44

Here is a part of the data sheet for today:

Code: Select all

Transite
Datum: 24. Mai 2018
UT:    0:00:00    Jul.Day  2458262.500800

  Planet     Länge           tgl. Bew.        Breite            Deklination

  Sonne      2°47'42"        57'40"           0° 0' 0" N        20°42'53" N
  Mond       26° 9'54"       13°26'37"        3°45'48" N        4°58'39" N
  Merkur     18° 0'29"       1°54'10"         1°30'16" S        15°44'52" N
  Venus      5°18'59"        1°11'32"         1°42'32" N        25° 2' 9" N
  Mars       2°51'49"        20'30"           2°24'22" S        21°51'24" S
  Jupiter    16°29'36"      -7' 5"            1°14'23" N        15°34'39" S
  Saturn     8° 9' 7"       -3' 9"            0°52'59" N        22°18'11" S


Have deleted the signs by mistake, but anyway...

Where Länge = Longitude and Breite = Latitude

Normally Latitude of Sun is always 0°, because Sun is always on ecliptic, its her path.

The other values are matching, only for sun they have taken another in the calculation.
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Postby lizard » May 25, 2018 10:49

I must confess, it is confusing, because for geographical coordinates the same words are used, longitude and latitude.

In manual description says:
int swe_calc_ut ( double tjd_ut, int ipl, int iflag, double* xx, char* serr),

where

tjd_ut =Julian day, Universal Time
ipl =body number
iflag =a 32 bit integer containing bit flags that indicate what kind of computation is wanted
xx =array of 6 doubles for longitude, latitude, distance, speed in long., speed in lat., and speed in dist.
serr[256] =character string to return error messages in case of error.


Here it is clearly written, resulting planet positions are called longitude and latitude, too.
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Postby lizard » May 25, 2018 20:07

Ever needed to know where and when the heck next total eclipse will happen? Swisseph can give the answer.

Code: Select all

' swe_next_eclipse.bas

' Example of a typical eclipse calculation from here (chap. 6):
' https://www.astro.com/swisseph/swephprg.htm?lang=g#_Toc505244854
' translated to FreeBASIC 1.05
' added actual date and output

' Find the next total eclipse, calculate the geographical position where
' it is maximal and the four contacts for this position

#include "swisseph.bi"
#include "datetime.bi"
     
dim as double jut = 0.0, tret(10), attr(20), geopos(10)
dim as double eclflag, dsecfr, dhour, tjd_start, tjd_now ' Julian day today
dim as zstring * 256 serr ' char(256)
dim as short whicheph = 0 ' default ephemeris
dim as short ifltype = SE_ECL_TOTAL or SE_ECL_CENTRAL or SE_ECL_NONCENTRAL
dim as short i, roundflag = SE_SPLIT_DEG_ROUND_SEC
dim as short gregflag = SE_GREG_CAL
dim as long iyear, imonth, iday, ihour, iminut, isecond
dim as long ideg, imin, isec, isgn

tjd_now = swe_julday(year(now),month(now),day(now),jut,SE_GREG_CAL) 

' find next eclipse anywhere on earth

eclflag = swe_sol_eclipse_when_glob(tjd_now, whicheph,  ifltype, @tret(0), 0, serr)
if (eclflag = -1) then print serr ' error?

' the time of the greatest eclipse has been returned in tret(0)
' now we can find geographical position of the eclipse maximum

tjd_start = tret(0)
eclflag = swe_sol_eclipse_where(tjd_start, whicheph, @geopos(0), @attr(0), serr)
if (eclflag = -1) then print serr ' error?

' the geographical position of the eclipse maximum is in geopos(0) and geopos(1)
' now we can calculate the four contacts for this place. The start time is chosen
' a day before the maximum eclipse:

tjd_start = tret(0) - 1
eclflag = swe_sol_eclipse_when_loc(tjd_start, whicheph, @geopos(0), @tret(0), @attr(0), 0, serr)
if (eclflag = -1) then print serr ' error?

' now tret() contains the following values:
' * tret(0) = time of greatest eclipse (Julian day value)
' * tret(1) = first contact
' * tret(2) = second contact
' * tret(3) = third contact
' * tret(4) = fourth contact

if screenres (320,200) then
  print "Error: Could not initialize graphics device."
  sleep
  end
end if

width 320/8, 200/16 ' big font

print
print " Today is " & day(now) & "." & month(now) & "." & year(now)
print " Next total eclipse is on"
Print

isgn = iif(geopos(0) < 1,-1,1)
ideg = int(geopos(0))
imin = int((geopos(0) - ideg) * 60)
print " Longitude : " & ideg & chr(248) & " " & imin & "' " & *iif(isgn < 1, @"W", @"O")

isgn = iif(geopos(1) < 1,-1,1)
ideg = int(geopos(1))
imin = int((geopos(1) - ideg) * 60)
print " Latitude  : " & ideg & chr(248) & " " & imin & "' " &  *iif(isgn < 1, @"S", @"N")

print
swe_revjul(tret(0), gregflag, @iyear, @imonth, @iday, @dhour)
ihour = int(dhour)
iminut = (dhour - ihour) * 60
print " at " & iday & ". " & imonth & ". " & iyear & " " & ihour & "h " & iminut & "m "

'prints out all 5 contacts
'for i = 0 to 4
  'swe_revjul(tret(i), gregflag, @iyear, @imonth, @iday, @dhour)
  'ihour = int(dhour)
  'iminut = (dhour - ihour) * 60
  'print " " & iday & ". " & imonth & ". " & iyear & " " & ihour & "h " & iminut & "m "
'next i

sleep


Proof on this site:
https://www.timeanddate.de/finsternis/alle

Edit: few little changes, added screenres in listing
Last edited by lizard on May 27, 2018 8:58, edited 5 times in total.
dodicat
Posts: 5024
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Astro.com astronomical / astrological calculations

Postby dodicat » May 25, 2018 20:36

Hour angle (Sidereal or Greenwich or local) and declination of a body are measured along and above/below the equinoctial.
Celestial latitude and longitude are measured from the ecliptic.
I think perhaps Celestial latitude and longitude are used more in astrology.

Thanks, I got the next eclipse

Code: Select all

 Today is 25.5.2018
Next total eclipse is on

Longitude : 109░ 0' 10'' W
Latitude  : 17░ 24' 4'' S

at 2. 7. 2019 19h 23m

As you can see, my console codepage gets the degree symbol wrong.
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Postby lizard » May 25, 2018 20:51

Thanks for your interest! Tried for hours, but could get it not working on Windows 32. But it worked last year.
coderJeff
Site Admin
Posts: 2614
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Astro.com astronomical / astrological calculations

Postby coderJeff » May 26, 2018 22:25

You can view the sky from earth and other planets. Free, open source, hosted on sourceforge.net. I'm no astronomer, but I enjoyed this software:
http://stellarium.org/
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Astro.com astronomical / astrological calculations

Postby lizard » May 27, 2018 5:35

Thanks coderJeff!

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest