Class: NumRu::Gtool3Var
- Inherits:
-
Object
- Object
- NumRu::Gtool3Var
- Defined in:
- lib/numru/gphys/gtool3.rb
Constant Summary collapse
- @@attkeys =
%w!DSET ITEM TITLE UNIT TIME DATE UTIM TDUR MISS CDATE CSIGN MDATE MSIGN!
Instance Method Summary collapse
- #[](*sel) ⇒ Object
- #attr ⇒ Object
- #axis(d) ⇒ Object
- #dim_names ⇒ Object
- #file ⇒ Object
- #get ⇒ Object
-
#initialize(file, name) ⇒ Gtool3Var
constructor
A new instance of Gtool3Var.
- #name ⇒ Object
- #rank ⇒ Object
- #shape ⇒ Object (also: #shape_current)
- #shape_ul0 ⇒ Object
- #typecode ⇒ Object
Constructor Details
#initialize(file, name) ⇒ Gtool3Var
Returns a new instance of Gtool3Var.
577 578 579 580 581 582 583 584 585 586 587 588 589 |
# File 'lib/numru/gphys/gtool3.rb', line 577 def initialize(file,name) case file when String file = Gtool3.open(file) when Gtool3 else raise ArgumentError, "not a Gtool3 or a String #{file.inspect}" end raise("Var '#{name}' is not in (#{file.path})") unless file.has_var?(name) @file = file @name = name @varinfo = file.varinfo(name) end |
Instance Method Details
#[](*sel) ⇒ Object
591 592 593 |
# File 'lib/numru/gphys/gtool3.rb', line 591 def [](*sel) @file.get(@name,*sel) end |
#attr ⇒ Object
634 635 636 637 638 |
# File 'lib/numru/gphys/gtool3.rb', line 634 def attr att = Hash.new @@attkeys.each{|k| att[k] = @varinfo[k]} att end |
#axis(d) ⇒ Object
640 641 642 |
# File 'lib/numru/gphys/gtool3.rb', line 640 def axis(d) @varinfo[:axes][d] end |
#dim_names ⇒ Object
611 612 613 |
# File 'lib/numru/gphys/gtool3.rb', line 611 def dim_names @varinfo[:axes].collect{|ax| ax["ITEM"]} end |
#file ⇒ Object
630 631 632 |
# File 'lib/numru/gphys/gtool3.rb', line 630 def file @file end |
#get ⇒ Object
595 596 597 |
# File 'lib/numru/gphys/gtool3.rb', line 595 def get self[] end |
#name ⇒ Object
599 600 601 |
# File 'lib/numru/gphys/gtool3.rb', line 599 def name @name end |
#rank ⇒ Object
607 608 609 |
# File 'lib/numru/gphys/gtool3.rb', line 607 def rank @varinfo[:rank] end |
#shape ⇒ Object Also known as: shape_current
615 616 617 |
# File 'lib/numru/gphys/gtool3.rb', line 615 def shape @varinfo[:shape].dup end |
#shape_ul0 ⇒ Object
620 621 622 623 624 625 626 627 628 |
# File 'lib/numru/gphys/gtool3.rb', line 620 def shape_ul0 if @varinfo[:time_seq] sh = @varinfo[:shape].dup sh[-1] = 0 sh else @varinfo[:shape].dup end end |
#typecode ⇒ Object
603 604 605 |
# File 'lib/numru/gphys/gtool3.rb', line 603 def typecode @varinfo[:natyp] end |