| SVMOP:Projects: From and To python datetime objects an UNIX time 02/03/2009 21:29 | |||||
|
from http://seehuhn.de/pages/pdate Conversion between Unix times and datetimeTo convert a Unix time stamp to datetime use the fromtimestamp constructor: >>> from datetime import datetime >>> datetime.fromtimestamp(1172969203.1) datetime.datetime(2007, 3, 4, 0, 46, 43, 100000)To convert a datetime object into a Unix time stamp, one has to first convert it into a struct_time: >>> from datetime import datetime >>> from time import mktime >>> t=datetime.now() >>> mktime(t.timetuple())+1e-6*t.microsecond 1172970859.472672 My example: In [26]: d1 = datetime.datetime.now() In [27]: d1 Out[27]: datetime.datetime(2009, 2, 3, 21, 25, 4, 588232) In [28]: time.time() Out[28]: 1233714322.753165 In [29]: time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond Out[29]: 1233714304.588232 In [30]: |
|||||
| SVMOP:Projects: First task = Interpolating while converting 02/03/2009 13:51 | |||||
|
My simplistic interpolation scheme was to count the number of
contiguous bad source data lines and interpolate that many
points over the gap. I got what I planned, but more often than not,
the bad source spans many more sample points than bad lines caught.
Now it looks as though I need to do a little analysis on the incoming data to find an average sample rate, and find any spans that are above +/- 1 second of that rate. Then interpolate over the gap, and sample the interpolation at the computed sample interval. |
|||||