DavidArmstrong / SiderealPlanets

General Astronomy library for advanced Arduino platforms
MIT License
11 stars 2 forks source link

Rise and set time for planets are wrong #11

Open JohnnyJagatpal opened 1 year ago

JohnnyJagatpal commented 1 year ago

Hi,

I just figured out that there seems to be an issue with the rise and set time for the planets Venus, Mars etc.

While you library outputs this:

Body Name: Moon Rise Time: 14/11/2023 6:06:37 Set Time: 14/11/2023 14:50:45 Body Name: Mercury Rise Time: 14/11/2023 6:19:23 Set Time: 14/11/2023 14:44:39 Body Name: Venus Rise Time: 14/11/2023 6:24:54 Set Time: 14/11/2023 15:00:56 Body Name: Mars Rise Time: 14/11/2023 1:00:14 Set Time: 14/11/2023 12:48:30 Body Name: Jupiter Rise Time: 14/11/2023 5:07:52 Set Time: 14/11/2023 14:29:31 Body Name: Saturn Rise Time: 14/11/2023 14:00:38 Set Time: 14/11/2023 3:50:43 Body Name: Uranus Rise Time: 14/11/2023 11:32:51 Set Time: 14/11/2023 21:45:35 Body Name: Neptune Rise Time: 14/11/2023 14:26:40 Set Time: 14/11/2023 4:57:09

online resources show these times (Rise,Transit,Set):

image e.g: http://www.geoastro.de/smp/ but I also checked others.

Assuming there are small deviations, because I only did the bare minimum to test, it appears that Venus should have times from Mars, Mars from Jupiter, etc. In this example I used UTC +1 and lat 45 long 45.

Could you check that? Otherwise, great library! Thank you!

DavidArmstrong commented 1 year ago

Hi, I've been looking over my code, both examples and source, to see if there was something obvious that was missing. However, I don't have your source code to review with that. I'll admit that sometimes my documentation may lack an important detail on how to use a function, which is why I include examples to show how the various functions work together. In this case, besides the normal setup for date, time, latitude, longitude, time zone, etc. the calling sequence to be used for showing planet rise/set times should be, as an example:

myAstro.doVenus(); myAstro.doRAdec2AltAz(); if (myAstro.doRiseSetTimes(0.)) { printTime(myAstro.getRiseTime()); printTime(myAstro.getSetTime()); } else { Serial.print("No rise/set times"); } Serial.println("");

Again, since I don't have your code to check, it's unknown to me whether these calls are being done in this order,, or if there is some other intervening call that is interfering with this sequence.

Dave

On Tue, Nov 14, 2023 at 12:32 PM JohnnyJagatpal @.***> wrote:

Hi,

I just figured out that there seems to be an issue with the rise and set time for the planets Venus, Mars etc.

While you library outputs this:

Rise Time: 14/11/2023 6:06:37 Set Time: 14/11/2023 14:50:45 Body Name: Mercury Rise Time: 14/11/2023 6:19:23 Set Time: 14/11/2023 14:44:39 Body Name: Venus Rise Time: 14/11/2023 6:24:54 Set Time: 14/11/2023 15:00:56 Body Name: Mars Rise Time: 14/11/2023 1:00:14 Set Time: 14/11/2023 12:48:30 Body Name: Jupiter Rise Time: 14/11/2023 5:07:52 Set Time: 14/11/2023 14:29:31 Body Name: Saturn Rise Time: 14/11/2023 14:00:38 Set Time: 14/11/2023 3:50:43 Body Name: Uranus Rise Time: 14/11/2023 11:32:51 Set Time: 14/11/2023 21:45:35 Body Name: Neptune Rise Time: 14/11/2023 14:26:40 Set Time: 14/11/2023 4:57:09

online resources show these times:

[image: image] https://user-images.githubusercontent.com/59693248/282915627-070c5675-ef2d-491a-b1b7-b153ec23f3aa.png e.g: http://www.geoastro.de/smp/ but I also checked others.

Assuming there are small deviations, because I only did the bare minimum to test, it appears that Venus should have times from Mars, Mars from Jupiter, etc. In this example I used UTC +1 and lat 45 long 45.

Could you check that? Otherwise, great library! Thank you!

— Reply to this email directly, view it on GitHub https://github.com/DavidArmstrong/SiderealPlanets/issues/11, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACGQKOWASWU4VOT5SCTYE3YEPIM5AVCNFSM6AAAAAA7LNEDBKVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE4TGNJSGA2TONA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

DavidArmstrong commented 1 year ago

Here is a sample sketch that I wrote using the current library to output rise/set times that match up fairly closely with what you have:

/* Sidereal Planets Library - modified sample sketch

include

// Need the following define for SAMD processors

if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)

define Serial SERIAL_PORT_USBVIRTUAL

endif

SiderealPlanets myAstro; double ra,dec;

void setup() { Serial.begin(9600); delay(2000); //SAMD boards may need a long time to init SerialUSB Serial.println("\nSidereal Planets Functions"); myAstro.begin(); Serial.println("\nBecause these calculations are dependent on both time and location,"); Serial.println("those values have to be set first."); Serial.println("We can use the decimalDegrees() function to make this easier."); Serial.println("We define:"); Serial.println("DST off, time zone = +1"); Serial.println("GMT date: Nov 14, 2023 GMT Time: 00:00:00\n"); myAstro.setLatLong(myAstro.decimalDegrees(45,0,0), myAstro.decimalDegrees(45,0,0)); myAstro.setTimeZone(1); myAstro.rejectDST(); myAstro.setGMTdate(2023,11,14); myAstro.setGMTtime(0,0,0);

Serial.print("Sun: "); myAstro.doSun(); myAstro.doRAdec2AltAz(); ra = myAstro.getRAdec(); dec = myAstro.getDeclinationDec(); if (myAstro.doSunRiseSetTimes()) { printTime(myAstro.getSunriseTime()); printTime(myAstro.getSetTime()); } else { Serial.print("No rise/set times "); } printDegMinSecs2(ra); Serial.print(" "); printDegMinSecs2(dec); Serial.println("");

Serial.print("Moon: "); myAstro.doMoon(); myAstro.doRAdec2AltAz(); ra = myAstro.getRAdec(); dec = myAstro.getDeclinationDec(); if (myAstro.doMoonRiseSetTimes()) { printTime(myAstro.getMoonriseTime()); printTime(myAstro.getMoonsetTime()); } else { Serial.print("No rise/set times "); } printDegMinSecs2(ra); Serial.print(" "); printDegMinSecs2(dec); Serial.println("");

Serial.print("Mercury: "); myAstro.doMercury(); myAstro.doRAdec2AltAz(); ra = myAstro.getRAdec(); dec = myAstro.getDeclinationDec(); if (myAstro.doRiseSetTimes(0.)) { printTime(myAstro.getRiseTime()); printTime(myAstro.getSetTime()); } else { Serial.print("No rise/set times "); } printDegMinSecs2(ra); Serial.print(" "); printDegMinSecs2(dec); Serial.println("");

Serial.print("Venus: "); myAstro.doVenus(); myAstro.doRAdec2AltAz(); ra = myAstro.getRAdec(); dec = myAstro.getDeclinationDec(); if (myAstro.doRiseSetTimes(0.)) { printTime(myAstro.getRiseTime()); printTime(myAstro.getSetTime()); } else { Serial.print("No rise/set times "); } printDegMinSecs2(ra); Serial.print(" "); printDegMinSecs2(dec); Serial.println("");

Serial.print("Mars: "); myAstro.doMars(); myAstro.doRAdec2AltAz(); ra = myAstro.getRAdec(); dec = myAstro.getDeclinationDec(); if (myAstro.doRiseSetTimes(0.)) { printTime(myAstro.getRiseTime()); printTime(myAstro.getSetTime()); } else { Serial.print("No rise/set times "); } printDegMinSecs2(ra); Serial.print(" "); printDegMinSecs2(dec); Serial.println("");

Serial.print("Jupiter: "); myAstro.doJupiter(); myAstro.doRAdec2AltAz(); ra = myAstro.getRAdec(); dec = myAstro.getDeclinationDec(); if (myAstro.doRiseSetTimes(0.)) { printTime(myAstro.getRiseTime()); printTime(myAstro.getSetTime()); } else { Serial.print("No rise/set times "); } printDegMinSecs2(ra); Serial.print(" "); printDegMinSecs2(dec); Serial.println("");

Serial.print("Saturn: "); myAstro.doSaturn(); myAstro.doRAdec2AltAz(); ra = myAstro.getRAdec(); dec = myAstro.getDeclinationDec(); if (myAstro.doRiseSetTimes(0.)) { printTime(myAstro.getRiseTime()); printTime(myAstro.getSetTime()); } else { Serial.print("No rise/set times "); } printDegMinSecs2(ra); Serial.print(" "); printDegMinSecs2(dec); Serial.println("");

Serial.print("Uranus: "); myAstro.doUranus(); myAstro.doRAdec2AltAz(); ra = myAstro.getRAdec(); dec = myAstro.getDeclinationDec(); if (myAstro.doRiseSetTimes(0.)) { printTime(myAstro.getRiseTime()); printTime(myAstro.getSetTime()); } else { Serial.print("No rise/set times "); } printDegMinSecs2(ra); Serial.print(" "); printDegMinSecs2(dec); Serial.println("");

Serial.print("Neptune: "); myAstro.doNeptune(); myAstro.doRAdec2AltAz(); ra = myAstro.getRAdec(); dec = myAstro.getDeclinationDec(); if (myAstro.doRiseSetTimes(0.)) { printTime(myAstro.getRiseTime()); printTime(myAstro.getSetTime()); } else { Serial.print("No rise/set times "); } printDegMinSecs2(ra); Serial.print(" "); printDegMinSecs2(dec); Serial.println(""); }

void loop() { while(1); //Freeze }

void printTime(double n) { boolean sign = (n < 0.); if (sign) n = -n; long lsec = n 3600.0; long deg = lsec / 3600; long min = (lsec - (deg 3600)) / 60; float secs = (lsec - (deg 3600) - (min 60)); if (sign) Serial.print("-"); print2digitsUSB(deg); Serial.print(":"); print2digitsUSB(min); Serial.print(":"); print2digitsUSB(abs(secs)); Serial.print(" "); }

void print2digitsUSB(int number) { if (number < 10) { Serial.print("0"); } Serial.print(number); }

void printDegMinSecs2(double n) { boolean sign = false; if (n < 0.) { n = -n; sign = true; } long lsec = n 3600.0; long deg = lsec / 3600; long min = (lsec - (deg 3600)) / 60; long secs = (lsec - (deg 3600) - (min 60)); if (sign) Serial.print("-"); Serial.print(deg); Serial.print(":"); print2digitsUSB(min); Serial.print(":"); print2digitsUSB(secs); Serial.print(" "); }