コード例 #1
0
ファイル: NcGroup.cs プロジェクト: maka-io/netcdf4.net
        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);
        }
コード例 #2
0
ファイル: NcGroup.cs プロジェクト: maka-io/netcdf4.net
        public NcVar AddVar(string name, NcType ncType, List<NcDim> ncDimVector) {
            CheckNull();
            CheckDefine();
            NcType tmpType=null;
            Int32 varId=0;
            Int32[] dimIds = new Int32[ncDimVector.Count];
            if(ncType.IsNull())
                throw new exceptions.NcNullType("Attempt to invoke NcGroup.AddVar with a Null NcType object");
            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");
            for(int i=0;i<ncDimVector.Count;i++) {
                if(ncDimVector[i].IsNull())
                    throw new exceptions.NcNullDim("Attempt to invoke NcGroup.AddVar failed: NcType must be defined in either the current group or a parent group");
                NcDim tmpDim = GetDim(ncDimVector[i].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");
                dimIds[i] = ncDimVector[i].GetId();
            }
            NcCheck.Check(NetCDF.nc_def_var(myId, name, tmpType.GetId(), ncDimVector.Count, dimIds, ref varId));

            return new NcVar(this, varId);
        }
コード例 #3
0
ファイル: NcGroup.cs プロジェクト: maka-io/netcdf4.net
        // Add a scalar variable
        public NcVar AddVar(string name, NcType type) 
        {
            CheckNull();
            CheckDefine();
            if(type.IsNull())
                throw new exceptions.NcNullType("Attempt to invoke NcGroup.AddVar failed: typeName must be defined in either the current group or a parent group");

            Int32 varId = 0;
            Int32[] dimIds = null;
            NcCheck.Check(NetCDF.nc_def_var(myId, name,  type.GetId(), 0, dimIds, ref varId));
            return new NcVar(this, varId);
        }