pro rd_arc_nam_2310,fn,nvar,max_pts,rec,ohdr,odata,scale,flag ; Simple reader for LASE aerosol and water vapor profile data in gaines/hipskind format # 2310 ; Documentation is at https://cloud1.arc.nasa.gov/solve/archiv/archive.tutorial.html. ; 7/15/2004 Susan Kooi ; input -- name of archive file ; output ; -- nvar, number of variables in the data array [always 1] ; -- rec, number of profiles in the file ; -- max_pts, size of largest profile in odata ; -- ohdr, fltarr, 2-dim array of header info ; -- 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 ; sample usage -- ; f= file_search('*.NAM') ; rd_arc_nam_2310,f(0),nvar,max_pts,rec,ohdr,odata,scale,flag ; indx= 100 ; alt= findgen(ohdr(3,indx)) * ohdr(5,indx) + ohdr(4,indx) ; plot,odata(*,indx),alt,xran=[0,120] ; plot profile 100 ; contents of ohdr for LASE/NAMMA -- ; 0= start time (UT) of averaging interval, sec ; 1= end time, sec ; 2= mid time, sec (same as ohdr(7:9)) ; 3= # words of data in this profile ; 4= altitude of the first word of data, m ; 5= # meters per word (constant) ; 6= aircraft altitude, m ; 7= hour ; 8= minute ; 9= seconds ; 10= latitude, degrees North ; 11= longitude, degrees East openr,l,fn,error = err,/get if(err ne 0) then begin print, -2, !err_string stop endif ; read header saving scale and flag arrays only ;num_wd_ind= 1 ; TC4 num_wd_ind= 3 ; NAM & PECAN 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 ;print,aline endfor readf,l,nvar rd_cnt= rd_cnt+1 scale=fltarr(nvar) flag=fltarr(nvar) readf,l,scale scale=[1.0,scale] rd_cnt= rd_cnt+1 readf,l,flag rd_cnt= rd_cnt+1 for i=1, nvar do begin readf,l,aline rd_cnt= rd_cnt+1 ;print,aline endfor 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] ; for ease of codeing later 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 ;print,aline ; read data max_recs= 11.*60.*60./2 ; assuming 11 hour flight at 2 sec/rec max_points= 1000 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 if(h(num_wd_ind) gt 0) then begin x= fltarr(h(num_wd_ind)) readf,l,x data(0:n_elements(x)-1,rec)= x ; The following line was added to skip over the ozone uncertainty for i=2,nvar do readf,l,x endif ; stop,' check data and x' rec= rec+1 endwhile rec=rec-1 print,' Done reading ',rec,' records from '+fn free_lun,l ; ; cleanups ; max_pts=max(hdr(num_wd_ind,*)) print,' Largest profile has ',max_pts,' values.' print,' Smallest profile has ',min(hdr(num_wd_ind,*)),' values.' flag= flag*scale(1:*) orig_h_flag=h_flag h_flag= h_flag*h_scale(1:*) ; NOTE: flag values that appear to no longer be 99999's after ; scaling are still correct internally. It is the default ; print format that is rounding them. odata=replicate(h_flag(1),max_pts,rec) for i=0, rec-1 do begin ; resize data to actual amount 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