我是Python新手,我在尝试格式化RINEX(卫星导航数据,如GPS)时遇到问题,因此我最终得到一个包含三列的ASCII文件(GPS时间;卫星ID;信号类型(几个)子列)),最终将被操纵以产生信号延迟错误。 我目前正在尝试通过检查脚本各个阶段的输出来完成我的代码,因此有大量的打印语句散布在各处。我的代码的主体是:
def remove_header(self):
#Grab header and discard
for count, self.line in enumerate(self.rinexFile, 1):
if "END OF HEADER" in self.line:
self.header_number = count
eoh = self.line
self.end_header = eoh.strip()
print "%s at line %d." % (self.end_header, count)
self.container_1 = self.rinexFile[self.header_number:]
open('FALK1179.14o', 'w').writelines(self.container_1)
def epoch_grabber(self):
#Grab data
self.rinexFile_one = open('FALK1179.14o', 'r+').readlines()
for count, self.line_1 in enumerate(self.rinexFile_one, 0):
#Grab epoch
#self.raw_data = line.split()
if " 14 " in self.line_1:
self.epoch_data = self.line_1.split()
self.index = datetime.strptime(' '.join(self.epoch_data[0:6]), '%y %m %d %H %M %S.%f0')
else:
pass
def satellite_number_and_id(self):
#Identify number of satellites in each epoch block
satNum_init = self.epoch_data[7]
satNum_temp = satNum_init[0:2]
if satNum_temp.find("G") == 1:
self.satNum = satNum_temp.replace("G", "")
self.satNum = int(self.satNum)
else:
self.satNum = satNum_temp
self.satNum = int(self.satNum)
#List the SVIDs of each satellite
satNum_init_tem = satNum_init[2:]
satId_temp = satNum_init_tem.split("G")
self.sat_Id = filter(None, satId_temp)
def satData_package(self):
#Looping through for every satellite and create dummy frame
data = {}
for line in self.container_1:
line = line.strip()
if not line: continue
if line.startswith(" 14 "):
if line not in data: data[line] = []
epoch_line = line
continue
self.satData = data[epoch_line].append(line)
print "satData: %s" % (self.satData)
遇到循环问题,如epoch_grabber函数中所示。我的印刷语句一遍又一遍地生成相同的结束时期,而不是从第一个时代开始,例如:Epoch:2014-04-27 00:00:30,Epoch:2014-04-27 00:01:00,Epoch :2014-04-27 00:01:30,等等。相反它只是循环:Epoch:2014-04-27 23:59:30,Epoch:2014-04-27 23:59:30,Epoch:2014-04-27 23:59:30。
意图是拥有时代,然后将所有后续卫星的信号打包在一起,然后是下一个时期开始的下一个“块”。每个纪元的间隔为30秒。然后应该进一步拆分块以产生单独的卫星文件,每个文件包含一列中的纪元,以及其余的信号。
欢迎任何建议