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



2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
# File 'ext/numru/netcdfraw.c', line 2011

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



793
794
795
# File 'lib/numru/netcdf.rb', line 793

def inspect
  'NetCDFDim:'+name
end

#lengthObject



1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
# File 'ext/numru/netcdfraw.c', line 1196

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



797
798
799
800
801
802
803
# File 'lib/numru/netcdf.rb', line 797

def length_ul0
  if unlimited?
    0
  else
    length
  end
end

#nameObject



1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
# File 'ext/numru/netcdfraw.c', line 1236

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



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

VALUE
NetCDF_dim_name(VALUE Dim,VALUE dimension_newname)
{
  int ncid;
  int status;
  int dimid;
  char *c_dim_name;
  struct NetCDFDim *Netcdf_dim;

  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)


1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
# File 'ext/numru/netcdfraw.c', line 1258

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