NetCDF

From Fluids Wiki
Revision as of 15:09, 12 April 2018 by Ddeepwel (talk | contribs) (Created page with "NetCDF is a self-describing format that is easily portable between different operating systems. Here are some VERY useful command line functions to operate/investigate your N...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

NetCDF is a self-describing format that is easily portable between different operating systems.

Here are some VERY useful command line functions to operate/investigate your NetCDF files.

The ncks and ncap2 are available on Graham after loading the module nco. nccmp is always available. All three are available on Boogaloo.

ncks

The NetCDF Kitchen Sink (ncks) offers everything you need and more.

It's primary use for you will likely be to take a large netcdf file and copy a portion (the interesting part of your simulation) into another file. This way Paraview and Visit will be much quicker because the file will be smaller. To copy all points along the x dimension between the first (0-indexing) and the 512th (511 because of 0-indexing) use:

ncks -d x,0,511 file_in.nc file_out.nc

You can also add a stride:

ncks -d x,0,511,2 file_in.nc file_out.nc

which skips every second point. There should be a way to do this in multiple dimension, but this has not been tested yet.

ncap2

The NetCDF Arithmetic Processor version 2 allows you to make new variables from old ones through arithmetic operations.

Suppose you want the kinetic energy density and have the u, v, and w velocities. Then run:

ncap2 -s "ke=0.5*(u*u + v*v + w*w)" file_in.nc file_out.nc

This will create a new file with an additional variable called ke.

nccmp

NetCDF Compare will compare two netcdf files. Shocking, I know.