Changeset 1948 for trunk/python
- Timestamp:
- 11/10/10 16:16:23 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r1947 r1948 2 2 3 3 import os 4 import numpy 4 5 try: 5 6 from functools import wraps as wraps_dec … … 735 736 736 737 737 def get_time(self, row=-1, asdatetime=False, prec= 0):738 def get_time(self, row=-1, asdatetime=False, prec=-1): 738 739 """\ 739 740 Get a list of time stamps for the observations. … … 747 748 asdatetime: return values as datetime objects rather than strings 748 749 749 prec: number of digits shown. Note this number is equals to 750 the digits of MVTime, i.e., 0<prec<3: dates with hh:: 751 only, <5: with hh:mm:, <7 or 0: with hh:mm:ss, 750 prec: number of digits shown. Default -1 to automatic calculation. 751 Note this number is equals to the digits of MVTime, 752 i.e., 0<prec<3: dates with hh:: only, 753 <5: with hh:mm:, <7 or 0: with hh:mm:ss, 752 754 and 6> : with hh:mm:ss.tt... (prec-6 t's added) 753 755 754 756 """ 755 #from time import strptime756 757 from datetime import datetime 758 if prec < 0: 759 # automagically set necessary precision +1 760 prec = 7 - numpy.floor(numpy.log10(min(self.get_inttime()))) 761 prec = max(6, int(prec)) 762 else: 763 prec = max(0, prec) 764 if asdatetime: 765 #precision can be 1 millisecond at max 766 prec = min(12, prec) 767 757 768 times = self._get_column(self._gettime, row, prec) 758 769 if not asdatetime: 759 770 return times 760 #format = "%Y/%m/%d/%H:%M:%S"761 771 format = "%Y/%m/%d/%H:%M:%S.%f" 762 772 if prec < 7: … … 766 776 format = format.replace(substr[i],"") 767 777 if isinstance(times, list): 768 #return [datetime(*strptime(i, format)[:6]) for i in times]769 778 return [datetime.strptime(i, format) for i in times] 770 779 else: 771 #return datetime(*strptime(times, format)[:6])772 780 return datetime.strptime(times, format) 773 781
Note:
See TracChangeset
for help on using the changeset viewer.