當前位置: 首頁>>代碼示例>>Python>>正文


Python Channel.range方法代碼示例

本文整理匯總了Python中models.Channel.range方法的典型用法代碼示例。如果您正苦於以下問題:Python Channel.range方法的具體用法?Python Channel.range怎麽用?Python Channel.range使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Channel的用法示例。


在下文中一共展示了Channel.range方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create

# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import range [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.range方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。