---------------------------------------------
RubyNetCDF is the Ruby interface of the NetCDF library. Ruby is a free object-oriented scripting language and is available from http://www.ruby-lang.org/. To handle numeric data, RubyNetCDF uses NArray, which is the standard numeric multi-dimensional array class for Ruby (http://www.ruby-lang.org/en/raa-list.rhtml?name=NArray). An NArray object holds numeric data in a consecutive memory area pointed by a C pointer. Thus, it is computationally efficient. NArray is similar to NumPy for Python, but results of some benchmark tests suggests that NArray is more efficient than NumPy.
RubyNetCDF consists of the four class in the following.
class NetCDF -- the file class
An NetCDF object represents a NetCDF file
class NetCDFDim -- the dimension class
Although in its C version a NetCDF dimension is represented by a combination of a file ID and a dimension ID, it is represented by only one NetCDFDim object in RubyNetCDF.
class NetCDFVar -- the variable class
Although in its C version a NetCDF variable is represented by a combination of a file ID and a variable ID, it is represented by only one NetCDFVar object in RubyNetCDF.
class NetCDFAtt -- the attribute class
Although in its C version a NetCDF attribute is represented by a combination of file ID, variable ID, and its name, it is represented by only one NetCDFAtt object in RubyNetCDF.
Errors are basically handled by raising exceptions. However, light errors in value-returning methods are handled by returning nil (e.g., if a non-existent attribute name is specified in attribute reading). Those methods that returns nil on error are explicitly written as such in the following.
Security handling is done just as in the pre-defined File class.
---------------------------------------------
method_name(argument1, argument2, ...) -- arguments that can be omitted are expressed as Argument_name=Default_value
Explanation of its function
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
---------------------------------------------
Class Methods
Instance Methods
Class Methods
Instance Methods
Class Methods
Instance Methods
Class Methods
Instance Methods
---------------------------------------------
NetCDF.open(filename, mode="r", share=false)
Opens a file (class method). If mode="w" and non-existent, a new file is created.
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
NetCDF.new
Aliased to NetCDF.open
NetCDF.create(filename, noclobber=false, share=false)
Creates a NetCDF file (class method)
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
close
Closes the file.
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
ndims
Returns the number of dimensions in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
nvars
Returns the number of variables in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
natts
Returns the number of global attributes in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
unlimited
Returns the unlimited dimension in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
path
Returns the path of the file (contents of the filename specified when opened/created)
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
redef
Switches to the define mode. Does nothing if already in it.
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
enddef
Switches to the data mode. Does nothing if already in it.
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
sync
Synchronizes the disk copy of a netCDF dataset with in-memory buffer
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
def_dim(dimension_name, length)
Define a dimension
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
put_att(attribute_name, value, atttype=nil)
Sets a global attribute
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
def_var(variable_name, vartype, dimensions)
Defines a variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
var(var_name)
Opens an existing variable in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
dim(dimension_name)
Opens an existing dimension in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
att(attribute_name)
Opens an existing global attribute in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
fill=(filemode)
Sets a fill mode. (Default behavior of NetCDF is FILL.)
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
each_dim{ ... }
Iterator regarding the dimensions in the file. Ex.: {|i| print i.name,"\n"} prints names of all dimensions
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
each_var{ ... }
Iterator regarding the variables in the file. Ex.: {|i| print i.name,"\n"} prints names of all variables
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
each_att{ ... }
Iterator regarding the global attributes of the file. Ex.: {|i| print i.name,"\n"} prints names of all of them.
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
dim_names
Returns the names of all dimensions in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
var_names
Returns the names of all variables in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
att_names
Returns the names of all the global attributes of the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
---------------------------------------------
length
Returns the length of the dimension
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
name=(dimension_newname)
Rename the dimension
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
name
Returns the name of the dimension
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
unlimited?
Inquires whether the dimension is unlimited or not
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
---------------------------------------------
dim(dim_num)
Inquires the dim_num-th dimension of the variable (dim_num=0,1,2,..)
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
dims
Returns an array of all the dimensions of the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
each_att{ ... }
Iterator regarding the global attributes of the variables. Ex.: {|i| print i.name,"\n"} prints names of all of them.
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
dim_names
Returns the names of all the dimensions of the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
att_names
Returns the names of all the attributes of the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
name
Returns the name of the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
name=(variable_newname)
Rename the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
ndims
Number of dimensions of the variable (which is rank of the variable).
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
ntype
vartype
Data value type of the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
natts
Returns the number of the attributes of the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
file
Inquires the file that the variable is in
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
att(attribute_name)
Returns the attribute specified by its name
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
put_att(attribute_name, value, atttype=nil)
Sets an attribute
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
put(value, option=nil)
Set the values of the variable
Arguments
option (Hash) : Optional argument to limit the portion of the variable to output values. If omitted, the whole variable is subject to the output. This argument accepts a Hash whose keys contain either "index" or a combination of "start","end", and "stride". The value of "index" points the index of a scalar portion of the variable. The other case is used to designate a regularly ordered subset, where "start" and "end" specifies bounds in each dimension and "stride" specifies intervals in it. As in Array "start", "end", and "index" can take negative values to specify index backward from the end. However, "stride" has to be positive, so reversing the array must be done afterwards if you like.
Example: If the variable is 2D:
{"start"=>[2,5],"end"=>[6,-1],"stride"=>[2,4]} -- Specifies a subset made as follows: the 1st dimension from the element 2 to the element 6 (note that the count starts with 0, so that the element 2 is the 3rd one) with an interval of 2; the 2nd dimension from the element 6 to the last element (designated by -1) with an interval of 5.
{"index"=>[0,0]}: Scalar of the fist element
{"index"=>[0,-2]}: Scalar from the 1st element of with respect to the 1st dimension and the 2nd element from the last with respect to the 2nd dimension
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
get(option=nil)
Returns values of the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
---------------------------------------------
name
Returns the name of the attribute
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
name=(attribute_newname)
Rename the attribute
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
copy(var_or_file)
Copies an attribute to a variable or a file. If file, becomes an global attribute
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
delete
Delete an attribute
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
put(value, atttype=nil)
Sets the value of the attribute
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
get
Returns the values of the attribute
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
atttype
Inquires the type of attribute values
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF