ImportOs,sysImportstring fromDatetimeImport*Import TimeImportCalendarImportJsonstart=Time.clock ()#Read DataFilePath ='e:\\new folder\\16050320.024'fileorg= Open (FilePath,'R') Linedata=[line.strip (). Replace ('\ t',' ') forLineinchFileorg.readlines ()ifLine! ='\ n']fileorg.close ()#Parse DataDatainfo = Linedata[2].split (' ') Reso=float (datainfo[0]) Xnum= Int (datainfo[6]) Ynum= Int (datainfo[7]) Startlon= reso/2.0Startlat= reso/2.0Data='\ n'. Join (Linedata[3:])#print (str (xnum) + "+ str (ynum) +" "+ str (Startlon) +" "+ str (Startlat) +" + str (reso));#Write DataFile_object = open ('T639.txt','W') File_object.write ("NCOLS"+ STR (xnum) +"\ n") File_object.write ("NROWS"+ STR (ynum) +"\ n") File_object.write ("Xllcenter"+ STR (Startlon) +"\ n") File_object.write ("Yllcenter"+ STR (startlat) +"\ n")#round (Yreso, 3) *File_object.write ("cellsize"+ STR (RESO) +"\ n") File_object.write ("Nodata_value"+ STR (-9999) +"\ n") file_object.writelines (data) file_object.close ()#End =time.clock () Datespantransfer= End-StartPrint("read:%f s"% Datespantransfer)
Python Analytic Weather Forecast (T639) data