pro rd_cm4_2310,fn,max_pts,rec,ohdr,odata,scale,flag,rm_flags=rm_flags ; Reader for gaines/hipskind format 2310 for LASE/CAMEX-4 ascii archive files. ; 12/3/2000 sk ; modification 7/25/2001 mbc: ; keyword rm_flags - removes interpolation and in situ data flags ; input -- name of archive file ; output ; -- max_pts, size of largest profile ; -- rec, number of profiles in the file ; -- ohdr, fltarr, array of header info ; time, elapsed seconds from start ; number of values in the profile ; gps altitude of first data word, meters ; altitude increment, meters ; gps altitude of aircrage, meters ; time, hrs ; time, min ; time, sec ; gps latitude, degrees N ; gps longitude, degrees E ; -- odata, 2 dim array of data, sized max_pts, rec ; -- scale, array of scale factors for data ; -- flag, array of bad data flags for data ; ; Limitations -- the data matrix is not altitude aligned. This can be done ; with the information in the profile headers. For each profile, ; the third header entry is the altitude of the first data word, the fourth ; header entry is the altitude interval between consecutive data values. ; for example, to calculate the altitude profile for profile 10 ; i= 10 ; alt_arr= findgen(ohdr(1,i)) * ohdr(3,i) + ohdr(2,i) ; plot,odata(*,i),alt_arr ; openr,l,fn,error = err,/get if(err ne 0) then begin print, -2, !err_string stop endif ; read header saving scale and flag values only aline='' rd_cnt= 0 readf,l,num_head,num_format if(num_format ne 2310) then begin print,' Wrong archive format file = ',num_format print,' Expected format 2310 only! return endif rd_cnt= rd_cnt+1 for i=1,9 do begin readf,l,aline rd_cnt= rd_cnt+1 endfor readf,l,nvar rd_cnt= rd_cnt+1 readf,l,scale rd_cnt= rd_cnt+1 readf,l,flag rd_cnt= rd_cnt+1 readf,l,aline rd_cnt= rd_cnt+1 readf,l,nhdr rd_cnt= rd_cnt+1 h_scale=fltarr(nhdr) h_flag=lonarr(nhdr) readf,l,h_scale h_scale= [1.0,h_scale] ; time (elapsed secs) + header values rd_cnt= rd_cnt+1 readf,l,h_flag rd_cnt= rd_cnt+1 while(rd_cnt lt num_head) do begin readf,l,aline rd_cnt= rd_cnt+1 endwhile ; read data assuming LASE 11 hrs max at full resolution (6 sec/rec) max_recs= 11.*60./.1 max_points= 500 hdr=fltarr(nhdr+1,max_recs) h=fltarr(nhdr+1) rec=0 data=fltarr(max_points,max_recs) while not(eof(l)) do begin readf,l,h hdr(*,rec)= h * h_scale x=lonarr(h(1)) ; length of profile varies readf,l,x x = x * scale if (keyword_set(rm_flags)) then undo_flags2,x data(0:h(1)-1,rec)= x rec= rec+1 endwhile rec=rec-1 print,' Done reading ',rec,' records from '+fn free_lun,l ; ; cleanups ; max_pts=max(hdr(1,*)) print,' Largest profile has ',max_pts,' values.' flag= flag*scale orig_h_flag=h_flag h_flag= h_flag*h_scale(1:*) odata=replicate(h_flag(1),max_pts,rec) for i=0, rec-1 do begin ; resize data to largest profile odata(0:max_pts-1,i)= data(0:max_pts-1,i) endfor ohdr=fltarr(nhdr+1,rec) for i=0, nhdr do begin xx= hdr(i,0:rec-1) ohdr(i,*)= xx endfor end pro undo_flags2,profiles flag1=where((profiles gt 9000.1) and $ (profiles lt 13000.),count1) flag2=where((profiles gt 99000.1) and $ (profiles lt 103000.) and $ (profiles ne 99999.9) and $ (profiles ne 99999.0),count2) flag3=where((profiles gt 999000.1) and $ (profiles lt 1003000.),count3) flag4=where((profiles gt 990) and $ (profiles lt 1100),count4) ; H2O only!!!!!!!!! if (count1 gt 0) then profiles(flag1)=profiles(flag1)-10000. if (count2 gt 0) then profiles(flag2)=profiles(flag2)-100000. if (count3 gt 0) then profiles(flag3)=profiles(flag3)-1000000. if (count4 gt 0) then profiles(flag4)=profiles(flag4)-1000. return end