Skip to main content

still problem with JD algorithm

6 posts / 0 new
Last post
pox
pox's picture
still problem with JD algorithm

Hi,

Thought I'd cracked this, but obviously not!

While reporting my obs 2 nights ago using the charting/reporting tool I have written, the JD was 1 day too late, and I have also had a reply to the same effect by my one and only user so far. Here is what I am using (VB6) which comes from this forum ex Meeus, with small changes - I don't need negative dates for obvious reasons! Below gives just the julian day - the decimal of the time is added to the result.

Public Function julian(Y As Integer, m As Integer, d As Integer) As Long
Dim a As Integer, b As Integer
a = Int(Y / 100)
b = 2 - a + Int(a / 4)
If m > 2 Then
'do nothing
Else
Y = Y - 1
m = m + 12
End If
julian = Int(365.25 * (Y + 4716)) + Int(30.6001 * (m + 1)) + d + b - 1524.5
End Function

David Benn
David Benn's picture
Comparison

Happy to compare notes with my implementation. Looks very much the same as:

https://sourceforge.net/p/vstar/code/HEAD/tree/trunk/src/org/aavso/tools/vstar/util/date/MeeusDateUtil.java

https://sourceforge.net/p/vstar/code/HEAD/tree/trunk/test/org/aavso/tools/vstar/util/date/DateUtilTestBase.java

If you want to compare results of specific date tests, let me know.

David

pox
pox's picture
Thanks David, looks as though

Thanks David, looks as though you include the day (decimal and all) as one of the parameters, whereas I add it on after the 'integer' JD (without decimal) has been returned. Could be that's what is giving me the wrong result, so I shall give that a try. Many thanks.

David Benn
David Benn's picture
Day

Hi Michael

Yep, that makes sense. When I looked quickly at your code above I didn't notice the integer type for day in your function's parameter list. As you say, mine is of a real type:

public double calendarToJD(int year, int month, double day)

...

David

pox
pox's picture
Hi David,

Hi David,

Yes, that did it! Just ran the new code and everything correct to 4 dp. Cheers!

David Benn
David Benn's picture
Nice

Glad to help Michael.

David

Log in to post comments
AAVSO 49 Bay State Rd. Cambridge, MA 02138 aavso@aavso.org 617-354-0484