---atttype
属性値の型を問う
引数
* なし
戻り値
* "char","byte","sint","int","sfloat","float"
対応する(利用する) C 版 NetCDF の関数
* nc_inq_atttype
---typecode
属性値の型を問う(NArrayのtypecodeで返す)
引数
* なし
戻り値
* Fixnumオブジェクト (NArray:BYTE, NArray:SINT, NArray:LINT, NArray:SFLOAT, NArray:SFLOAT, NArray:DFLOAT)
対応する(利用する) C 版 NetCDF の関数
* nc_inq_atttype
=end
ruby-netcdf-0.7.1.1/doc/Ref_man_jp.html 0000644 0000041 0000041 00000201540 12556371372 017640 0 ustar www-data www-data
Untitled
RubyNetCDF version : 0.7.1
---------------------------------------------
RubyNetCDF NetCDF ゃ若 Ruby ゃ潟帥若с若鴻сRuby
若吾с鴻荐茯с
ユсRubyNetCDF 医ら
Ruby т篏帥紊罨≦医らゃ
NArray
сゃ潟鴻若鏆荀
NArray 若帥C ゃ潟帥若g<≪守
篆荐膊罘莖羣合NArray Python
NumPy 篌若綛障ゃ鴻 NArray 祉 NumPy 合
腓阪
激с潟RubyNetCDF 若炊宴<純
箴篏帥
NArrayMiss
綽荀с荅潟篏睡羈荀
憜 NetCDF-4 泣若с(違若帥≪泣若)
RubyNetCDF 篁ヤ鐚ゃ鴻罕
NetCDF -- <ゃ
筝ゃNetCDF鴻吾с筝ゃ NetCDF <ゃ絲上
NetCDFDim -- 罨≦
C NetCDF с罨≦<ゃID罨≦ID鐚紊違腟ц;
Ruby с筝ゃ NetCDFDim 吾ст撮茵
NetCDFVar -- 紊違
C NetCDF с紊違<ゃID紊ID鐚紊違腟ц;
Ruby с筝ゃ NetCDFVar 吾ст撮茵
NetCDFAtt -- 絮с
C NetCDF с絮с<ゃID紊ID絮у腟ц;
Ruby с筝ゃ NetCDFAtt 吾ст撮茵
ゃ若с NetCDF 紊違 char, byte, short, int,
float, double 泣若 Ruby 鐚罩g∈
荐 NArray 鐚d緇c "char", "byte", "sint",
"int", "sfloat", "float" 若違緇cNetCDFVar 鴻 vartype
(=ntype) 絖筝ゃ菴障NetCDF鴻 def_var
純紊違絎臂篁鴻羈綽荀
ゃ若с "float" C ц double 潟
с Ruby dс -- 腟粋昭帥 Float
鴻C float с double 絲上с
NetCDFVar 鴻 get <純<ゃ筝 NArray 紊違
茯粋昭"char" 紊違ゃ "byte" NArray 茯粋昭障
NArray "char" с NArray
byte ф絖膂≦宴с鴻筝遵
若堺箴紊榊絲上篏ゃ菴<純
с荵遵小若 nil 菴у上鐚絮уゃ緇絎
絮с絖鐚箴紊倶 nil 榊
<純ゃャ≪荐
腟粋昭帥 File 鴻祉ャc弱上
RubyNetCDFゃ若障罨<茵 Ruby 違吾
ゃ若若綽荀
require 'numru/netcdf'
(NetCDFVar鴻) 若炊<純篏帥
篁ヤ絎茵綽荀
require 'numru/netcdf_miss'
т require 'numru/netcdf'
絎茵с
若鴻域若炊宴
NArrayMiss
сゃ潟鴻若違
require 'numru/netcdf'
若吟NArrayMiss
筝荀с
с'numru' ("Numerical Ruby") 若吟若ゃ
若剛賢泣c若сRubyNetCDF ゃ若臀
篁ヤс
file = NumRu::NetCDF.create('tmp.nc')
x = file.def_dim('x',10)
y = file.def_dim('y',10)
v = file.def_var('v','float',[x,y])
file.close
сNumRu ゃ若≪吾ャ若с≪吾ャ
с腥咲с茵腦帥с
翫若吟若ゃ寂賢鴻茵腦
鴻≪吾ャ若ゃ若篏帥馹莎激
馹莎激с翫"NumRu::" NumRu
≪吾ャ若ゃ潟若у鐚憜鴻潟若
с鐚緇c罨<吾
include NumRu
file = NetCDF.create('tmp.nc')
...
篏睡箴潟若宴若吾障 demo test
違с
---------------------------------------------
-
罘純茹h
綣
- 綣1 (鴻障緇): 茯
- 綣2 (鴻障緇): 茯
- ...
祉
絲上() C NetCDF ∽
- NetCDF ver 3 ∽医綣с翫∽違膈罘純
腓冴贋・絲上翫綣у箴絖∽違
---------------------------------------------
---------------------------------------------
- NC_NOWRITE, NC_WRITE, NC_SHARE, NC_CLOBBER, NC_NOCLOBBER, NC_64BIT_OFFSET, NC_NETCDF4, NC_CLASSIC_MODEL, NCVERSION, SUPPORT_BIGMEM : NumRu::NetCDF::NC_NOWRITE ≪祉鴻
-
ゃ NetCDF version 4 篏帥c
鐚潟 NetCDF ゃver 4鐚true 鐚
с (NetCDF 3) false 菴
-
(<純 NetCDF-4 篏帥推戎緒с
箴紊榊). NetCDF.create т<ゃ若絎.
荐絎 "classic".
綣
- cmode : 篁ヤ
- 0, nil, or NetCDF::NC_CLASSIC_MODEL : classic format
(篁ュ NetCDF-3 若). 荐絎.
- NetCDF::NC_64BIT_OFFSET : classic 鐚紊違泣ゃ冴紊с堺ャ
- NetCDF::NC_NETCDF4 : HDF5 若鴻 NetCDF-4 違若
- ( NetCDF::NC_NETCDF4 | NetCDF::NC_CLASSIC_MODEL) [
NetCDF::NC_NETCDF4 NetCDF::NC_CLASSIC_MODEL bit "or"]:
NetCDF-4 違若鐚違若帥≪篏帥狗.
-
(<純 NetCDF-4 篏帥推戎緒с
箴紊榊).
NetCDF.create т<ゃ若憜荐絎菴.
-
<ゃ若鰹鴻<純鐚mode="w" с<ゃ絖井域鋎
綣
- filename (String): <ゃ
- mode (String) : ュ阪≪若: "r"(茯水); "w","w+" (吾
莨若 -- 憜筝荳筝吾(羔!)); "r+","a","a+" (菴遵 --
憜絎鴻障障吾莨若水) 腟粋昭帥 File 鴻
≪若с茯粋昭帥純羈鐚 NetCDF
若狗菴遵篏c鴻鴻若
- share (true or false) : shared≪若 (吾莨若推賢
ゃ篁祉鴻茯粋昭帥緇翫 true C
吟若冴ゃ膃5腴 nc_open с)
祉
絲上() C NetCDF ∽
-
NetCDF.open<純ゃ≪鴻с
-
NetCDF<ゃ篏鐚鴻<純)
綣
- filename (String) : <ゃ
- noclobber (true or false) : 筝吾
- share (true or false) : shared mode 篏帥 (吾莨若推賢
ゃ篁祉鴻茯粋昭帥緇翫 true C
吟若冴ゃ膃5腴 nc_open с)
祉
絲上() C NetCDF ∽
-
潟NetCDF<ゃ篏鐚鴻<純)
ф浦障若冴羔
綣
- tmpdir (String) : 潟若<ゃ臀c弱
医紊違ф絎c種TMPDIR,TMP,or
TEMP鐚障 '.'祉ャ≪若≪若с '.' 帥
- share (true or false) : shared mode 篏帥
祉
絲上() C NetCDF ∽
-
<ゃ若
綣
祉
絲上() C NetCDF ∽
-
<ゃ筝罨≦違菴
綣
祉
絲上() C NetCDF ∽
-
<ゃ筝紊違違菴
綣
祉
絲上() C NetCDF ∽
-
<ゃ筝違若絮с違菴
綣
祉
絲上() C NetCDF ∽
-
<ゃ筝unlimited dimension菴
綣
祉
絲上() C NetCDF ∽
-
<ゃ. open/createfilename綣違筝荳菴.
綣
祉
絲上() C NetCDF ∽
-
define mode≪篏nil菴
綣
祉
- true (絎臂≪若吾紊眼);
nil (≪絎臂≪若筝).
篁宴у眼с翫箴紊榊.
絲上() C NetCDF ∽
-
data mode ャ≪篏nil菴
綣
祉
- true (若帥≪若吾紊眼);
nil (≪若帥≪若筝).
篁宴у眼с翫箴紊榊.
絲上() C NetCDF ∽
-
篁絎臂≪若.
綣
祉
- true (篁絎臂≪若);
false (篁若帥≪若);
nil (篁 -- 茯水冴絨).
絲上() C NetCDF ∽
-
<≪寂賢<若c鴻筝<ゃ
綣
祉
絲上() C NetCDF ∽
-
dimension絎臂
綣
- dimension_name (String) : 絎臂dimension
- length (Integer) : dimension激≦狗罨≦ 0
祉
絲上() C NetCDF ∽
-
違若絮с荐絎
綣
- attribute_name (String) : 違若絮с
- value (Numeric, String, Array of Numeric, or NArray) : 荐絎
- atttype (nil or String) : 絮с.
"char"(="string"),"byte", "sint","int","sfloat", "float" (
,1,1,2,4,4,8 ゃ)) 障 nil (ゃ障篁祉)
祉
絲上() C NetCDF ∽
-
紊違絎臂
綣
- variable_name (String) : 絎臂variable
- vartype (String or Fixnum) : 紊違帥ゃ ("char", "byte", "sint", "sint", "int",
"sfloat", "float" 障NArraytypecode(Fixnum))
- dimensions (Array) : variable罨≦NetCDFDim Array
罨≦罨≦激紊違
rank
祉
絲上() C NetCDF ∽
-
def_var綽荀障罨≦絎臂
√罨≦激翫箴紊
綣
- variable_name (String) : 絎臂variable
- vartype (String) : 紊違帥ゃ ("char", "byte", "sint", "sint", "int",
"sfloat", "float" )
- shape_ul0 (Array of Integer) : 紊違綵≪潟<罨≦激
狗罨≦若ц;激紊違 rank
- dimnames (Array of String) : 罨≦. 激(=>rank)
shape_ul0 膈違
祉
絲上() C NetCDF ∽
-
<ゃ√紊違若
綣
祉
絲上() C NetCDF ∽
-
<ゃ筝紊違障若
綣
- names (nil or Array of String) : 若潟紊医. nil鐚鐚
祉
- NetCDFVar吾сArraynames絖紊医障遺紊榊
絲上() C NetCDF ∽
-
√罨≦若
綣
- dimension_name (String) : 若潟罨≦
祉
絲上() C NetCDF ∽
-
<ゃ筝罨≦障若
綣
- names (nil or Array of String) : 若潟罨≦. nil鐚鐚
祉
- NetCDFDim吾сArraynames絖罨≦障遺紊榊
絲上() C NetCDF ∽
-
√違若絮с若
綣
- attribute_name (String) : 若潟違若絮у
祉
絲上() C NetCDF ∽
-
fillmode紊眼(NetCDF FILL с)
綣
- fillmode (true for FILL or false for NOFILL)
祉
絲上() C NetCDF ∽
-
罨≦≪ゃ若.
箴: {|i| print i.name,"\n"} у罨≦茵腓.
綣
祉
絲上() C NetCDF ∽
-
紊違≪ゃ若.
箴: {|i| print i.name,"\n"} у紊違茵腓.
綣
祉
絲上() C NetCDF ∽
-
違若絮с≪ゃ若.
箴: {|i| print i.name,"\n"} у絮с茵腓.
綣
祉
絲上() C NetCDF ∽
- (nc_inq_natts, nc_inq_attname)
-
<ゃ筝罨≦ャ菴
綣
祉
絲上() C NetCDF ∽
- (nc_inq_ndims, nc_inq_dimname)
-
<ゃ筝紊違ャ菴
綣
祉
絲上() C NetCDF ∽
- (nc_inq_nvars, nc_inq_varname)
-
<ゃ筝違若絮сャ菴
綣
祉
絲上() C NetCDF ∽
- (nc_inq_natts, nc_inq_attname)
---------------------------------------------
-
罨≦激菴
綣
祉
絲上() C NetCDF ∽
-
length ≦狗罨≦≪若菴
綣
祉
絲上() C NetCDF ∽
-
ゃ
綣
- dimension_newname (String) : 違
祉
絲上() C NetCDF ∽
-
菴
綣
祉
絲上() C NetCDF ∽
-
≦狗罨≦鐚
綣
祉
絲上() C NetCDF ∽
---------------------------------------------
-
NetCDF紊違若潟NetCDF#var (NetCDF鴻ゃ
鴻帥潟鴻<純var) 篏帥c堺ャ<祉ィ絅
綣
- file (NetCDF or String) : NetCDF吾с(NetCDF)
障 NetCDF <ゃ(String)
- varname (String) : file筝紊医
- mode (String) : ュ阪≪若file String 篏帥
鐚NetCDF.open荀鐚
- share (true or false) : shared≪若
file String 篏帥鐚NetCDF.open荀鐚
祉
絲上() C NetCDF ∽
- (nc_open, nc_create, nc_inq_varid 膈)
-
scaled_getт戎NArray阪.
綣
- na_type (Integer) : NArray::BYTE, NArray::SINT, NArray::INT,
NArray::SFLOAT, or NArray::FLOAT
祉
-
NetCDFVar.unpack_type=ц┃絎NArray菴.
祉
- nil, NArray::BYTE, NArray::SINT, NArray::INT,
NArray::SFLOAT, or NArray::FLOAT
-
(<純 NetCDF-4 篏帥推戎緒с
箴紊榊).
(違鋎)紊違х軒(deflate). <純鐚
紊違篏 (NetCDF#def_var) 緇鐚NetCDF#enddef
若九若違違.
綣
- deflate_level (Integer) :: 0 to 9. (0: no compression; 9:
highest compression; recommended: 1 or 2).
- shuffle (optional; true or false; default: false) if true,
turn on the shuffle filter.
- <URL:http://www.unidata.ucar.edu/software/netcdf/papers/AMS_2008.pdf>:
``The shuffle algorithm changes the byte order in the data stream;
when used with integers that are all close together, this
results in a better compression ratio. There is no benefit
from using the shuffle filter without also using
compression.''
- Note: shuffle is effective for float variables too (tested by horinouchi).
祉
-
(<純 NetCDF-4 篏帥推戎緒с
箴紊榊).
憜х軒(deflation)<帥若菴
祉
- [shuffle, deflate, deflate_level] (a 3-element Array).
shuffle deflate true 障 false. deflate_level 贋(0-9).
-
(<純 NetCDF-4 篏帥推戎緒с
箴紊榊).
潟c≪潟荐絎篏睡帥ゃ潟違 deflate
Arguments
- endian : 罨<:
NetCDF::NC_ENDIAN_NATIVE (=0) (default),
NetCDF::NC_ENDIAN_LITTLE (=1), or NetCDF::NC_ENDIAN_BIG (=2).
Return value
-
(<純 NetCDF-4 篏帥推戎緒с
箴紊榊).
憜潟c≪活┃絎菴.
Return value
- 罨<:
NetCDF::NC_ENDIAN_NATIVE (=0) (default),
NetCDF::NC_ENDIAN_LITTLE (=1), or NetCDF::NC_ENDIAN_BIG (=2).
-
紊違 dim_num (0違)罨≦
綣
- dim_num (Fixnum) : 0,1,2,...罨≦0
祉
絲上() C NetCDF ∽
-
紊違罨≦菴
綣
祉
絲上() C NetCDF ∽
-
紊違綵≪菴. 篏≦狗罨≦激若.
篁紊違絎臂箴水.
綣
祉
絲上() C NetCDF ∽
- (nc_inq_vardimid, nc_inq_unlimdim 膈)
-
紊違憜綵≪菴.
綣
祉
絲上() C NetCDF ∽
-
紊遺賢絮(NetCDFAtt)≪ゃ若
綣
祉
絲上() C NetCDF ∽
- (nc_inq_natts, nc_inq_attname)
-
紊遺賢罨≦ャ菴
綣
祉
絲上() C NetCDF ∽
- (nc_inq_varndims, nc_inq_vardimid, nc_inq_dimname )
-
紊遺賢絮сャ菴
綣
祉
絲上() C NetCDF ∽
- (nc_inq_natts, nc_inq_attname)
-
紊違菴
綣
祉
絲上() C NetCDF ∽
-
篁帥
綣
- variable_newname (String) : 違
祉
絲上() C NetCDF ∽
-
罨≦違
綣
祉
絲上() C NetCDF ∽
-
ndims≪
-
vartypeュ
-
紊医ゃ
綣
祉
- String ("char","byte","sint","int","sfloat", or "float")
絲上() C NetCDF ∽
-
紊医ゃ(NArraytypecodeц)
綣
祉
- Fixnum吾с (NArray:BYTE, NArray:SINT, NArray:LINT, NArray:SFLOAT, NArray:SFLOAT, NArray:DFLOAT)
絲上() C NetCDF ∽
-
絮с違
綣
祉
絲上() C NetCDF ∽
-
紊違絮<ゃ
綣
祉
絲上() C NetCDF ∽
-
絎絮с菴
綣
- attribute_name (String) : 冴絮у
祉
絲上() C NetCDF ∽
-
絮с荐絎
綣
- attribute_name (String) : attribute
- value (Numeric, String, Array of Numeric, or NArray) : 荐絎
- atttype (nil or String) : 絮с.
"char"(="string"),"byte", "sint","int","sfloat", "float" (
,1,1,2,4,4,8 ゃ)) 障 nil (ゃ障篁祉)
祉
絲上() C NetCDF ∽
-
simple_putュ(alias)
-
ゃャ
綣
- value : ャ (Numeric,Array(Numeric1罨≦)NArray)
鴻(Numeric)障激鐚翫ゃ筝罕荐絎
option (Hash) : 紊違筝絎激с喝違
ャ違紊医篏絲乗院激ャ若
"start","end","stride"腟障"index"篏睡с"index"
1荀膣鐚鴻種"end","stride"ュャ
吾鴻荀膣違 value筝眼
違start,end,indexсArray翫罕莢ゃу
篏臀絎с"stride"罩cゃ水篁с
綣c菴医ラ
箴鐚 紊違2罨≦翫:
{"start"=>[2,5],"end"=>[6,-1],"stride"=>[2,4]} -- 膃1罨≦
荀膣 2 6 障 1 ゃ (0違ц膣 2 3 с
羈)膃2罨≦荀膣 6 緇(=-1)障 3 ゃ
c泣祉
{"index"=>[0,0]}: 荀膣
鴻弱
{"index"=>[0,-2]}: 1罨≦, 2罨≦緇2
鴻弱
祉
絲上() C NetCDF ∽
- nc_put_var_<type>, nc_put_vars_<type>, nc_put_var1_<type>
-
self絮 scale_factor and/or add_offset NArray 膈 "pack" .
scale_factor and/or add_offset 荐絎
(na-add_offset)/scale_factor 菴с na 菴
綣
- na : pack 医ら (NArray, NArrayMiss, Array)
祉
-
simple_put 罕pack絮 scale_factor add_offset 茹i
綣亥ゃ put 茹hс
-
simple_getュ(alias)
-
ゃ冴
綣
- option (Hash) : 紊違筝絎激с喝違篁
罕 put
祉
絲上() C NetCDF ∽
- nc_get_var_<type>, nc_get_vars_<type>, nc_get_var1_<type>
-
self絮 scale_factor and/or add_offset NArray 膈 "unpack" .
scale_factor and/or add_offset 荐絎
na * scale_factor + add_offset 菴с na 菴
coerce c紊 -- 箴違 na sint
scale_factor add_offset sfloat с違菴ゃ sfloat
菴ゃ NetCDFVar.unpack_type= 篏帥c
純絎с
綣
- na : unpack 医ら (NArray, or NArrayMiss)
祉
-
simple_get 罕unpack絮 scale_factor add_offset 茹i
綣亥ゃ put 茹hс
-
NetCDFVar#get 罕泣祉 NArray#[] 罕絎.
NArrayс泣若泣祉絎号鴻篁
膀蚊絎с {0..-1,2} ゃ障荀膣
違鐚激ャ若膀(Range)ゃ鴻(Integer)絎
NArray鐚罨≦篁ヤ紊違鐚罨≦ゃ潟鴻
絎堺ャ
-
NetCDFVar#put 罕泣祉 NArray#[]= 罕絎.
NArrayс泣若泣祉絎号鴻篁
膀蚊絎с {0..-1,2} ゃ障荀膣
違鐚激ャ若膀(Range)ゃ鴻(Integer)絎
NArray鐚罨≦篁ヤ紊違鐚罨≦ゃ潟鴻
絎堺ャ
-
get罕若炊
若炊罔羣絮 valid_range, (valid_min and/or valid_max),
障 missing_value 絎茹i篏
若吟若冴ゃィ絅с missin_value
茹i missing_value valid_* 絖翫
missng_value 鴻若睡峨c翫箴紊
榊
筝荐若炊鐚篁刻絎違<純
NArrayMiss 吾с菴с NArray 菴
綣
祉
- NArrayMiss吾с (若炊絎翫) 障 NArray
吾с (若炊絎翫)
NetcdfError 篁ュ箴紊榊
- missing_value 若炊合蚊 (筝荐с).
絲上() C NetCDF ∽
箴
罨<箴с get get_with_miss 臀.
[] 若炊茹i (
get
若с).
file = NetCDF.open('hogehoge.nc')
var = file.var('var')
def var.get(*args); get_with_miss(*args); end
p var.get # --> inteprets data missing if defined
p var[0..-1,0] # --> inteprets data missing if defined (assumed 2D)
-
get_with_miss罕unpack鴻宴若潟違茵.
罨ゅ堺 pack 若帥絲乗院茵(紊
潟潟潟激с恰。)valid_* / missing_value
pack 若帥違 unpack若帥
筝眼鐚鐚 unpack 若帥絲乗院
у堺潟潟潟激с潟絲上с
箴
-
put罕若炊
value
NArray <純 put
. value
NArrayMiss с self 絮с若炊
絎臂 (get_with_missс)value
筝若炊茹i潟<value
筝罨若帥
罨 (missing_value 障 _FillValue 障若炊合
紊綵) 臀筝с<ゃ吾莨若障
value
筝罨若帥 self
合蚊ャc
с
綣
- value : NArrayMiss 障 put ц┗鴻吾с.
- option (Hash) : put 荀.
祉
絲上() C NetCDF ∽
箴
罨<箴с put put_with_miss 臀.
[]= 若炊茹i (
put
若с).
file = NetCDF.open('hogehoge.nc')
var = file.var('var')
def var.put(*args); put_with_miss(*args); end
var.put = narray_miss # --> inteprets data missing if defined
var[0..-1,0] = narray_miss # --> inteprets data missing if defined (assumed 2D)
-
put_with_miss罕pack鴻宴若潟違茵.
罨ゅ堺 pack 若帥絲乗院茵(紊
潟潟潟激с恰。)valid_* / missing_value
pack 若帥違 unpack若帥
筝眼鐚鐚 unpack 若帥絲乗院
у堺潟潟潟激с潟絲上с
箴
---------------------------------------------
-
絮с菴
綣
祉
絲上() C NetCDF ∽
-
絮с紊
綣
- attribute_newname (String) : 違
祉
絲上() C NetCDF ∽
-
絮сャ紊違障<ゃ潟若<ゃ翫違若絮с
綣
- var_or_file (NetCDFVar or NetCDF)
祉
絲上() C NetCDF ∽
-
絮с
綣
祉
絲上() C NetCDF ∽
-
絮сゃ荐絎
綣
- value (Numeric, String, Array of Numeric, or NArray) : ャ
- atttype (nil or String) : 絮с.
"char"(="string"),"byte", "sint","int","sfloat", "float" (
,1,1,2,4,4,8 ゃ)) 障 nil (ゃ障篁祉)
祉
絲上() C NetCDF ∽
-
絮с筝荳冴
綣
祉
- 絖障NArray吾с (羈: 鴻若翫激1
NArray)
絲上() C NetCDF ∽
-
絮уゃ
綣
祉
- "char","byte","sint","int","sfloat","float"
絲上() C NetCDF ∽
-
絮уゃ(NArraytypecodeц)
綣
祉
- Fixnum吾с (NArray:BYTE, NArray:SINT, NArray:LINT, NArray:SFLOAT, NArray:SFLOAT, NArray:DFLOAT)
絲上() C NetCDF ∽
ruby-netcdf-0.7.1.1/doc/Ref_man.html 0000644 0000041 0000041 00000176002 12556371372 017153 0 ustar www-data www-data
Untitled
RubyNetCDF version : 0.7.1
---------------------------------------------
RubyNetCDF is the Ruby interface of the NetCDF library. Ruby is a free
object-oriented scripting language and is freely available from
the Ruby homepage.
To handle numeric data, RubyNetCDF uses
NArray, which is the standard numeric multi-dimensional array class
for Ruby. Thus, you have to have installed it before installing this library.
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.
Optionally, RubyNetCDF offers methods to handle data missing
automatically. To use it, you will also
need NArrayMiss.
See Usage for details.
Currently, NetCDF-4 support is partial (the new data models have not been
supported).
RubyNetCDF consists of the four classes 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.
All the NetCDF variable types char, byte, short, int, float, and
double are supported in this Ruby interface. These types are called,
however, differently in it to adhere to the convention of Ruby, or,
more specifically, of NArray. These types are named to as "char",
"byte", "sint", "int", "sfloat", and "float", respectively. Therefore,
the vartype (=ntype) method of the NetCDFVar class returns one of these
strings. The def_var method of the NetCDF class also accepts one of
them to define a variable. It should be noted especially that "float"
in this library means the double in the NetCDF terminology. This is
due to the convention of Ruby -- the predefined Float class
corresponds to the double in C, not the float.
The "get" method of NetCDFVar class reads a variable in a NArray of
the same type as in the file, except for the "char" type which is read
into a "byte". This is because NArray does not have a "char" type.
However, it not is not supposed to be a problem, since a byte NArray
can easily handle string data.
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 return nil on error are explicitly written as such
in the following.
Security handling is done just as in the pre-defined File class.
To use the RubyNetCDF library, load the library first by placing the
following line in your Ruby program to load the library:
require 'numru/netcdf'
If you want to use automatic data-missing-handling methods
(of NetCDFVar class), use the following:
require 'numru/netcdf_miss'
This will call require 'numru/netcdf'
inside at the beginning, so
you do not have to call the both. The missing-data handling is done
with NArrayMiss,
so you have have installed it. This is, however, not needed if you only
call require 'numru/netcdf'
.
Here, 'numru', which stands for "Numerical Ruby", is the name of
the subdirectory in the user's load path where the RubyNetCDF library
is placed. Then, it can be used as in the following:
file = NumRu::NetCDF.create('tmp.nc')
x = file.def_dim('x',10)
y = file.def_dim('y',10)
v = file.def_var('v','float',[x,y])
file.close
Here, NumRu is the module that has the library in it. The
reason why NetCDF library is wrapped in such a module is to avoid
conflicts in the name space. Without this kind of treatment,
problems happen if the user wants to use a library that happens to
have a class or module with the same name as even one of the classes
in this library.
If such a problem is not expected to happen, the prefix "NumRu::" can
be eliminated by "including" the NumRu module as in the following, so
that to place "NumRu::" is not needed anymore in the current scope:
include NumRu
file = NetCDF.create('tmp.nc')
...
For more examples, see demo and test programs included in the
distribution package.
---------------------------------------------
-
Explanation of its function
Arguments
- name of argument1 (its class or possible values): explanation
- name of argument2 (its class or possible values): explanation
- ...
Return value
- Explanation of the return value
Corresponding (dependent) function(s) in the C library of NetCDF
- Name(s) in NetCDF ver 3. The function equivalent to the current
method, if not in parenthesis. If no direct correspondence,
dependent functions are listed in parentheses.
---------------------------------------------
---------------------------------------------
- NC_NOWRITE, NC_WRITE, NC_SHARE, NC_CLOBBER, NC_NOCLOBBER, NC_64BIT_OFFSET, NC_NETCDF4, NC_CLASSIC_MODEL, NCVERSION, SUPPORT_BIGMEM : these constants can accessed by NumRu::NetCDF::NC_NOWRITE etc.
-
Returens wheather the linked NetCDF library is NetCDF-4 (true/false).
false means that it is version 3.
-
(Available only when NetCDF version 4 is used. Error is raised if not.)
Set the file format created by NetCDF.create. The initial setting is
"classic" (conventional netcdf 3 format).
Arguments
- cmode : one of the following:
- 0, nil, or NetCDF::NC_CLASSIC_MODEL : the classic format
(original NetCDF-3 format). This is the default setting of
RubyNetCDF.
- NetCDF::NC_64BIT_OFFSET : classic but supports larger variables
- NetCDF::NC_NETCDF4 : The new NetCDF-4 format based on HDF5
- ( NetCDF::NC_NETCDF4 | NetCDF::NC_CLASSIC_MODEL) [bit "or" of
NetCDF::NC_NETCDF4 and NetCDF::NC_CLASSIC_MODEL ]: the new
NetCDF-4 format but new data models are disabled.
-
(Available only when NetCDF version 4 is used. Error is raised if not.)
Returns the current setting of the creation format.
-
Opens a file (class method). If mode="w" and the file does not
exist, a new file is created.
Arguments
- filename (String): file name (path)
- mode (String) : IO mode "r" (read only); "w","w+" (write --
current contents are overwritten (eliminated!)); "r+","a","a+"
(append -- writable while current contents are preserved).
All the options permit reading, unlike the predefined File class.
Note that to "append" will require extra time and disk
space due to the limitations of the original NetCDF library,
which is used in this library.
- share (true or false) : Whether to use the "shared" mode or not
(set true if a file being written may be read from other
processes. See nc_open in Ch.5 of users' guide of the C version)
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Aliased to NetCDF.open
-
Creates a NetCDF file (class method)
Arguments
- filename (String) : file name (path)
- noclobber (true or false) : overwrite or not if the file exists
- share (true or false) : Whether to use the shared mode or not
(set true if a file being written may be read from other
processes. See nc_open in Ch.5 of users' guide of the C version)
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Creates a temporary NetCDF file (class method).
Its name is automatically generated, and it is deleted when closed.
Arguments
- tmpdir (String) : directory to place the temporary file.
By default, "." or a directory specified by an environmental
variable (TMPDIR or TMP or TEMP) is used. In a secure mode,
theses environmental variable is NOT used, and the default
value is '.'.
- share (true or false) : Whether to use the shared mode or not
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Closes the file.
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Returns the number of dimensions in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Returns the number of variables in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Returns the number of global attributes in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Returns the unlimited dimension in the file
Arguments
Return value
- a NetCDFDim if it exists; nil if not
Corresponding (dependent) function(s) in the C library of NetCDF
-
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
-
Switches to the define mode. Does nothing if already in it (nil returned).
Arguments
Return value
- true if successfully switched to the define mode;
nil if the file is already in the define mode.
Exception is raised if unsuccessful for other reasons.
Corresponding (dependent) function(s) in the C library of NetCDF
-
Switches to the data mode. Does nothing if already in it (nil returned).
Arguments
Return value
- true if successfully switched to the data mode;
nil if the file is already in the data mode.
Exception is raised if unsuccessful for other reasons.
Corresponding (dependent) function(s) in the C library of NetCDF
-
Inquire whether the file is in the define mode.
Arguments
Return value
- true if the data is in the define mode;
false if the file is in the data mode;
nil otherwise (possibly the file is read-only).
Corresponding (dependent) function(s) in the C library of NetCDF
- combination of nc_redef and nc_enddef
-
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
-
Define a dimension
Arguments
- dimension_name (String) : Name of the dimension to be defined
- length (Integer) : length of the dimension. 0 for unlimited.
Return value
- defined dimension (NetCDFDim object)
Corresponding (dependent) function(s) in the C library of NetCDF
-
Sets a global attribute
Arguments
- attribute_name (String) : name of the global attribute
- value (Numeric, String, Array of Numeric, or NArray) : value of the attribute
- atttype (nil or String) : data type of the attribute value.
nil lets it automatically determined from the value.
"char" (or "string"), "byte", "sint", "int", "sfloat", or "float"
specifies the type explicitly (1,1,2,4,4,8 bytes, respectively)
Return value
- created attribute (NetCDFAtt object)
Corresponding (dependent) function(s) in the C library of NetCDF
-
Defines a variable
Arguments
- name (String) : Name of the variable to define
- vartype (String or Fixnum) : data type of the variable ("char", "byte", "sint",
"sint", "int", "sfloat", or "float"), or a NArray typecodes(Fixnum)
- dimensions (Array) : Dimensions of the variable. An Array of
NetCDFDim, in the order from the fastest varying dimension to
the slowest varying one; its length becomes the rank of the
variable.
Return value
- defined variable (NetCDFVar object)
Corresponding (dependent) function(s) in the C library of NetCDF
-
Same as def_var but defines dimensions first if needed.
Raise exception if it conflicts with the lengths of existing dimensions.
Arguments
- name (String) : Name of the variable to define
- vartype (String) : data type of the variable ("char", "byte", "sint",
"sint", "int", "sfloat", or "float")
- shape_ul0 (Array of Integer) : Shape of the variable, i.e.,
lengths of dimensions. The unlimited dimension is specified by zero.
The length of shape_ul0 determines the rank of the variable.
- dimnames (Array of String) : Names of the dimensions. Its length
(=>rank) must be equal to that of shape_ul0
Return value
- defined variable (NetCDFVar object)
Corresponding (dependent) function(s) in the C library of NetCDF
-
Opens an existing variable in the file
Arguments
- var_name (String) : Name of the variable to open
Return value
- a NetCDFVar object; nil if the variable does not exist
Corresponding (dependent) function(s) in the C library of NetCDF
-
Opens existing variables in the file
Arguments
- names (nil or Array of String): Names of the variables to open;
all variables are returned if nil (default).
Return value
- Array of NetCDFVar objects; exception is raised if names has a
non-existent name
Corresponding (dependent) function(s) in the C library of NetCDF
-
Opens an existing dimension in the file
Arguments
- dimension_name (String) : Name of the dimension to open
Return value
- a NetCDFDim object; nil if the dimension does not exist
Corresponding (dependent) function(s) in the C library of NetCDF
-
Opens existing dimensions in the file
Arguments
- names (nil or Array of String): Names of the dimensions to open;
all dimensions are returned if nil (default).
Return value
- Array of NetCDFDim objects; exception is raised if names has a
non-existent name
Corresponding (dependent) function(s) in the C library of NetCDF
-
Opens an existing global attribute in the file
Arguments
- attribute_name (String) : Name of the global attribute to open
Return value
- a NetCDFAtt object if the attribute exists; nil if not
Corresponding (dependent) function(s) in the C library of NetCDF
- (nc_inq_attid used for inquiry)
-
Sets a fill mode. (Default behavior of NetCDF is FILL.)
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Iterator regarding the dimensions in the file.
Ex.: {|i| print i.name,"\n"} prints names of all dimensions
Arguments
- { ... } : Block for the iterator. A "do end" block is the alternative.
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_ndims)
-
Iterator regarding the variables in the file.
Ex.: {|i| print i.name,"\n"} prints names of all variables
Arguments
- { ... } : Block for the iterator. A "do end" block is the alternative.
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_nvars)
-
Iterator regarding the global attributes of the file.
Ex.: {|i| print i.name,"\n"} prints names of all of them.
Arguments
- { ... } : Block for the iterator. A "do end" block is the alternative.
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_natts, nc_inq_attname)
-
Returns the names of all dimensions in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (nc_inq_ndims, nc_inq_dimname)
-
Returns the names of all variables in the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_nvars, nc_inq_varname)
-
Returns the names of all the global attributes of the file
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_natts, nc_inq_attname)
---------------------------------------------
-
Returns the length of the dimension
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Same as length but returns 0 for the unlimited dimension
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Rename the dimension
Arguments
- dimension_newname (String) : new name
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Returns the name of the dimension
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Inquires whether the dimension is unlimited or not
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_unlimdim)
---------------------------------------------
-
open a NetCDF variable. This can also be done with NetCDF#var
(instance method of NetCDF class), which is recommended over
this method.
Arguments
- file (NetCDF or String) : a NetCDF file object (NetCDF)
or the path of a NetCDF file (String).
- varname (String) : name of the variable in the file
- mode (String) : IO mode -- used if file is a String (see NetCDF.open)
- share (true or false) : Whether to use the "shared" mode or
not -- used if file is a String (see NetCDF.open)
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_open, nc_create, nc_inq_varid etc.)
-
Fix the NArray type to be used in unpack.
Arguments
- na_type (Integer) : NArray::BYTE, NArray::SINT, NArray::INT,
NArray::SFLOAT, or NArray::FLOAT
Return value
-
Returns the NArray type set by NetCDFVar.unpack_type=.
Return value
- nil, NArray::BYTE, NArray::SINT, NArray::INT,
NArray::SFLOAT, or NArray::FLOAT
-
(Available only when NetCDF version 4 is used. Error is raised if not.)
Makes the current (newly created) variable "deflated" (=compressed).
This method must be called after
defining a variable (NetCDF#def_var) and before calling NetCDF#enddef.
Arguments
- deflate_level (Integer) :: 0 to 9. (0: no compression; 9:
highest compression; recommended: 1 or 2).
- shuffle (optional; true or false; default: false) if true,
turn on the shuffle filter.
- <URL:http://www.unidata.ucar.edu/software/netcdf/papers/AMS_2008.pdf>:
``The shuffle algorithm changes the byte order in the data stream;
when used with integers that are all close together, this
results in a better compression ratio. There is no benefit
from using the shuffle filter without also using
compression.''
- Note: shuffle is effective for float variables too (tested by horinouchi).
Return value
-
(Available only when NetCDF version 4 is used. Error is raised if not.)
Returns the present deflation parameters.
Return value
- [shuffle, deflate, deflate_level] (a 3-element Array),
where the values of shuffle and deflate are
true or false, and deflate_level is an Integer (0-9).
-
(Available only when NetCDF version 4 is used. Error is raised if not.)
Sets (changes) the endian. See deflate for when to use it.
Arguments
- endian : one of the following constants:
NetCDF::NC_ENDIAN_NATIVE (=0) (default),
NetCDF::NC_ENDIAN_LITTLE (=1), or NetCDF::NC_ENDIAN_BIG (=2).
Return value
-
(Available only when NetCDF version 4 is used. Error is raised if not.)
Returns the current endian setting.
Return value
- one of the following constants:
NetCDF::NC_ENDIAN_NATIVE (=0) (default),
NetCDF::NC_ENDIAN_LITTLE (=1), or NetCDF::NC_ENDIAN_BIG (=2).
-
Inquires the dim_num-th dimension of the variable (dim_num=0,1,2,..)
Arguments
- dim_num (Fixnum) : 0,1,... 0 is the fastest varying dimension.
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_vardimid)
-
Returns an array of all the dimensions of the variable
Arguments
Return value
- Array of NetCDFDim objects.
Corresponding (dependent) function(s) in the C library of NetCDF
-
Returns the shape of the variable, but the length of the unlimited dimension is set to zero.
Good to define another variable.
Arguments
Return value
- Array. [length of 0th dim, length of 1st dim,.. ]
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_vardimid, nc_inq_unlimdim etc)
-
Returns the current shape of the variable.
Arguments
Return value
- Array. [length of 0th dim, length of 1st dim,.. ]
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_vardimid etc)
-
Iterator regarding the global attributes of the variables.
Ex.: {|i| print i.name,"\n"} prints names of all of them.
Arguments
- { ... } : Block for the iterator. A "do end" block is the alternative.
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_natts, nc_inq_attname)
-
Returns the names of all the dimensions of the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_varndims, nc_inq_vardimid, nc_inq_dimname)
-
Returns the names of all the attributes of the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- (dependent on nc_inq_natts, nc_inq_attname)
-
Returns the name of the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Rename the variable
Arguments
- variable_newname (String) : new name
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
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
-
Aliased to ndims
-
Aliased to vartype
-
Inquires the data value type of the variable
Arguments
Return value
- String ("char","byte","sint","int","sfloat", or "float")
Corresponding (dependent) function(s) in the C library of NetCDF
-
Inquires the data type of the variable (returns a typecode of NArray)
Arguments
Return value
- a Fixnum (NArray:BYTE, NArray:SINT, NArray:LINT, NArray:SFLOAT, NArray:SFLOAT, NArray:DFLOAT)
Corresponding (dependent) function(s) in the C library of NetCDF
-
Returns the number of the attributes of the variable
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Inquires the file that the variable is in
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Returns the attribute specified by its name
Arguments
- attribute_name (String) : Name of the attribute
Return value
- a NetCDFAtt object if the attribute exists; nil if not
Corresponding (dependent) function(s) in the C library of NetCDF
- (nc_inq_attid is used for inquiry)
-
Sets an attribute
Arguments
- attribute_name (String) : name of the attribute
- value (Numeric, String, Array of Numeric, or NArray) : value of the attribute
- atttype (nil or String) : data type of the attribute value.
nil lets it automatically determined from the value.
"char" (="string"), "byte", "sint", "int", "sfloat", or "float"
specifies the type explicitly (1,1,2,4,4,8 bytes, respectively)
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Aliased to simple_put
-
Set the values of the variable
Arguments
- value : value to set (Numeric, Array of Numeric (1D only), or
NArray (possibly multi-D)). If it is a Numeric or length==1, the value
is set uniformly.
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
- nc_put_var_<type>, nc_put_vars_<type>, nc_put_var1_<type>
-
Pack a NArray (etc) using the attributes scale_factor and/or add_offset of self.
If scale_factor and/or add_offset is defined, returns
(na-add_offset)/scale_factor. Returns na if not.
Arguments
- na : a numeric array to pack (NArray, NArrayMiss, or Array)
Return value
-
Same as simple_put but interprets the attributes scale_factor and/or add_offset using pack.
See the document for simple_put for arguments etc.
-
Aliased to simple_get.
-
Returns values of the variable
Arguments
- option (Hash) : Optional argument to limit the portion of the
variable to get values. Its usage is the same as in the method
put.
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- nc_get_var_<type>, nc_get_vars_<type>, nc_get_var1_<type>
-
Unpack a NArray (etc) using the attributes scale_factor and/or add_offset of self.
If scale_factor and/or add_offset is defined, returns
na * scale_factor + add_offset. Returns na if not.
Type conversion is made by the coercing -- for example
if na is sint and scale_factor and add_offset is sfloat,
return value is sfloat. The type of the return value can be specified
explicitly with NetCDFVar.unpack_type=.
Arguments
- na : a numeric array to unpack (NArray, or NArrayMiss)
Return value
-
Same as simple_get but interprets the attributes scale_factor and/or add_offset using unpack.
See the document for simple_get for arguments etc.
-
Same as NetCDFVar#get but a subset is specified as in the method [] of NArray.
In addition to the subset specifications supported by NArray,
ranges with steps are supported, which is specified
like {0..-1, 3}, i.e., a 1-element Hash with the key and value
representing the range (Range) and the step (Integer), respectively.
Unlike NArray, 1-dimensional indexing of multi-dimensional
variables is not support.
-
Same as NetCDFVar#put but a subset is specified as in the method []= of NArray.
In addition to the subset specifications supported by NArray,
ranges with steps are supported, which is specified
like {0..-1, 3}, i.e., a 1-element Hash with the key and value
representing the range (Range) and the step (Integer), respectively.
Unlike NArray, 1-dimensional indexing of multi-dimensional
variables is not support.
-
Same as get but interprets data missing.
Data missing is specified by the standard attributes valid_range,
(valid_min and/or valid_max), or missing_value, with the precedence being
this order. Unlike the
recommendation in the NetCDF User's guide, missing_value is
interpreted if present. If missing_value and valid_* present
simultaneously, missing_value must be outside the valid range.
Otherwise, exception is raised.
If data missing is specified as stated above, this method returns a NArrayMiss.
If not, it returns a NArray. Thus, you can use this whether
data missing is defined or not.
Arguments
Return value
- an NArrayMiss (if data missing is specified) or an NArray
(if data missing is NOT specified)
Possible exception in addition to NetcdfError.
- missing_value is in the valid range (see above).
Corresponding (dependent) function(s) in the C library of NetCDF
- See get. This method is written in Ruby.
EXAMPLE
The following is an example to replace get with get_with_miss.
It will also make [] interpret data missing,
since it calls get
internally.
file = NetCDF.open('hogehoge.nc')
var = file.var('var')
def var.get(*args); get_with_miss(*args); end
p var.get # --> interprets data missing if defined
p var[0..-1,0] # --> interprets data missing if defined (assumed 2D)
-
Same as get_with_miss but handles data scaling too using unpack.
Missing data handling using valid_* / missing_value is applied
basically to packed data, which is consistent with most
conventions. However, it is applied to unpacked data
if and only if the type of valid_* / missing_value is not the same as
the packed data and is the samed as the unpacked data.
This treatment can handle all conventions.
EXAMPLE
- See above. The same thing applies.
-
Same as put but interprets data missing.
If value
is an NArray, the methods behaves as put.
Data missing in value
is interpreted if it is an NArrayMiss
and data missing is specified by attributes in self
(see get_with_miss ).
Namely, the data which are "invalid" in the value
is replaced
with a missing value when written in the file.
(missing_value or _FillValue or a value outside
the valid range). No check is made whether "valid" values in the
NArrayMiss is within the valid range of self
.
Arguments
- value : NArrayMiss or what is allowed in put.
- option (Hash) : See put.
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
- See put. This method is written in Ruby.
EXAMPLE
The following is an example to replace put with put_with_miss.
It will also make []= interpret data missing,
since it calls put
internally.
file = NetCDF.open('hogehoge.nc')
var = file.var('var')
def var.put(*args); put_with_miss(*args); end
var.put = narray_miss # --> interprets data missing if defined
var[0..-1,0] = narray_miss # --> interprets data missing if defined (assumed 2D)
-
Same as put_with_miss but handles data scaling too using pack.
Missing data handling using valid_* / missing_value is applied
basically to packed data, which is consistent with most
conventions. However, it is applied to unpacked data
if and only if the type of valid_* / missing_value is not the same as
the packed data and is the samed as the unpacked data.
This treatment can handle all conventions.
EXAMPLE
- See above. The same thing applies.
---------------------------------------------
-
Returns the name of the attribute
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Rename the attribute
Arguments
- attribute_newname (String) : New name
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Copies an attribute to a variable or a file. If file, becomes an global attribute
Arguments
- var_or_file (NetCDFVar or NetCDF)
Return value
- Resultant new attribute (NetCDFAtt)
Corresponding (dependent) function(s) in the C library of NetCDF
-
Delete an attribute
Arguments
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Sets the value of the attribute
Arguments
- value (Numeric, String, Array of Numeric, or NArray) : value of the attribute
- atttype (nil or String) : data type of the attribute value.
nil lets it automatically determined from the value.
"char" (="string"), "byte", "sint", "int", "sfloat", or "float"
specifies the type explicitly (1,1,2,4,4,8 bytes, respectively)
Return value
Corresponding (dependent) function(s) in the C library of NetCDF
-
Returns the values of the attribute
Arguments
Return value
- String or an NArray object (NOTE: even a scalar is returned as
an NArray of length 1)
Corresponding (dependent) function(s) in the C library of NetCDF
-
Inquires the type of attribute values
Arguments
Return value
- "char","byte","sint","int","sfloat","float"
Corresponding (dependent) function(s) in the C library of NetCDF
-
Inquires the type of attribute values (returns a NArray typecode)
Arguments
Return value
- a Fixnum (NArray:BYTE, NArray:SINT, NArray:LINT, NArray:SFLOAT, NArray:SFLOAT, NArray:DFLOAT)
Corresponding (dependent) function(s) in the C library of NetCDF
ruby-netcdf-0.7.1.1/doc/README_JP.txt 0000644 0000041 0000041 00000012253 12556371372 017002 0 ustar www-data www-data ***** README_JP.txt --- RubyNetCDF とは?--- *****
*** RubyNetCDF の背景と目的 ***
今日、気象、大気、超高層科学などの分野に置いては、観測機器の発達により、
多くの観測データが得られるようになり、さらに計算機科学の発達により、計
算機シミュレーションによる数値解析がさかんに行われるようになった。その
結果、現在では各研究室単位で扱われるデータ量だけを考えても、その量はか
なり膨大なものとなり、少しでも、効率よくデータ処理を行う必要がでてきた。
さらに、観測データ、シミュレーションのデータを解析するためのプログラム
作成はファイルのフォーマットが違えば、逐一そのフォーマットに合わせて、
プログラムを作成せねばならず、非常に労力と時間を費やすことになる。これ
を解決するには、様々なフォーマットデータを統一して扱えるインターフェー
スが必要で、そのインタフェースは可視化や、数値計算にも適したものが必要
である。そのような背景をふまえて、開発効率が高く、プログラムの保守管理
が容易であるという理由からオブジェクト指向言語rubyを用いたデータ処理、
可視化環境開発が有効と考える。そのための種々のフォーマットデータを扱
うためのインターフェース作りの一つとして、自己記述型フォーマットである、
netCDFデータのCインターフェースにおけるrubyによるラッパーの開発を目的と
する。
*** netCDFについて ***
netCDFは、Univercity Corporation for Atmospheric Researchによって開発さ
れた。バイナリデータとの違いは、netCDFは単なる数値配列のならびになってい
るのではなく、その他の付加的情報をそのファイルの中に持っているということ
である。具体的な構造は、
file--has→dimenstions
↑ ref
--has→variables→ attributes
--has→attributes (global)
といった具合に、次元、変数名、属性という付加的情報を持ったフォーマットで
ある。
netCDFのインターフェースとしては、C言語用、FORTRAN言語用、C++言語用、
perl言語用、とあるが、rubyはもともとCでかかれており、さらに機能拡張をす
る場合は拡張ライブラリというプログラムをCで作成して実現することができる
ようになっている。そこでC言語インターフェースにrubyの側からアクセスでき
るように拡張ライブラリを作成する。
*** 実際に開発したプログラムの仕様 ***
まず、上記のようなnetCDFの構造に合わせて、新しく拡張ライブラリ中に
4つのクラスを定義した。
〇 NetCDFクラス
〇 NetCDFDim クラス
〇 NetCDFVar クラス
〇 NetCDFAtt クラス
このクラスのそれぞれにCインターフェースに合わせて作成したメソッドだけで
なく、NetCDFDim,NetCDFAttクラスのオブジェクトに関するイテレータが容易に
できるメソッドを用意し、変数へのデータの書込や、データの読み出しもハッシュ
を利用したオプション引数による制御を可能にすることで利用しやすいインター
フェースを実現した。またrubyの配列は数値計算に向いていないので、netCDF
ファイルに書き込む前、またnetCDFファイルから読み出したデータ配列の格納
には、数値計算に適した数値型配列NArrayを使用している。
一つ一つのメソッドの仕様については、netcdf-0.01.tar.gzに同梱されている
how_to_use_netcdf.docまたはhow_to_use_netcdf.pdfに記載されているのでそ
ちらを参照下さい。
*** インストール方法および注意事項等 ***
netcdf-0.01.tar.gzを展開してできるnetcdf-0.01/ディレクトリにある
extconf.rbを使用して、
ruby extconf.rb,
make
make test
make site-install(またはmake install)
でインストールできる。(make test はテストをするだけなのでしなくても良
い)
またこのプログラムを使用するためには、NArrayがあらかじめインストールさ
れていることが必要になる。またNArrayのヘッダファイル、
narray.h,
narray_config.h
はrubyのヘッダファイルruby.hの格納場所
(通常/usr/local/lib/ruby/1.6/アーキテクチャ名)
以下にコピーしておく必要がある。
さらに、これは注意事項です。
ここで、extconf.rbの中では、netcdf-0.01/にあるmkmf.rbを呼び出して、
実行しますが、一部rubyのもともとのmkmf.rbに変更を加えています。
変更の仕方を以下に示します。今後、rubyのバージョンアップが行われ、
mkmf.rbが書き換えられた際の参考にしてください。
**********************************************************************
install: $(archdir)/$(DLLIB)
site-install: $(sitearchdir)/$(DLLIB)
となっているので、$(archdir)/$(DLLIB): と
$(sitearchdir)/$(DLLIB): にそれぞれ、
$(archdir)/$(DLLIB): $(DLLIB) のほうは
@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(rubylibdir) $(archdir)
@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555,
true)' $(DLLIB) $(archdir)/$(DLLIB)
の直後に、
@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)'
netcdf.rb $(rubylibdir)/netcdf.rb
を、
$(sitearchdir)/$(DLLIB): $(DLLIB) のほうは
@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(libdir) $(sitearchdir)
@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555,
true)' $(DLLIB) $(sitearchdir)/$(DLLIB)
の直後に、
@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555,
true)' netcdf.rb $(sitelibdir)/netcdf.rb
を加えています。
disclean: に対し、もとは
@$(RM) core ruby$(EXEEXT) *~
であるのに対し、
@$(RM) core ruby$(EXEEXT) *~ *.nc demo/*.nc
と、*.nc ファイルを消去するようにしました。
*************************************************************************
配布条件はRubyのライセンスに準拠する。
なお、netcdf,ruby,narrayに関する情報は以下のURLを参照下さい。
netcdfのホームページ
http://www.unidata.ucar.edu/packages/netcdf/
rubyのホームページ
http://www.ruby-lang.org/
narrayのホームページ
http://www.ruby-lang.org/en/raa-list.rhtml?name=NArray
***** End of the README_JP.txt *****
ruby-netcdf-0.7.1.1/doc/Ref_man.rd 0000644 0000041 0000041 00000132725 12556371372 016620 0 ustar www-data www-data =begin
=RubyNetCDF Reference Manual
RubyNetCDF version : 0.7.1
* (())
---------------------------------------------
==Overview
RubyNetCDF is the Ruby interface of the NetCDF library. Ruby is a free
object-oriented scripting language and is freely available from
(()).
To handle numeric data, RubyNetCDF uses
(()), which is the standard numeric multi-dimensional array class
for Ruby. Thus, you have to have installed it before installing this library.
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.
Optionally, RubyNetCDF offers methods to handle data missing
automatically. To use it, you will also
need (()).
See (()) for details.
Currently, NetCDF-4 support is partial (the new data models have not been
supported).
===Structure
RubyNetCDF consists of the four classes in the following.
* (()) -- the file class
An NetCDF object represents a NetCDF file
* (()) -- 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.
* (()) -- 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.
* (()) -- 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.
===Data type
All the NetCDF variable types char, byte, short, int, float, and
double are supported in this Ruby interface. These types are called,
however, differently in it to adhere to the convention of Ruby, or,
more specifically, of NArray. These types are named to as "char",
"byte", "sint", "int", "sfloat", and "float", respectively. Therefore,
the vartype (=ntype) method of the NetCDFVar class returns one of these
strings. The def_var method of the NetCDF class also accepts one of
them to define a variable. It should be noted especially that "float"
in this library means the double in the NetCDF terminology. This is
due to the convention of Ruby -- the predefined Float class
corresponds to the double in C, not the float.
The "get" method of NetCDFVar class reads a variable in a NArray of
the same type as in the file, except for the "char" type which is read
into a "byte". This is because NArray does not have a "char" type.
However, it not is not supposed to be a problem, since a byte NArray
can easily handle string data.
===Error handling
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 return nil on error are explicitly written as such
in the following.
===Security features
Security handling is done just as in the pre-defined File class.
===Usage
To use the RubyNetCDF library, load the library first by placing the
following line in your Ruby program to load the library:
require 'numru/netcdf'
If you want to use automatic data-missing-handling methods
(of NetCDFVar class), use the following:
require 'numru/netcdf_miss'
This will call (({require 'numru/netcdf'})) inside at the beginning, so
you do not have to call the both. The missing-data handling is done
with (()),
so you have have installed it. This is, however, not needed if you only
call (({require 'numru/netcdf'})).
Here, 'numru', which stands for "Numerical Ruby", is the name of
the subdirectory in the user's load path where the RubyNetCDF library
is placed. Then, it can be used as in the following:
file = NumRu::NetCDF.create('tmp.nc')
x = file.def_dim('x',10)
y = file.def_dim('y',10)
v = file.def_var('v','float',[x,y])
file.close
Here, NumRu is the module that has the library in it. The
reason why NetCDF library is wrapped in such a module is to avoid
conflicts in the name space. Without this kind of treatment,
problems happen if the user wants to use a library that happens to
have a class or module with the same name as even one of the classes
in this library.
If such a problem is not expected to happen, the prefix "NumRu::" can
be eliminated by "including" the NumRu module as in the following, so
that to place "NumRu::" is not needed anymore in the current scope:
include NumRu
file = NetCDF.create('tmp.nc')
...
For more examples, see demo and test programs included in the
distribution package.
---------------------------------------------
==How to read this manual
--- method_name(argument1, argument2, ...) -- arguments that can be omitted are expressed as Argument_name=Default_value
Explanation of its function
Arguments
* name of argument1 (its class or possible values): explanation
* name of argument2 (its class or possible values): explanation
* ...
Return value
* Explanation of the return value
Corresponding (dependent) function(s) in the C library of NetCDF
* Name(s) in NetCDF ver 3. The function equivalent to the current
method, if not in parenthesis. If no direct correspondence,
dependent functions are listed in parentheses.
---------------------------------------------
==Method Index
* (())
Class Methods
* (()) returens wheather the linked library is NetCDF-4 (true/false)
* (()) Set the file format created by NetCDF.create (for NetCDF-4 only).
* (()) Returns the current setting of the creation format (for NetCDF-4 only).
* (()) Opens a file (class method). If mode="w" and non-existent, a new
* (()) Aliased to NetCDF.open
* (()) Creates a NetCDF file (class method)
* (()) Creates a temporary NetCDF file (class method)
Instance Methods
* (()) Closes the file.
* (()) Returns the number of dimensions in the file
* (()) Returns the number of variables in the file
* (()) Returns the number of global attributes in the file
* (()) Returns the unlimited dimension in the file
* (()) Returns the path of the file (contents of the filename specified when opened/created)
* (()) Switches to the define mode. Does nothing if already in it (nil returned).
* (()) Switches to the data mode. Does nothing if already in it (nil returned).
* (()) Inquire whether the file is in the define mode.
* (()) Synchronizes the disk copy of a netCDF dataset with in-memory buffer
* (()) Define a dimension
* (()) Sets a global attribute
* (()) Defines a variable
* (()) Same as def_var but defines dimensions first if needed
* (()) Opens an existing variable in the file
* (()) Opens existing variables in the file
* (()) Opens an existing dimension in the file
* (()) Opens existing dimensions in the file
* (()) Opens an existing global attribute in the file
* (()) Sets a fill mode. (Default behavior of NetCDF is FILL.)
* (()) Iterator regarding the dimensions in the file.
* (()) Iterator regarding the variables in the file.
* (()) Iterator regarding the global attributes of the file.
* (()) Returns the names of all dimensions in the file
* (()) Returns the names of all variables in the file
* (()) Returns the names of all the global attributes of the file
* (())
Class Methods
Instance Methods
* (()) Returns the length of the dimension
* (()) Same as length but returns 0 for the unlimited dimension
* (()) Rename the dimension
* (()) Returns the name of the dimension
* (()) Inquires whether the dimension is unlimited or not
* (())
Class Methods
* (()) Combines NetCDF.open and NetCDF#Var to open a variable with one line (no need to use this).
* (()) Fix the NArray type to be used
in (())
* (()) Returns the NArray type set by (()).
Instance Methods
* (()) Sets "deflation" (compression). (netCDF-4 only)
* (()) Retuns present deflation parameters. (netCDF-4 only)
* (()) Sets (changes) the endian. (netCDF-4 only)
* (()) Retunrs the present endian setting. (netCDF-4 only)
* (()) Inquires the dim_num-th dimension of the variable (dim_num=0,1,2,..)
* (()) Returns an array of all the dimensions of the variable
* (()) Returns the shape of the variable, but the length of the unlimited dimension is set to zero.
* (()) Returns the current shape of the variable.
## * (()) Returns a combination of filename (path) and variable name as path+'?var='+varname
* (()) Iterator regarding the global attributes of the variables.
* (()) Returns the names of all the dimensions of the variable
* (()) Returns the names of all the attributes of the variable
* (()) Returns the name of the variable
* (()) Rename the variable
* (()) Number of dimensions of the variable (which is rank of the variable).
* (()) aliased to ndims
* (()) Aliased to vartype
* (()) Inquires the data value type of the variable
* (()) Inquires the data type of the variable (returns a typecode of NArray)
* (()) Returns the number of the attributes of the variable
* (()) Inquires the file that the variable is in
* (()) Returns the attribute specified by its name
* (()) Sets an attribute
* (()) Aliased to (())
* (()) Set the values of the variable
* (()) Pack a NArray (etc) using the attributes scale_factor and/or add_offset of self.
* (()) Same as (()) but interprets the attributes scale_factor and/or add_offset using (()).
* (()) Aliased to (())
* (()) Returns values of the variable
* (()) Unpack a NArray (etc) using the attributes scale_factor and/or add_offset of self.
* (()) Same as (()) but interprets the attributes scale_factor and/or add_offset using (()).
* ((<[]>)) Same as NetCDFVar#get but a subset is specified as in the method [] of NArray.
* ((<[]=>)) Same as NetCDFVar#put but a subset is specified as in the method []= of NArray.
Instance Methods added by requiring "numru/netcdf_miss"
* (()) Same as (()) but interprets data missing.
* (()) Same as (()) but handles data scaling too.
* (()) Same as (()) but interprets data missing.
* (()) Same as (()) but handles data scaling too.
* (())
Class Methods
Instance Methods
* (()) Returns the name of the attribute
* (()) Rename the attribute
* (()) Copies an attribute to a variable or a file. If file, becomes an global attribute
* (()) Delete an attribute
* (()) Sets the value of the attribute
* (()) Returns the values of the attribute
* (()) Inquires the type of attribute values
* (()) Inquires the type of attribute values (returns a NArray typecode)
---------------------------------------------
=class NetCDF
===constants
* NC_NOWRITE, NC_WRITE, NC_SHARE, NC_CLOBBER, NC_NOCLOBBER, NC_64BIT_OFFSET, NC_NETCDF4, NC_CLASSIC_MODEL, NCVERSION, SUPPORT_BIGMEM : these constants can accessed by NumRu::NetCDF::NC_NOWRITE etc.
===Class Methods
---NetCDF.nc4?
Returens wheather the linked NetCDF library is NetCDF-4 (true/false).
false means that it is version 3.
---NetCDF.creation_format=(cmode)
(Available only when NetCDF version 4 is used. Error is raised if not.)
Set the file format created by NetCDF.create. The initial setting is
"classic" (conventional netcdf 3 format).
Arguments
* cmode : one of the following:
* 0, nil, or NetCDF::NC_CLASSIC_MODEL : the classic format
(original NetCDF-3 format). This is the default setting of
RubyNetCDF.
* NetCDF::NC_64BIT_OFFSET : classic but supports larger variables
* NetCDF::NC_NETCDF4 : The new NetCDF-4 format based on HDF5
* ( NetCDF::NC_NETCDF4 | NetCDF::NC_CLASSIC_MODEL) [bit "or" of
NetCDF::NC_NETCDF4 and NetCDF::NC_CLASSIC_MODEL ]: the new
NetCDF-4 format but new data models are disabled.
---NetCDF.creation_format
(Available only when NetCDF version 4 is used. Error is raised if not.)
Returns the current setting of the creation format.
---NetCDF.open(filename, mode="r", share=false)
Opens a file (class method). If mode="w" and the file does not
exist, a new file is created.
Arguments
* filename (String): file name (path)
* mode (String) : IO mode "r" (read only); "w","w+" (write --
current contents are overwritten (eliminated!)); "r+","a","a+"
(append -- writable while current contents are preserved).
All the options permit reading, unlike the predefined File class.
Note that to "append" will require extra time and disk
space due to the limitations of the original NetCDF library,
which is used in this library.
* share (true or false) : Whether to use the "shared" mode or not
(set true if a file being written may be read from other
processes. See nc_open in Ch.5 of users' guide of the C version)
Return value
* a NetCDF object
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_open, nc_create
---NetCDF.new
Aliased to NetCDF.open
---NetCDF.create(filename, noclobber=false, share=false)
Creates a NetCDF file (class method)
Arguments
* filename (String) : file name (path)
* noclobber (true or false) : overwrite or not if the file exists
* share (true or false) : Whether to use the shared mode or not
(set true if a file being written may be read from other
processes. See nc_open in Ch.5 of users' guide of the C version)
Return value
* a NetCDF object
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_create
---NetCDF.create_tmp(tmpdir=ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'.', share=false)
Creates a temporary NetCDF file (class method).
Its name is automatically generated, and it is deleted when closed.
Arguments
* tmpdir (String) : directory to place the temporary file.
By default, "." or a directory specified by an environmental
variable (TMPDIR or TMP or TEMP) is used. In a secure mode,
theses environmental variable is NOT used, and the default
value is '.'.
* share (true or false) : Whether to use the shared mode or not
Return value
* a NetCDF object
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_create
===Instance Methods
---close
Closes the file.
Arguments
* (none)
Return value
* nil
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_close
---ndims
Returns the number of dimensions in the file
Arguments
* (none)
Return value
* Integer
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_inq_ndims
---nvars
Returns the number of variables in the file
Arguments
* (none)
Return value
* Integer
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_inq_nvars
---natts
Returns the number of global attributes in the file
Arguments
* (none)
Return value
* Integer
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_inq_natts
---unlimited
Returns the unlimited dimension in the file
Arguments
* (none)
Return value
* a NetCDFDim if it exists; nil if not
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_inq_unlimdim
---path
Returns the path of the file (contents of the filename specified when opened/created)
Arguments
* (none)
Return value
* String
Corresponding (dependent) function(s) in the C library of NetCDF
* (none)
---redef
Switches to the define mode. Does nothing if already in it (nil returned).
Arguments
* (none)
Return value
* true if successfully switched to the define mode;
nil if the file is already in the define mode.
Exception is raised if unsuccessful for other reasons.
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_redef
---enddef
Switches to the data mode. Does nothing if already in it (nil returned).
Arguments
* (none)
Return value
* true if successfully switched to the data mode;
nil if the file is already in the data mode.
Exception is raised if unsuccessful for other reasons.
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_enddef
---define_mode?
Inquire whether the file is in the define mode.
Arguments
* (none)
Return value
* true if the data is in the define mode;
false if the file is in the data mode;
nil otherwise (possibly the file is read-only).
Corresponding (dependent) function(s) in the C library of NetCDF
* combination of nc_redef and nc_enddef
---sync
Synchronizes the disk copy of a netCDF dataset with in-memory buffer
Arguments
* (none)
Return value
* nil
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_sync
---def_dim(dimension_name, length)
Define a dimension
Arguments
* dimension_name (String) : Name of the dimension to be defined
* length (Integer) : length of the dimension. 0 for unlimited.
Return value
* defined dimension (NetCDFDim object)
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_def_dim
---put_att(attribute_name, value, atttype=nil)
Sets a global attribute
Arguments
* attribute_name (String) : name of the global attribute
* value (Numeric, String, Array of Numeric, or NArray) : value of the attribute
* atttype (nil or String) : data type of the attribute value.
nil lets it automatically determined from the value.
"char" (or "string"), "byte", "sint", "int", "sfloat", or "float"
specifies the type explicitly (1,1,2,4,4,8 bytes, respectively)
Return value
* created attribute (NetCDFAtt object)
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_put_att_
---def_var(name, vartype, dimensions)
Defines a variable
Arguments
* name (String) : Name of the variable to define
* vartype (String or Fixnum) : data type of the variable ("char", "byte", "sint",
"sint", "int", "sfloat", or "float"), or a NArray typecodes(Fixnum)
* dimensions (Array) : Dimensions of the variable. An Array of
NetCDFDim, in the order from the fastest varying dimension to
the slowest varying one; its length becomes the rank of the
variable.
Return value
* defined variable (NetCDFVar object)
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_def_var
---def_var_with_dim(name, vartype, shape_ul0, dimnames)
Same as def_var but defines dimensions first if needed.
Raise exception if it conflicts with the lengths of existing dimensions.
Arguments
* name (String) : Name of the variable to define
* vartype (String) : data type of the variable ("char", "byte", "sint",
"sint", "int", "sfloat", or "float")
* shape_ul0 (Array of Integer) : Shape of the variable, i.e.,
lengths of dimensions. The unlimited dimension is specified by zero.
The length of shape_ul0 determines the rank of the variable.
* dimnames (Array of String) : Names of the dimensions. Its length
(=>rank) must be equal to that of shape_ul0
Return value
* defined variable (NetCDFVar object)
Corresponding (dependent) function(s) in the C library of NetCDF
* (nc_def_var)
---var(var_name)
Opens an existing variable in the file
Arguments
* var_name (String) : Name of the variable to open
Return value
* a NetCDFVar object; nil if the variable does not exist
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_inq_varid
---vars(names)
Opens existing variables in the file
Arguments
* names (nil or Array of String): Names of the variables to open;
all variables are returned if nil (default).
Return value
* Array of NetCDFVar objects; exception is raised if names has a
non-existent name
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_inq_varid
---dim(dimension_name)
Opens an existing dimension in the file
Arguments
* dimension_name (String) : Name of the dimension to open
Return value
* a NetCDFDim object; nil if the dimension does not exist
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_inq_dimid
---dims(names)
Opens existing dimensions in the file
Arguments
* names (nil or Array of String): Names of the dimensions to open;
all dimensions are returned if nil (default).
Return value
* Array of NetCDFDim objects; exception is raised if names has a
non-existent name
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_inq_dimid
---att(attribute_name)
Opens an existing global attribute in the file
Arguments
* attribute_name (String) : Name of the global attribute to open
Return value
* a NetCDFAtt object if the attribute exists; nil if not
Corresponding (dependent) function(s) in the C library of NetCDF
* (nc_inq_attid used for inquiry)
---fill=(filemode)
Sets a fill mode. (Default behavior of NetCDF is FILL.)
Arguments
* fillmode (true or false)
Return value
* nil
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_set_fill
---each_dim{ ... }
Iterator regarding the dimensions in the file.
Ex.: {|i| print i.name,"\n"} prints names of all dimensions
Arguments
* { ... } : Block for the iterator. A "do end" block is the alternative.
Return value
* self
Corresponding (dependent) function(s) in the C library of NetCDF
* (dependent on nc_inq_ndims)
---each_var{ ... }
Iterator regarding the variables in the file.
Ex.: {|i| print i.name,"\n"} prints names of all variables
Arguments
* { ... } : Block for the iterator. A "do end" block is the alternative.
Return value
* self
Corresponding (dependent) function(s) in the C library of NetCDF
* (dependent on nc_inq_nvars)
---each_att{ ... }
Iterator regarding the global attributes of the file.
Ex.: {|i| print i.name,"\n"} prints names of all of them.
Arguments
* { ... } : Block for the iterator. A "do end" block is the alternative.
Return value
* self
Corresponding (dependent) function(s) in the C library of NetCDF
* (dependent on nc_inq_natts, nc_inq_attname)
---dim_names
Returns the names of all dimensions in the file
Arguments
* (none)
Return value
* Array of NetCDFDim
Corresponding (dependent) function(s) in the C library of NetCDF
* (nc_inq_ndims, nc_inq_dimname)
---var_names
Returns the names of all variables in the file
Arguments
* (none)
Return value
* Array of String
Corresponding (dependent) function(s) in the C library of NetCDF
* (dependent on nc_inq_nvars, nc_inq_varname)
---att_names
Returns the names of all the global attributes of the file
Arguments
* (none)
Return value
* Array of NetCDFAtt
Corresponding (dependent) function(s) in the C library of NetCDF
* (dependent on nc_inq_natts, nc_inq_attname)
---------------------------------------------
=class NetCDFDim
===Class Methods
===Instance Methods
---length
Returns the length of the dimension
Arguments
* (none)
Return value
* Integer
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_inq_dimlen
---length_ul0
Same as length but returns 0 for the unlimited dimension
Arguments
* (none)
Return value
* Integer
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_inq_dimlen
---name=(dimension_newname)
Rename the dimension
Arguments
* dimension_newname (String) : new name
Return value
* nil
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_rename_dim
---name
Returns the name of the dimension
Arguments
* (none)
Return value
* String
Corresponding (dependent) function(s) in the C library of NetCDF
* nc_inq_dimname
---unlimited?
Inquires whether the dimension is unlimited or not
Arguments
* (none)
Return value
* true or false
Corresponding (dependent) function(s) in the C library of NetCDF
* (dependent on nc_inq_unlimdim)
---------------------------------------------
=class NetCDFVar
===Class Methods
---NetCDFVar.new(file,varname,mode="r",share=false)
open a NetCDF variable. This can also be done with NetCDF#var
(instance method of NetCDF class), which is recommended over
this method.
Arguments
* file (NetCDF or String) : a NetCDF file object (NetCDF)
or the path of a NetCDF file (String).
* varname (String) : name of the variable in the file
* mode (String) : IO mode -- used if file is a String (see NetCDF.open)
* share (true or false) : Whether to use the "shared" mode or
not -- used if file is a String (see NetCDF.open)
Return value
* a NetCDFVar object
Corresponding (dependent) function(s) in the C library of NetCDF
* (dependent on nc_open, nc_create, nc_inq_varid etc.)
---NetCDFVar.unpack_type=(na_type)
Fix the NArray type to be used in (()).
Arguments
* na_type (Integer) : NArray::BYTE, NArray::SINT, NArray::INT,
NArray::SFLOAT, or NArray::FLOAT
Return value
* na_type (the argument)
---NetCDFVar.unpack_type
Returns the NArray type set by (()).
Return value
* nil, NArray::BYTE, NArray::SINT, NArray::INT,
NArray::SFLOAT, or NArray::FLOAT
===Instance Methods
---deflate(deflate_level, shuffle=false)
(Available only when NetCDF version 4 is used. Error is raised if not.)
Makes the current (newly created) variable "deflated" (=compressed).
This method must be called after
defining a variable (NetCDF#(())) and before calling NetCDF#((