Difference between revisions of "CESM exercise II: view and discuss model output"
(→View the results)
(→View the results)
|Line 42:||Line 42:|
> ncdump -h ''casename''.clm2.h0.0001-01.nc
> ncdump -h ''casename''.clm2.h0.0001-01.nc
As you will see, there are many fields in this file.
As you will see, there are many fields in this file
Revision as of 00:34, 23 March 2011
Back to Thursday, March 24th
View the results
Now we will look at some output from your IG run. When a run completes successfully, output is written to several archive directories. Let's look at your archived files:
> cd ~/swgfs/archive/case_name > ls
You will see directories corresponding to different model components. The "rest" directory contains restart files that are needed to continue an earlier run without starting over from the beginning. Restart files are very important for long simulations that can take several days, weeks, or even months to complete.
Let's look in the land directory:
> cd lnd > ls
There are two subdirectories called hist and logs. First look at the log file:
> cd logs > ls
You will likely have two compressed log files, one for your 5-day run and the other for your multiyear run. Unzip the second one (which will have a later time stamp):
> gunzip lnd.log.yymmdd-hhmmss.gz > less lnd.log.yymmdd-hhmmss
You can go quickly to the end of the file by typing Shift-G. You will see something like this at the end:
> Successfully wrote local restart file ./IG_f19g16.clm2.r.0002-01-01-00000
This means that just before finishing, CLM wrote a restart file so that it can start later where it left off.
Now let's look at the CLM history files:
> cd ../hist > ls
You should see one file for each month of the run. The .nc suffix means that these are netCDF files. The netCDF format is commonly used for climate model output. This format is 'self-describing', which means that the file contains not only lots of data, but also 'metadata' with useful information about the data.
Each of the monthly files contains a number of monthly average fields. This command will tell you about the contents of the first monthly file:
> ncdump -h casename.clm2.h0.0001-01.nc
As you will see, there are many fields in this file. We can visualize the data using the program ncview. To look at a file using ncview, type this:
> ncview filename
A blue window will pop up on your screen. First you will choose a field to view. Put your cursor over the box that says (176)2d vars and hold down your left mouse button. You will see a long list of fields. Keeping the button held down, you then move your cursor over the name of the field you want to look at and release the mouse button.
Let's look at the surface air temperature field. Move the cursor to the field labeled TSA.
Let's say we're interested in the surface mass balance of glaciated gridcells from year 10 of the run, averaged over 12 months.
We can post-process the data using NCO, a suite of programs for useful manipulation of netCDF files. For details, see http://nco.sourceforge.net/.
To average all the history variables over 12 months, use the ncra command:
> ncra -n 12,2,1 infile.nc outfile.nc
The -n command tells NCO to average over files that have the same name as infile.nc, apart from a numerical file identifier.
- The '12' indicates that there are 12 files to average.
- The '2' says that the identifier has 2 digits (01, 02, ..., 12)
- The '1' says that the identifier changes with a stride of 1.
The outfile name is arbitrary. In our case, we can type:
> ncra -n 12,2,1 case_name.clm2.h0.0010-01.nc case_name.clm2.h0.0010-avg.nc > ls
To view the contents of the new file:
> ncdump -h case_name.clm2.h0.0010-avg.nc | less
Hit the space bar to scroll through the output.
Note the following:
- The grid dimensions are 96 x 144.
- There are some time-independent variables (e.g., area, topo) with lower-case names.
- There are many time-dependent variables (including QICE, the surface mass balance) with names in all caps.
Now we can plot the data.
My favorite netCDF viewer is ferret, but ferret is not installed on bluefire.
Let's use ncview instead:
> ncview case_name.clm2.h0.0010-avg.nc
The ncview GUI should pop up. Click on the 2d vars button.
If the ncview GUI does not pop up, that's probably because your path isn't set up to find it. Try this instead:
> /contrib/bin/ncview case_name.clm2.h0.0010-avg.nc
As a shortcut, you can add an alias in your .cshrc file in your home directory.
alias ncview '/contrib/bin/ncview'
After you save the new version of .cshrc, you will need to type this:
> source .cshrc
Then the alias should work.
Unfortunately, there are so many variables that we can't get to QICE (one of the limitations of ncview).
Let's make a file that doesn't have so many variables:
> ncra -v QICE -n 12,2,1 case_name.clm2.h0.0010-01.nc case_name.clm2.h0.0010-QICE.nc
Here we have used the -v option to specify the variables to average over.
The resulting file has just one time-dependent variable QICE, a function of lat, lon and time:
> ncdump -h case_name.clm2.h0.0010-QICE.nc
Let's try ncview again:
> ncview case_name.clm2.h0.0010-QICE.nc
You should see a global plot of QICE on the global land grid.
To magnify the plot, left-click as many times as desired on the button that says M X3. To shrink the plot, right-click on this button.
We can see QICE for glaciated cells not only in Greenland and Antarctica, but also in the Himalayas, Canadian archipelago, Alaskan coastal range, and Patagonia (and New Zealand!).
The units of QICE are mm/s (or equivalently, kg/m2/s). If you prefer m/yr, you can change the units in the file using the ncflint command:
> ncflint -w 3.16e4,0 case_name.clm2.h0.0010-QICE.nc case_name.clm2.h0.0010-QICE.nc case_name.clm2.h0.0010-QICEmyr.nc
where the factor 3.16e4 converts from mm/s to m/yr.
(This syntax can be interpreted as follows. The form of the command is
> ncflint -w weight1, weight2 infile1.nc infile2.nc outfile.nc
with the result that variables in the output file have values outfile_var = weight1*infile1_var + weight2*infile2_var. If weight2 = 0, then infile2 is irrelevant and the effect is simply to multiply variables in infile1 by a constant. Perhaps there is a simpler way to do this. In ferret it is easy to multiply data by a constant without changing the netCDF file.)
You may want to look at other data fields in the monthly mean files and in the yearly average file.
As a final exercise, let's compute the surface mass balance integrated over the Greenland ice sheet. NCO has a command for this too:
> ncwa -N -v QICE -a lat,lon -B 'gris_mask > 0.5' -w area -N case_name.clm2.h0.0010-avg.nc outfile.nc
- -N says to compute the integrated total as opposed to the average.
- -v tells which variable(s) to sum and/or average over
- -a tells which dimensions to sum over
- -B says to sum only over cells that meet a masking condition (in our case, Greenland cells have gris_mask = 1.0, and all other cells have gris_mask = 0.0)
- -w says to weight by the variable that follows (grid cell area in this case)
Let's look at the output:
> ncdump outfile.nc
We're interested in the area-integrated value of QICE. Note that area has units of km2, whereas QICE has units of mm/s. To convert to km3/yr, multiply the result by 3.16e7 (the number of seconds in a year) and divide by 1e6 (the number of mm in a km). Recall that 1 km3 (liquid water equivalent) of ice weighs 1 Gigaton.
For the present-day (or at least preindustrial) climate of Greenland, the net surface mass balance is ~300 to 400 km3/y. How do your results compare?