pro get_mplcmask1cloth_list,varname,data,site,date,missing ;*************************************************************** ; Inputs - set here or passed in through the command line ;*************************************************************** ; Site to process ;site='sgp' ; Date to process ;date='19980731' ; Variables to get ;varname=['base_time','time_offset','Heights',$ ; 'CloudMaskMplCloth','qc_BeamAttenuationMplCloth'] ; Missing data flag ;missing=-8888 ;************************************************************** ; Establish some constants ;************************************************************** ; Print flag dp='no' ; List of 2d variables in the file and their dimensions ; This variable is (time,height) var2=['CloudMaskMplCloth'] vardim2=make_array(n_elements(var2),/int,value=2) ; List of 1d variables in the file and their dimensions ; These variables are (time) var1=['qc_BeamAttenuationMplCloth'] vardim1=make_array(n_elements(var1),/int,value=1) ; Variables that aren't to be combined across files var0=['base_time','time_offset','Heights'] vardim0=make_array(n_elements(var0),/int,value=0) ; Combine these all into one big array var=[var2,var1,var0] vardim=[vardim2,vardim1,vardim0] ;*************************************************************** ; Make sure the dates are in an array ;*************************************************************** ; Number of different dates to pick up numdates=n_elements(date) ; Put the search dates in an array of dates called curdate curdate=make_array(/string,numdates) if numdates gt 1 then begin for i=0,numdates-1 do begin curdate[i]=strcompress(string(date[i]),/remove_all) endfor endif else begin curdate[0]=strcompress(string(date),/remove_all) endelse ;*************************************************************** ; Set up strings to build the filename ;*************************************************************** ; Main arm site directory arm_dir='/uufs/chpc.utah.edu/common/home/mace_grp/data/arm/'+site+'/' ; Arm data directory and datastream depends on site if site eq 'sgp' then begin datastream='sgpmplcmask1clothC1.c1' height_dim_name='nheights' endif else if site eq 'nsa' then begin datastream='nsamplcmask1clothC1.c1' height_dim_name='nheights' endif else if site eq 'twpc1' then begin datastream='twpmplcmask1clothC1.c1' height_dim_name='nheights' endif else if site eq 'twpc2' then begin datastream='twpmplcmask1clothC2.c1' height_dim_name='nheights' endif else if site eq 'twpc3' then begin datastream='twpmplcmask1clothC3.c1' height_dim_name='nheights' endif ;*************************************************************** ; Loop through the dates and make an array of file names ;*************************************************************** ; Loop through the dates for i=0,numdates-1 do begin ; Create the filename arm_file=arm_dir+datastream+'/'+strmid(curdate[i],0,4)+'/'+$ datastream+'*.'+curdate[i]+'*cd*' ; Unzip them if necessary unix_command='gunzip -fq '+arm_file+'*gz' spawn,unix_command ; Get a list of the files for the day filesd=file_search(arm_file,count=num_files) ; Put these files in one big list if files exist for this date if num_files gt 0 then begin if n_elements(files) eq 0 then begin files=filesd endif else begin files=[files,filesd] endelse endif endfor ;end of loop through the dates ; Number of files to read and cat together num_files=n_elements(files) ; Continue processing if there are files if num_files gt 0 then begin ;*************************************************************** ; Loop through all the matching files and read in the data ;*************************************************************** for i=0,num_files-1 do begin ; Print the filename print,files[i] ; Open the netcdf file cdf_id=ncdf_open(files[i]) ; Get the dimension id's time_did=ncdf_dimid(cdf_id,'time') height_did=ncdf_dimid(cdf_id,height_dim_name) ; Get the dimensions ncdf_diminq,cdf_id,time_did,charstring,ntimes ncdf_diminq,cdf_id,height_did,charstring,nheights ; Create array for nodata value dummy1d=make_array(ntimes,/float,value=missing) dummy2d=make_array(ntimes,nheights,/float,value=missing) ; Get the variable ids for v=0,n_elements(varname)-1 do begin xstr=varname[v]+'_id=ncdf_varid(cdf_id,"'+varname[v]+'")' result=execute(xstr) if dp eq 'yes' then print,varname[v] endfor ; ; Loop through the variable names. Get the variable if it exists. ; If it doesn't exist, set the variable equal to the dummy array. ; for v=0,n_elements(varname)-1 do begin ; Determine the dimension of this variable xstr='idx=where(var eq "'+varname[v]+'",count)' result=execute(xstr) if count eq 0 then begin print,varname[v],'variable not in list of acceptable variables' stop endif else begin dim=vardim[idx] if dim eq 1 then dumname='dummy1d' $ else if dim eq 2 then dumname='dummy2d' $ else if dim eq 3 then dumname='dummy3d' endelse if dp eq 'yes' then print,'processing ',varname[v],'dimension',dim ; Get the variable if dim ne 0 then begin xstr='if '+varname[v]+'_id gt -1 then ncdf_varget,cdf_id,'+$ varname[v]+'_id,'+varname[v]+' else '+varname[v]+'='+dumname endif else begin xstr='if '+varname[v]+'_id gt -1 then ncdf_varget,cdf_id,'+$ varname[v]+'_id,'+varname[v] endelse result=execute(xstr) ; Transpose 2d variables if dim gt 1 then begin if dp eq 'yes' then print,'transposing' xstr=varname[v]+'=transpose('+varname[v]+')' result=execute(xstr) endif endfor ; ; Combine the data ; for v=0,n_elements(varname)-1 do begin if varname[v] eq 'time_offset' then begin if n_elements(com_btto) eq 0 then begin com_btto=long(base_time)+long(time_offset) endif else begin com_btto=[long(com_btto),long(base_time)+long(time_offset)] endelse endif if varname[v] ne 'base_time' and varname[v] ne 'time_offset' and $ varname[v] ne 'Heights' then begin xstr='if n_elements(com_'+varname[v]+') eq 0 then com_'+$ varname[v]+'='+varname[v]+' else com_'+varname[v]+$ '=[com_'+varname[v]+','+varname[v]+']' result=execute(xstr) endif endfor ; Close the netcdf file ncdf_close,cdf_id endfor ;end of looping though the matching files ;*************************************************************** ; Zip up the data files ;*************************************************************** for i=0,num_files-1 do begin unix_command='gzip -fq '+files[i] ;zip the data files spawn,unix_command endfor ;****************************************** ; Remove the 'com_' prefix from the data array names ;****************************************** for v=0,n_elements(varname)-1 do begin if varname[v] eq 'base_time' then begin base_time=long(com_btto[0]) endif else if varname[v] eq 'time_offset' then begin time_offset=long(com_btto)-long(base_time) endif else if varname[v] ne 'Heights' then begin xstr=varname[v]+'=com_'+varname[v] result=execute(xstr) endif endfor ;end of loop through variables ;***************************************** ; Put the data in a structure to pass back out ;***************************************** data={data,filename:'string'} for v=0,n_elements(varname)-1 do begin xstr='data=create_struct(data,"'+varname[v]+'",'+varname[v]+')' result=execute(xstr) endfor ;*************************************************************** ; Plot the data ;*************************************************************** do_plot='no' if do_plot eq 'yes' then begin ; ; Find the size of the arrays ; numtimes=n_elements(time_offset) ;number of times numheights=n_elements(height) ;number of heights ; ; Calculate time array for plotting ; ; Number of seconds in a day sec_per_day=24D*60D*60D ; Get IDL julian day of day 1 day1=julday(1,1,1970,0,0,0) ; Get IDL julian day of the entire time array julian_day=double(day1 + (base_time+time_offset)/sec_per_day) ; Check the dates caldat,julian_day,mm,dd,yy,hh,mi,ss print,yy[0],mm[0],dd[0],hh[0],mi[0],ss[0],'start time' print,yy[numtimes-1],mm[numtimes-1],dd[numtimes-1],hh[numtimes-1],$ mi[numtimes-1],ss[numtimes-1],'end time' ; Shorten the array ;result=where(height le 15,count) ;height=height[result] ;signal=signal[*,result] ; Set up the plot window,0,xsize=600,ysize=600,/pixmap loadct,39 !p.background=!d.n_colors-1 dummy=label_date(date_format=['%H:%I']) ; Postion plots xl=0.11 & xr=0.85 yb=0.07 & yt=0.9 sx=0.05 & sy=0.08 numplots_x=1 & numplots_y=1 position_plots,xl,xr,yb,yt,sx,sy,numplots_x,numplots_y,pos cbpos=pos cbpos[*,0]=cbpos[*,3]+0.07 cbpos[*,2]=0.99 ; ; Data max and min ; dmin=-2 dmax=1 ; ; Scale the data ; image=bytscl(CloudMaskMplCloth,max=dmax,min=dmin) contour,CloudMaskMplCloth,julian_day,heights/1000.0,/nodata,xstyle=4,ystyle=4,$ position=pos[0,*] px=!x.window*!d.x_vsize py=!y.window*!d.y_vsize sx=px[1]-px[0]+1 sy=py[1]-py[0]+1 tv,congrid(image,sx,sy),px[0],py[0] contour,CloudMaskMplCloth,julian_day,heights/1000.0,/noerase,/nodata,$ xtickformat='label_date',xstyle=1,ystyle=1,$ xtickunits='hour',xticklen=-0.02,yticklen=-0.02,$ color=0,xtitle='signal',$ ytitle='Height (km)',position=pos[0,*] colorbar_fanning,maxrange=dmax,minrange=dmin,$ title='signal',$ ncolors=256,format='(F6.2)',$ vertical=1,color=0,position=cbpos[0,*] image_name=datastream+'.gif' write_gif,image_name,tvrd() stop endif ;end of do_plot endif ;end of found files return end