Useful Tools: Difference between revisions
Line 39: | Line 39: | ||
The <tt>/ford1/share</tt> version could be more bleeding-edge than the <tt>/ford1/local</tt> version as it will usually be whatever version is in the latest Baselibs tag. | The <tt>/ford1/share</tt> version could be more bleeding-edge than the <tt>/ford1/local</tt> version as it will usually be whatever version is in the latest Baselibs tag. | ||
=== Example Uses of CDO === | |||
==== Display info about a file ==== | |||
=== Display info about a file === | |||
CDO offers many operators that provide information about a file. The most important two are '''infon''' and '''sinfon'''. Note the '''n''' at the end: that means "display variable names". If you don't provide that, you'll still get information, but it'll be for variables -1, -2, -3, etc. | CDO offers many operators that provide information about a file. The most important two are '''infon''' and '''sinfon'''. Note the '''n''' at the end: that means "display variable names". If you don't provide that, you'll still get information, but it'll be for variables -1, -2, -3, etc. | ||
==== Short Information ==== | ===== Short Information ===== | ||
If you just want a summary of what's in the file, use '''sinfon''': | If you just want a summary of what's in the file, use '''sinfon''': | ||
Line 96: | Line 96: | ||
cdo sinfon: Processed 26 variables over 1 timestep ( 0.02s ) | cdo sinfon: Processed 26 variables over 1 timestep ( 0.02s ) | ||
==== Information and Simple Statistics ==== | ===== Information and Simple Statistics ===== | ||
The other operator, '''infon''', provides more information and some useful statistics: | The other operator, '''infon''', provides more information and some useful statistics: | ||
Line 158: | Line 158: | ||
As you can see, you not only get information, but statistics. It provides the number of values on the grid, <tt>Gridsize</tt>; the number of Missing Values, <tt>Miss</tt>; and the <tt>Minimum</tt>, <tt>Mean</tt>, and <tt>Maximum</tt> for each <tt>Level</tt> for each value. | As you can see, you not only get information, but statistics. It provides the number of values on the grid, <tt>Gridsize</tt>; the number of Missing Values, <tt>Miss</tt>; and the <tt>Minimum</tt>, <tt>Mean</tt>, and <tt>Maximum</tt> for each <tt>Level</tt> for each value. | ||
=== Diff two files === | ==== Diff two files ==== | ||
One of the main reasons CDO is attractive is for diffing two files. With binary files, such as the old restarts, one could use <tt>cmp</tt> or <tt>diff</tt> to check for differences. However, <tt>cmp</tt> will not work on NetCDF files because while the data might be the same, the metadata surely won't: | One of the main reasons CDO is attractive is for diffing two files. With binary files, such as the old restarts, one could use <tt>cmp</tt> or <tt>diff</tt> to check for differences. However, <tt>cmp</tt> will not work on NetCDF files because while the data might be the same, the metadata surely won't: | ||
Line 244: | Line 244: | ||
endif | endif | ||
=== Extract fields(s) from a file === | ==== Extract fields(s) from a file ==== | ||
==== Extract variable(s) from a file ==== | ===== Extract variable(s) from a file ===== | ||
Often, our NetCDF4 files have many variables and we only care about one. CDO allows one to extract or ''select'' one or more variables. For example, if you only want CLCN, use '''selname''': | Often, our NetCDF4 files have many variables and we only care about one. CDO allows one to extract or ''select'' one or more variables. For example, if you only want CLCN, use '''selname''': | ||
Line 273: | Line 273: | ||
cdo sinfon: Processed 1 variable over 1 timestep ( 0.00s ) | cdo sinfon: Processed 1 variable over 1 timestep ( 0.00s ) | ||
==== Extract time(s) from a file ==== | ===== Extract time(s) from a file ===== | ||
To extract a single (or multiple) year from a multi-step file, you can use <tt>selyear</tt>,''year''. For multiple years, you can either do <tt>cdo '''selyear,1999,2000,2001'''</tt> or <tt>cdo '''selyear,1999/2001'''</tt>. | To extract a single (or multiple) year from a multi-step file, you can use <tt>selyear</tt>,''year''. For multiple years, you can either do <tt>cdo '''selyear,1999,2000,2001'''</tt> or <tt>cdo '''selyear,1999/2001'''</tt>. | ||
Line 364: | Line 364: | ||
cdo sinfon: Processed 7 variables over 36 timesteps ( 0.00s ) | cdo sinfon: Processed 7 variables over 36 timesteps ( 0.00s ) | ||
==== Other select operators ==== | ===== Other select operators ===== | ||
CDO has many of these operators: | CDO has many of these operators: | ||
Line 392: | Line 392: | ||
selindexbox Select an index box | selindexbox Select an index box | ||
=== Combining Operators === | ==== Combining Operators ==== | ||
Often, you want to do multiple operations on a file. You could, say, do a '''selname''' and output only one variable to a file, then a '''sellevel''' on that new file to select a single level, and then a '''selyear''' on ''that'', etc.: | Often, you want to do multiple operations on a file. You could, say, do a '''selname''' and output only one variable to a file, then a '''sellevel''' on that new file to select a single level, and then a '''selyear''' on ''that'', etc.: |