public NcVarAtt(NcGroup grp, NcVar var, Int32 index) : base(false) { ASCIIEncoding encoder = new ASCIIEncoding(); groupId = grp.GetId(); varId = var.GetId(); byte[] buffer = new byte[(int)NetCDF.netCDF_limits.NC_MAX_NAME]; NcCheck.Check(NetCDF.nc_inq_attname(groupId, varId, index, buffer)); string sbuffer = encoder.GetString(buffer); myName = sbuffer.Substring(0, sbuffer.IndexOf('\0')); // A null-terminated C-string }
public NcVar(NcVar rhs) { nullObject = rhs.nullObject; myId = rhs.myId; groupId = rhs.groupId; }
public Dictionary<string, NcVar> GetVars(Location location=Location.Current) { Dictionary<string, NcVar> vars = new Dictionary<string, NcVar>(); if(LocationIsCurrentGroup(location)) { int varCount = GetVarCount(); Int32[] varIds = new Int32[varCount]; NcCheck.Check(NetCDF.nc_inq_varids(myId, ref varCount, varIds)); foreach(Int32 varId in varIds) { NcVar tmpVar = new NcVar(this, varId); vars.Add(tmpVar.GetName(), tmpVar); } } if(LocationIsParentGroup(location)) { foreach(KeyValuePair<string, NcGroup> g in GetGroups(GroupLocation.ParentsGrps)) { g.Value.GetVars().ToList().ForEach(x => vars[x.Key] = x.Value); } } if(LocationIsChildGroup(location)) { foreach(KeyValuePair<string, NcGroup> g in GetGroups(GroupLocation.AllChildrenGrps)) { g.Value.GetVars().ToList().ForEach(x => vars[x.Key] = x.Value); } } return vars; }
public void GetCoordVar(string coordVarName, ref NcDim ncDim, ref NcVar ncVar, Location location = Location.Current) { ncDim = GetDim(coordVarName, location); ncVar = GetVar(coordVarName, location); }
private void FileSetup(ref NcFile file, ref NcDim dim1, ref NcVar var1, NcType type, int len=20) { file = TestHelper.NewFile(filePath); dim1 = file.AddDim("time", len); var1 = file.AddVar("temp", type, dim1); }
private void FileSetup(ref NcFile file, ref NcDim dim1, ref NcVar var1, string type="int") { file = TestHelper.NewFile(filePath); dim1 = file.AddDim("time", 20); var1 = file.AddVar("temp",type,"time"); }