Stephane Raynaud wrote:
> Hi,
> 
> date2num and num2date perform conversion between datetime and 'days
> since 0001-01-01' and vice versa.
> For such task, they strictly use ordinal dates for their numeric days,
> 1 meaning  '0001-01-01' by definition.
> Thus, date2num(datetime.datetime(1,1,1,0,0,0)) return 1. which is
> supposed to mean '1 days since 0001', which is wrong (because it
> points to datetime.datetime(1,1,2,0,0,0)).
> 
> Since year zero cannot be used (here for time units) because it
> doesn't exist, don't you think that the ordinal date
> (datetime.datetime(1,1,2,0,0,0).tordinal()) should not be strictly
> used as a reference numeric time, but its value-1?

Stephane, yes, what you say makes sense.  Long ago I settled on a 
convention of using "decimal days" referenced to the start of a 
"yearbase" for time calculations and for plotting variables against 
time.  So if the yearbase is 2008, then noon on January 1 of 2008 is 
0.5.  The more common convention in oceanography, though, was to label 
days of the year with a 1-based count and then add the fraction of the 
day, so what is 0.5 to me is 1.5 to many others.  In this case, where 
the time scale origin (the start of the yearbase) might be in the middle 
of one's time series, the decimal day definition is clearly superior (at 
least to me).  But in the case of the matplotlib dates module the 
distinction is less important, because the origin is quite arbitrary and 
will almost always be far smaller than the minimum of the range plotted. 
  The datenum is mainly useful for calculations, not for direct display. 
Note that the datetime module (and therefore mpl.dates) simply doesn't 
work for BC dates.

Personally, I would be perfectly happy to implement your suggestion so 
that the reality would correspond to the dates module docstring; but 
maybe this would break some user code, so others might prefer to modify 
the docstring to reflect the present behavior instead.

John, I suspect you wrote the dates module and use it heavily--what do 
you think about the two methods of bringing the docstring and the 
behavior into alignment?  Any problem with fixing the behavior?

Eric

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to