Method: NumRu::VArrayNetCDF.new2

Defined in:
lib/numru/gphys/varraynetcdf.rb

.new2(file, name, ntype, dimensions, vary = nil) ⇒ Object Also known as: def_var

< redefined class methods > ##



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/numru/gphys/varraynetcdf.rb', line 151

def new2(file, name, ntype, dimensions, vary=nil)
	   dimensions = dimensions.collect{|dim| 
	     if dim.is_a?(String)
	       # specification by name is available for existing dimensions
	       file.dim(dim) || raise("dimension "+dim+" is not in "+file.path)
	     else
	       dim
	     end
	   }
	    va = new( file.def_var(name, ntype, dimensions) )
   if ( @@deflation_level &&
        ## file.respond_to?(:format) &&  # supported by ruby-netcdf 0.7.2 or later
        file.format >= NetCDF::NC_FORMAT_NETCDF4 &&
        (dimensions.length >=2 || @@deflate_all) )
     file.var(name).deflate(@@deflation_level, @@shuffle)
   end
   if vary
	      vary.att_names.each{|name| va.set_att(name, vary.get_att(name))}
	    end 
   va
end