Class: NumRu::Gtool3Var

Inherits:
Object
  • Object
show all
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

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

#attrObject



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_namesObject



611
612
613
# File 'lib/numru/gphys/gtool3.rb', line 611

def dim_names
  @varinfo[:axes].collect{|ax| ax["ITEM"]}
end

#fileObject



630
631
632
# File 'lib/numru/gphys/gtool3.rb', line 630

def file
  @file
end

#getObject



595
596
597
# File 'lib/numru/gphys/gtool3.rb', line 595

def get
  self[]
end

#nameObject



599
600
601
# File 'lib/numru/gphys/gtool3.rb', line 599

def name
  @name
end

#rankObject



607
608
609
# File 'lib/numru/gphys/gtool3.rb', line 607

def rank
  @varinfo[:rank]
end

#shapeObject Also known as: shape_current



615
616
617
# File 'lib/numru/gphys/gtool3.rb', line 615

def shape
  @varinfo[:shape].dup
end

#shape_ul0Object



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

#typecodeObject



603
604
605
# File 'lib/numru/gphys/gtool3.rb', line 603

def typecode
  @varinfo[:natyp]
end