pro get_mwr, curdate,site,datastream,input_flag common mwr_data, base_time, time_offset, $ vap,liq,tbsky23,tbsky31,irtemp,wetwindow,lat,lon,alt ; ; Pieces to use to make the directory and filename ; if input_flag eq 'one' then begin if site eq 'twpc1' then begin armdatadir='/data/mace/arm_data/twp/Manus_C1/' datastream='twpmwrlosC1.b1' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' datastream='twpmwrlosC2.b1' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' datastream='nsamwrlosC1.a1' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' datastream='sgp1mwravgC1.c1' endif armfile=armdatadir+datastream+'/'+datastream+'.'+curdate+'*.cd*' endif else if input_flag eq 'eos' then begin if site eq 'twpc1' then begin armdatadir='/data/mace/arm_data/twp/Manus_C1/' eosfilename='twpC1.eos_val_mace.c1' datastream='twpmwrlosC1.b1' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' eosfilename='twpC2.eos_val_mace.c1' datastream='twpmwrlosC2.b1' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' eosfilename='nsaC1.eos_val_mace.c1' datastream='nsamwrlosC1.a1' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' eosfilename='sgpC1.eos_val_mace.c1' datastream='sgp1mwravgC1.c1' endif armfile=armdatadir+eosfilename+'/'+eosfilename+'.'+curdate+'*.cd*' endif ; ; Unzip the data files ; unix_command='gunzip -fq '+armfile spawn,unix_command ; ; Get a list of the matching filenames ; print, 'filename ',armfile files=findfile(armfile,count=count) print, 'files ',files print, 'count ',count if count eq 0 then exit ;no files for this day ; ; Process files ; j=-1 ;counts number of cdf files for i=0,count-1 do begin ;do for all the matching files in the directory ; ; Don't try to process any gif or png files that may be in the directory ; if strpos(files[i],'gif') eq -1 and $ strpos(files[i],'png') eq -1 then begin j=j+1 ; ; Open the netcdf file ; cdfid=ncdf_open(files[i]) ; ; Get the dimension id's ; time_did=ncdf_dimid(cdfid,'time') ; ; Get the variable id's ; base_time_id=ncdf_varid(cdfid,'base_time') time_offset_id=ncdf_varid(cdfid,'time_offset') vap_id=ncdf_varid(cdfid,'vap') liq_id=ncdf_varid(cdfid,'liq') tbsky23_id=ncdf_varid(cdfid,'tbsky23') ;variables have a different name before 12-31-1999 if tbsky23_id eq -1 then tbsky23_id=ncdf_varid(cdfid,'23tbsky') tbsky31_id=ncdf_varid(cdfid,'tbsky31') ;variables have a different name before 12-31-1999 if tbsky31_id eq -1 then tbsky31_id=ncdf_varid(cdfid,'31tbsky') irtemp_id=ncdf_varid(cdfid,'ir_temp') ;variables have a different name after 4-1-2001 if irtemp_id eq -1 then irtemp_id=ncdf_varid(cdfid,'sky_ir_temp') wetwindow_id=ncdf_varid(cdfid,'wet_window') waterflag_id=ncdf_varid(cdfid,'water_flag_fraction') lat_id=ncdf_varid(cdfid,'lat') lon_id=ncdf_varid(cdfid,'lon') alt_id=ncdf_varid(cdfid,'alt') ; ; Get the data ; if base_time_id ne -1 then ncdf_varget, cdfid, base_time_id, base_time ;Base time in Epoch, seconds since 1970-1-1 0:0:0 if time_offset_id ne -1 then ncdf_varget, cdfid, time_offset_id, time_offset ;Time offset from base_time if vap_id ne -1 then ncdf_varget, cdfid, vap_id, vap if liq_id ne -1 then ncdf_varget, cdfid, liq_id, liq if tbsky23_id ne -1 then ncdf_varget, cdfid, tbsky23_id, tbsky23 if tbsky31_id ne -1 then ncdf_varget, cdfid, tbsky31_id, tbsky31 if irtemp_id ne -1 then ncdf_varget, cdfid, irtemp_id, irtemp if wetwindow_id ne -1 then ncdf_varget, cdfid, wetwindow_id, wetwindow if waterflag_id ne -1 then ncdf_varget, cdfid, waterflag_id, wetwindow if lat_id ne -1 then ncdf_varget, cdfid, lat_id, lat if lon_id ne -1 then ncdf_varget, cdfid, lon_id, lon if alt_id ne -1 then ncdf_varget, cdfid, alt_id, alt ; ; Combine the data into big arrays ; if j eq 0 then begin ;if it is the first file if time_offset_id ne -1 then com_btto=base_time+time_offset if vap_id ne -1 then com_vap=vap if liq_id ne -1 then com_liq=liq if tbsky23_id ne -1 then com_tbsky23=tbsky23 if tbsky31_id ne -1 then com_tbsky31=tbsky31 if irtemp_id ne -1 then com_irtemp=irtemp if wetwindow_id ne -1 or waterflag_id ne -1 then com_wetwindow=wetwindow endif else begin ;if it is not the first file if time_offset_id ne -1 then com_btto=[com_btto,base_time+time_offset] if vap_id ne -1 then com_vap=[com_vap,vap] if liq_id ne -1 then com_liq=[com_liq,liq] if tbsky23_id ne -1 then com_tbsky23=[com_tbsky23,tbsky23] if tbsky31_id ne -1 then com_tbsky31=[com_tbsky31,tbsky31] if irtemp_id ne -1 then com_irtemp=[com_irtemp,irtemp] if wetwindow_id ne -1 or waterflag_id ne -1 then com_wetwindow=[com_wetwindow,wetwindow] endelse ;end of if it is the first file ; ; Close the netcdf file ; ncdf_close,cdfid endif ;only process cdf files endfor ;loop through number of matching file names ; ; Skip the rest if there are no files ; if j lt 0 then print, 'found no files' if j lt 0 then exit ; ; Skip the rest if there are no variables ; if vap_id eq -1 and liq_id eq -1 and tbsky23_id eq -1 $ and tbsky31_id eq -1 and irtemp_id eq -1 and wetwindow_id eq -1 $ then begin if input_flag eq 'eos' then begin openw,15,'/data/mace4/arm_data/eos/eos_image_name.dat' printf,15,0 close,15 endif print, 'found no variables' ; ; Zip up the data files ; unix_command='gzip -fq '+armfile ;zip the data files spawn,unix_command unix_command='gunzip -fq *gif.gz' ;unzip any gif files unintentionally zipped spawn,unix_command unix_command='chmod 664 '+armfile ;change permissions spawn,unix_command unix_command='chgrp met-mace '+armfile ;change group spawn,unix_command exit endif ; ; Create the final arrays ; if base_time_id ne -1 then base_time=com_btto[0] if time_offset_id ne -1 then time_offset=com_btto-com_btto[0] if vap_id ne -1 then vap=com_vap if liq_id ne -1 then liq=com_liq if tbsky23_id ne -1 then tbsky23=com_tbsky23 if tbsky31_id ne -1 then tbsky31=com_tbsky31 if irtemp_id ne -1 then irtemp=com_irtemp if wetwindow_id ne -1 or waterflag_id ne -1 then wetwindow=com_wetwindow ; ; Zip up the data files ; unix_command='gzip -fq '+armfile ;zip the data files spawn,unix_command unix_command='gunzip -fq *gif.gz' ;unzip any gif files unintentionally zipped spawn,unix_command unix_command='chmod 664 '+armfile ;change permissions spawn,unix_command unix_command='chgrp met-mace '+armfile ;change group spawn,unix_command return end