Class: GrADS::Gridded

Inherits:
Object
  • Object
show all
Defined in:
lib/grads/binary.rb,
lib/grads/binary.rb,
lib/grads/gridded.rb,
lib/grads/gridded.rb

Defined Under Namespace

Classes: Variable, Writer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctl_file, radius: nil) ⇒ Gridded

Returns a new instance of Gridded.



131
132
133
134
135
136
# File 'lib/grads/binary.rb', line 131

def initialize (ctl_file, radius: nil)
  @ctl_file = ctl_file
  @entries = scan_ctl_file(ctl_file)
  @radius = radius
  parse_entries(@entries)
end

Instance Attribute Details

#chunksizeObject (readonly)

Returns the value of attribute chunksize.



146
147
148
# File 'lib/grads/binary.rb', line 146

def chunksize
  @chunksize
end

#ctl_fileObject (readonly)

Returns the value of attribute ctl_file.



138
139
140
# File 'lib/grads/binary.rb', line 138

def ctl_file
  @ctl_file
end

#dsetObject (readonly)

Returns the value of attribute dset.



139
140
141
# File 'lib/grads/binary.rb', line 139

def dset
  @dset
end

#entriesObject (readonly)

Returns the value of attribute entries.



138
139
140
# File 'lib/grads/binary.rb', line 138

def entries
  @entries
end

#isizeObject (readonly)

Returns the value of attribute isize.



141
142
143
# File 'lib/grads/binary.rb', line 141

def isize
  @isize
end

#jsizeObject (readonly)

Returns the value of attribute jsize.



141
142
143
# File 'lib/grads/binary.rb', line 141

def jsize
  @jsize
end

#pdefObject (readonly)

Returns the value of attribute pdef.



140
141
142
# File 'lib/grads/binary.rb', line 140

def pdef
  @pdef
end

#projObject (readonly)

Returns the value of attribute proj.



140
141
142
# File 'lib/grads/binary.rb', line 140

def proj
  @proj
end

#taxisObject (readonly)

Returns the value of attribute taxis.



143
144
145
# File 'lib/grads/binary.rb', line 143

def taxis
  @taxis
end

#titleObject (readonly)

Returns the value of attribute title.



139
140
141
# File 'lib/grads/binary.rb', line 139

def title
  @title
end

#tsizeObject (readonly)

Returns the value of attribute tsize.



142
143
144
# File 'lib/grads/binary.rb', line 142

def tsize
  @tsize
end

#undefObject (readonly)

Returns the value of attribute undef.



139
140
141
# File 'lib/grads/binary.rb', line 139

def undef
  @undef
end

#vardimsObject (readonly)

Returns the value of attribute vardims.



145
146
147
# File 'lib/grads/binary.rb', line 145

def vardims
  @vardims
end

#varnamesObject (readonly)

Returns the value of attribute varnames.



145
146
147
# File 'lib/grads/binary.rb', line 145

def varnames
  @varnames
end

#varoffsetsObject (readonly)

Returns the value of attribute varoffsets.



145
146
147
# File 'lib/grads/binary.rb', line 145

def varoffsets
  @varoffsets
end

#varsObject (readonly)

Returns the value of attribute vars.



145
146
147
# File 'lib/grads/binary.rb', line 145

def vars
  @vars
end

#vectorpairObject (readonly)

Returns the value of attribute vectorpair.



144
145
146
# File 'lib/grads/binary.rb', line 144

def vectorpair
  @vectorpair
end

#xaxisObject (readonly)

Returns the value of attribute xaxis.



143
144
145
# File 'lib/grads/binary.rb', line 143

def xaxis
  @xaxis
end

#xsizeObject (readonly)

Returns the value of attribute xsize.



142
143
144
# File 'lib/grads/binary.rb', line 142

def xsize
  @xsize
end

#yaxisObject (readonly)

Returns the value of attribute yaxis.



143
144
145
# File 'lib/grads/binary.rb', line 143

def yaxis
  @yaxis
end

#ysizeObject (readonly)

Returns the value of attribute ysize.



142
143
144
# File 'lib/grads/binary.rb', line 142

def ysize
  @ysize
end

#zaxisObject (readonly)

Returns the value of attribute zaxis.



143
144
145
# File 'lib/grads/binary.rb', line 143

def zaxis
  @zaxis
end

#zsizeObject (readonly)

Returns the value of attribute zsize.



142
143
144
# File 'lib/grads/binary.rb', line 142

def zsize
  @zsize
end

Instance Method Details

#forward(rlon, rlat) ⇒ Object



509
510
511
# File 'lib/grads/binary.rb', line 509

def forward (rlon, rlat)
  return @forward[rlon, rlat]
end

#inverse(fi, fj) ⇒ Object



505
506
507
# File 'lib/grads/binary.rb', line 505

def inverse (fi, fj)
  return @inverse[fi,fj]
end

#lonlatObject



513
514
515
516
517
518
519
# File 'lib/grads/binary.rb', line 513

def lonlat
  fi = CArray.float(xsize).seq
  fj = CArray.float(ysize).seq
  ii = fi[ysize,:%]
  jj = fj[:%,xsize]
  return @inverse[ii, jj]
end

#template(ctl_file, &block) ⇒ Object



532
533
534
535
536
# File 'lib/grads/binary.rb', line 532

def template (ctl_file, &block)
  asm = Writer.new(self)
  asm.define(&block)
  asm.write(ctl_file)
end

#var(name) ⇒ Object



525
526
527
528
529
530
# File 'lib/grads/binary.rb', line 525

def var (name)
  unless @varnames.include?(name)
    raise "invalid variable name '#{name}'"
  end
  return Variable.new(name, self)
end

#xyObject



521
522
523
# File 'lib/grads/binary.rb', line 521

def xy
  return @xy[]
end