Reduce WRF output

Since I want to reduce the size of WRF-output files and to make them easier to process I am using Run time IO and do not save time invariant variables, as latitude, longitude oder topography. Otherwise these variables would be written to wrfout_* for every time step, but they would never change.

For that reason, I let the model run for some minutes and do save all variables, including e.g. latitude and longitude. For the production runs I use the above mentioned run time IO.

When the runs are made, I want to add the time invariant variables to my output fields. Doing this will lead to a problem regarding time axis. Latitude will be used as an example here. XLAT does depend on "Time", as all other variables in wrfout_d01*.nc do. If I would append XLAT to wrfout_* by doing:

ncks -v XLAT file_with_all_vars.nc -A wrfout_d01.nc

XLAT would be messed up with the other time steps included in wrfout_d01*.nc. So I need the time invariant variables to have no time dimension (since they do NOT depend on time).

First extract one (here first) time step of XLAT from wrfout (with all variables written to history stream 0):

ncks -H -d Time,1 -v XLAT wrfout_with_all_variables/wrfout_d01_1979-01-01_00:00:00.nc latitudes.nc

It is important to have a time dimension of length 1! To remove the time dimension one can simply average over this dimension. For this one can use the averaging tool ncwa.

ncwa -a Time latitudes.nc latitudes_without_time.nc

This averages all variables in latitudes.nc over the dimension "Time". Now append XLAT, without time dimension, to your wrfout_d01*.nc file(s), which do not have the time invariant variable yet:

ncks -v XLAT latitudes_without_time.nc -A experiment/wrfout_d01_1979-01-01_00:00:00.nc

Now you have a smaller wrfout_* file and the model can write the output much faster, since it has to write less variables (more important the more often one wants to write output!). This is of particular interest if one saves many time steps (every 6 hours), makes long runs and applies monthly averaging afterwards.

Same procedure for other time invariant fields, as e.g. XLONG, XLAT_U, XLONG_U, XLAT_V, XLONG_V...