Hi,
It works, but I still have a little problem.
The result file ("prediction.txt") has musical notes.. as shown in the following figure.
How can I remove the musical notes?
If I copy them and paste them in Excel, they are pasted as follows.
139.998818623999990 49.993421150400003
1.028651821
140.012089035999990 49.993421150400003
1.051712292
140.025359450000000 49.993421150400003
0.991534726
140.038629861999990 49.993421150400003
1.164933449
140.051900275000010 49.993421150400003
1.189701191
140.065170687999990 49.993421150400003
1.110428796
140.078441101000010 49.993421150400003
1.316123727
I think the musical notes means putting the values in the next lines..
How can I solve this problem.
The following is this code.
lonlat_data=asciiread("mosaic_lonlat.txt", -1, "string") ;(/1373413,2/), "float")
predict_data=asciiread("rf_image_prediction1_revised.txt", -1, "string") ;(/1373413,1/), "float")
nlines=dimsizes(predict_data)
predict_data_new=new(nlines,string)
do i=0,nlines-1
str=str_split(lonlat_data(i),",")
predict_data_new(i)=str(0)+" "+str(1)+" "+predict_data(i)
end do
asciiwrite("prediction.txt", predict_data_new)
Thanks a lot.
Miae
-------------------------------------------------
Miae Kim
School of Urban and Environment Engineering
Ulsan National Institute of Science and Technology (UNIST)
UNIST-gil 50, Ulsan 689-798, South Korea
Mobile: +82-10-9421-8287
E-mail: toa0710@naver.com
-----Original Message-----
From: "Mary Haley"<haley@ucar.edu>
To: "김미애"<toa0710@naver.com>;
Cc: "ncl-talk"<ncl-talk@ucar.edu>;
Sent: 2014-03-14 (금) 03:53:46
Subject: Re: [ncl-talk] Incorrect values in places of decimals
Hi,
If you want to preserve *exactly* what's in the original two files, then I suggest reading and writing everything as strings. This code should hopefully do it: lonlat_data = asciiread("mosaic_lonlat.txt", -1, "string")
predict_data = asciiread("rf_image_prediction1_revised.txt", -1, "string")
nlines = dimsizes(predict_data)
predict_data_new = new(nlines,string)
do i=0,nlines-1
str = str_split(lonlat_data(i),",")
predict_data_new(i)=str(0) + " " + str(1) + " " + predict_data(i)
end do
asciiwrite("prediction.txt",predict_data_new) The above code gave me this file, using the sample lines you sent me below: 139.998818623999990 49.993421150400003 1.028651821140.012089035999990 49.993421150400003 1.051712292140.025359450000000 49.993421150400003 0.991534726140.038629861999990 49.993421150400003 1.164933449140.051900275000010 49.993421150400003 1.189701191140.065170687999990 49.993421150400003 1.110428796 --Mary On Mar 13, 2014, at 9:04 AM, 김미애 <toa0710@naver.com> wrote:
Hello,
Actually, I tried "double" at first. But, it was same.
Although I tried "float" and "double", the results were wrong. How can I resolve this problem?
Thank you
-------------------------------------------------
Miae Kim
School of Urban and Environment Engineering
Ulsan National Institute of Science and Technology (UNIST)
UNIST-gil 50, Ulsan 689-798, South Korea
Mobile: +82-10-9421-8287
E-mail: toa0710@naver.com
-----Original Message-----
From: "Mary Haley"<haley@ucar.edu>
To: "김미애"<toa0710@naver.com>;
Cc: "ncl-talk"<ncl-talk@ucar.edu>;
Sent: 2014-03-13 (목) 23:17:27
Subject: Re: [ncl-talk] Incorrect values in places of decimals
Try reading the data in double precision rather than float. Replace the “float” with “double”.
—Mary
On Mar 13, 2014, at 2:51 AM, 김미애 <toa0710@naver.com> wrote:
Hello,
I attempted to combine 3 text files into 1 text file.
One is data values, and the others are longitude and latitude.
I made the final text file including the three data, but those values were incorrect.
As shown in down below, those values have too long places of decimals.
I don't know why, but the output text file has different .. incorrect values.
Let's see the first line of it.
139.998825073242188 49.993419647216797 1.028651834
The last 11 digits are incorrect in longitude and latitude.
The last 2 digits are incorrect in data values.
....
The following is my code.
Where am I doing wrong? How can I get the correct values
<My code>
lonlat_data=asciiread("mosaic_lonlat.txt", (/1373413,2/), "float")
predict_data=asciiread("rf_image_prediction1_revised.txt", (/1373413,1/), "float")
;print(lonlat_data(0:9,1))
dims=dimsizes(predict_data)
ny=dims(0) ;1373413
predict_data_new=new((/ny,3/),float)
do i=0,ny-1
predict_data_new(i,0)=lonlat_data(i,0)
predict_data_new(i,1)=lonlat_data(i,1)
predict_data_new(i,2)=predict_data(i,0)
end do
predict_data_new@_FillValue=-9999
;print(predict_data_new(0:9,0:2))
;exit
fmtx="f23.15,f23.15,f15.9"
opt=True
opt@fout="prediction.txt"
write_matrix(predict_data_new,fmtx,opt)
<The fraction of the output text file with the 3 text files>
139.998825073242188 49.993419647216797 1.028651834
140.012084960937500 49.993419647216797 1.051712275
140.025360107421875 49.993419647216797 0.991534710
140.038635253906250 49.993419647216797 1.164933443
140.051895141601563 49.993419647216797 1.189701200
....
<The fraction of data values>
1.028651821
1.051712292
0.991534726
1.164933449
1.189701191
1.110428796
....
<The fraction of longitude and latitude>
139.998818623999990,49.993421150400003
140.012089035999990,49.993421150400003
140.025359450000000,49.993421150400003
140.038629861999990,49.993421150400003
140.051900275000010,49.993421150400003
140.065170687999990,49.993421150400003
...
Thank you so much
Miae
-------------------------------------------------
Miae Kim
School of Urban and Environment Engineering
Ulsan National Institute of Science and Technology (UNIST)
UNIST-gil 50, Ulsan 689-798, South Korea
Mobile: +82-10-9421-8287
E-mail: toa0710@naver.com
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Mar 13 23:25:17 2014
This archive was generated by hypermail 2.1.8 : Fri Mar 14 2014 - 15:08:52 MDT