本文整理匯總了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)