pro get_blc, curdate,site,datastream,input_flag common blc_data, base_time, time_offset, $ cbh1,cbh2,cbh3,lat,lon,alt ; ; Pieces to use to make the directory and filename ; if input_flag eq 'one' then begin armdatadir='/data/mace3/arm_data/sgp/' datastream='sgpblcC1.a1' armfile=armdatadir+datastream+'/'+datastream+'.'+curdate+'.*.cd*' endif else if input_flag eq 'eos' then begin armdatadir='/data/mace4/arm_data/eos/netcdf/' eosfilename='sgpC1.eos_val_mace.c1' datastream='sgpblcC1.a1' armfile=armdatadir+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 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') first_cbh_id=ncdf_varid(cdfid,'cloud1') second_cbh_id=ncdf_varid(cdfid,'cloud2') third_cbh_id=ncdf_varid(cdfid,'cloud3') lat_id=ncdf_varid(cdfid,'lat') lon_id=ncdf_varid(cdfid,'lon') alt_id=ncdf_varid(cdfid,'alt') ; ; Get the data ; ncdf_varget, cdfid, base_time_id, base_time ncdf_varget, cdfid, time_offset_id, time_offset ncdf_varget, cdfid, first_cbh_id, cbh1 ncdf_varget, cdfid, second_cbh_id, cbh2 ncdf_varget, cdfid, third_cbh_id, cbh3 ncdf_varget, cdfid, lat_id, lat ncdf_varget, cdfid, lon_id, lon 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 first_cbh_id ne -1 then com_cbh1=cbh1 if second_cbh_id ne -1 then com_cbh2=cbh2 if third_cbh_id ne -1 then com_cbh3=cbh3 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 first_cbh_id ne -1 then com_cbh1=[com_cbh1,cbh1] if second_cbh_id ne -1 then com_cbh2=[com_cbh2,cbh2] if third_cbh_id ne -1 then com_cbh3=[com_cbh3,cbh3] endelse ;end of if it is the first file ; ; Close the netcdf file ; ncdf_close,cdfid endif ;only process gif files endfor ;loop through number of matching file names ; ; Skip the rest if there are no variables ; if j lt 0 then print, 'found no variables' if j lt 0 then exit ; ; 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 first_cbh_id ne -1 then cbh1=com_cbh1 if second_cbh_id ne -1 then cbh2=com_cbh2 if third_cbh_id ne -1 then cbh3=com_cbh3 ; ; 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