idl programming language - idl strange symbols in file -
i've written several idl programs analyse data. keep simple programs read in time varying data , calculate fourier spectrum. spectrum written file using code:
openw,3,filename printf,3,[transpose(freq),transpose(power)],format='(e,e)' close,3
the file read program using code:
rdfloat,filename,freq,power,/double
the rdfloat procedure can found here: http://idlastro.gsfc.nasa.gov/
the error when trying read file is: "input conversion error. unit: 101" when delve in file being read, notice several types of unrecognised characters. dont know if these result of writing file or thing else related number of files being created (over 300 files)
these symbols/characters in place of single number:
< dle> < dc1> < dc2> < dc3> < dc4> < can> < nak> < em> < soh> < syn>
example of appears in file being read, note not consecutive lines.
7.7346< dle>18165493007e+01 8.4796811549010105e+00 7.7354408697119453e+01 1.04459538071< dc2>1749e+01 7.7360701595839< can>28e+01 3.0447318983094189e+00
whenever run procedures write files, there @ least 1 file has or of these characters. file/s contains these characters different.
can explain these symbols , might doing create them how ensure not written file?
i see 2 things may causing problem. first, want suggest few tips.
when open file, useful use /get_lun keyword because allows idl find , use logical unit number (lun) available (e.g., in case left lun 3 open somewhere else). when print formatted data, should specify total width , number of decimal places. make things easier because need not worry changing spacings between numbers in file.
so change first set of code following (or variant of following):
openw,gunit,filename[0],/get_lun,error=err j=0l, n_elements(freq) - 1l begin printf,gunit,freq[j],power[j],format='(2e20.12)' endfor free_lun,gunit ;; better using close routine
so first potential issue see if variable power
calculated using fft.pro, complex float or complex double, depending on input , keywords used.
the second potential issue may due incorrect format statement. did not tell printf
how many columns or rows expect. might not know how handle input properly, guesses , may result in characters show. characters may spacing characters due vague format statement or software using @ files (e.g., not recommend using word open text files, use text editor).
side note: can open , read file wrote in similar fashion showed above, changed following:
n = file_lines(filename[0]) freq = dblarr(n) power = dblarr(n) openr,gunit,filename[0],/get_lun,error=err j=0l, n_elements(freq) - 1l begin readf,gunit,freq[j],power[j],format='(2e20.12)' endfor free_lun,gunit ;; better using close routine
Comments
Post a Comment