Exemple #1
0
        // 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;
        }
Exemple #2
0
 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);
 }
Exemple #3
0
        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);
        }