public NcDim AddDim(NcDim dim) { CheckNull(); CheckDefine(); Int32 dimId = 0; NcCheck.Check(NetCDF.nc_def_dim(myId, dim.GetName(), dim.IsUnlimited() ? NetCDF.NC_UNLIMITED : dim.GetSize(), ref dimId)); return new NcDim(this, dimId); }
public NcVar AddVar(string name, NcType ncType, NcDim ncDim) { CheckNull(); CheckDefine(); if(ncType.IsNull()) throw new exceptions.NcNullType("Attempt to invoke NcGroup.AddVar failed: NcType must be defined in either the current group or a parent group"); NcType tmpType = GetType(ncType.GetName(), Location.ParentsAndCurrent); if(tmpType.IsNull()) throw new exceptions.NcNullType("Attempt to invoke NcGroup.AddVar failed: NcType must be defined in either the current group or a parent group"); if(ncDim.IsNull()) throw new exceptions.NcNullDim("Attempt to invoke NcGroup.AddVar failed: NcDim must be defined in either the current group or a parent group"); NcDim tmpDim = GetDim(ncDim.GetName(), Location.ParentsAndCurrent); if(tmpDim.IsNull()) throw new exceptions.NcNullDim("Attempt to invoke NcGroup.AddVar failed: NcDim must be defined in either the current group or a parent group"); Int32 varId=0; Int32[] dimId = {tmpDim.GetId()}; NcCheck.Check(NetCDF.nc_def_var(myId, name, tmpType.GetId(), 1, dimId, ref varId)); return new NcVar(this, varId); }
// Get the dictionary (map) of NcDim objects public Dictionary<string, NcDim> GetDims(Location location=Location.Current) { CheckNull(); Dictionary<string, NcDim> ncDims = new Dictionary<string, NcDim>(); // search current group if(LocationIsCurrentGroup(location)) { Int32 dimCount = GetDimCount(); Int32[] dimIds = new Int32[dimCount]; NcCheck.Check(NetCDF.nc_inq_dimids(myId, ref dimCount, dimIds, 0)); for(int i=0;i<dimCount;i++) { NcDim tmpDim = new NcDim(this, dimIds[i]); ncDims.Add(tmpDim.GetName(), tmpDim); } } if(LocationIsParentGroup(location)) { Dictionary<string, NcGroup> groups = GetGroups(GroupLocation.ParentsGrps); foreach(KeyValuePair<string, NcGroup> k in groups) { k.Value.GetDims().ToList().ForEach(x => ncDims[x.Key] = x.Value); } } if(LocationIsChildGroup(location)) { Dictionary<string, NcGroup> groups = GetGroups(GroupLocation.AllChildrenGrps); foreach(KeyValuePair<string, NcGroup> k in groups) { k.Value.GetDims().ToList().ForEach(x => ncDims[x.Key] = x.Value); } } return ncDims; }
public void GetCoordVar(string coordVarName, ref NcDim ncDim, ref NcVar ncVar, Location location = Location.Current) { ncDim = GetDim(coordVarName, location); ncVar = GetVar(coordVarName, location); }
public NcDim(NcDim rhs) { nullObject = rhs.nullObject; myId = rhs.myId; groupId = rhs.groupId; }
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"); }