Below are useful command-line utilites that can be called from the CDM library. The easiest way to use these is to grab the latest netcdfAll.jar file.
Prints the textual representation of a dataset to standard output. Similar functionality to the ncdump utility program. By default, just the header (ncdump -h) is output. This application works on any CDM file, not just netCDF files.
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.NCdumpW filepath [-cdl | -ncml] [-c | -vall] [-v varName1;varName2;..] [-v varName(0:1,:,12)]
where:
filepath
: pathname of any CDM file.-cdl
: show CDL (strict mode)-ncml
: show NcML (default)-c
: show data for coordinate variables only-vall
: show data for all variables-v varName1;varName2;..
:
show data for these variables, use variable's full names (including groups if present)
-v varName(0:1,:,12)
:
show data for a section of this variable only, using F90 section specificiation
Copies a dataset to a netCDF-3 (default) or netCDF-4 file. The input may be any CDM dataset, including OPeNDAP URLs, NcML, GRIB files, etc. If the dataset uses the extended data model, you must write to netCDF-4. If writing to netCDF-4, you must have the netcdf-4 C library loaded.
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.write.Nccopy [options]
Options:
* -i, --input
Input dataset.
* -o, --output
Output file.
-f, --format
Output file format. Allowed values = [netcdf3, netcdf4, netcdf4_classic,
netcdf3c, netcdf3c64, ncstream]
Default: netcdf3
-isLargeFile, --isLargeFile
Write to large file format. Only used in NetCDF 3. Allowed values =
[standard, grib, none]
Default: false
-st, --strategy
Chunking strategy. Only used in NetCDF 4. Allowed values = [standard,
grib, none]
Default: standard
-d, --deflateLevel
Compression level. Only used in NetCDF 4. Allowed values = 0 (no
compression, fast) to 9 (max compression, slow)
Default: 5
-sh, --shuffle
Enable the shuffle filter, which may improve compression. Only used in
NetCDF 4. This option is ignored unless a non-zero deflate level is specified.
Default: true
-h, --help
Display this help and exit
Default: false
Compares two CDM files for semantic equivilence.
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.util.CompareNetcdf2 file1 file2 [-showEach] [-compareData]
where
-showEach
: show details of comparing each object-compareData
: compare data alsofile1
: first file to comparefile2
: second file to compareCopies a BUFR file's messages into separate output files, depending on message type.
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.iosp.bufr.writer.BufrSplitter --fileSpec <fileIn> --dirOut <dirOut>
where
--fileSpec
: file to split--dirOut
: output directory of split operationCopies a CDM point feature dataset to CF/NetCDF format. The CF conventions target NetCDF-3, but you can also write NetCDF-4 files in classic mode. For that, you must first install the C library.
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.ft.point.writer.CFPointWriter [options] Options: * -i, --input Input file. * -o, --output Output file. -f, --format Output file format. Allowed values = [netcdf3, netcdf4, netcdf4_classic, netcdf3c, netcdf3c64, ncstream] Default: netcdf3 -st, --strategy Chunking strategy. Only used in NetCDF 4. Allowed values = [standard, grib, none] Default: standard -d, --deflateLevel Compression level. Only used in NetCDF 4. Allowed values = 0 (no compression, fast) to 9 (max compression, slow) Default: 5 -sh, --shuffle Enable the shuffle filter, which may improve compression. Only used in NetCDF 4. This option is ignored unless a non-zero deflate level is specified. Default: true -h, --help Display this help and exit Default: false
Write GRIB Collection Indexes from an XML file containing a GRIB <featureCollection> XML element.
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.grib.collection.GribCdmIndex [options]
Options:
* -fc, --featureCollection
Input XML file containing <featureCollection> root element
-update, --CollectionUpdateType
Collection Update Type
Default: always
-h, --help
Display this help and exit
Default: false
Example:
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.grib.collection.GribCdmIndex -fc /data/fc/gfs_example.xml
Note that the output file is placed in the root directory of the collection, as specified by the Collection Specification of the GRIB <featureCollection>.
Scans all the files in a directory to see if they are CDM files and can be identified as a particular feature type.
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.ft.scan.FeatureScan directory [-subdirs]
where
directory
: scan this directory-subdirs
: recurse into subdirectories