Changeset 1947
- Timestamp:
- 11/10/10 14:48:15 (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r1938 r1947 725 725 return outvec 726 726 727 def _get_column(self, callback, row=-1 ):727 def _get_column(self, callback, row=-1, *args): 728 728 """ 729 729 """ 730 730 if row == -1: 731 return [callback(i ) for i in range(self.nrow())]731 return [callback(i, *args) for i in range(self.nrow())] 732 732 else: 733 733 if 0 <= row < self.nrow(): 734 return callback(row )735 736 737 def get_time(self, row=-1, asdatetime=False ):734 return callback(row, *args) 735 736 737 def get_time(self, row=-1, asdatetime=False, prec=0): 738 738 """\ 739 739 Get a list of time stamps for the observations. … … 747 747 asdatetime: return values as datetime objects rather than strings 748 748 749 """ 750 from time import strptime 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, 752 and 6> : with hh:mm:ss.tt... (prec-6 t's added) 753 754 """ 755 #from time import strptime 751 756 from datetime import datetime 752 times = self._get_column(self._gettime, row )757 times = self._get_column(self._gettime, row, prec) 753 758 if not asdatetime: 754 759 return times 755 format = "%Y/%m/%d/%H:%M:%S" 760 #format = "%Y/%m/%d/%H:%M:%S" 761 format = "%Y/%m/%d/%H:%M:%S.%f" 762 if prec < 7: 763 nsub = 1 + (((6-prec)/2) % 3) 764 substr = [".%f","%S","%M"] 765 for i in range(nsub): 766 format = format.replace(substr[i],"") 756 767 if isinstance(times, list): 757 return [datetime(*strptime(i, format)[:6]) for i in times] 758 else: 759 return datetime(*strptime(times, format)[:6]) 768 #return [datetime(*strptime(i, format)[:6]) for i in times] 769 return [datetime.strptime(i, format) for i in times] 770 else: 771 #return datetime(*strptime(times, format)[:6]) 772 return datetime.strptime(times, format) 760 773 761 774 -
trunk/src/Scantable.cpp
r1931 r1947 684 684 std::string Scantable::formatTime(const MEpoch& me, bool showdate) const 685 685 { 686 return formatTime(me, showdate, 0); 687 } 688 689 std::string Scantable::formatTime(const MEpoch& me, bool showdate, uInt prec) const 690 { 686 691 MVTime mvt(me.getValue()); 687 692 if (showdate) 688 mvt.setFormat(MVTime::YMD); 693 //mvt.setFormat(MVTime::YMD); 694 mvt.setFormat(MVTime::YMD, prec); 689 695 else 690 mvt.setFormat(MVTime::TIME); 696 //mvt.setFormat(MVTime::TIME); 697 mvt.setFormat(MVTime::TIME, prec); 691 698 ostringstream oss; 692 699 oss << mvt; … … 1035 1042 } 1036 1043 1037 std::string Scantable::getTime(int whichrow, bool showdate) const 1038 { 1039 MEpoch::ROScalarColumn timeCol(table_, "TIME"); 1044 // std::string Scantable::getTime(int whichrow, bool showdate) const 1045 // { 1046 // MEpoch::ROScalarColumn timeCol(table_, "TIME"); 1047 // MEpoch me; 1048 // if (whichrow > -1) { 1049 // me = timeCol(uInt(whichrow)); 1050 // } else { 1051 // Double tm; 1052 // table_.keywordSet().get("UTC",tm); 1053 // me = MEpoch(MVEpoch(tm)); 1054 // } 1055 // return formatTime(me, showdate); 1056 // } 1057 1058 std::string Scantable::getTime(int whichrow, bool showdate, uInt prec) const 1059 { 1040 1060 MEpoch me; 1041 if (whichrow > -1) { 1042 me = timeCol(uInt(whichrow)); 1043 } else { 1044 Double tm; 1045 table_.keywordSet().get("UTC",tm); 1046 me = MEpoch(MVEpoch(tm)); 1047 } 1048 return formatTime(me, showdate); 1061 me = getEpoch(whichrow); 1062 return formatTime(me, showdate, prec); 1049 1063 } 1050 1064 -
trunk/src/Scantable.h
r1931 r1947 368 368 369 369 std::string summary(bool verbose=false); 370 std::string getTime(int whichrow=-1, bool showdate=true) const; 370 //std::string getTime(int whichrow=-1, bool showdate=true) const; 371 std::string getTime(int whichrow=-1, bool showdate=true, casa::uInt prec=0) const; 371 372 double getIntTime(int whichrow) const { return integrCol_(whichrow); } 372 373 … … 505 506 506 507 std::string formatTime(const casa::MEpoch& me, bool showdate)const; 508 std::string formatTime(const casa::MEpoch& me, bool showdate, casa::uInt prec)const; 507 509 508 510 /** -
trunk/src/ScantableWrapper.h
r1931 r1947 84 84 { return table_->getTsys(whichrow); } 85 85 86 std::string getTime(int whichrow=0) const 87 { return table_->getTime(whichrow); } 86 //std::string getTime(int whichrow=0) const 87 // { return table_->getTime(whichrow); } 88 std::string getTime(int whichrow=0, int prec = 0) const 89 { return table_->getTime(whichrow, true, casa::uInt(prec)); } 88 90 89 91 double getIntTime(int whichrow=0) const -
trunk/src/python_Scantable.cpp
r1908 r1947 99 99 .def("_getparangle", &ScantableWrapper::getParAngle, 100 100 (boost::python::arg("whichrow")=0) ) 101 //.def("_gettime", &ScantableWrapper::getTime, 102 // (boost::python::arg("whichrow")=0) ) 101 103 .def("_gettime", &ScantableWrapper::getTime, 102 (boost::python::arg("whichrow")=0) ) 104 (boost::python::arg("whichrow")=0, 105 boost::python::arg("prec")=0) ) 103 106 .def("_getinttime", &ScantableWrapper::getIntTime, 104 107 (boost::python::arg("whichrow")=0) )
Note:
See TracChangeset
for help on using the changeset viewer.