Class: NumRu::GPhys::GribDim
- Inherits:
-
Object
- Object
- NumRu::GPhys::GribDim
- Defined in:
- lib/numru/gphys/grib.rb
Overview
NumRu::GPhys::GribDim
Class Methods
—new( vat, name, length )
Methods
—var —length —name —typecode —get —[](indices) —put_att(key,val) —set_att(key,val) —att(key) —att_names —inspect
Instance Method Summary collapse
- #[](ind) ⇒ Object
- #att(key) ⇒ Object
- #att_names ⇒ Object
- #get ⇒ Object
-
#initialize(var, name) ⇒ GribDim
constructor
A new instance of GribDim.
- #inspect ⇒ Object
- #length ⇒ Object (also: #total)
- #name ⇒ Object
- #put(ary) ⇒ Object
- #put_att(key, val) ⇒ Object (also: #set_att)
- #typecode ⇒ Object
- #val ⇒ Object
- #var ⇒ Object
Constructor Details
#initialize(var, name) ⇒ GribDim
Returns a new instance of GribDim.
1583 1584 1585 1586 1587 |
# File 'lib/numru/gphys/grib.rb', line 1583 def initialize(var,name) @var = var @name = name @attr = Hash.new end |
Instance Method Details
#[](ind) ⇒ Object
1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 |
# File 'lib/numru/gphys/grib.rb', line 1619 def [](ind) v = val if Hash === ind # {range=>step} --> array of indices ran, step = ind.to_a[0] dlen = v.length f = ran.first f += dlen if f<0 e = ran.end e += dlen if e<0 e -= 1 if ran.exclude_end? ind = Array.new (f..e).step(step){|n| ind.push(n)} end return v[ind] end |
#att(key) ⇒ Object
1646 1647 1648 |
# File 'lib/numru/gphys/grib.rb', line 1646 def att(key) @attr[key] end |
#att_names ⇒ Object
1649 1650 1651 |
# File 'lib/numru/gphys/grib.rb', line 1649 def att_names @attr.keys end |
#get ⇒ Object
1598 1599 1600 |
# File 'lib/numru/gphys/grib.rb', line 1598 def get @ary end |
#inspect ⇒ Object
1652 1653 1654 |
# File 'lib/numru/gphys/grib.rb', line 1652 def inspect "GribDim: #{name}" end |
#length ⇒ Object Also known as: total
1591 1592 1593 |
# File 'lib/numru/gphys/grib.rb', line 1591 def length @length end |
#name ⇒ Object
1595 1596 1597 |
# File 'lib/numru/gphys/grib.rb', line 1595 def name @name end |
#put(ary) ⇒ Object
1634 1635 1636 1637 1638 1639 1640 1641 |
# File 'lib/numru/gphys/grib.rb', line 1634 def put(ary) if ary.typecode <= NArray::INT # 2014-09-22 horinouchi ary = ary.to_type(NArray::DFLOAT) end @ary = ary @length = val.length return @ary end |
#put_att(key, val) ⇒ Object Also known as: set_att
1642 1643 1644 |
# File 'lib/numru/gphys/grib.rb', line 1642 def put_att(key,val) @attr[key]=val end |
#typecode ⇒ Object
1601 1602 1603 1604 1605 1606 1607 |
# File 'lib/numru/gphys/grib.rb', line 1601 def typecode if NArray===@ary @ary.typecode elsif Array===@ary @ary[0]["value"].typecode end end |
#val ⇒ Object
1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 |
# File 'lib/numru/gphys/grib.rb', line 1608 def val if Array===@ary if att("long_name")=="Hybrid level" return @ary[0]["value"] else return @ary[1]["value"] end else return @ary end end |
#var ⇒ Object
1588 1589 1590 |
# File 'lib/numru/gphys/grib.rb', line 1588 def var @var end |