[Scipy-svn] r2825 - trunk/Lib/sandbox/timeseries

scipy-svn@scip... scipy-svn@scip...
Mon Mar 5 16:00:11 CST 2007


Author: mattknox_ca
Date: 2007-03-05 16:00:08 -0600 (Mon, 05 Mar 2007)
New Revision: 2825

Modified:
   trunk/Lib/sandbox/timeseries/tcore.py
Log:
added support for extra weekly frequencies

Modified: trunk/Lib/sandbox/timeseries/tcore.py
===================================================================
--- trunk/Lib/sandbox/timeseries/tcore.py	2007-03-05 21:59:19 UTC (rev 2824)
+++ trunk/Lib/sandbox/timeseries/tcore.py	2007-03-05 22:00:08 UTC (rev 2825)
@@ -88,12 +88,25 @@
     else:
         raise ValueError("Invalid value for observed attribute: %s " % str(obStr))
 
+_weekly_prefixes = ['W','WEEK','WEEKLY']
+_week_end_map = {
+    FR_WKSUN:'SUNDAY',
+    FR_WKSAT:'SATURDAY',
+    FR_WKFRI:'FRIDAY',
+    FR_WKTHU:'THURSDAY',
+    FR_WKWED:'WEDNESDAY',
+    FR_WKTUE:'TUESDAY',
+    FR_WKMON:'MONDAY'}
 
+def _gen_weekly_strs(day):
+    result = []
+    for pr in _weekly_prefixes:
+        result += [pr+'-'+day_str for day_str in (day[:3], day)]
+    return result
 
 freq_dict = { FR_ANN: ['A','Y','ANNUAL','ANNUALLY','YEAR','YEARLY'],
               FR_QTR: ['Q','QUARTER','QUARTERLY',],
               FR_MTH: ['M','MONTH','MONTHLY',],
-              FR_WK: ['W','WEEK','WEEKLY',],
               FR_BUS: ['B','BUSINESS','BUSINESSLY'],
               FR_DAY: ['D','DAY','DAILY',],
               FR_HR: ['H','HOUR','HOURLY',],
@@ -101,6 +114,11 @@
               FR_SEC: ['S','SECOND','SECONDLY',],
               FR_UND: ['U','UNDEF','UNDEFINED'],
                 }
+                
+for _freq, day_str in _week_end_map.iteritems():
+    freq_dict[_freq] = _gen_weekly_strs(day_str)
+freq_dict[FR_WK] += _weekly_prefixes
+    
 freq_revdict = reverse_dict(freq_dict)
 
 def freq_fromstr(freq_asstr):



More information about the Scipy-svn mailing list