comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Indexing problem.. Please help me out!!!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Indexing problem.. Please help me out!!! [message #55705] Tue, 04 September 2007 16:47
kim20026 is currently offline  kim20026
Messages: 54
Registered: November 2006
Member
First of all, I am really sorry to everyone here. I should have done
this
kind of stuff in other languages such as C++ or Fortran, but I
couldn't.
Please understand me.

What I am trying to do now is to merge 40 files with same format into
one file. Fortunately, the format of those file is identical...
actually each file is composed of 5 headers and one array
(site_arr=fltarr(25,365)). I don't need headers at all, and I just
ignored them. I prepared for a big array(met_arr = fltarr(25,
365*40)) to accomodate the 40 files.


I had no trouble to read the first file, but I faced an indexing
problem in proceeding further.
1) I read the first file and record it in the first 365 line of
met_arr.
2) I was frustrated when I tried to read next file and write it in
the
proper location in the met_arr.


I thought it was just a simple indexing problem, but it was not
simple
as I expected.


This is what I have done so far. Just take a look and give me any
suggestions and comments. Thank you all!!!


Harry


------------------------------------------------------------ ---------------­--------------------------------
pro NWS_All


batch_st = 'batch_nws.txt'
N_nws = file_lines(batch_st)
Sites = Strarr(N_nws)


openr, lun, batch_st, /get_lun
readf, lun, Sites
Free_lun, lun
close, /all


header1=''
header2=''
header3=''
header4=''
header5=''


met_arr = fltarr(25, 14600)
site_arr = fltarr(25, 365)
c1 = 0
close, 2
openw, 2, 'NWS_SWR_All.txt'
for i = 0, 3 do begin; 39 do begin


;open 1st file


file = strcompress(Sites[i], /remove_all)
nmet = file_lines(file)


close,1
openr,1, file
readf,1,header1
readf,1,header2
readf,1,header3
readf,1,header4
readf,1,header5
readf,1,site_arr
close,1
for j = 0, nmet-1 do begin
DD = 365*(i+1)-1
if j lt DD then begin
Met_arr[0, *] = i+1
Met_arr[1:24, 365*i:365*(i+1)-1] = site_arr[1:24, *]
endif else begin
i=i+1
Met_arr[0, *] = i+1
Met_arr[1:24, 365*i:365*(i+1)-1] = site_arr[1:24, *]
endelse
printf, 2, Met_arr[0:24, *], format = '(25(f10.2, 2x))'
endfor
endfor


close, 2
end
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: how IDL or ION returns an alpha image (32 bits)
Next Topic: Re: Accurate/fast interpolation

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:09:56 PDT 2025

Total time taken to generate the page: 0.00396 seconds