Sha256: cfd1cf43299bce6293cc1757796c695c34447b88c02ead374434f67ce5d1a62f

Contents?: true

Size: 1.6 KB

Versions: 10

Compression:

Stored size: 1.6 KB

Contents

#!/usr/bin/env ruby

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

gpprint - a command to print the values of a variable specified by a gtool4-type URL. 

= DESCRIPTION

((*gpprint*)) is a command-line tool to print the values of a variable
specified by a gtool4-type URL. Outputs are comma-separated ascii
texts with line feeding to avoid long lines and are made to stdout.

= USAGE

     % gpprint url
 
where the format of the url is 

     path[@|/]varname[,dimname=pos1[:pos2[:thinning_intv]][,dimname=...]]

= EXAMPLES

    % gpprint data.nc@temp
    % gpprint data.nc@temp,lon=135.0
    % gpprint data.nc@temp,lon=130:150,lat=0
    % gpprint data.nc@temp,lon=130:150,lat=0:90:2

= HISTORY

  2004/12/14  T Horinouchi (created)
  2005/01/12  T Horinouchi (document -> in rd)
  2005/06/15  S Takehiro (set first_dim_length 1 when gp.shape[0] returns nil)
  2005/08/10  S Takehiro (utilize internal function for printing help message)
  2005/08/23  S Takehiro (common methods to gp* command moved to gpcommon.rb)
  2010/03/10  Y SASAKI (change help block into RD format)
  2012/02/19  S Takehiro (description for gturl format updated)

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

require "numru/gphys"
require "numru/gphys/gpcommon"
include NumRu

#------------------------ print help message ------------------------

help  if ARGV.length != 1 or /^-+h/ =~ ARGV[0]
gturl = ARGV[0]
gp = GPhys::IO.open_gturl(gturl)

new_line_int = 6
first_dim_len = (gp.shape[0]||1)
fmt = " %g,"
i = 1
gp.val.each do |v| 
  printf(fmt,v)
  print "\n" if (i % new_line_int) == 0 or (i % first_dim_len) == 0
  i += 1
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
gphys-1.5.2 bin/gpprint
gphys-1.5.1 bin/gpprint
gphys-1.5.0 bin/gpprint
gphys-1.4.3.2 bin/gpprint
gphys-1.4.3.1 bin/gpprint
gphys-1.4.3 bin/gpprint
gentooboontoo-gphys-1.3.1.1 bin/gpprint
gphys-1.2.2.1a bin/gpprint
gphys-1.2.2.1 bin/gpprint
gphys-1.2.2 bin/gpprint