wrfout_to_cf.ncl - Adding a Variable

An NCL based script to create new CF based NetCDF files from native wrfout NetCDF files.


A user can add there own variables at any time to the script.  The new variables can be something extracted directly from the WRFOUT file, processed with the WRF-ARW NCL tools, or calculated within the script.  Content must be added to several sections within the wrfout_to_cf.ncl script when adding a new variable.  This instructional will present an outline of the work that needs to be done.

Create and set a variable flag:

A flag needs to be set to specify that the variable is to be included in the output file.  The variables are categorized into larger sets of variables (out2dMet, out2dRadFlx, out2dLandSoil, outPressure, outEta, outSoil).  Determine the category that the new variable best fits and place the flag for the output variable in that category.  For example the variable ws_10m is placed in the category out2dMet and given the flag:  out2dMet@ws_10m.  The category (e.g. out2dMet) and the variable (out2dMet@ws_10m) must both be set to True for the variable to be included in the output file.

Set the variable contents:

The location for retrieving / calculating a variable is divided by the variable type and the method to assign the variable to the data.  For example, all out2dMet fields retrieved directly from the WRFOUT file are placed together within the script.  Another example is that all calculated values on eta levels are placed together.  Determine the best corresponding location to insert the new variable.  Make sure that it is placed within the larger category of variables (e.g. out2dMet) to be processed.  Refer to any number of variables within the script for examples as to how this can be done.

After assigning the data t the variable the CF attributes must be set for the new variable.  The CF attributes are determined by using the CF documentation (see the Variables page).  The key attributes are:  long_name, standard_name, and units.  The variable attributes are assigned by calling the internal procedure:  assignVarAttCoord.

Delete the time attribute - Eta level output only:

For some reason the attribute time is included with all of the eta level variables. If a new eta level variable is used/created, that variable has to be included to have the time attribute deleted.

Add the new variable to be outputted to the post-processed CF file:

The last step in adding a new variable is to include the variable in the output file.  Find the section where the data is written to the wrfpost file that corresponds to the category of variables (e.g. out2dMet).  Add a new if-then sequence to include the new variable.  The outputted variable is dimensioned based on the spatial and temporal subsetting.


The best method to add a new variable is to identify a similar variable that is currently in the script.  The similarities are based on the type of variable and the how the variable is retrieved and/or calculated.  Then follow that variable through the script to see how it is handled.

Overview Usage Variables Add a Variable Release Notes TO DO Download