pyStationInfo.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Parallel.GAMIT 作者: demiangomez 项目源码 文件源码
def parse_station_record(self, line):

        fieldnames = ['StationCode', 'StationName', 'DateStart', 'DateEnd', 'AntennaHeight', 'HeightCode', 'AntennaNorth', 'AntennaEast',
                      'ReceiverCode', 'ReceiverVers', 'ReceiverFirmware', 'ReceiverSerial', 'AntennaCode', 'RadomeCode', 'AntennaSerial']

        fieldwidths = (
        1, 6, 18, 19, 19, 9, 7, 9, 9, 22, 22, 7, 22, 17, 7, 20)  # negative widths represent ignored padding fields
        fmtstring = ' '.join('{}{}'.format(abs(fw), 'x' if fw < 0 else 's') for fw in fieldwidths)

        fieldstruct = struct.Struct(fmtstring)
        parse = fieldstruct.unpack_from

        if line[0] == ' ' and len(line) >= 77:
            record = dict(zip(fieldnames, map(str.strip, parse(line.ljust(fieldstruct.size))[1:])))
        else:
            return None

        # convert to datetime object
        DateStart, DateEnd = self.stninfodate2datetime(record['DateStart'], record['DateEnd'])
        record['DateStart'] = DateStart
        record['DateEnd'] = DateEnd
        record['StationCode'] = record['StationCode'].lower()

        return record
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号