Sha256: 36130467f6b85e2687cedefe47debbe3b4478dfcf7575c7c983c20974d37757c

Contents?: true

Size: 1.29 KB

Versions: 17

Compression:

Stored size: 1.29 KB

Contents

#!/usr/bin/env ruby

##############################################################
=begin
= NAME

grads2nc_with_gphys - GrADS to NetCDF converter

= WARNING

Not efficient if the GrADS file has many variables.

= USAGE

 % grads2nc_with_gphys infilename outfilename [-v varname1 [varname2 ...]]

= EXAMPLE

 % grads2nc_with_gphys ../testdata/T.jan.ctl tmp.nc
 % grads2nc_with_gphys ../testdata/T.jan.ctl tmp.nc -v T

=end
##############################################################

usage = "\n\n"+<<EOS
#{$0}: GrADS to NetCDF converter.

USAGE:
  % #{$0} infilename outfilename [-v varname1 [varname2 ...]]
  Here, the -v option is used to limit variables to copy
  (all variables are copied by default). Note that to copy many
  variables may not be effifient.
EOS

# < interpret command-line arguments >

varnames = nil
if ARGV[2] == '-v'
  varnames = []
  (ARGV.length-3).times{ varnames.unshift( ARGV.pop ) }
  ARGV.pop
end

if ARGV.length != 2
  raise usage
else
  infilename, outfilename = ARGV[0..1]
end

# < convert >

require "numru/gphys"
include NumRu
grfile = GrADS_Gridded.open(infilename)
varnames = grfile.varnames if !varnames
out_file = NetCDF.create(outfilename)
varnames.each do |varname|
  temp = GPhys::GrADS_IO.open(grfile,varname)
  GPhys::NetCDF_IO.write(out_file,temp)
end
out_file.close

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
gphys-1.5.6 bin/grads2nc_with_gphys
gphys-1.5.5 bin/grads2nc_with_gphys
gphys-1.5.4 bin/grads2nc_with_gphys
gphys-1.5.3 bin/grads2nc_with_gphys
gphys-1.5.2 bin/grads2nc_with_gphys
gphys-1.5.1 bin/grads2nc_with_gphys
gphys-1.5.0 bin/grads2nc_with_gphys
gphys-1.4.3.2 bin/grads2nc_with_gphys
gphys-1.4.3.1 bin/grads2nc_with_gphys
gphys-1.4.3 bin/grads2nc_with_gphys
gentooboontoo-gphys-1.3.1.1 bin/grads2nc_with_gphys
gphys-1.2.2.1a bin/grads2nc_with_gphys
gphys-1.2.2.1 bin/grads2nc_with_gphys
gphys-1.2.2 bin/grads2nc_with_gphys
gphys-1.1.1b bin/grads2nc_with_gphys
gphys-1.1.1a bin/grads2nc_with_gphys
gphys-1.1.1 bin/grads2nc_with_gphys