pro get_sounding_x_y,curdate,site,datastream,input_flag common sounding_x_y_data, base_time, time_offset, $ height,temp,relhum,sflag,press,ovptime,ovp_offset, $ ovp_str_time ; ; 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='twp.C1.merged_sounding/' fnprefix='Dtwp.C1.' fnsuffix='.merged_sounding.cd*' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' datastream='twp.C2.merged_sounding/' fnprefix='Dtwp.C2.' fnsuffix='.merged_sounding.cd*' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' datastream='nsa.C1.merged_sounding/' fnprefix='nsa.C1.' fnsuffix='.merged_sounding.cd*' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' datastream='sgp_merged_sounding/' fnprefix='Dsgp.C1.' fnsuffix='.merged_sounding.cd*' endif armfile=armdatadir+datastream+fnprefix+curdate+fnsuffix 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='twp.C1.merged_sounding' endif else if site eq 'twpc2' then begin armdatadir='/data/mace/arm_data/twp/Nauru_C2/' eosfilename='twpC2.eos_val_mace.c1' datastream='twp.C2.merged_sounding' endif else if site eq 'nsa' then begin armdatadir='/data/mace2/arm_data/nsa/' eosfilename='nsaC1.eos_val_mace.c1' datastream='nsa.C1.merged_sounding' endif else if site eq 'sgp' then begin armdatadir='/data/mace3/arm_data/sgp/' eosfilename='sgpC1.eos_val_mace.c1' datastream='sgp.C1.merged_sounding' 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 dimension sizes ; if time_did ge 0 then ncdf_diminq, cdfid, time_did, char_strng, num_times if height_did ge 0 then ncdf_diminq, cdfid, height_did, $ char_strng, num_heights ; ; 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') temp_id=ncdf_varid(cdfid,'temp') relhum_id=ncdf_varid(cdfid,'relhum') sflag_id=ncdf_varid(cdfid,'sndg_flag') press_id=ncdf_varid(cdfid,'pressure') ; ; Get the variables ; 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 temp_id ge 0 then ncdf_varget, cdfid, temp_id, temp if relhum_id ge 0 then ncdf_varget, cdfid, relhum_id, relhum if sflag_id ge 0 then ncdf_varget, cdfid, sflag_id, sflag if press_id ge 0 then ncdf_varget, cdfid, press_id, press ; ; 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 temp_id ne -1 then com_temp=temp if relhum_id ne -1 then com_relhum=relhum if sflag_id ne -1 then com_sflag=sflag if press_id ne -1 then com_press=press 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 temp_id ne -1 then com_temp=[com_temp,temp] if relhum_id ne -1 then com_relhum=[com_relhum,relhum] if sflag_id ne -1 then com_sflag=[com_sflag,sflag] if press_id ne -1 then com_press=[com_press,press] 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 temp_id eq -1 and relhum_id eq -1 and sflag_id eq -1 $ and press_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 openw,15,'/data/mace4/arm_data/eos/eos_image_name_ms.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 ;end of found no variables ; ; 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 temp_id ne -1 then temp=com_temp if relhum_id ne -1 then relhum=com_relhum if sflag_id ne -1 then sflag=com_sflag if press_id ne -1 then press=com_press ; ; Calculate the overpass time ; if site eq 'nsa' then py=69 if site eq 'sgp' then py=69 if site eq 'twpc1' then py=77 if site eq 'twpc2' then py=77 year=' ' & month=' ' & day=' ' & hour=' ' & minute=' ' & second=' ' year=fix(strmid(files[0],py,4)) month=fix(strmid(files[0],py+4,2)) day=fix(strmid(files[0],py+6,2)) hour=fix(strmid(files[0],py+9,2)) minute=fix(strmid(files[0],py+11,2)) second=fix(strmid(files[0],py+13,2)) ovptime=num_sec_ep(year,month,day,hour,minute,second) ovp_offset=long(ovptime)-long(base_time) if month lt 10 then month='0'+string(month) else month=string(month) if day lt 10 then day='0'+string(day) else day=string(day) if hour lt 10 then hour='0'+string(hour) else hour=string(hour) if minute lt 10 then minute='0'+string(minute) else minute=string(minute) if second lt 10 then second='0'+string(second) else second=string(second) ovp_str_time=strcompress(hour+':'+minute+':'+second,/remove_all) ; ; 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