;Title: acse_readwind ;Purpose: Read 449 wind profiler files for ACSE ; ;Inputs: sarg: date/time string, YYYYMMDDHH ; earg: data/time string, YYYYMMDDHH ; mode: wind mode: 0=low; 1=high ;Outputs time: time of profile [hours] ; height: height of observation [km] ; speed: wind speed [m/s] ; direction: wind direction [degrees] ;Keywords: directory: directory containing data ; factor: factor by which to decrease the vertical sample resolution ; algorithm: method for calculation (0 or 1, default: 0) ;I/O: ;Author: Matthew Shupe ;Date: 7/15/08, adapted 7/12/2014 ;Note: Wind data are in hourly averaged files ;------------------------------------------------------ pro acse_readwind,sarg,earg,mode,time,height,speed,direction,directory=directory,factor=factor,algorithm=algorithm if keyword_set(directory) then cd,directory,current=orig_dir if not keyword_set(algorithm) then algorithm=0 if algorithm eq 0 then alg='a' else alg='b' if mode eq 0 then hl='L' else hl='H' ;Determine the files to open sjd=julday(strmid(sarg,4,2),strmid(sarg,6,2),strmid(sarg,0,4))-julday(1,1,strmid(sarg,0,4))+1 if strmid(sarg,6,2) ne strmid(earg,6,2) then begin ejd=julday(strmid(earg,4,2),strmid(earg,6,2),strmid(earg,0,4))-julday(1,1,strmid(earg,0,4))+1 if ejd lt sjd then begin print,'ascos_readwind: cannot go across a new year.' stop endif numa=ejd-sjd+1 darg=strarr(numa) for i=0,numa-1 do begin darg[i]=strmid(sarg,2,2)+strtrim(sjd+i,2) endfor endif else begin darg=strmid(sarg,2,2)+strtrim(sjd,2) numa=n_elements(darg) endelse ;Initialize variables time=fltarr(24*numa*2) height=fltarr(150) speed=fltarr(24*numa*2,150) direction=fltarr(24*numa*2,150) jnk=' ' st12=strarr(12) st7=strarr(7) v1=0.0 & v2=0.0 & v3=0.0 ;Loop over daily arguments ind=0 mxindh=0 for d=0,numa-1 do begin ;Get the list of files for the daily argument arg='WQA'+darg[d]+hl+alg+'.CNS' file=findfile(arg,count=numf) ;Loop over all files in the day for f=0,numf-1 do begin print,'Reading ',file[f] openr,lun,/get_lun,file[f] while not eof(lun) do begin readf,lun,jnk readf,lun,jnk readf,lun,jnk readf,lun,jnk st7=strsplit(jnk,' ',/extract) time[ind]=float(st7[3])+float(st7[4])/60.+float(st7[5])/3600. for i=0,5 do readf,lun,jnk indh=0 readf,lun,jnk while strmid(jnk,0,1) ne "$" do begin st12=strsplit(jnk,' ',/extract) if ind eq 0 then begin height[indh]=float(st12[0]) mxindh=mxindh+1 endif speed[ind,indh]=float(st12[1]) direction[ind,indh]=float(st12[2]) indh=indh+1 readf,lun,jnk endwhile ind=ind+1 endwhile free_lun,lun endfor endfor if ind gt 0 then begin time=time[0:ind-1] speed=speed[0:ind-1,*] direction=direction[0:ind-1,*] height=height[0:mxindh-1] speed=speed[*,0:mxindh-1] direction=direction[*,0:mxindh-1] ;Reduce by the requested height factor if keyword_set(factor) then begin numh=n_elements(height) inds=indgen(fix(float(numh)/factor))*factor height=height[inds] speed=speed[*,inds] direction=direction[*,inds] endif ;Trim data to the hour range requested shr=fix(strmid(sarg,8,2)) ehr=fix(strmid(earg,8,2)) wh=where(time ge shr and time le ehr+24.0*(numa-1),nm) if nm gt 0 then begin time=time[wh] speed=speed[wh,*] direction=direction[wh,*] endif endif else begin time=findgen(24) height=findgen(40)/10. speed=fltarr(24,40)*0-999. direction=speed endelse if keyword_set(directory) then cd, orig_dir end