pro cutmerge,infile, MAXHEIGHT=maxheight ;-------------------------------------------------------------------------------- ;Title: cutmerge.pro ;Purpose: Script to create a netCDF file that contains only the important ; fields from the new merge files. ; ;I/O: cutmerge,'nsaarscl1clothC1.c1.20000419.000000.cdf' ; ;Inputs: infile: the new merge file to be cut down ; ; Keyword: MAXHEIGHT - maximum data height in meters in radar file. (Default: 15000.) ; ;Outputs: *a file is created with the convention: ; ;Author: Matthew Shupe ;Date: 5/25/00 ;Modified: 11/07/00 ;-------------------------------------------------------------------------------- if not(keyword_set(MAXHEIGHT)) then maxheight=15000. ;Open both the in and out files outfile=strmid(infile,0,3)+'mrgcutC1.c1.'+strmid(infile,18,19,/rev) print,'Cutting ',infile,' into > ',outfile fidi=ncdf_open(infile) fido=ncdf_create(outfile,/clobber) ;Set up the dimensions ncdf_varget,fidi,ncdf_varid(fidi,'Heights'),ht iwh=where(ht le maxheight,numht) ncdf_diminq,fidi,ncdf_dimid(fidi,'time'),tn,ts ncdf_diminq,fidi,ncdf_dimid(fidi,'nheights'),nn,ns ncdf_diminq,fidi,ncdf_dimid(fidi,'numlayers'),ln,ls tdid=ncdf_dimdef(fido,tn,ts) hdid=ncdf_dimdef(fido,nn,numht) ldid=ncdf_dimdef(fido,ln,ls) ;Define all of the variables fields=['base_time','time_offset','Heights','Reflectivity','MeanDopplerVelocity',$ 'SpectralWidth','SignaltoNoiseRatio','CloudLayerBottomHeightMplCloth',$ 'CloudLayerTopHeightMplCloth','ModeId'] fieldids=['bvid','ovid','hvid','rvid','vvid','wvid','nvid','svid','tvid','mvid'] bvid=ncdf_vardef(fido,fields[0],/long) ovid=ncdf_vardef(fido,fields[1],[tdid],/double) hvid=ncdf_vardef(fido,fields[2],[hdid],/float) rvid=ncdf_vardef(fido,fields[3],[hdid,tdid],/short) vvid=ncdf_vardef(fido,fields[4],[hdid,tdid],/short) wvid=ncdf_vardef(fido,fields[5],[hdid,tdid],/short) nvid=ncdf_vardef(fido,fields[6],[hdid,tdid],/short) svid=ncdf_vardef(fido,fields[7],[ldid,tdid],/float) tvid=ncdf_vardef(fido,fields[8],[ldid,tdid],/float) mvid=ncdf_vardef(fido,fields[9],[hdid,tdid],/char) ;Copy all variable and global attributes for i=0,n_elements(fields)-1 do begin vi=ncdf_varid(fidi,fields[i]) junk=ncdf_varinq(fidi,vi) for j=0,junk.natts-1 do $ junka=ncdf_attcopy(fidi,fields[i],ncdf_attname(fidi,vi,j),fido,fields[i]) endfor junk=ncdf_inquire(fidi) for i=0,junk.ngatts-1 do $ junka=ncdf_attcopy(fidi,/in_global,ncdf_attname(fidi,/global,i),fido,/out_global) ncdf_attput,fido,/global,'comment_etl','This file has been cut down to include certain fields from the original file: '+infile ;End the definition mode ncdf_control,fido,/fill ncdf_control,fido,/endef ;Fill the variables in the output file for i=0,n_elements(fields)-1 do begin res=execute("ncdf_varget,fidi,ncdf_varid(fidi,'"+fields[i]+"'),"+fields[i]) if i eq 2 then Heights=Heights[iwh] if (i eq 3) or (i eq 4) or (i eq 5) or (i eq 6) or (i eq 9) then res=execute(fields[i]+'='+fields[i]+'[iwh,*]') res=execute('ncdf_varput,fido,'+fieldids[i]+','+fields[i]) endfor ;ncdf_varget,fidi,ncdf_varid(fidi,'base_time'),base_time ;ncdf_varput,fido,bvid,base_time ;ncdf_varget,fidi,ncdf_varid(fidi,'time_offset'),time_offset ;ncdf_varput,fido,ovid,time_offset ;ncdf_varget,fidi,ncdf_varid(fidi,'Heights'),Heights ;ncdf_varput,fido,hvid,Heights ;ncdf_varget,fidi,ncdf_varid(fidi,'Reflectivity'),Reflectivity ;ncdf_varput,fido,rvid,transpose(Reflectivity) ;ncdf_varget,fidi,ncdf_varid(fidi,'MeanDopplerVelocity'),MeanDopplerVelocity ;ncdf_varput,fido,vvid,MeanDopplerVelocity ;ncdf_varget,fidi,ncdf_varid(fidi,'SpectralWidth'),SpectralWidth ;ncdf_varput,fido,wvid,SpectralWidth ;ncdf_varget,fidi,ncdf_varid(fidi,'SignaltoNoiseRatio'),SignaltoNoiseRatio ;ncdf_varput,fido,nvid,SignaltoNoiseRatio ;ncdf_varget,fidi,ncdf_varid(fidi,'CloudLayerBottomHeightMplCloth'),CloudLayerBottomHeightMplCloth ;ncdf_varput,fido,svid,CloudLayerBottomHeightMplCloth ;ncdf_varget,fidi,ncdf_varid(fidi,'CloudLayerTopHeightMplCloth'),CloudLayerTopHeightMplCloth ;ncdf_varput,fido,tvid,CloudLayerTopHeightMplCloth ;ncdf_varget,fidi,ncdf_varid(fidi,'ModeId'),ModeId ;ncdf_varput,fido,mvid,ModeId ncdf_close,fido ncdf_close,fidi end ;prog