Bug in julian2num()/num2julian()?

Hi

I think there is a bug in the conversion routines jul2num() and num2jul(). I
tried to define a date axis for satellite data. The time is measured in a
modified Julian Date (JD). So reading in the data and then doing

mp = julian2num(jd)
dates = num2date(mp)

resulted in an error "year out of range" (or so). I looked at the values and
they were way to high. Inspection of the source date.py showed for the
conversion routines

julian2num: j + 1721425.5
num2julian: j - 1721425.5

Since the JD measures days from 4713 BC - earlier than the matplotlib
zeropoint - the conversion should be the other way round, i.e. for julian2num
we should subtract.

After correcting this, I could still not reconcile my measurement dates with
the result of num2date(). In the source it is stated that counting starts at
0001-01-01 00:00:00 UTC (JD 1721423.5), which BTW does not match the number
used in the routines. The only way to correct this was to use an offset of JD
1721424.5 (January 2nd, 0001, 00:00:00).

So the correct formulae should be

julian2num: j - 1721424.5
num2julian: j + 1721424.5

or am I missing something?

VERSION INFO: matplotlib V. 0.99.1.1/python 2.6.2

on opensuse 11.2/x86_64

Cheers
gl

···

--
Günter Lichtenberg

2010/3/4 Günter Lichtenberg <Guenter.Lichtenberg@...820...>:

Hi

I think there is a bug in the conversion routines jul2num() and num2jul(). I
tried to define a date axis for satellite data. The time is measured in a
modified Julian Date (JD). So reading in the data and then doing

Hi Günter,

Thanks for digging into this. Could you file a report on the bug tracker

Thanks,
JDH

Done under

2963391 Wrong conversion in julian2num/num2julian

gl

···

On Thursday 04 March 2010 14:20:41 you wrote:

2010/3/4 Günter Lichtenberg <Guenter.Lichtenberg@...820...>:
> Hi
>
> I think there is a bug in the conversion routines jul2num() and
> num2jul(). I tried to define a date axis for satellite data. The time is
> measured in a modified Julian Date (JD). So reading in the data and then
> doing

Hi Günter,

Thanks for digging into this. Could you file a report on the bug tracker

--
Dr. Günter Lichtenberg
Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR)
Institut für Methodik der Fernerkundung (MF-AP)
82234 Weßling
Tel. +49-8153-28-1331
Fax +49-8153-28-1446
Guenter.Lichtenberg@...820...

Günter Lichtenberg wrote:

···

On Thursday 04 March 2010 14:20:41 you wrote:

2010/3/4 Günter Lichtenberg <Guenter.Lichtenberg@...820...>:

Hi

I think there is a bug in the conversion routines jul2num() and
num2jul(). I tried to define a date axis for satellite data. The time is
measured in a modified Julian Date (JD). So reading in the data and then
doing

Hi Günter,

Thanks for digging into this. Could you file a report on the bug tracker

Done under

2963391 Wrong conversion in julian2num/num2julian

gl

Thanks. Fixed in 8181 (branch) and 8182 (trunk).

Eric