diff --git a/fixhdr/LibTrace.py b/fixhdr/LibTrace.py index 68dabb4adf2d6a181b1141ca32534282343d8404..39e6b3064b3f4767ebb6d5a2ae889f77a87fc738 100755 --- a/fixhdr/LibTrace.py +++ b/fixhdr/LibTrace.py @@ -503,52 +503,59 @@ class Mseed(futils): Requires four tuples (see self.fixedhdr) """ - try: - self.infileseek(seekval) - fmtorderstr=self.setEndian(endianess) - #station info - #left justify values - #fmtstr0 = fmtorderstr + "6scc5s2s3s2s" - - SeqNum=self.Pad(hdrlist[0][0], 6) #SeqNum - DQual=hdrlist[0][1] #DataQual - Res=hdrlist[0][2] #Reserved - Stat=self.Pad(hdrlist[0][3], 5) #Stat - Loc=self.Pad(hdrlist[0][4], 2) #Loc - Chan=self.Pad(hdrlist[0][5], 3) #Chan - Net=self.Pad(hdrlist[0][6], 2) #Net - - #time info - #fmtstr1 = fmtorderstr + "HHBBBBH" - (Year, Day, Hour, Min, Sec, junk, Micro)=hdrlist[1] - Micro=int(Micro) - - #sample info - #fmtstr2 = fmtorderstr + "Hhh" - (NumSamp, SampFact, SampMult)=hdrlist[2] - - #misc info - #fmtstr3 = fmtorderstr + "BBBBlHH" - (actFlags, ioFlags, dqFlags, numblk, timecor, offsetData, offsetBlktt)=hdrlist[3] - #convert flag string to integer - actFlags = self.FlagStrtoInt(actFlags) - ioFlags = self.FlagStrtoInt(ioFlags) - dqFlags = self.FlagStrtoInt(dqFlags) - - #pack fields - fmtstr= fmtorderstr + "6scc5s2s3s2sHHBBBBHHhhBBBBlHH" - pack_hdr=self.spack(fmtstr,SeqNum, DQual, Res, Stat, Loc, Chan, Net,\ - Year, Day, Hour, Min, Sec, junk, Micro,\ - NumSamp, SampFact, SampMult,\ - actFlags, ioFlags, dqFlags, numblk, timecor, offsetData, offsetBlktt) - - #write header - self.infilewrite(pack_hdr) - - return 48 - except Exception as e: - print("error writing fixed header") - return 0 + #try: + self.infileseek(seekval) + fmtorderstr=self.setEndian(endianess) + #station info + #left justify values + #fmtstr0 = fmtorderstr + "6scc5s2s3s2s" + + SeqNum = self.Pad(hdrlist[0][0], 6) #SeqNum + DQual = hdrlist[0][1] #DataQual + Res = hdrlist[0][2] #Reserved + Stat = self.Pad(hdrlist[0][3], 5).encode() #Stat + Loc = self.Pad(hdrlist[0][4], 2).encode() #Loc + Chan = self.Pad(hdrlist[0][5], 3).encode() #Chan + Net = self.Pad(hdrlist[0][6], 2).encode() #Net + + #time info + #fmtstr1 = fmtorderstr + "HHBBBBH" + (Year, Day, Hour, Min, Sec, junk, Micro)=hdrlist[1] + Micro=int(Micro) + + #sample info + #fmtstr2 = fmtorderstr + "Hhh" + (NumSamp, SampFact, SampMult) = hdrlist[2] + + #misc info + #fmtstr3 = fmtorderstr + "BBBBlHH" + (actFlags, ioFlags, dqFlags, numblk, timecor, offsetData, + offsetBlktt)=hdrlist[3] + #convert flag string to integer + actFlags = self.FlagStrtoInt(actFlags) + ioFlags = self.FlagStrtoInt(ioFlags) + dqFlags = self.FlagStrtoInt(dqFlags) + print("SeqNum, DQual, Res, Stat, Loc, Chan, Net,Year, Day, Hour, Min, Sec, junk, Micro,NumSamp, SampFact, SampMult,actFlags, ioFlags, dqFlags,numblk, timecor, offsetData, offsetBlktt:", + SeqNum, DQual, Res, Stat, Loc, Chan, Net, + Year, Day, Hour, Min, Sec, junk, Micro, + NumSamp, SampFact, SampMult,actFlags, ioFlags, dqFlags, + numblk, timecor, offsetData, offsetBlktt) + #pack fields + fmtstr = fmtorderstr + "6scc5s2s3s2sHHBBBBHHhhBBBBlHH" + print("fmtstr") + pack_hdr = self.spack( + fmtstr,SeqNum, DQual, Res, Stat, Loc, Chan, Net, + Year, Day, Hour, Min, Sec, junk, Micro, + NumSamp, SampFact, SampMult,actFlags, ioFlags, dqFlags, + numblk, timecor, offsetData, offsetBlktt) + + #write header + self.infilewrite(pack_hdr) + + return 48 + #except Exception as e: + #print("error writing fixed header") + #return 0 ######################################################### def GetBlk(self, blknum, seekval=0): diff --git a/fixhdr/fixhdr.py b/fixhdr/fixhdr.py index 737743c8f7d96b072ef77dec01a13ecfa9570590..157ddc2d0d9e4b5471a3a392aaf4ea98625ecf93 100755 --- a/fixhdr/fixhdr.py +++ b/fixhdr/fixhdr.py @@ -2281,8 +2281,8 @@ class MainWindow: Net = Net.strip().decode() key = Stat + ":" + Loc + ":" + Net if key != self.TimeShiftName.get(): - blk_err+=1 - n+=1 + blk_err += 1 + n += 1 continue # determine time of blockette and process if between startEpoch