Astronomy

Converting Julian date to calendar date (Astronomy With Your Personal Computer)

Part 3 of converting the code in Astronomy With Your Personal Computer Last time we had a method for converting a calendar date to Julian, so here's the reverse. Notice that it calls the previous MinSec.DecimalToDegMinSec() method to convert the decimal portion to hours/minutes/seconds: public static DateTime ConvertDay(double DJ) { double D = DJ + 0.5; int I = (int)Math.Floor(D); double FD = D - I; if (FD == 1) { FD = 0; I += 1; } if (I > -115860) { int A = (int)Math.Floor((I / 36524.25) + .99835726) ......

Converting calendar date to Julian (Astronomy With Your Personal Computer)

Part 2 of converting the code in Astronomy With Your Personal Computer Astronomers frequently need to do arithmetic with dates, and rather than attempting to count the days in each month, it's far easier to simply convert the dates to Julian day numbers and just add or subtract. A while back I wrote a post on how to do this, but this method is slightly different - the subroutine in the book returns the number of days since 1900 January 0.5 (rather than the actual Julian date) due to the low-precision ......

Converting decimal degrees to degrees/minutes/seconds (Astronomy With Your Personal Computer)

Part 1 of my attempt at converting the code in Astronomy With Your Personal Computer. MINSEC - converting decimal degrees/hours into degrees/hours, minutes, and seconds (and vice-versa). Most astronomy calculations are going to be expressed as degrees, minutes and seconds of arc, but computers need to work in decimal degrees. These methods will allow you to convert from one to the other and back. To convert from decimal to degrees/minutes/seconds: The whole units of degrees will remain the same (i.e. ......

Determining Julian Date in C# or Java / Android

The two code blocks below will calculate the Julian date from a standard calendar date/time. Note that they assume you're passing UT time rather than time that's been offset for your local timezone. The formula used is based on the one in Jean Meeus' Astronomical Algorithms. You may want to add some rounding to the output to limit the number of digits after the decimal point, depending on what precision you can live with. For 5/13/2011 at 14:30:00, the Android version returns 2455695.1041666665; ......

Updating the book Astronomy With Your Personal Computer

Way back in the dark ages (1985 or so) there was a book title Astronomy With Your Personal Computer by Peter Duffett-Smith. This book provided BASIC routines for various astonomical calculations: date/time conversions, planetary location, eclipse information, etc. Some of the calculations would be handy for some mobile apps I'm working on, so I decided to look into converting the code to C#. Just looking at a few lines of the sample programs in the book, it becomes quickly obvious that simply converting ......