; IDL program to ingest SLODAR CT2 profiles into an IDL data structure ; Also saves data structure into an IDL save file. ; Nov 28, 2004 ;--------------------------------------------------------- function readslodar, file, prof ; ; Reads SLODAR file into a structure ; prof = { UTyear: 0, UTmonth: 0, UTday: 0, UT:0.0, $ ; r0:0.0, alt:FLTARR(9), Intcn2:FLTARR(9) ) nalt = 9 close, /all openr, 1, file ; No more than 1000 profiles per night! out = REPLICATE(prof, 1000) nprof = -1 aline = '' ; --- loop over the data file while not eof(1) do begin READF, 1, aline tmp = strsplit(aline, count=nitems, /extract) nprof = nprof+1 prof.UTyear = fix(strmid(tmp[0],0,4)) prof.UTmonth = fix(strmid(tmp[0],5,2)) prof.UTday = fix(strmid(tmp[0],8,2)) prof.UT = float(tmp[1]) dh = float(tmp[2]) prof.r0 = float(tmp[3]) for j=0,nalt-1 do begin prof.alt[j] = (0. + j)*dh prof.intcn2[j] = float(tmp[4+j]) endfor out[nprof] = prof endwhile close, 1 out[nprof] = prof nprof = nprof+1 print, 'Total profiles found: ', nprof out = out[0:nprof-1] nalt = 9 tmp = fltarr(nprof,nalt) for i=0,nprof-1 do tmp(i,*) = out[i].Intcn2 device, decomposed=0 ; to get the colors on X-display! loadct, 3 ; tvscl, congrid(tmp,400, 400, /interp) tvscl, sqrt(congrid(tmp,400, 400) ) ; SAVE, out, filename = 'slodar.idl' return, out END ;--------------------------------------------------------- ; the list of files is listslodar pro readall, list ; reads data from a list of files and saves in a structure prof = { UTyear: 0, UTmonth: 0, UTday: 0, UT: 0.0, $ r0: 0.0, alt:FLTARR(9), Intcn2:FLTARR(9) } openr, 11, list files = strarr(100) PRINT, '% Counting number of files ' aline = '' n = 0 while (not eof(11)) do begin READF, 11, aline files[n] = aline n = n+1 endwhile close, 11 print, 'Number of files found: ',n cnt = intarr(n) nprof=0 if (nprof eq 0) then begin FOR i=0,n-1 DO BEGIN PRINT, 'Counting profiles from '+files[i] tmp = readslodar(files[i],prof) k = n_elements(tmp) cnt[i]=k nprof = nprof+k print, k, ' profiles found' ; stop ENDFOR endif slodat = REPLICATE(prof, nprof) k = 0 FOR i=0,n-1 DO BEGIN PRINT, '%Reading profiles from '+files[i] slodat(k:k+cnt[i]-1) = readslodar(files[i],prof) k = k+ cnt[i] ENDFOR save, filename='slodar.idl', slodat end