; ; write_new_grid.pro writes the new time and height grid to ; the output netcdf file ; pro write_new_grid,grid_created common ncdf_file, oldcdfname,twoD,time_dim_name,height_dim_name,$ height_var_name,avgfilename,curdate common old_grid, num_times,num_heights,base_time,time_offset,$ height,site,files,num_files,num_days common new_grid, numtimes,newtimes, numheights, newheights,$ timespacing, heightspacing common bracket, startbst ; ; Open the netcdf file ; avg_id=ncdf_open(avgfilename, /write) ; ; Put netcdf file into define mode ; ncdf_control, avg_id, /redef ; ; Define dimensions ; time_id=ncdf_dimdef(avg_id, 'time', /unlimited) if twoD eq 'yes' then height2_did=ncdf_dimdef(avg_id, 'height' ,numheights) ; ; Define variables ; bst_id=ncdf_vardef(avg_id, 'base_time' ,/long) timeoff_id=ncdf_vardef(avg_id, 'time_offset', time_id ,/double) if twoD eq 'yes' then height2_id=ncdf_vardef(avg_id, 'height',height2_did) ; ; Define attributes ; ncdf_attput, avg_id, timeoff_id, 'long_name', 'Time offset from base_time' ncdf_attput, avg_id, timeoff_id, 'units', 'seconds' ncdf_attput, avg_id, bst_id, 'long_name', 'Base time in Epoch' ncdf_attput, avg_id, bst_id, 'units', 'seconds since 1970-01-01 00:00:00 00:00' if twoD eq 'yes' then begin ncdf_attput, avg_id, height2_id, 'long_name','range gate height above ground' ncdf_attput, avg_id, height2_id, 'units', 'meters' endif ; ; Change from define mode to data mode ; ncdf_control, avg_id, /endef ; ; Write variables ; ncdf_varput, avg_id, bst_id, startbst ncdf_varput, avg_id, timeoff_id, newtimes if twoD eq 'yes' then ncdf_varput, avg_id, height2_id, newheights ; ; Close the netcdf file ; ncdf_close,avg_id ; ; This set to 'yes' since the grid has been created. ; grid_created='yes' return end