示例#1
0
        private void ReadData(Stream fs)
        {
            foreach (Variable v in this.var_list)
            {
                if (fs.Position != v.begin)
                {
                    throw new FileFormatException("The variable " + v.name + " begins at " + v.begin + " but the stream is at " + fs.Position + " probably because the file is malformed.");
                }
                byte[][] data = NetCDFTools.values(v.type, v.length, fs, true);

                uint typeLength = NetCDFTools.getTypeLength(v.type);

                // too hard to organise the data into its actual shape until it's time to use it

                v.data = data;
            }
        }
示例#2
0
        public Variable(string name, int[] dimid, LinkedList <Attribute> vatt_list, NC_TYPE type, uint vsize, uint begin)
        {
            this.name      = name;
            this.dimid     = dimid;
            this.vatt_list = vatt_list;
            this.type      = type;
            this.vsize     = vsize;
            this.begin     = begin;

            this.length = this.vsize / NetCDFTools.getTypeLength(this.type);

            foreach (Attribute att in vatt_list)
            {
                if (att.name.Equals("units"))
                {
                    this.units = NetCDFTools.byteToString(att.values);
                }
                else if (att.name.Equals("missing_value"))
                {
                    this.missing_value = NetCDFTools.byteToFloat(att.values[0], att.type);
                }
                else if (att.name.Equals("valid_min"))
                {
                    this.valid_min = NetCDFTools.byteToFloat(att.values[0], att.type);
                }
                else if (att.name.Equals("valid_max"))
                {
                    this.valid_max = NetCDFTools.byteToFloat(att.values[0], att.type);
                }
                else if (att.name.Equals("valid_max"))
                {
                    this.valid_max = NetCDFTools.byteToFloat(att.values[0], att.type);
                }
                else if (att.name.Equals("scale_factor"))
                {
                    this.scale_factor = NetCDFTools.byteToFloat(att.values[0], att.type);
                }
                else if (att.name.Equals("add_offset"))
                {
                    this.add_offset = NetCDFTools.byteToFloat(att.values[0], att.type);
                }
            }
        }