⇐ ⇒

[CF-metadata] Useful script for folks who use the CF checker

From: Rich Signell <rsignell>
Date: Tue, 23 Nov 2004 09:48:12 -0500

I use the CF checker at

http://titania.badc.rl.ac.uk/cgi-bin/cf-checker.pl

to test the compliance of my netcdf files.

The checker is nice and easy -- you just browse
for your netcdf file, and hit "check file", but of
course at that point it ships the whole file off
to the UK, and if you've got a large file you might
need to go get a cup of coffee.

Since the checker doesn't care about the *data* in
the file, I use the following script to create
a clone of my netcdf file with the unlimited dimension
set to 0 (without any data that depends on the unlimited
dimension). I then send *that* netcdf file to the checker.
Much faster and less waste of bandwidth.

Somebody who is a real programmer (or just someone
who knows how write decent scripts) could clean this
up, but I just wanted to show to idea in case it's useful.

Or maybe someone has an even better idea? Perhaps the
Checker should just work on the CDL header
(the result of "ncdump -h" ?)

Anyway, here's the small script, which assumes that you
have a unlimited dimension variable, and also that ncgen
will function correctly.

#!/bin/sh
# do_check
#
# Purpose: Makes NetCDF file with no data for the the
# "BADC CF-Convention compliance checker for NetCDF format"
# <http://titania.badc.rl.ac.uk/cgi-bin/cf-checker.pl>
#
# Usage: do_check <input.nc> <output.nc>
#
ncdump -h $1 > /tmp/$$a.cdl
sed 's/[[:digit:]]\+ currently/0 currently/' < /tmp/$$a.cdl > /tmp/$$b.cdl
ncgen -o $2 /tmp/$$b.cdl
rm /tmp/$$a.cdl /tmp/$$b.cdl
#
# end

-- 
Richard P. Signell           rsignell at usgs.gov
U.S. Geological Survey       Phone: (508) 457-2229
384 Woods Hole Road          Fax:   (508) 457-2310
Woods Hole, MA  02543-1598  
Received on Tue Nov 23 2004 - 07:48:12 GMT

This archive was generated by hypermail 2.3.0 : Tue Sep 13 2022 - 23:02:40 BST

⇐ ⇒