"""This code takes the raw data from the Nortek AWAC and prepares it for matlab You input a raw binary *.WPR file from the AWAC and it outputs three Currents files with all of the currents data, as well as a waves orbital velocity, range, pressure and sysinfo file for each wave burst""" import sys, struct, math, shutil, os try: infileName = sys.argv[1] except: print 'error' sys.exit(1) ifile = open(infileName, 'rb') testOfile=open('test','w') currentsOfile = open('currents', 'w') currentsHeaderOfile = open('currentsHeader','w') currentsTiltOfile = open('currentsTilt','w') currentsOfile.write('%this is the Nortek AWAC Currents data \n') currentsHeaderOfile.write('%this is the Header data for the Nortek AWAC Currents data \n %it includes Header Info, Date info, Pressure and Temp \n') currentsTiltOfile.write('%this is the Tilt readings (heading pitch and roll) for the Nortek AWAC Currents data \n') # HARDWARE CONFIGURATION #read header and make sure it is valid HWconfID= 0x05a5 readHeaderID=ifile.read(2) headerID=struct.unpack('H',readHeaderID)[0] if headerID != HWconfID: print 'error with Hardware Config Header' sys.exit(1) #size of structure in words (1 word = 2 bytes) readSize=ifile.read(2) size=struct.unpack('H',readSize)[0] #compute the length in bytes - the checksum length=(size*2)-2 #Serial Number (not sure what to do with this) readSerial=ifile.read(14) #Board Configuration readBoardC=ifile.read(2) #Board Frequency (kHz) readBoardF=ifile.read(2) #PIC Code Version # readPIC=ifile.read(2) #Hardware Revision readHardRev=ifile.read(2) #Recorder Size (*65536 bytes) readRecSize=ifile.read(2) #Status readStatus=ifile.read(2) #Spare ifile.read(12) #Firmware Version readFirmVersion=ifile.read(4) firmVersion=struct.unpack('I',readFirmVersion)[0] currentsHeaderOfile.write(str(firmVersion)) currentsHeaderOfile.write(' %Firmware Version \n') #Checksum readCheckSum=ifile.read(2) # HEAD CONFIGURATION #read header and make sure it is valid HeadConfID= 0x04a5 readHeaderID=ifile.read(2) headerID=struct.unpack('H',readHeaderID)[0] if headerID != HeadConfID: print 'error with Head Config Header' sys.exit(1) #size of structure in words (1 word = 2 bytes) readSize=ifile.read(2) size=struct.unpack('H',readSize)[0] #compute the length in bytes - the checksum length=(size*2)-2 #Head Configuration readHeadConfig=ifile.read(2) #Head Frequency (kHz) readHeadFreq=ifile.read(2) headFreq=struct.unpack('H',readHeadFreq)[0] currentsHeaderOfile.write(str(headFreq)) currentsHeaderOfile.write(' %head frequency in khz \n') #Head Type readHeadType=ifile.read(2) #Head Serial Number readHeadSerial=ifile.read(12) #System Data ifile.read(176) #Spare ifile.read(22) #Number of beams readNbeams=ifile.read(2) Nbeams=struct.unpack('H',readNbeams)[0] currentsHeaderOfile.write(str(Nbeams)) currentsHeaderOfile.write(' %number of beams \n') #Checksum readChecksum=ifile.read(2) # USER CONFIGURATION #read header and make sure it is valid UserConfID= 0x00a5 readHeaderID=ifile.read(2) headerID=struct.unpack('H',readHeaderID)[0] if headerID != UserConfID: print 'error with User Config Header' sys.exit(1) #size of structure in words (1 word = 2 bytes) readSize=ifile.read(2) size=struct.unpack('H',readSize)[0] #compute the length in bytes - the checksum length=(size*2)-2 #Transmit Pulse Length (counts) readPulse=ifile.read(2) pulse=struct.unpack('H',readPulse)[0] currentsHeaderOfile.write(str(pulse)) currentsHeaderOfile.write(' %transmit pulse length (counts) \n') #Blanking Distance (counts) readBlanking=ifile.read(2) blanking=struct.unpack('H',readBlanking)[0] #Receive Length (counts) readReceive=ifile.read(2) receive=struct.unpack('H',readReceive)[0] currentsHeaderOfile.write(str(receive)) currentsHeaderOfile.write(' %recieve length (counts) \n') #Time Between Pings (counts) readTimePing=ifile.read(2) timePing=struct.unpack('H',readTimePing)[0] currentsHeaderOfile.write(str(timePing)) currentsHeaderOfile.write(' %time between pings (counts) \n') #Time Between Burst Sequence (counts) readTimeBurst=ifile.read(2) timeBurst=struct.unpack('H',readTimeBurst)[0] currentsHeaderOfile.write(str(timeBurst)) currentsHeaderOfile.write(' %time between burst sequence (counts) \n') #Number of Beam Sequences per Burst readBeamSeq=ifile.read(2) beamSeq=struct.unpack('H',readBeamSeq)[0] currentsHeaderOfile.write(str(beamSeq)) currentsHeaderOfile.write(' %number of beam sequences per burst \n') #Average interval (seconds) readAvgInt=ifile.read(2) avgInt=struct.unpack('H',readAvgInt)[0] currentsHeaderOfile.write(str(avgInt)) currentsHeaderOfile.write(' %average interval (seconds) \n') #Number of Beams (alread have this from before) readNbeams=ifile.read(2) #Timing Controller Mode readTimeCont=ifile.read(2) #Power Control Register readPowerCont=ifile.read(2) #Spare ifile.read(6) #Compass Update Rate readCompRate=ifile.read(2) #Coordinate System (0=ENU, 1=XYZ, 2=Beam) readCoord=ifile.read(2) coord=struct.unpack('H',readCoord)[0] currentsHeaderOfile.write(str(coord)) currentsHeaderOfile.write(' %coord system, 0=ENU, 1=XYZ, 2=Beam \n') #Number of Cells or Bins readNcells=ifile.read(2) Ncells=struct.unpack('H',readNcells)[0] currentsHeaderOfile.write(str(Ncells)) currentsHeaderOfile.write(' %number of bins or cells \n') #Cell Size readCellSize=ifile.read(2) cCellSize=struct.unpack('H',readCellSize)[0] #compute the currents cell size cell=cCellSize*100.0*(750/((headFreq*1000.0*4)/255.0)) cellint = math.floor(cell) rawCellSize=0.01*cellint/256.0 cellSize=math.cos(25*(math.pi/180))*rawCellSize currentsHeaderOfile.write(str('%3.2f' %cellSize)) currentsHeaderOfile.write(' %bin cell size (m) \n') #compute the blanking distance pLength=rawCellSize*100.0 cellBlanking=blanking*100.0*(750.0/32768.0)-pLength cellBlanking=0.01*math.floor(cellBlanking) cellBlanking=math.cos(25*(math.pi/180))*cellBlanking currentsHeaderOfile.write(str('%3.2f' %cellBlanking)) currentsHeaderOfile.write(' %blanking distance (m) \n') #compute and write the cell depths currentsHeaderOfile.write(' % cell heights from bottom (meters) \n') depths=[] for i in range(1,Ncells+1): depths.append(cellBlanking+cellSize*i) currentsHeaderOfile.write(str('%3.2f' %depths[i-1])) currentsHeaderOfile.write('\n') #Measurement Interval readMeasInt=ifile.read(2) measInt=struct.unpack('H',readMeasInt)[0] currentsHeaderOfile.write(str(measInt)) currentsHeaderOfile.write(' %measurement interval (seconds) \n') #Recorder Deployment Name readDepName=ifile.read(6) #Recorder Wrap Mode readRecWrap=ifile.read(2) #Deployment Start Time (we can use the start time of the samples instead) readStarTime=ifile.read(6) #Time Between Diagnostic Measurements (seconds) readDiagTime=ifile.read(4) diagTime=struct.unpack('I',readDiagTime)[0] #Mode readMode=ifile.read(2) #User Input Sound Speed Adjustment Factor readAdjSound=ifile.read(2) # Number of Samples in Diagnostic Mode readNsamples=ifile.read(2) Nsamples=struct.unpack('H',readNsamples)[0] # Beam and Cell Number to Measure in Diagnostic Mode readNbeamCell=ifile.read(2) #Number Pings in Diagnostic Mode readNpingsDiag=ifile.read(2) #Mode Test readModeTest=ifile.read(2) #Analog Input Address readAnalAddr=ifile.read(2) #Software Version readSoftVers=ifile.read(2) #Spare ifile.read(2) #Velocity Adjustment Table readVelAdjTable=ifile.read(180) #File Comments readFileComments=ifile.read(180) #Mode for data rate and wave cell position readMode=ifile.read(2) byteList=struct.unpack('2B', readMode) def int2msbits(n, count=8): """returns the most-significant binary of integer n, using count number of digits""" return "".join([str((n >> y) & 1) for y in range(0, count)]) bytemap = '' bitmap = '' for ind in range(len(byteList)): byte = struct.pack('B', byteList[ind]) bytemap += byte bits = int2msbits(byteList[ind]) bitmap += bits #Percentage for Wave Cell Positioning readPercWave=ifile.read(2) PercWave=struct.unpack('H',readPercWave)[0] PercWave=(PercWave/32767)*100 #Wave Transmit Pulse readWavePulse=ifile.read(2) wavePulse=struct.unpack('H',readWavePulse)[0] #Fixed Wave Blanking Distance (counts) readFixedBlanking=ifile.read(2) fixedBlanking=struct.unpack('H',readFixedBlanking)[0] #Wave Measurement Cell Size readWaveCellSize=ifile.read(2) waveCellSize=struct.unpack('H',readWaveCellSize)[0] #Number of Diagnostic/Wave Samples readWaveSamples=ifile.read(2) waveSamples=struct.unpack('H',readWaveSamples)[0] #Spare ifile.read(8) #Analog Output Scale Factor readAnalogScale=ifile.read(2) #Correlation Threshold readCorrThresh=ifile.read(2) #Spare ifile.read(2) #Transmit Pulse Length Second Lag (counts) readPulseLag=ifile.read(2) #Spare ifile.read(30) #Stage Match Filter Constants readStageMatch=ifile.read(16) #Checksum readChecksum=ifile.read(2) # VELOCITY PROFILE DATA #first create the lists that we can write the data to and then write to the file currentsTime=[] currentsPress=[] currentsTemp=[] currentsHeading=[] currentsPitch=[] currentsRoll=[] allVel1=[] allVel2=[] allVel3=[] allAmp1=[] allAmp2=[] allAmp3=[] VelID= 0x20a5 readHeaderID=ifile.read(2) headerID=struct.unpack('H',readHeaderID)[0] if headerID != VelID: print 'error with Velocity Profile Header' sys.exit(1) while headerID == VelID: #size in words readSize=ifile.read(2) if len(readSize) == 0: break size=struct.unpack('H',readSize)[0] #compute the length in bytes - the checksum length=(size*2)-2 # READ AND COMPUTE THE START TIME FOR THE CURRENT VEL>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #minute readMinute=ifile.read(1) minute=struct.unpack('B',readMinute)[0] minute=str(hex(minute))[2:4] #Second readSecond=ifile.read(1) second=struct.unpack('B',readSecond)[0] second=str(hex(second))[2:4] #day readDay=ifile.read(1) day=struct.unpack('B',readDay)[0] day=str(hex(day))[2:4] #hour readHour=ifile.read(1) hour=struct.unpack('B',readHour)[0] hour=str(hex(hour))[2:4] #year readYear=ifile.read(1) year=struct.unpack('B',readYear)[0] year=str(hex(year))[2:4] #month readMonth=ifile.read(1) month=struct.unpack('B',readMonth)[0] month=str(hex(month))[2:4] #century century = str(20) startTime=century+(year.zfill(2))+(month.zfill(2))+(day.zfill(2))+(hour.zfill(2))+(minute.zfill(2))+(second.zfill(2)) #create a time stamp for the file names that only includes from year up to minutes FileStamp=(year.zfill(2))+(month.zfill(2))+(day.zfill(2))+(hour.zfill(2))+(minute.zfill(2)) currentsTime.append(FileStamp) #error code readError=ifile.read(2) error=struct.unpack('H',readError)[0] #analog input 1 readAnalog1=ifile.read(2) analog1=struct.unpack('H',readAnalog1)[0] #Battery Voltage (.1 V) readBattery=ifile.read(2) battery=struct.unpack('H',readBattery)[0] #Speed of Sound or Analog 2 (.1 m/s) readSound=ifile.read(2) sound=struct.unpack('H',readSound)[0] #Heading (.1 deg) readHeading=ifile.read(2) heading=struct.unpack('H',readHeading)[0] currentsHeading.append(heading) #Pitch (.1 deg) readPitch=ifile.read(2) pitch=struct.unpack('h',readPitch)[0] currentsPitch.append(pitch) #Roll (.1 deg) readRoll=ifile.read(2) roll=struct.unpack('h',readRoll)[0] currentsRoll.append(roll) #pressure MSB in mm readPressMSB=ifile.read(1) pressureMSB=struct.unpack('B',readPressMSB)[0] #status code readStatus=ifile.read(1) #pressure LSW in mm readPressLSW=ifile.read(2) pressureLSW=struct.unpack('H',readPressLSW)[0] #compute the Pressure pressure= 65536*pressureMSB + pressureLSW currentsPress.append(pressure) #Temperature (0.01 deg C) readTemp=ifile.read(2) temp=struct.unpack('h',readTemp)[0] currentsTemp.append(temp) #Spare readSpare=ifile.read(88) #Read in the velocity data for beam 1-3 (mm/s) from cell 1(bottom) to n numCells=3*Ncells vel1=[] vel2=[] vel3=[] while numCells > 0: readVel=ifile.read(2) vel=struct.unpack('h',readVel)[0] if numCells > 2*Ncells: vel1.append(vel) elif numCells > Ncells: vel2.append(vel) else: vel3.append(vel) numCells -=1 allVel1.append(vel1) allVel2.append(vel2) allVel3.append(vel3) #Read in the amplitude data for beam 1-3 (counts) from cell 1(bottom) to n numCells=3*Ncells amp1=[] amp2=[] amp3=[] while numCells > 0: readAmp=ifile.read(1) amp=struct.unpack('B',readAmp)[0] if numCells > 2*Ncells: amp1.append(amp) elif numCells > Ncells: amp2.append(amp) else: amp3.append(amp) numCells -=1 allAmp1.append(amp1) allAmp2.append(amp2) allAmp3.append(amp3) #Add a fill byte if there are an odd number of cells if Ncells/2 != 0: ifile.read(1) else: ifile.read(0) #Compute the Checksum ifile.seek(-(length+1),1) dataStruct=ifile.read(length) total =0 for byte in dataStruct: value = struct.unpack('B', byte)[0] total += value #add 0xb58c in hex to put the cs in the right format cs=total #Read in the Checksum readChecksum=ifile.read(2) checksum=struct.unpack('H',readChecksum)[0] # WAVE DATA HEADER WdataID=0x31a5 #Read the Sync and ID as a 2 byte hex instead of seperately readHeaderID=ifile.read(2) if len(readHeaderID) == 0: break headerID=struct.unpack('H',readHeaderID)[0] while headerID == WdataID: if headerID != WdataID: break pressureOfile = open('pressure', 'w') rangeOfile = open('range', 'w') orbitOfile = open('orbit', 'w') sysinfoOfile = open('sysinfo', 'w') #write the data from the hardware/user config to the sysinfoOfile sysinfoOfile.write(str(coord)) sysinfoOfile.write(' %coord system, 0=ENU, 1=XYZ, 2=Beam \n') sysinfoOfile.write(str(bitmap)) sysinfoOfile.write(' % bit1:data rate 0=1Hz,1=2Hz bit2:wave cell position 0=fixed,1=dynamic bit3=type of pos 0=% of mean press, 1=% of min press \n') sysinfoOfile.write(str(PercWave)) sysinfoOfile.write(' %percentage for wave cell position \n') #size in words readSize=ifile.read(2) size=struct.unpack('H',readSize)[0] #compute the length in bytes - the checksum length=(size*2)-2 # READ AND COMPUTE THE START TIME FOR THE WAVE HEADER>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #minute readMinute=ifile.read(1) minute=struct.unpack('B',readMinute)[0] minute=str(hex(minute))[2:4] #Second readSecond=ifile.read(1) second=struct.unpack('B',readSecond)[0] second=str(hex(second))[2:4] #day readDay=ifile.read(1) day=struct.unpack('B',readDay)[0] day=str(hex(day))[2:4] #hour readHour=ifile.read(1) hour=struct.unpack('B',readHour)[0] hour=str(hex(hour))[2:4] #year readYear=ifile.read(1) year=struct.unpack('B',readYear)[0] year=str(hex(year))[2:4] #month readMonth=ifile.read(1) month=struct.unpack('B',readMonth)[0] month=str(hex(month))[2:4] #century century = str(20) startTime=century+(year.zfill(2))+(month.zfill(2))+(day.zfill(2))+(hour.zfill(2))+(minute.zfill(2))+(second.zfill(2)) #create a time stamp for the file names that only includes from year up to minutes FileStamp=(year.zfill(2))+(month.zfill(2))+(day.zfill(2))+(hour.zfill(2))+(minute.zfill(2)) sysinfoOfile.write(startTime) sysinfoOfile.write(' % this is the start time \n') #Number of Wave Data records to follow readWaveRecords=ifile.read(2) waveRecords=struct.unpack('H',readWaveRecords)[0] #Blanking Distance (counts) readBlanking=ifile.read(2) blanking=struct.unpack('H',readBlanking)[0] #Battery Voltage readBattery=ifile.read(2) #Sound Speed readSound=ifile.read(2) sound=struct.unpack('H',readSound)[0] sysinfoOfile.write(str(sound)) sysinfoOfile.write(' %speed of sound (0.1m/s) \n') #Heading readHeading=ifile.read(2) heading=struct.unpack('H',readHeading)[0] sysinfoOfile.write(str(heading)) sysinfoOfile.write(' %heading \n') #Pitch readPitch=ifile.read(2) pitch=struct.unpack('h',readPitch)[0] sysinfoOfile.write(str(pitch)) sysinfoOfile.write(' %pitch \n') #Roll readRoll=ifile.read(2) roll=struct.unpack('h',readRoll)[0] sysinfoOfile.write(str(roll)) sysinfoOfile.write(' %roll \n') #Min Pressure Value (mm) readMinPress=ifile.read(2) minPress=struct.unpack('H',readMinPress)[0] sysinfoOfile.write(str(minPress)) sysinfoOfile.write(' %min press (mm) \n') #Max Pressure Value (mm) readMaxPress=ifile.read(2) #Temperature readTemp=ifile.read(2) #hCell Size (counts) readCellSize=ifile.read(2) hCellSize=struct.unpack('H',readCellSize)[0] #compute the wave cell size cell=hCellSize*100.0*(750/((headFreq*1000.0*4)/255.0)) cellint = math.floor(cell) cellSize=0.01*cellint/256.0 sysinfoOfile.write(str('%3.2f' %cellSize)) sysinfoOfile.write(' %wave cell size (m) \n') #compute the wave cell position pLength=cellSize*100.0 cellDist=blanking*100.0*(750.0/32768.0)-pLength cellDist=0.01*math.floor(cellDist) beamCellPos=cellDist+cellSize cellPos=math.cos(25*(math.pi/180))*beamCellPos sysinfoOfile.write(str('%3.2f' %cellPos)) sysinfoOfile.write(' %wave cell position (m) \n') testOfile.write(str('%3.2f' %cellPos)) testOfile.write(' \n') #Noise Amplitude Beam1 readAmpBeam1=ifile.read(1) #Noise Amplitude Beam2 readAmpBeam2=ifile.read(1) #Noise Amplitude Beam3 readAmpBeam3=ifile.read(1) #Noise Amplitude Beam4 readAmpBeam4=ifile.read(1) #Processing Mag Beam1 readMagBeam1=ifile.read(2) #Processing Mag Beam2 readMagBeam2=ifile.read(2) #Processing Mag Beam3 readMagBeam3=ifile.read(2) #Processing Mag Beam4 readMagBeam4=ifile.read(2) #Spare ifile.read(14) #Checksum readChecksum=ifile.read(2) #WAVE DATA #what is the wave ID or the extra data structure ID waveID= 0x30a5 extraID= 0x42a5 headerID=waveID while (headerID == waveID) or (headerID == extraID): #Read the Sync and ID as a 2 byte hex instead of seperately readHeaderID=ifile.read(2) if len(readHeaderID) == 0: break headerID=struct.unpack('H',readHeaderID)[0] if (headerID != waveID) and (headerID != extraID): break #if the extra data structure exists, read through it if headerID == extraID: readSize=ifile.read(2) size=struct.unpack('H',readSize)[0] ifile.read(size*2-2) #size in words readSize=ifile.read(2) size=struct.unpack('H',readSize)[0] #compute the length in bytes - the checksum length=(size*2)-2 #Pressure readPressure=ifile.read(2) pressure=struct.unpack('H',readPressure)[0] pressureOfile.write(str(pressure)) pressureOfile.write('\n') #AST 1 readAST1=ifile.read(2) AST1=struct.unpack('H',readAST1)[0] rangeOfile.write(str('%06d' % AST1)) rangeOfile.write(' \n') #Analog input aInput=ifile.read(2) #Velocity Beam 1 (mm/s) readVel1=ifile.read(2) vel1=struct.unpack('h',readVel1)[0] orbitOfile.write(str('%06d' % vel1)) orbitOfile.write(' ') #Velocity Beam 2 (mm/s) readVel2=ifile.read(2) vel2=struct.unpack('h',readVel2)[0] orbitOfile.write(str('%06d' % vel2)) orbitOfile.write(' ') #Velocity Beam 3 (mm/s) readVel3=ifile.read(2) vel3=struct.unpack('h',readVel3)[0] orbitOfile.write(str('%06d' % vel3)) orbitOfile.write('\n') #AST 2 readAST2=ifile.read(2) AST2=struct.unpack('H',readAST2)[0] rangeOfile.write(str('%06d' % AST2)) rangeOfile.write(' \n') #Noise Amplitude for Beam 1 readAmp1=ifile.read(1) amp1=struct.unpack('B',readAmp1)[0] #Noise Amplitude for Beam 2 readAmp2=ifile.read(1) amp2=struct.unpack('B',readAmp2)[0] #Noise Amplitude for Beam 3 readAmp3=ifile.read(1) amp3=struct.unpack('B',readAmp3)[0] #AST quality readASTQuality=ifile.read(1) ASTQuality=struct.unpack('B',readASTQuality)[0] #CheckSum readChecksum=ifile.read(2) pressureOfile.close() rangeOfile.close() orbitOfile.close() sysinfoOfile.close() shutil.copy('pressure','pressure_'+FileStamp+'.txt') shutil.copy('orbit','orbit_'+FileStamp+'.txt') shutil.copy('range','range_'+FileStamp+'.txt') shutil.copy('sysinfo','sysinfo_'+FileStamp+'.txt') os.remove('pressure') os.remove('orbit') os.remove('range') os.remove('sysinfo') #write the rest of the data to the currents file and rename currentsHeaderOfile.write('%List of time records for this data set, YYMMDDHHMM \n') for date in currentsTime: currentsHeaderOfile.write(str(date)) currentsHeaderOfile.write('\n') currentsHeaderOfile.write('%List of pressure readings for each current burst \n') for press in currentsPress: currentsHeaderOfile.write(str(press/1000.000)) currentsHeaderOfile.write('\n') currentsHeaderOfile.write('%List of temp readings in degrees C for each current burst \n') for temp in currentsTemp: currentsHeaderOfile.write(str(temp/100.00)) currentsHeaderOfile.write('\n') currentsTiltOfile.write('%List heading,pitch and roll values in degrees for each current burst \n') for value in range(len(currentsHeading)): currentsTiltOfile.write(str('%- 8.1f' %(currentsHeading[value]/10.0))) currentsTiltOfile.write(str('%- 8.1f' %(currentsPitch[value]/10.0))) currentsTiltOfile.write(str('%- 8.1f' %(currentsRoll[value]/10.0))) currentsTiltOfile.write('\n') #write the vel and amplitude data to the file currentsOfile.write('% velocities and amplitudes with lines of Ncells for each burst \n') currentsOfile.write('% velocities from lowest cell up, in m/s ---- amplitudes in counts \n') currentsOfile.write('% vel1(beam1, x or u) vel2(beam2, y or v) vel3(beam3, z or w) ---- amp1(beam1) amp2(beam2) amp3(beam3) \n') for list in range(len(allVel1)): for i in range(0,Ncells): currentsOfile.write(str('%- 8.3f' % (allVel1[list][i]/1000.000))) currentsOfile.write(str('%- 8.3f' % (allVel2[list][i]/1000.000))) currentsOfile.write(str('%- 8.3f' % (allVel3[list][i]/1000.000))) currentsOfile.write(str('%-8d' % allAmp1[list][i])) currentsOfile.write(str('%-8d' % allAmp2[list][i])) currentsOfile.write(str('%-8d' % allAmp3[list][i])) currentsOfile.write( '\n') currentsOfile.close() currentsHeaderOfile.close() currentsTiltOfile.close() shutil.copy('currents','currents_'+currentsTime[0]+'.txt') shutil.copy('currentsHeader','currentsHeader_'+currentsTime[0]+'.txt') shutil.copy('currentsTilt','currentsTilt_'+currentsTime[0]+'.txt') print 'End Of File, Processing Complete' currentsOfile.close() currentsHeaderOfile.close() currentsTiltOfile.close() pressureOfile.close() rangeOfile.close() orbitOfile.close() sysinfoOfile.close() os.remove('currents') os.remove('currentsHeader') os.remove('currentsTilt') ifile.close() testOfile.close()