private static LinkedList <Attribute> att_list(Stream fs) { LinkedList <Attribute> list = new LinkedList <Attribute>(); int attribute_tag = NetCDFTools.int4(fs); // should be 0xC uint num_attrs = NetCDFTools.non_neg(fs); if (attribute_tag == 0xC && num_attrs > 0) { for (int i = 0; i < num_attrs; i++) { string name = NetCDFTools.name(fs); NC_TYPE type = (NC_TYPE)NetCDFTools.non_neg(fs); uint nelems = NetCDFTools.non_neg(fs); byte[][] valueArray = NetCDFTools.values(type, nelems, fs); list.AddLast(new Attribute(name, type, valueArray)); } } return(list); }
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; } }