pro get_mpl, curdate,site,datastream,input_flag common mpl_data, base_time, time_offset, height,$ backscat,mpl_base,km_flag ; ; 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='twpmplC1.a1' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' datastream='twpmplC2.a1' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' datastream='nsamplC1.a1' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' datastream='sgpmplC1.a1' 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='twpmplC1.a1' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' eosfilename='twpC2.eos_val_mace.c1' datastream='twpmplC2.a1' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' eosfilename='nsaC1.eos_val_mace.c1' datastream='nsamplC1.a1' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' eosfilename='sgpC1.eos_val_mace.c1' datastream='sgpmplC1.a1' 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') height_did=ncdf_dimid(cdfid,'range_bins') if height_did eq -1 then height_did=ncdf_dimid(cdfid,'height') ; ; Get the variable id's ; base_time_id=ncdf_varid(cdfid,'base_time') time_offset_id=ncdf_varid(cdfid,'time_offset') height_id=ncdf_varid(cdfid,'bin_heights') if height_id eq -1 then height_id=ncdf_varid(cdfid,'range_bins') backscat_id=ncdf_varid(cdfid,'backscatter') if backscat_id eq -1 then backscat_id=ncdf_varid(cdfid,'detector_counts') mpl_id=ncdf_varid(cdfid,'cloud_base_height') km_flag=1000. if mpl_id eq -1 then begin mpl_id=ncdf_varid(cdfid,'preliminary_cbh') if mpl_id eq -1 then mpl_id=ncdf_varid(cdfid,'cbh') km_flag=1. endif ; ; Get the data ; if base_time_id ne -1 then ncdf_varget, cdfid, base_time_id, base_time if time_offset_id ne -1 then ncdf_varget, cdfid, time_offset_id, time_offset if height_id ne -1 then ncdf_varget, cdfid, height_id, height if backscat_id ne -1 then ncdf_varget, cdfid, backscat_id, backscat backscat=transpose(backscat) if mpl_id ne -1 then ncdf_varget, cdfid, mpl_id, mpl_base ; ; 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 backscat_id ne -1 then com_backscat=backscat if mpl_id ne -1 then com_mpl_base=mpl_base 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 backscat_id ne -1 then com_backscat=[com_backscat,backscat] if mpl_id ne -1 then com_mpl_base=[com_mpl_base,mpl_base] 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 backscat_id eq -1 and mpl_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 backscat_id ne -1 then backscat=com_backscat if mpl_id ne -1 then mpl_base=com_mpl_base ; ; 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