pro get_vceil25k, curdate,site,datastream,input_flag common vceil25k_data, base_time, time_offset, $ range,detsta,statflg,cbh1,cbh2,cbh3,highsig,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='twpvceil25kC1.b1' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' datastream='twpvceil25kC2.b1' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' datastream='nsavceil25kC1.a1' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' datastream='sgpvceil25kC1.a1' endif armfile=armdatadir+datastream+'/'+datastream+'.'+curdate+'.*.cd*' endif else if input_flag eq 'eos' then begin armdatadir='/data/mace4/arm_data/eos/netcdf/' if site eq 'twpc1' then begin eosfilename='twpC1.eos_val_mace.c1' datastream='twpvceil25kC1.b1' endif else if site eq 'twpc2' then begin eosfilename='twpC2.eos_val_mace.c1' datastream='twpvceil25kC2.b1' endif else if site eq 'nsa' then begin eosfilename='nsaC1.eos_val_mace.c1' datastream='nsavceil25kC1.a1' endif else if site eq 'sgp' then begin eosfilename='sgpC1.eos_val_mace.c1' datastream='sgpvceil25kC1.a1' endif 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') range_did=ncdf_dimid(cdfid,'range') ; ; Get the variable id's ; base_time_id=ncdf_varid(cdfid,'base_time') time_offset_id=ncdf_varid(cdfid,'time_offset') range_id=ncdf_varid(cdfid,'range') detsta_id=ncdf_varid(cdfid,'detection_status') statflag_id=ncdf_varid(cdfid,'status_flag') first_cbh_id=ncdf_varid(cdfid,'first_cbh') second_cbh_id=ncdf_varid(cdfid,'second_cbh') third_cbh_id=ncdf_varid(cdfid,'third_cbh') alt_highest_signal_id=ncdf_varid(cdfid,'alt_highest_signal') 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, range_id, range ncdf_varget, cdfid, detsta_id, detsta ncdf_varget, cdfid, statflag_id, statflag ncdf_varget, cdfid, first_cbh_id, cbh1 ncdf_varget, cdfid, second_cbh_id, cbh2 ncdf_varget, cdfid, third_cbh_id, cbh3 ncdf_varget, cdfid, alt_highest_signal_id, highsig 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 range_id ne -1 then com_range=range if detsta_id ne -1 then com_detsta=detsta if statflag_id ne -1 then com_statflag=statflag 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 if alt_highest_signal_id ne -1 then com_highsig=highsig 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 range_id ne -1 then com_range=[com_range,range] if detsta_id ne -1 then com_detsta=[com_detsta,detsta] if statflag_id ne -1 then com_statflag=[com_statflag,statflag] 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] if alt_highest_signal_id ne -1 then com_highsig=[com_highsig,highsig] 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 range_id ne -1 then range=com_range if detsta_id ne -1 then detsta=com_detsta if statflag_id ne -1 then statflag=com_statflag 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 if alt_highest_signal_id ne -1 then highsig=com_highsig ; ; 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