casatasks/src/private/flaghelper.py

Modified
425 425 tbuff0 = tbuff[0]
426 426 tbuff1 = tbuff[1]
427 427 elif isinstance(tbuff, list) and len(tbuff) == 1:
428 428 tbuff0 = tbuff1 = tbuff[0]
429 429 elif isinstance(tbuff, float):
430 430 tbuff0 = tbuff1 = tbuff
431 431 else:
432 432 casalog.post('Time buffer (tbuff) is not of type float or list', 'WARN')
433 433 return
434 434
435 + def get_date_format(timestamp):
436 + '''Guess date-time string format to use in quanta tool time conversion,
437 + depending on whether the date seems to be present (as in
438 + 2013/11/15/10:35:05)
439 + '''
440 + if timestamp.count('/') >= 3:
441 + return 'ymd'
442 + else:
443 + return ''
444 +
435 445 for cmddict in alist:
436 446 if 'timerange' in cmddict:
437 447 timerange = cmddict['timerange']
438 448 if timerange.find('~') != -1:
439 - t0,t1 = timerange.split('~',1)
440 - date_included = timerange.count('/') >= 3
441 - if date_included:
442 - date_format = 'ymd'
443 - else:
444 - date_format = ''
449 + t0, t1 = timerange.split('~',1)
450 + date_time_format_t0 = get_date_format(t0)
451 + date_time_format_t1 = get_date_format(t1)
445 452
446 453 # start time
447 454 startTime = qalocal.totime(t0)['value']
448 455 startTimeSec = (startTime * 24 * 3600) - tbuff0
449 456 startTimeSec = qalocal.quantity(startTimeSec, 's')
450 - paddedT0 = qalocal.time(startTimeSec, form=date_format, prec=9)[0]
457 + paddedT0 = qalocal.time(startTimeSec, form=date_time_format_t0, prec=9)[0]
451 458 # end time
452 459 endTime = qalocal.totime(t1)['value']
453 460 endTimeSec = (endTime * 24 * 3600) + tbuff1
454 461 endTimeSec = qalocal.quantity(endTimeSec, 's')
455 - paddedT1 = qalocal.time(endTimeSec, form=date_format, prec=9)[0]
462 + paddedT1 = qalocal.time(endTimeSec, form=date_time_format_t1, prec=9)[0]
456 463
457 464 # update the original dictionary
458 465 cmddict['timerange'] = paddedT0+'~'+paddedT1
459 466
460 467 return
461 468
462 469 def parseDictionary(cmdlist, reason='any', shadow=True):
463 470 '''Create a dictionary after parsing a list of flag commands.
464 471 If reason is different than 'any', only the selected
465 472 rows will be parsed to the final dictionary.

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut