本文整理汇总了Python中models.Channel.range_unit方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.range_unit方法的具体用法?Python Channel.range_unit怎么用?Python Channel.range_unit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Channel
的用法示例。
在下文中一共展示了Channel.range_unit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import range_unit [as 别名]
def create(source, generator=sws.Diver()):
''' create sourcefile instance for monfile '''
headerdict = generator.get_header(source)
mon = MonFile()
header = headerdict['HEADER']
mon.company = header.get('COMPANY',None)
mon.compstat = header.get('COMP.STATUS',None)
if 'DATE' in header and 'TIME' in header:
dt = header.get('DATE') + ' ' + header.get('TIME')
mon.date = datetime.datetime.strptime(dt,'%d/%m/%Y %H:%M:%S')
else:
mon.date = datetime.datetime.now()
mon.monfilename = header.get('FILENAME',None)
mon.createdby = header.get('CREATED BY',None)
mon.num_points = int(header.get('Number of points','0'))
s = headerdict['Logger settings']
mon.instrument_type = s.get('Instrument type',None)
mon.status = s.get('Status',None)
serial = s.get('Serial number',None)
if serial is not None:
serial = re.split(r'[-\s+]',serial)[1]
mon.serial_number = serial
mon.instrument_number = s.get('Instrument number',None)
mon.location = s.get('Location',None)
mon.sample_period = s.get('Sample period',None)
mon.sample_method = s.get('Sample method','T')
mon.num_channels = int(s.get('Number of channels','1'))
s = headerdict['Series settings']
mon.start_date = datetime.datetime.strptime(s['Start date / time'],'%H:%M:%S %d/%m/%y')
mon.end_date = datetime.datetime.strptime(s['End date / time'], '%H:%M:%S %d/%m/%y')
channels = []
for i in range(mon.num_channels):
channel = Channel(number = i+1)
name = 'Channel %d' % (i+1)
s = headerdict[name]
channel.identification = s.get('Identification',name)
t = s.get('Reference level','0 -')
channel.reference_level, channel.reference_unit = re.split(r'\s+',t)
channel.range, channel.range_unit = re.split(r'\s+', s.get('Range','0 -'))
# omit degree symbol
channel.reference_unit= ''
channel.range_unit= ''
channels.append(channel)
return (mon, channels)