pro get_smet_mettwr_smos, curdate,site,datastream,input_flag common smet_mettwr_smos_data, base_time,time_offset,precip,temp,$ relhum,wspd,dewpt,wdir,press,vpress,lat,lon,alt ; ; Pieces to use to make the directory and filename ; year=fix(strmid(curdate,0,4)) month=fix(strmid(curdate,4,2)) check_date=year+month/12. if input_flag eq 'one' then begin if site eq 'twpc1' then begin armdatadir='/data/mace/arm_data/twp/Manus_C1/' datastream='twpsmet60sC1.b1' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' datastream='twpsmet60sC2.b2' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' datastream='nsamettwrC1.a1' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' if check_date ge (2001.0 + 4./12.) then begin datastream='sgp1smosE13.b1' endif else begin datastream='sgp1smosE13.a0' endelse 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='twpsmet60sC1.b2' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' eosfilename='twpC2.eos_val_mace.c1' datastream='twpsmet60sC2.b2' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' eosfilename='nsaC1.eos_val_mace.c1' datastream='nsamettwrC1.a1' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' eosfilename='sgpC1.eos_val_mace.c1' datastream='sgp1smosE13.a0' 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 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') if input_flag eq 'eos' then begin dewpt_id=ncdf_varid(cdfid,'sfc_dew_pt_temp_mean') if site eq 'sgp' then $ press_id=ncdf_varid(cdfid,'sfc_bar_pres') $ else $ press_id=ncdf_varid(cdfid,'sfc_atmos_pressure') if site eq 'sgp' then $ temp_id=ncdf_varid(cdfid,'sfc_temp') $ else $ temp_id=ncdf_varid(cdfid,'sfc_temp_mean') if site eq 'sgp' then $ relhum_id=ncdf_varid(cdfid,'sfc_rh') $ else $ relhum_id=ncdf_varid(cdfid,'sfc_relh_mean') if site eq 'sgp' then $ precip_id=ncdf_varid(cdfid,'sfc_precip') $ else $ precip_id=ncdf_varid(cdfid,'sfc_precip_mean') if site eq 'twpc1' or site eq 'twpc2' then $ wspd_id=ncdf_varid(cdfid,'sfc_wind1_spd_vec_avg') $ else if site eq 'sgp' then $ wspd_id=ncdf_varid(cdfid,'sfc_wspd') $ else if site eq 'nsa' then $ wspd_id=ncdf_varid(cdfid,'sfc_wind_spd_mean') if site eq 'twpc1' or site eq 'twpc2' then $ wdir_id=ncdf_varid(cdfid,'sfc_wind1_dir_vec_avg') $ else if site eq 'sgp' then $ wdir_id=ncdf_varid(cdfid,'sfc_wdir') $ else if site eq 'nsa' then $ wdir_id=ncdf_varid(cdfid,'sfc_wind_dir_vec_avg') if site eq 'sgp' then $ vpress_id=ncdf_varid(cdfid,'sfc_vap_pres') $ else $ vpress_id=ncdf_varid(cdfid,'sfc_vap_pres_mean') endif else begin dewpt_id=ncdf_varid(cdfid,'dew_pt_temp_mean') if site eq 'sgp' then $ press_id=ncdf_varid(cdfid,'bar_pres') $ else $ press_id=ncdf_varid(cdfid,'atmos_pressure') if site eq 'sgp' then $ temp_id=ncdf_varid(cdfid,'temp') $ else $ temp_id=ncdf_varid(cdfid,'temp_mean') if site eq 'sgp' then $ relhum_id=ncdf_varid(cdfid,'rh') $ else $ relhum_id=ncdf_varid(cdfid,'relh_mean') if site eq 'sgp' then $ precip_id=ncdf_varid(cdfid,'precip') $ else $ precip_id=ncdf_varid(cdfid,'precip_mean') if site eq 'twpc1' or site eq 'twpc2' then $ wspd_id=ncdf_varid(cdfid,'wind1_spd_vec_avg') $ else if site eq 'sgp' then $ wspd_id=ncdf_varid(cdfid,'wspd') $ else if site eq 'nsa' then $ wspd_id=ncdf_varid(cdfid,'wind_spd_mean') if site eq 'twpc1' or site eq 'twpc2' then $ wdir_id=ncdf_varid(cdfid,'wind1_dir_vec_avg') $ else if site eq 'sgp' then $ wdir_id=ncdf_varid(cdfid,'wdir') $ else if site eq 'nsa' then $ wdir_id=ncdf_varid(cdfid,'wind_dir_vec_avg') if site eq 'sgp' then $ vpress_id=ncdf_varid(cdfid,'vap_pres') $ else $ vpress_id=ncdf_varid(cdfid,'vap_pres_mean') endelse ;not eos 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 if time_offset_id ne -1 then ncdf_varget,cdfid,time_offset_id,time_offset if dewpt_id ne -1 then ncdf_varget,cdfid,dewpt_id,dewpt if press_id ne -1 then ncdf_varget,cdfid,press_id,press if temp_id ne -1 then ncdf_varget,cdfid,temp_id,temp if relhum_id ne -1 then ncdf_varget,cdfid,relhum_id,relhum if precip_id ne -1 then ncdf_varget,cdfid,precip_id,precip if wspd_id ne -1 then ncdf_varget,cdfid,wspd_id,wspd if wdir_id ne -1 then ncdf_varget,cdfid,wdir_id,wdir if vpress_id ne -1 then ncdf_varget,cdfid,vpress_id,vpress 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 ; ; If NSA then select variables closest to the ground ; [0,*]=40 m [1,*]=20 m [2,*]=10 m [3,*]=2 m if site eq 'nsa' and input_flag ne 'eos' then begin wspd=reform(wspd[3,*]) wdir=reform(wdir[3,*]) temp=reform(temp[3,*]) relhum=reform(relhum[3,*]) dewpt=reform(dewpt[3,*]) vpress=reform(vpress[3,*]) endif ; ; 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 dewpt_id ne -1 then com_dewpt=dewpt if press_id ne -1 then com_press=press if temp_id ne -1 then com_temp=temp if relhum_id ne -1 then com_relhum=relhum if precip_id ne -1 then com_precip=precip if wspd_id ne -1 then com_wspd=wspd if wdir_id ne -1 then com_wdir=wdir if vpress_id ne -1 then com_vpress=vpress 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 dewpt_id ne -1 then com_dewpt=[com_dewpt,dewpt] if press_id ne -1 then com_press=[com_press,press] if temp_id ne -1 then com_temp=[com_temp,temp] if relhum_id ne -1 then com_relhum=[com_relhum,relhum] if precip_id ne -1 then com_precip=[com_precip,precip] if wspd_id ne -1 then com_wspd=[com_wspd,wspd] if wdir_id ne -1 then com_wdir=[com_wdir,wdir] if vpress_id ne -1 then com_vpress=[com_vpress,vpress] endelse ;end of if it is the first file ; ; Close 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 variables ; if j lt 0 then print, 'found no files' if j lt 0 then exit ; ; Skip the rest if there are no variables ; if dewpt_id eq -1 and press_id eq -1 and temp_id eq -1 $ and relhum_id eq -1 and precip_id eq -1 and wspd_id eq -1 $ and wdir_id eq -1 and vpress_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 dewpt_id ne -1 then dewpt=com_dewpt if press_id ne -1 then press=com_press if temp_id ne -1 then temp=com_temp if relhum_id ne -1 then relhum=com_relhum if precip_id ne -1 then precip=com_precip if wspd_id ne -1 then wspd=com_wspd if wdir_id ne -1 then wdir=com_wdir if vpress_id ne -1 then vpress=com_vpress ; ; 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