pro get_stret, curdate,site,datastream,input_flag common stret_data, base_time, time_offset, height, $ nmean,lwc,re,tau ; ; 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='Dtwpc1stretC1.Mace' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' eosfilename='twpC2.eos_val_mace.c1' datastream='Dtwpc2stretC1.Mace' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' eosfilename='nsaC1.eos_val_mace.c1' datastream='DnsastretC1.Mace' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' eosfilename='sgpC1.eos_val_mace.c1' datastream='DsgpstretC1.Mace' 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,'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,'height') nmean_id=ncdf_varid(cdfid,'N_mean') lwc_id=ncdf_varid(cdfid,'lwc') re_id=ncdf_varid(cdfid,'re') tau_id=ncdf_varid(cdfid,'tau') ; ; 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 height_id ne -1 then ncdf_varget, cdfid, height_id, height if nmean_id ne -1 then ncdf_varget, cdfid, nmean_id, nmean if lwc_id ne -1 then ncdf_varget, cdfid, lwc_id, lwc if re_id ne -1 then ncdf_varget, cdfid, re_id, re if tau_id ne -1 then ncdf_varget, cdfid, tau_id, tau ; ; 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 nmean_id ne -1 then com_nmean=nmean if lwc_id ne -1 then com_lwc=lwc if re_id ne -1 then com_re=re if tau_id ne -1 then com_tau=tau 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 nmean_id ne -1 then com_nmean=[com_nmean,nmean] if lwc_id ne -1 then com_lwc=[com_lwc,lwc] if re_id ne -1 then com_re=[com_re,re] if tau_id ne -1 then com_tau=[com_tau,tau] 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 nmean_id eq -1 and lwc_id eq -1 and re_id eq -1 $ and tau_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 nmean_id ne -1 then nmean=com_nmean if lwc_id ne -1 then lwc=com_lwc if re_id ne -1 then re=com_re if tau_id ne -1 then tau=com_tau ; ; 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