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