当前位置: 首页>>代码示例>>Python>>正文


Python Channel.reference_unit方法代码示例

本文整理汇总了Python中models.Channel.reference_unit方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.reference_unit方法的具体用法?Python Channel.reference_unit怎么用?Python Channel.reference_unit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Channel的用法示例。


在下文中一共展示了Channel.reference_unit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import reference_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)
开发者ID:jpcvandam,项目名称:acaciadata,代码行数:51,代码来源:monfile.py


注:本文中的models.Channel.reference_unit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。