Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ artifacts/
*.sln.ide
.vs/
.idea/
/src/NGrib/nuget/*.log
/src/NGrib/nuget/20250313-165204.log
/src/NGrib/nuget/20250313-165310.log
15 changes: 15 additions & 0 deletions src/NGrib/BufferedBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,21 @@ public int ReadUIntN(int nbBit)
}
}

public void ReadUIntN(int nbBit, int[] buffer, int nbValues, int skip = 0)
{
NextUIntN();

if (skip > 0)
{
ReadUIntN(skip);
}

for (int i = 0; i < nbValues; i++)
{
buffer[i] = ReadUIntN(nbBit);
}
}

public int ReadIntN(int nbBit)
{
var result = ReadUIntN(nbBit);
Expand Down
65 changes: 35 additions & 30 deletions src/NGrib/Grib1/Grib1ProductDefinitionSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,36 +401,41 @@ public Grib1WaveSpectra2DDirFreq WaveSpectra2DDirFreq
/// </remarks>
public int[] CustomData { get; }

// *** constructors *******************************************************

/// <summary> Constructs a <tt>Grib1ProductDefinitionSection</tt> object from a raf.
///
/// </summary>
/// <param name="raf">with PDS content
///
/// </param>
/// <throws> NotSupportedException if raf contains no valid GRIB file </throws>
//UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
internal Grib1ProductDefinitionSection(System.IO.Stream raf)
{
// octets 1-3 PDS length
length = (int) GribNumbers.uint3(raf);


// Paramter table octet 4
table_version = raf.ReadByte();

// Center octet 5
center_id = raf.ReadByte();

// octet 6 Generating Process - See Table A
process_id = raf.ReadByte();

// octet 7 (id of grid type) - not supported yet
grid_id = raf.ReadByte();

//octet 8 (flag for presence of GDS and BMS)
int exists = raf.ReadByte();
// *** constructors *******************************************************

/// <summary> Constructs a <tt>Grib1ProductDefinitionSection</tt> object from a raf.
///
/// </summary>
/// <param name="raf">with PDS content
///
/// </param>
/// <throws> NotSupportedException if raf contains no valid GRIB file </throws>
//UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'"
internal Grib1ProductDefinitionSection(System.IO.Stream raf)
{
// octets 1-3 PDS length
length = (int)GribNumbers.uint3(raf);

if (length <= 0)
{
lengthErr = true;
return;
}

// Paramter table octet 4
table_version = raf.ReadByte();

// Center octet 5
center_id = raf.ReadByte();

// octet 6 Generating Process - See Table A
process_id = raf.ReadByte();

// octet 7 (id of grid type) - not supported yet
grid_id = raf.ReadByte();

//octet 8 (flag for presence of GDS and BMS)
int exists = raf.ReadByte();
//BKSystem.IO.BitStream s = new BKSystem.IO.BitStream(8);
// s.WriteByte((byte)raf.ReadByte());
// s.Position = 0;
Expand Down
17 changes: 11 additions & 6 deletions src/NGrib/Grib2/CodeTables/4_1_ParameterCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
* This file is part of NGrib.
*
* Copyright © 2020 Nicolas Mangué
*
*
* NGrib is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
*
* NGrib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with NGrib. If not, see <https://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -120,8 +120,12 @@ private ParameterCategory(Discipline discipline, int code, string description)
new ParameterCategory(Discipline.MeteorologicalProducts, 18, "Nuclear/radiology");

///<summary>Physical atmospheric properties</summary>
public static ParameterCategory PhysicalAtmosphericProperties { get; } = new ParameterCategory(Discipline.MeteorologicalProducts,
19, "Physical atmospheric properties");
public static ParameterCategory PhysicalAtmosphericProperties { get; } =
new ParameterCategory(Discipline.MeteorologicalProducts, 19, "Physical atmospheric properties");

///<summary>Atmospheric Chemical Constituents</summary>
public static ParameterCategory AtmosphericChemicalConstituents { get; } =
new ParameterCategory(Discipline.MeteorologicalProducts, 20, "Atmospheric Chemical Constituents");

///<summary>CCITT IA5 string</summary>
public static ParameterCategory CcittIa5String { get; } =
Expand Down Expand Up @@ -208,6 +212,7 @@ private ParameterCategory(Discipline discipline, int code, string description)
.Add(Electrodynamics)
.Add(NuclearRadiology)
.Add(PhysicalAtmosphericProperties)
.Add(AtmosphericChemicalConstituents)
.Add(CcittIa5String)
.Add(Miscellaneous)
.Add(HydrologyBasicProducts)
Expand All @@ -225,6 +230,6 @@ private ParameterCategory(Discipline discipline, int code, string description)
.Add(SurfaceProperties)
.Add(SubSurfaceProperties)
.GroupBy(c => c.Discipline)
.ToDictionary(g => g.Key, g => (IReadOnlyCollection<ParameterCategory>) g.ToImmutableList());
.ToDictionary(g => g.Key, g => (IReadOnlyCollection<ParameterCategory>)g.ToImmutableList());
}
}
Loading