Eric Firing wrote: > 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 > > Eric:
There are alternate versions num2date and a date2num in basemap that handle arbitrary calendars (not just 'proleptic gregorian') and arbitrary reference times (not just 'days since 0001-01-01 00:00:00'). The docstrings are at http://matplotlib.sourceforge.net/mpl_toolkits.basemap.basemap.html, down near the bottom of the page. I don't know if this addresses the problem you're talking about though... -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : [EMAIL PROTECTED] 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel