def asdatestring(mjd, digit, timeonly=False): datedict = qa.splitdate(qa.quantity(mjd, 'd')) if digit > 10 : digit = 10 sstr_tmp = str(numpy.round(datedict['s'], digit)).split('.') sstr = sstr_tmp[0] + '.' + sstr_tmp[1][0:digit] if timeonly: return '%s:%s:%s'%(datedict['hour'],datedict['min'],sstr) else: return '%s/%s/%s/%s:%s:%s'%(datedict['year'],datedict['month'],datedict['monthday'],datedict['hour'],datedict['min'],sstr)
def mepoch_to_str(mepoch, showdate=True, showtime=True, showmjd=True): """ Given an epoch as a measure, return it as a nicely formatted string. """ tdic = qa.splitdate(mepoch['m0']) fmt = "" if showdate: fmt += '%(year)d-%(month)02d-%(monthday)02d' if showtime: if fmt: fmt += '/' fmt += '%(hour)02d:%(min)02d:%(sec)02d %(tz)s' tdic['tz'] = mepoch['refer'] if showmjd: islast = False if fmt: fmt += ' (' islast = True fmt += 'MJD %(mjd).2f' if islast: fmt += ')' return fmt % tdic