; IDL program to ingest XFAS SODAR CT2 profiles into an IDL data structure ; Also saves data structure into an IDL save file. ; Nov 24, 2004: add wind and quality evaluation ;--------------------------------------------------------- function readsodar, file, prof ; ; Reads SODAR file into a structure ; ; prof = { UTyear: 0, UTmonth: 0, UTday: 0, UThour:0.0, UTmin:0.0, $ ; nlevels:40, alt:FLTARR(40), ct2:FLTARR(40) } close, /all openr, 1, file out = REPLICATE(prof, 50) nprof = -1 aline = '' ialt = 100 ; --- loop over the data file while not eof(1) do begin READF, 1, aline tmp = strsplit(aline, count=nitems, /extract) ; Header line for a new profile? Save the previous, get time if ((nitems eq 4) and (strmid(tmp[0],0,5) eq '2004-')) then begin ; print, nitems, ' --- ',strmid(tmp[0],0,5) if (nprof ge 0) then begin prof.nlevels = ialt out[nprof] = prof endif nprof = nprof+1 ialt = 0 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.UThour = fix(strmid(tmp[1],0,2)) prof.UTmin = fix(strmid(tmp[1],3,2)) print, 'Reading profile, UT ',tmp[1] endif ; Data line? if ((nitems eq 37) and (ialt lt 40)) then begin prof.alt[ialt] = float(tmp[0]) ct2 = float(tmp[29]) sigw = float(tmp[23]) if (ct2 gt 1 ) then ct2 = 0. u = float(tmp[3]) & v = float(tmp[4]) & w = float(tmp[5]) ; mask unreliable data if ((sigw gt 1) or (sigw lt 0.2)) then begin ct2=0 u = 0. & v = 0. & w = 0. endif prof.ct2[ialt] = ct2 prof.u[ialt] = u prof.v[ialt] = v prof.w[ialt] = w prof.sigw[ialt] = sigw ialt++ endif endwhile close, 1 prof.nlevels = ialt out[nprof] = prof nprof = nprof+1 print, 'Total profiles found: ', nprof print, 'UT range: ',out[0].UThour,':',out[0].UTmin,' -- ',out[nprof-1].UThour,':',out[nprof-1].UTmin out = out[0:nprof-1] nalt = n_elements(out[0].ct2) tmp = fltarr(nprof,nalt) for i=0,nprof-1 do tmp(i,*) = out[i].ct2 device, decomposed=0 ; to get the colors on X-display! loadct, 4 ; tvscl, congrid(tmp,400, 400, /interp) tvscl, sqrt(congrid(tmp,400, 400) ) ; SAVE, out, filename = 'sodar.idl' return, out END ;--------------------------------------------------------- pro readall, list ; reads data from a list of files and saves in a structure prof = { UTyear: 0, UTmonth: 0, UTday: 0, UThour:0.0, UTmin:0.0, $ nlevels:39, alt:FLTARR(39), ct2:FLTARR(39), $ u:fltarr(39), v:fltarr(39), w:fltarr(39),sigw:fltarr(39) } 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 = readsodar(files[i],prof) k = n_elements(tmp) cnt[i]=k nprof = nprof+k print, k, ' profiles found' ; stop ENDFOR endif spdat = REPLICATE(prof, nprof) k = 0 FOR i=0,n-1 DO BEGIN PRINT, '%Reading profiles from '+files[i] spdat(k:k+cnt[i]-1) = readsodar(files[i],prof) k = k+ cnt[i] ENDFOR save, filename='sodar.idl', spdat end