示例#1
0
        public GRIB2IdentificationSection(FileStream fs)
        {
            //段长度,段号
            long position = fs.Position;

            _sectionHeader = new GRIB2SectionHeader(fs);
            if (_sectionHeader.SectionNo != 1)
            {
                return;
            }
            _centerId             = GribNumberHelper.Int2(fs);
            _subcenterId          = GribNumberHelper.Int2(fs);
            _masterTableVersionNo = fs.ReadByte();
            _locationTableVersion = fs.ReadByte();
            _significanceOfRT     = fs.ReadByte();
            int year   = GribNumberHelper.Int2(fs);
            int month  = fs.ReadByte();
            int day    = fs.ReadByte();
            int hour   = fs.ReadByte();
            int minute = fs.ReadByte();
            int second = fs.ReadByte();

            _referenceTime = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc);
            _productStatus = fs.ReadByte();
            _productType   = fs.ReadByte();
            fs.Seek(position + _sectionHeader.SectionLength, SeekOrigin.Begin);
        }
 public GRIB2DataRepresentationSection(FileStream fs)
 {
     _sectionHeader = new GRIB2SectionHeader(fs);
     _dataPoints    = GribNumberHelper.Int4(fs);
     _dataTemplate  = (int)GribNumberHelper.Uint2(fs);
     SetOtherAttributeByDataTemplateNo(fs);
 }
示例#3
0
        private int _nb;                   //Number of contributing spectral bands(Template 30)

        public GRIB2ProductDefinitionSection(FileStream fs)
        {
            _sectionHeader = new GRIB2SectionHeader(fs);
            _coordinates   = GribNumberHelper.Int2(fs);
            _productDefinitionTemplateNo = GribNumberHelper.Int2(fs);
            SetOtherAttributeByProductDefinition(fs);
        }
示例#4
0
 public GRIB2DataSection(FileStream fs)
 {
     _sectionHeader = new GRIB2SectionHeader(fs);
     if (_sectionHeader.SectionLength > 0 && _sectionHeader.SectionLength < fs.Length)
     {
         fs.Seek(_sectionHeader.SectionLength - 5, SeekOrigin.Current);
     }
 }
示例#5
0
        public GRIB2DataSection(FileStream fs, long dataOffset)
        {
            long position = fs.Position;

            _sectionHeader = new GRIB2SectionHeader(fs);
            _dataOffset    = dataOffset;
            _dataLength    = _sectionHeader.SectionLength - 5;
            fs.Seek(position + _sectionHeader.SectionLength, SeekOrigin.Begin);
        }
        public GRIB2DataRepresentationSection(FileStream fs)
        {
            long position = fs.Position;

            _sectionHeader = new GRIB2SectionHeader(fs);
            _dataPoints    = GribNumberHelper.Int4(fs);
            _dataTemplate  = (int)GribNumberHelper.Uint2(fs);
            SetOtherAttributeByDataTemplateNo(fs);
            fs.Seek(position + _sectionHeader.SectionLength, SeekOrigin.Begin);
        }
示例#7
0
        private int _nb;                   //Number of contributing spectral bands(Template 30)

        public GRIB2ProductDefinitionSection(FileStream fs)
        {
            long position = fs.Position;

            _sectionHeader = new GRIB2SectionHeader(fs);
            _coordinates   = GribNumberHelper.Int2(fs);
            _productDefinitionTemplateNo = GribNumberHelper.Int2(fs);
            SetOtherAttributeByProductDefinition(fs);
            fs.Seek(position + _sectionHeader.SectionLength, SeekOrigin.Begin);
        }
示例#8
0
 public GRIB2LocalUseSection(FileStream fs)
 {
     _sectionHeader = new GRIB2SectionHeader(fs);
     if (_sectionHeader.SectionNo != 2)
     {
         fs.Seek(-5, SeekOrigin.Current);
         return;
     }
     _localUse = new byte[_sectionHeader.SectionLength - 5];
     fs.Read(_localUse, 0, _localUse.Length);
 }
示例#9
0
        private float _dstart;         //Dstart ― offset from origin to inner bound


        public GRIB2GridDefinitionSection(FileStream fs)
        {
            _sectionHeader  = new GRIB2SectionHeader(fs);
            _source         = fs.ReadByte();
            _pointsNumber   = GribNumberHelper.Int4(fs);
            _olon           = fs.ReadByte();
            _iolon          = fs.ReadByte();
            _gridTemplateNo = GribNumberHelper.Int2(fs);
            _gridName       = GetGridNameByGridNo();
            SetAttributeByGridTemplateNo(fs);
        }
        private float _dstart;         //Dstart ― offset from origin to inner bound


        public GRIB2GridDefinitionSection(FileStream fs)
        {
            long position = fs.Position;

            _sectionHeader  = new GRIB2SectionHeader(fs);
            _source         = fs.ReadByte();
            _pointsNumber   = GribNumberHelper.Int4(fs);
            _olon           = fs.ReadByte();
            _iolon          = fs.ReadByte();
            _gridTemplateNo = GribNumberHelper.Int2(fs);
            _gridName       = GetGridNameByGridNo();
            SetAttributeByGridTemplateNo(fs);
            fs.Seek(position + _sectionHeader.SectionLength, SeekOrigin.Begin);
        }
示例#11
0
        private bool[] _bitmap = null;//是否是位图

        public GRIB2BitMapSection(FileStream fs, int numberPoints)
        {
            int[] bitmask = new int[] { 128, 64, 32, 16, 8, 4, 2, 1 };
            _sectionHeader   = new GRIB2SectionHeader(fs);
            _bitMapIndicator = fs.ReadByte();
            // no bitMap
            if (_bitMapIndicator != 0)
            {
                return;
            }
            sbyte[] data = new sbyte[_sectionHeader.SectionLength - 6];
            StreamReadHelper.ReadInput(fs, data, 0, data.Length);
            // create new bit map, octet 4 contains number of unused bits at the end
            _bitmap = new bool[numberPoints];
            // fill bit map
            for (int i = 0; i < _bitmap.Length; i++)
            {
                _bitmap[i] = (data[i / 8] & bitmask[i % 8]) != 0;
            }
        }