Hello guys,
I am completely new to IDL. I have problems with outputting 2D arrays
into a txt file. What i have to do is run the procedure a 1000 times,
and the procedure is looking for a number of clumps hit in X-ray and
optical area, and it goes through different inclination and azimuthal
angle, and stores all the values into a 2D arrays, one for X-ray and
one for Optical region. Here is my code:
function satellite,clumps,nasteps,nisteps,fnamex,fnameo
azi=0.0
observer_azi=0.0
ii=0.0
observer_i=0.0
lines_x=fltarr(nisteps+1,nasteps+1)
lines_o=fltarr(nisteps+1,nasteps+1)
; each row has same azi
for i=0L,nasteps-1 do lines_x[0,i+1]=(360.0/(nasteps-1))*i
for i=0L,nasteps-1 do lines_o[0,i+1]=(360.0/(nasteps-1))*i
; each column has same inclination from -90 to 90
for i=0L,nisteps-1 do lines_x[i+1,0]=(180.0/(nisteps-1))*i-90.0
for i=0L,nisteps-1 do lines_o[i+1,0]=(180.0/(nisteps-1))*i-90.0
for j=1L,nisteps do begin
for i=1L,nasteps do begin
intersect_x=fltarr(2,50)
intersect_o=fltarr(2,600)
print, 'Azimuth=', lines_x[0,i]
print, 'Inclination=', lines_x[j,0]
line_sphere_test,clumps,lines_x[0,i],lines_x[j,
0],intersect_x,intersect_o
print, moment(intersect_x[0,*])
print, moment(intersect_o[0,*])
lines_x[j,i]=(moment(intersect_x[0,*]))[0]
lines_o[j,i]=(moment(intersect_o[0,*]))[0]
print,'end of a step'
endfor
endfor
openw,1,fnamex
openw,2,fnameo
for j=0L,nasteps do begin
printf,1,lines_x[*,j]
printf,2,lines_o[*,j]
endfor
close,1
close,2
return, lines_o
end
and this is how i run the code 1000 times:pro run_satellite
N = 1000
root='datarun5_kemal'
nasteps=3
nisteps=3
for i=0,N-1 do begin
fxray=root+strtrim(i,2)+'_xray.txt'
fopt=root+strtrim(i,2)+'_opt.txt'
clumps=clumps_generator(1000,0.5,2,30,0.02,1.5)
test=satellite(clumps,nasteps,nisteps,fxray,fopt)
endfor
return
end
The problem that occurs is the way tables(arrays) are formated. First
it doesnt output 1000 txt files for each, but it crams them up in a
few, and then I cant figure out formatting at all. What i want is
having them, in tables where i can later go through each column, and
analyze data. Can somebody please help me?
|