Class: NumRu::NetCDFDim

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

Instance Method Summary collapse

Instance Method Details

#==(Dimb) ⇒ Object



2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
# File 'ext/numru/netcdfraw.c', line 2027

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



524
525
526
527
528
529
530
531
532
533
534
535
# File 'ext/numru/netcdfraw.c', line 524

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



797
798
799
# File 'lib/numru/netcdf.rb', line 797

def inspect
  'NetCDFDim:'+name
end

#lengthObject



1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
# File 'ext/numru/netcdfraw.c', line 1207

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



801
802
803
804
805
806
807
# File 'lib/numru/netcdf.rb', line 801

def length_ul0
   if unlimited?
	 0
   else
	 length
   end
end

#nameObject



1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
# File 'ext/numru/netcdfraw.c', line 1248

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



1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
# File 'ext/numru/netcdfraw.c', line 1226

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(3);
  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)


1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
# File 'ext/numru/netcdfraw.c', line 1270

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);
  }
}