コード例 #1
0
 public NcVlenType(NcType ncType) : base(ncType)
 {
     if (GetTypeClass() != NcTypeEnum.NC_VLEN)
     {
         throw new exceptions.NcException("The NcType object must be the base of a Vlen type");
     }
 }
コード例 #2
0
ファイル: NcOpaqueType.cs プロジェクト: wclwksn/netcdf4.net
 public NcOpaqueType(NcType ncType) : base(ncType)
 {
     if (GetTypeClass() != NcTypeEnum.NC_OPAQUE)
     {
         throw new exceptions.NcBadType("The NcType object must have a base type of NC_OPAQUE");
     }
 }
コード例 #3
0
ファイル: NcEnumType.cs プロジェクト: wclwksn/netcdf4.net
 public NcEnumType(NcType ncType) : base(ncType)
 {
     if (GetTypeClass() != NcTypeEnum.NC_ENUM)
     {
         throw new exceptions.NcBadType("The NcType object must be of type NC_ENUM");
     }
 }
コード例 #4
0
        // Constructor
        public NcType(NcGroup grp, string name)
        {
            nullObject = false;
            groupId    = grp.GetId();
            NcType typeTmp = grp.GetType(name, Location.ParentsAndCurrent);

            myId = typeTmp.GetId();
        }
コード例 #5
0
ファイル: TestNcType.cs プロジェクト: maka-io/netcdf4.net
        public bool TestTypes() {
            for(int i=1;i<13;i++) {
                NcType t = new NcType(i);
                Assert.Equals(t.GetId(), i);
                if(i==1) { // byte
                    Assert.Equals(t.GetName(), "byte");
                    Assert.Equals(t.GetSize(), 1); // A byte should be just one byte right?
                } else {
                    Assert.NotNull(t.GetName());
                    Assert.True(t.GetSize() > 0);
                }
            }

            return true;
        }
コード例 #6
0
ファイル: NcType.cs プロジェクト: maka-io/netcdf4.net
 // Compares global types
 public virtual bool Equals(NcType other) {
     return myId == other.myId;
 }
コード例 #7
0
 // Copy constructor
 public NcType(NcType rhs)
 {
     nullObject = rhs.nullObject;
     myId       = rhs.myId;
     groupId    = rhs.groupId;
 }
コード例 #8
0
ファイル: NcGroup.cs プロジェクト: maka-io/netcdf4.net
        public Dictionary<string, NcType> GetTypes(Location location=Location.Current) {
            CheckNull();
            Dictionary<string, NcType> ncTypes = new Dictionary<string, NcType>();

            // search in current group
            if(location == Location.Current || location == Location.ParentsAndCurrent 
                                                        || location == Location.ChildrenAndCurrent
                                                        || location == Location.All) {
                Int32 typeCount = GetTypeCount();
                Int32[] typeIds = new Int32[typeCount];
                NcCheck.Check(NetCDF.nc_inq_typeids(myId, ref typeCount, typeIds));

                foreach(Int32 i in typeIds) {
                    NcType tmpType = new NcType(this, i);
                    ncTypes.Add(tmpType.GetName(), tmpType);
                }
            }

            // search in parent groups
            if(location == Location.Parents || location == Location.ParentsAndCurrent 
                                                        || location == Location.All) {
                Dictionary<string, NcGroup> groups = GetGroups(GroupLocation.ParentsGrps);
                foreach(KeyValuePair<string, NcGroup> k in groups) {
                    k.Value.GetTypes().ToList().ForEach(x => ncTypes[x.Key] = x.Value);
                }
            }

            // search in child groups
            if(location == Location.Children || location == Location.ChildrenAndCurrent
                                                        || location == Location.All) {
                Dictionary<string, NcGroup> groups = GetGroups(GroupLocation.AllChildrenGrps);
                foreach(KeyValuePair<string, NcGroup> k in groups) {
                    k.Value.GetTypes().ToList().ForEach(x => ncTypes[x.Key] = x.Value);
                }
            }
            return ncTypes;
        }
コード例 #9
0
 // Compares global types
 public virtual bool Equals(NcType other)
 {
     return(myId == other.myId);
 }
コード例 #10
0
ファイル: TestNcVar.cs プロジェクト: maka-io/netcdf4.net
 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);
 }
コード例 #11
0
ファイル: NcGroup.cs プロジェクト: maka-io/netcdf4.net
        public int GetTypeCount(NcTypeEnum enumType, Location location=Location.Current) {
            CheckNull();
            Int32 ntypes=0;
            // search in current group
            if(location == Location.Current || location == Location.ParentsAndCurrent 
                                                        || location == Location.ChildrenAndCurrent
                                                        || location == Location.All) {
                Int32 ntypesp=0;
                Int32[] typeidsp = null;
                NcCheck.Check(NetCDF.nc_inq_typeids(myId, ref ntypesp, typeidsp));
                typeidsp = new Int32[ntypesp];
                NcCheck.Check(NetCDF.nc_inq_typeids(myId, ref ntypesp, typeidsp));

                foreach(Int32 i in typeidsp) {
                    NcType typeTmp = new NcType(this,i);
                    if(typeTmp.GetTypeClass() == enumType)
                        ntypes++;
                }
            }

            // search in parent groups
            if(location == Location.Parents || location == Location.ParentsAndCurrent 
                                                        || location == Location.All) {
                Dictionary<string, NcGroup> groups = GetGroups(GroupLocation.ParentsGrps);
                foreach(KeyValuePair<string, NcGroup> k in groups) {
                    ntypes += k.Value.GetTypeCount(enumType);
                }
            }

            // search in children groups
            if(location == Location.Children || location == Location.ChildrenAndCurrent
                                                        || location == Location.All) {
                Dictionary<string, NcGroup> groups = GetGroups(GroupLocation.AllChildrenGrps);
                foreach(KeyValuePair<string, NcGroup> k in groups) {
                    ntypes += k.Value.GetTypeCount(enumType);
                }
            }
            return ntypes;
        }
コード例 #12
0
ファイル: NcType.cs プロジェクト: maka-io/netcdf4.net
 // Copy constructor
 public NcType(NcType rhs) {
     nullObject = rhs.nullObject;
     myId = rhs.myId;
     groupId = rhs.groupId;
 }
コード例 #13
0
ファイル: NcVar.cs プロジェクト: maka-io/netcdf4.net
 public NcVarAtt PutAtt(string name, NcType type, double[] dataValues) {
     CheckNull();
     CheckDefine();
     if(!type.IsFixedType())
         throw new NotImplementedException("PutAtt() not implemented for non-fixed types");
     NcCheck.Check(NetCDF.nc_put_att_double(groupId, myId, name, type.GetId(), dataValues.Length, dataValues));
     return GetAtt(name);
 }
コード例 #14
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);
        }
コード例 #15
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);
        }
コード例 #16
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);
        }
コード例 #17
0
ファイル: NcGroup.cs プロジェクト: maka-io/netcdf4.net
 public NcVlenType AddVlenType(string name, NcType baseType) {
     CheckNull();
     CheckDefine();
     Int32 typeId=0;
     NcCheck.Check(NetCDF.nc_def_vlen(myId, name, baseType.GetId(), ref typeId));
     NcVlenType ncTypeTmp = new NcVlenType(this, name);
     return ncTypeTmp;
 }
コード例 #18
0
ファイル: NcEnumType.cs プロジェクト: maka-io/netcdf4.net
 public NcEnumType(NcType ncType ) : base(ncType) {
     if(GetTypeClass() != NcTypeEnum.NC_ENUM) 
         throw new exceptions.NcBadType("The NcType object must be of type NC_ENUM");
 }
コード例 #19
0
ファイル: NcOpaqueType.cs プロジェクト: maka-io/netcdf4.net
 public NcOpaqueType(NcType ncType) : base(ncType) {
     if(GetTypeClass() != NcTypeEnum.NC_OPAQUE)
         throw new exceptions.NcBadType("The NcType object must have a base type of NC_OPAQUE");
 }
コード例 #20
0
ファイル: NcGroup.cs プロジェクト: maka-io/netcdf4.net
 public NcGroupAtt PutAtt(string name, NcType type, Int16[] dataValues) {
     CheckNull();
     CheckDefine();
     //TODO: Support for VLEN | OPAQUE | ENUM | COMPOUND
     if(!type.IsFixedType())
         throw new NotImplementedException("PutAtt() not implemented for non-fixed types");
     NcCheck.Check(NetCDF.nc_put_att_short(myId, NcAtt.NC_GLOBAL, name, type.GetId(), dataValues.Length, dataValues ));
     return GetAtt(name);
 }
コード例 #21
0
ファイル: NcVar.cs プロジェクト: maka-io/netcdf4.net
 public NcVarAtt PutAtt(string name, NcType type, float datumValue) {
     CheckNull();
     CheckDefine();
     if(!type.IsFixedType())
         throw new NotImplementedException("PutAtt() not implemented for non-fixed types");
     NcCheck.Check(NetCDF.nc_put_att_float(groupId, myId, name, type.GetId(), 1, new float[] { datumValue }));
     return GetAtt(name);
 }
コード例 #22
0
ファイル: NcGroup.cs プロジェクト: maka-io/netcdf4.net
 public NcGroupAtt PutAtt(string name, NcType type, float[] dataValues) {
     CheckNull();
     CheckDefine();
     if(!type.IsFixedType())
         throw new NotImplementedException("PutAtt() not implemented for non-fixed types");
     NcCheck.Check(NetCDF.nc_put_att_float(myId, NcAtt.NC_GLOBAL, name, type.GetId(), dataValues.Length, dataValues ));
     return GetAtt(name);
 }
コード例 #23
0
ファイル: NcGroup.cs プロジェクト: maka-io/netcdf4.net
 public NcGroupAtt PutAtt(string name, NcType type, double datumValue) {
     CheckNull();
     CheckDefine();
     if(!type.IsFixedType())
         throw new NotImplementedException("PutAtt() not implemented for non-fixed types");
     NcCheck.Check(NetCDF.nc_put_att_double(myId, NcAtt.NC_GLOBAL, name, type.GetId(), 1, new double[] { datumValue }));
     return GetAtt(name);
 }
コード例 #24
0
ファイル: NcVlenType.cs プロジェクト: maka-io/netcdf4.net
 public NcVlenType(NcType ncType) : base(ncType) {
     if(GetTypeClass() != NcTypeEnum.NC_VLEN)
         throw new exceptions.NcException("The NcType object must be the base of a Vlen type");
 }