Module: NumRu::GPhys::Gtool3_IO
- Defined in:
- lib/numru/gphys/gphys_gtool3_io.rb
Constant Summary collapse
- @@default_calendar =
e.g., “360_day”
nil
Class Method Summary collapse
- .default_calendar ⇒ Object
- .default_calendar=(cal) ⇒ Object
- .is_a_Gtool3?(filename) ⇒ Boolean
- .open(file, varname) ⇒ Object
-
.var_names(file) ⇒ Object
def write(file, gphys, name=nil) end.
- .var_names_except_coordinates(file) ⇒ Object
Class Method Details
.default_calendar ⇒ Object
69 70 71 |
# File 'lib/numru/gphys/gphys_gtool3_io.rb', line 69 def default_calendar @@default_calendar end |
.default_calendar=(cal) ⇒ Object
66 67 68 |
# File 'lib/numru/gphys/gphys_gtool3_io.rb', line 66 def default_calendar=(cal) @@default_calendar = cal end |
.is_a_Gtool3?(filename) ⇒ Boolean
73 74 75 |
# File 'lib/numru/gphys/gphys_gtool3_io.rb', line 73 def is_a_Gtool3?(filename) Gtool3.is_a_Gtool3?(filename) end |
.open(file, varname) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/numru/gphys/gphys_gtool3_io.rb', line 77 def open(file, varname) if file.is_a?(String) file = Gtool3.open(file) elsif ! file.is_a?(Gtool3) raise ArgumentError, "1st arg must be a Gtool3 or a file name" end var = file.var(varname) data = VArrayGtool3.new(var) axes = Array.new for i in 0...var.rank gax = var.axis(i) gloc = gax["LOC"] if gloc["ITEM"]=="time" loc = VArrayGtool3Time.new(gloc, @@default_calendar) else loc = VArrayGtool3.make_coord(gloc) end # if (gwgt = gax("WGT")) # wgt = VArray.new(gwgt.delete(:val), gwgt, gwgt.delete("ITEM")) # cell_center = true # cell = true # else cell = false # end axis = Axis.new(cell,false) if !cell axis.set_pos( loc ) end axes[i] = axis end grid = Grid.new( *axes ) GPhys.new(grid,data) end |
.var_names(file) ⇒ Object
def write(file, gphys, name=nil)
end
120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/numru/gphys/gphys_gtool3_io.rb', line 120 def var_names(file) opened = false case file when String file = Gtool3.open(file,"r") when Gtool3 opened = true else raise ArgumentError, "arg must be a Gtool3 or a file name" end var_names = file.var_names file.close unless opened return var_names end |
.var_names_except_coordinates(file) ⇒ Object
134 135 136 |
# File 'lib/numru/gphys/gphys_gtool3_io.rb', line 134 def var_names_except_coordinates(file) var_names(file) end |