Changeset 1948


Ignore:
Timestamp:
11/10/10 16:16:23 (14 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: changed default value of prec=-1 in scantable.get_time

Test Programs:

Put in Release Notes: No

Module(s):

Description:

Chenged the default value of parameter prec=-1 in scantable.get_time.
When prec=-1, necessary time precision is automatically calculated based on
minimum integration time in the scantable.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r1947 r1948  
    22
    33import os
     4import numpy
    45try:
    56    from functools import wraps as wraps_dec
     
    735736
    736737
    737     def get_time(self, row=-1, asdatetime=False, prec=0):
     738    def get_time(self, row=-1, asdatetime=False, prec=-1):
    738739        """\
    739740        Get a list of time stamps for the observations.
     
    747748            asdatetime:   return values as datetime objects rather than strings
    748749
    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,
    752754                          and 6> : with hh:mm:ss.tt... (prec-6 t's added)
    753755
    754756        """
    755         #from time import strptime
    756757        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
    757768        times = self._get_column(self._gettime, row, prec)
    758769        if not asdatetime:
    759770            return times
    760         #format = "%Y/%m/%d/%H:%M:%S"
    761771        format = "%Y/%m/%d/%H:%M:%S.%f"
    762772        if prec < 7:
     
    766776                format = format.replace(substr[i],"")
    767777        if isinstance(times, list):
    768             #return [datetime(*strptime(i, format)[:6]) for i in times]
    769778            return [datetime.strptime(i, format) for i in times]
    770779        else:
    771             #return datetime(*strptime(times, format)[:6])
    772780            return datetime.strptime(times, format)
    773781
Note: See TracChangeset for help on using the changeset viewer.