Class: NumRu::NetCDFDim

Inherits:
Object
  • Object
show all
Defined in:
lib/numru/netcdf.rb,
ext/netcdfraw.c

Instance Method Summary collapse

Instance Method Details

#==(Dimb) ⇒ Object



1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
# File 'ext/netcdfraw.c', line 1884

VALUE 
NetCDF_dim_eql(VALUE Dima,VALUE Dimb)
{
  struct NetCDFDim *Netcdf_dima;
  struct NetCDFDim *Netcdf_dimb;

  if( rb_obj_is_kind_of(Dimb, cNetCDFDim) ){
      Data_Get_Struct(Dima,struct NetCDFDim,Netcdf_dima);
      Data_Get_Struct(Dimb,struct NetCDFDim,Netcdf_dimb);
  
      if(Netcdf_dima->ncid == Netcdf_dimb->ncid && 
	 Netcdf_dima->dimid == Netcdf_dimb->dimid){
	  return Qtrue;
      } else {
	  return Qfalse;
      }
  } else {
      return Qfalse;
  }
}

#cloneObject

The methods of the NetCDFDim class



519
520
521
522
523
524
525
526
527
528
529
530
# File 'ext/netcdfraw.c', line 519

VALUE
NetCDF_dim_clone(VALUE dim)
{
    VALUE clone;
    struct NetCDFDim *nd1, *nd2;

    Data_Get_Struct(dim, struct NetCDFDim, nd1);
    nd2 = NetCDF_dim_init(nd1->ncid, nd1->dimid);
    clone = Data_Wrap_Struct(cNetCDFDim, 0, NetCDF_dim_free, nd2);
    CLONESETUP(clone, dim);
    return clone;
}

#inspectObject



779
780
781
# File 'lib/numru/netcdf.rb', line 779

def inspect
  'NetCDFDim:'+name
end

#lengthObject



1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
# File 'ext/netcdfraw.c', line 1171

VALUE
NetCDF_dim_length(VALUE Dim)
{
  int ncid;
  int status;
  int dimid;
  size_t lengthp;
  struct NetCDFDim *Netcdf_dim;
  
  Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
  ncid=Netcdf_dim->ncid;
  dimid=Netcdf_dim->dimid;

  status = nc_inq_dimlen(ncid,dimid,&lengthp);
  if(status != NC_NOERR) NC_RAISE(status);
  
  return(INT2NUM(lengthp));
}

#length_ul0Object



783
784
785
786
787
788
789
# File 'lib/numru/netcdf.rb', line 783

def length_ul0
   if unlimited?
	 0
   else
	 length
   end
end

#nameObject



1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
# File 'ext/netcdfraw.c', line 1212

VALUE
NetCDF_dim_inqname(VALUE Dim)
{
  int ncid;
  int status;
  int dimid;
  char c_dim_name[NC_MAX_NAME];
  struct NetCDFDim *Netcdf_dim;
  VALUE str;
  
  Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
  ncid=Netcdf_dim->ncid;
  dimid=Netcdf_dim->dimid;
  
  status = nc_inq_dimname(ncid,dimid,c_dim_name);
  if(status !=NC_NOERR) NC_RAISE(status);
  
  str = rb_str_new2(c_dim_name);
  OBJ_TAINT(str);
  return(str);
}

#name=(dimension_newname) ⇒ Object



1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
# File 'ext/netcdfraw.c', line 1190

VALUE
NetCDF_dim_name(VALUE Dim,VALUE dimension_newname)
{
  int ncid;
  int status;
  int dimid;
  char *c_dim_name;
  struct NetCDFDim *Netcdf_dim;
  
  rb_secure(4);
  Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
  ncid=Netcdf_dim->ncid;
  dimid=Netcdf_dim->dimid;
  Check_Type(dimension_newname,T_STRING);
  c_dim_name = StringValueCStr(dimension_newname);

  status = nc_rename_dim(ncid,dimid,c_dim_name);
  if(status !=NC_NOERR) NC_RAISE(status);
  
  return Qnil;
}

#unlimited?Boolean

Returns:

  • (Boolean)


1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
# File 'ext/netcdfraw.c', line 1234

VALUE
NetCDF_dim_whether_unlimited(VALUE Dim)
{
  int status;
  int uldid;
  struct NetCDFDim *Netcdf_dim;
  
  Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
  status=nc_inq_unlimdim(Netcdf_dim->ncid,&uldid);
  if(status !=NC_NOERR) NC_RAISE(status);
  if(Netcdf_dim->dimid == uldid){
      return(Qtrue);
  } else {
      return(Qfalse);
  }
}