예제 #1
0
        /// <summary>
        /// Get mapped netcdf data type for array elements, special case for char[]
        /// </summary>
        /// <param name="array"></param>
        /// <returns></returns>
        private NetCdfDataType GetNetCdfDataType(Array array)
        {
            var type = array.GetType().GetElementType();

            if (type == typeof(char[]))
            {
                return(NetCdfDataType.NC_CHAR);
            }
            return(NetCdfWrapper.GetNetCdf3DataType(type));
        }
예제 #2
0
        public NetCdfVariable AddVariable(string varName, Type type, NetCdfDimension[] ncDimensions)
        {
            int varId;

            CheckResult(NetCdfWrapper.nc_def_var(id, varName, NetCdfWrapper.GetNetCdf3DataType(type), ncDimensions.Length,
                                                 ncDimensions.Select(d => (int)d).ToArray(), out varId));
            var ncVar = new NetCdfVariable(varId);

            // variable name is unique here, guaranteed by nc_def_var call above
            ncVariableLookupByName.Add(varName, ncVar);
            return(ncVar);
        }