pro readrds,arg,stime,press,tdry,dp,rh,alt,SJTIME=sjtime,RAW=raw,FILE=file,FIRSTLAST=firstlast,PLATFORM=platform ;---------------------------------------------------------------------- ;Title: readrds.pro ; ;Purpose: Read the PACS radiosonde text files. ; ;Input: arg: a string filename argument for the desired file to read. (YYYYMMDD) ; ;Output: stime: time [decimal hours] ; press: pressure [mb] ; tdry: dry bulb temperature [C] ; dp: dew point temperature [C] ; rh: relative humidity [%] ; alt: calculated altitude above mean sea level [km] ;Keywords: sjtime: optional julian decimal time ; raw: if set then no cleaning of the data is performed ; file: set to an exact filename if only one file is to be read. ; firstlast: if 0 then read only the first file of the day, if 1 only the last. ; platform: string variable set to the instrument platform (i.e. shbglastxtC1.a1) ; ;Note: Default (i.e. no RAW keyword set) interpolates all data to an MMCR-like height ; scale of 45m. ; ;I/O format: readrds,farg,stime,press,tdry,dp,rh,alt, SJTIME=sjtme ; ;Author: Matthew Shupe ;Date: 3/07/00 (original) ;Modified: 6/6/2001 ;---------------------------------------------------------------------- ; ;Future addition possibilities: ; Deal with bad data >smoothing or interpolation ;---------------------------------------------------------------------- if not(keyword_set(FILE)) then begin farg='pac*'+arg+'*.txt' file=findfile(farg,count=nfil) endif else nfil=1 ;If no sounding for this day if nfil eq 0 then begin stime=-1 platform='' return endif platform=strmid(file[0],0,strpos(file[0],'.1')) ;If only want the first or last sounding of the day if keyword_set(FIRSTLAST) then begin if firstlast eq 0 then file=file[0] else file=file[nfil-1] nfil=1 endif ;If raw data is desired then can only read one file for this day ; if not then set up the interpolated output matrices. if keyword_set(raw) then nfil=1 else begin hts=findgen(382)*.045 +.105 nhts=n_elements(hts) stime=fltarr(nfil,nhts) sjtime=stime & press=stime & tdry=stime & dp=stime & rh=stime & alt=stime endelse restore,'glas_idltemplate.dat' for i=0,nfil-1 do begin in=read_ascii(file[i],template=glas_idltemplate) ;Calculate Dew Point Temp dw=(1 / ( (1/(in.temp+273.15)) - (alog(in.rh/100.0)/5417.0) ))-273.15 ;Determine the time axis ;----------------- shr=strmid(file[i],9,2,/rev) smi=strmid(file[i],7,2,/rev) st=float(shr+(smi + (in.time)/60.)/60.) yr=strmid(arg,0,4) sjt=julday(strmid(arg,4,2),strmid(arg,6,2),yr,0,0,0)-julday(1,1,yr,0,0,0)+1+st/24. if (strmid(arg,4,4) eq '1231') and (fix(sjt[n_elements(sjt)-1])-fix(sjt[0]) eq 1) then begin iwh=where(fix(sjt) ne fix(sjt[0])) sjt[iwh]=1 + (sjt[iwh] mod 1) endif ;Clean up any bad data flags by interpolation and get only the balloon ascent ; Interpolate to a set height scale that is similar to the MMCR's. ;----------------------------------------------------- if not(keyword_set(RAW)) then begin ;Fix the raw data iwh=where(in.press eq min(in.press[where(in.press gt 0)]),num) pr=in.press[0:iwh[num-1]] td=in.temp[0:iwh[num-1]] dw=dw[0:iwh[num-1]] re=in.rh[0:iwh[num-1]] al=in.alt[0:iwh[num-1]] st=st[0:iwh[num-1]] sjt=sjt[0:iwh[num-1]] num=n_elements(pr) iwh=where(pr gt 0) pr=interpol(pr[iwh],iwh,indgen(num)) iwh=where(al gt 0,pos) if pos gt 0 then al=interpol(al[iwh],iwh,indgen(num)) iwh=where(td lt 100 and td gt -200) td=interpol(td[iwh],iwh,indgen(num)) iwh=where(dw lt 100 and dw gt -200) dw=interpol(dw[iwh],iwh,indgen(num)) iwh=where(re lt 150 and re gt 0) re=interpol(re[iwh],iwh,indgen(num)) ;Interpolate to a fixed height scale tdry[i,*]=interpol(td,al/1000.,hts) dp[i,*]=interpol(dw,al/1000.,hts) press[i,*]=interpol(pr,al/1000.,hts) rh[i,*]=interpol(re,al/1000.,hts) stime[i,*]=interpol(st,al/1000.,hts) sjtime[i,*]=interpol(sjt,al/1000.,hts) alt[i,*]=hts endif else begin press=in.press tdry=in.temp dp=dw rh=in.rh alt=in.alt/1000. stime=st sjtime=sjt endelse endfor end