Christopher Bull bio photo

Christopher Bull

Aspiring Oceanographer at the British Antarctic Survey. Big data python enthusiast. Outdoor adventurer.

Email Twitter Github

I often finding myself wanting basic information about netCDF files when writing scripts that read/write netCDF files…

The following ncdump command provides a useful overview. The mapping grabs the clipboard register and opens the corresponding netcdf header in a new vim vertical split..

nnoremap <leader>nc :vnew<Bar>0r!ncdump -c <C-R>+<CR>

What about if you want to have a quick look at a plot of one of the variables? Works with ncview too!

nnoremap <leader>ncv :exec '!ncview <C-R>+'<CR>

Speaking of working with netCDF files, here’s a handy snippet for the python library…

snippet loadnetcdf
from netCDF4 import Dataset
infile='/path/to/netcdf4/file.nc'
ifile=Dataset(infile, 'r')
varone=ifile.variables['']
endsnippet
In category: hpc