Skip to content

Commit fcd55ef

Browse files
committed
Update WMO GRIB2 tables
Update WMO GRIB2 tables to version 37. Closes #1415
1 parent 1ab5629 commit fcd55ef

8 files changed

Lines changed: 94411 additions & 28919 deletions

File tree

grib/src/main/java/ucar/nc2/grib/grib2/table/WmoCodeFlagTables.java

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (c) 2019-2026 John Caron and University Corporation for Atmospheric Research/Unidata
3+
* See LICENSE for license information.
4+
*/
5+
16
package ucar.nc2.grib.grib2.table;
27

38
import com.google.common.collect.ImmutableList;
@@ -21,20 +26,20 @@
2126
public class WmoCodeFlagTables {
2227

2328
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(WmoCodeFlagTables.class);
24-
public static final Version standard = Version.GRIB2_22_0_0;
29+
public static final Version standard = Version.GRIB2_37;
2530

2631
public enum Version {
27-
GRIB2_22_0_0;
32+
GRIB2_37;
2833

2934
public String getResourceName() {
30-
return "/resources/grib2/wmo/" + this.name() + "_CodeFlag_exp_en.xml";
35+
return "/resources/grib2/wmo/" + this.name() + "_CodeFlag.xml";
3136
}
3237

3338
@Nullable
3439
String[] getElemNames() {
35-
if (this == GRIB2_22_0_0) {
36-
return new String[] {"GRIB2_22_0_0_CodeFlag_exp_en", "Title_en", "SubTitle_en",
37-
"MeaningParameterDescription_en", "UnitComments_en"};
40+
if (this == GRIB2_37) {
41+
return new String[] {"GRIB2_CodeFlag_en", "Title_en", "SubTitle_en", "MeaningParameterDescription_en",
42+
"UnitComments_en"};
3843
}
3944

4045
return null;
@@ -109,7 +114,7 @@ public WmoParamTable getParamTable(int discipline, int category) {
109114

110115
/*
111116
* Param Table:
112-
* <GRIB2_22_0_0_CodeFlag_exp_en>
117+
* <GRIB2_CodeFlag_exp_en>
113118
* <No>524</No>
114119
* <Title_en>Code table 4.2 - Parameter number by product discipline and parameter category</Title_en>
115120
* <SubTitle_en>Product discipline 0 - Meteorological products, parameter category 1: moisture</SubTitle_en>
@@ -118,36 +123,36 @@ public WmoParamTable getParamTable(int discipline, int category) {
118123
* <UnitComments_en>kg-1</UnitComments_en>
119124
* <ElementDescription_en>Number of particles per unit mass of air</ElementDescription_en>
120125
* <Status>Operational</Status>
121-
* </GRIB2_22_0_0_CodeFlag_exp_en>
126+
* </GRIB2_CodeFlag_exp_en>
122127
*
123128
* Code Table:
124-
* <GRIB2_22_0_0_CodeFlag_exp_en>
129+
* <GRIB2_CodeFlag_exp_en>
125130
* <No>2</No>
126131
* <Title_en>Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table</Title_en>
127132
* <CodeFlag>1</CodeFlag>
128133
* <MeaningParameterDescription_en>Hydrological products</MeaningParameterDescription_en>
129134
* <Status>Operational</Status>
130-
* </GRIB2_22_0_0_CodeFlag_exp_en>
135+
* </GRIB2_CodeFlag_exp_en>
131136
*
132137
* FlagTable:
133-
* <GRIB2_22_0_0_CodeFlag_exp_en>
138+
* <GRIB2_CodeFlag_exp_en>
134139
* <No>168</No>
135140
* <Title_en>Flag table 3.4 - Scanning mode</Title_en>
136141
* <CodeFlag>1</CodeFlag>
137142
* <Value>0</Value>
138143
* <MeaningParameterDescription_en>Points of first row or column scan in the +i (+x)
139144
* direction</MeaningParameterDescription_en>
140145
* <Status>Operational</Status>
141-
* </GRIB2_22_0_0_CodeFlag_exp_en>
142-
* <GRIB2_22_0_0_CodeFlag_exp_en>
146+
* </GRIB2_CodeFlag_exp_en>
147+
* <GRIB2_CodeFlag_exp_en>
143148
* <No>169</No>
144149
* <Title_en>Flag table 3.4 - Scanning mode</Title_en>
145150
* <CodeFlag>1</CodeFlag>
146151
* <Value>1</Value>
147152
* <MeaningParameterDescription_en>Points of first row or column scan in the -i (-x)
148153
* direction</MeaningParameterDescription_en>
149154
* <Status>Operational</Status>
150-
* </GRIB2_22_0_0_CodeFlag_exp_en>
155+
* </GRIB2_CodeFlag_exp_en>
151156
*/
152157

153158
private void readGribCodes(Version version) throws IOException {
@@ -175,8 +180,8 @@ private void readGribCodes(Version version) throws IOException {
175180
Map<String, WmoTable> map = new HashMap<>();
176181

177182
List<Element> featList = root.getChildren(elems[0]); // main element
183+
int line = 0;
178184
for (Element elem : featList) {
179-
String line = elem.getChildTextNormalize("No");
180185
String tableName = elem.getChildTextNormalize(elems[1]); // Title_en
181186
Element subtableElem = elem.getChild(elems[2]); // "SubTitle_en"
182187

@@ -194,7 +199,7 @@ private void readGribCodes(Version version) throws IOException {
194199
continue;
195200
}
196201

197-
if (subtableElem != null) {
202+
if (subtableElem != null && !subtableElem.getTextNormalize().isEmpty()) {
198203
tableName = subtableElem.getTextNormalize();
199204
}
200205

@@ -212,6 +217,7 @@ private void readGribCodes(Version version) throws IOException {
212217
String status = (statusElem == null) ? null : statusElem.getTextNormalize();
213218

214219
wmoTable.addEntry(line, code, value, meaning, unit, status);
220+
line++;
215221
}
216222
ios.close();
217223

@@ -283,7 +289,7 @@ private WmoTable(String name, TableType type) {
283289
}
284290
}
285291

286-
private WmoEntry addEntry(String line, String code, String value, String meaning, String unit, String status) {
292+
private WmoEntry addEntry(int line, String code, String value, String meaning, String unit, String status) {
287293
WmoEntry entry = new WmoEntry(line, code, value, meaning, unit, status);
288294
boolean isRange = (entry.start != entry.stop);
289295
if (!isRange) {
@@ -327,8 +333,8 @@ public class WmoEntry {
327333
private final int number, value;
328334
private final String code, meaning, name, unit, status;
329335

330-
WmoEntry(String line, String code, String valueS, String meaning, String unit, String status) {
331-
this.line = Integer.parseInt(line);
336+
WmoEntry(int line, String code, String valueS, String meaning, String unit, String status) {
337+
this.line = line;
332338
this.code = code;
333339
this.meaning = meaning;
334340
this.status = status;

grib/src/main/java/ucar/nc2/grib/grib2/table/WmoTemplateTables.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/*
2-
* Copyright (c) 1998-2018 John Caron and University Corporation for Atmospheric Research/Unidata
2+
* Copyright (c) 1998-2026 John Caron and University Corporation for Atmospheric Research/Unidata
33
* See LICENSE for license information.
44
*/
5+
56
package ucar.nc2.grib.grib2.table;
67

78
import com.google.common.collect.ImmutableList;
@@ -52,19 +53,19 @@ public class WmoTemplateTables {
5253
convertMap.put("Forecast generating process identifier (defined by originating centre)", "ProcessId");
5354
}
5455

55-
public static final Version standard = Version.GRIB2_22_0_0;
56+
public static final Version standard = Version.GRIB2_37;
5657

5758
public enum Version {
58-
GRIB2_22_0_0;
59+
GRIB2_37;
5960

6061
String getResourceName() {
61-
return "/resources/grib2/wmo/" + this.name() + "_Template_en.xml";
62+
return "/resources/grib2/wmo/" + this.name() + "_Template.xml";
6263
}
6364

6465
@Nullable
6566
String[] getElemNames() {
66-
if (this == GRIB2_22_0_0) {
67-
return new String[] {"GRIB2_22_0_0_Template_en", "Title_en", "Note_en", "Contents_en"};
67+
if (this == GRIB2_37) {
68+
return new String[] {"GRIB2_Template_en", "Title_en", "Note_en", "Contents_en"};
6869
}
6970
return null;
7071
}
@@ -86,15 +87,15 @@ public static WmoTemplateTables getInstance() {
8687
}
8788

8889
/*
89-
* <GRIB2_22_0_0_Template_en>
90+
* <GRIB2_Template_en>
9091
* <No>1451</No>
9192
* <Title_en>Product definition template 4.55 - spatio-temporal changing tiles at a horizontal level or horizontal
9293
* layer at a point in time</Title_en>
9394
* <OctetNo>35</OctetNo>
9495
* <Contents_en>Type of second fixed surface</Contents_en>
9596
* <Note_en>(see Code table 4.5)</Note_en>
9697
* <Status>Operational</Status>
97-
* </GRIB2_22_0_0_Template_en>
98+
* </GRIB2_Template_en>
9899
*/
99100

100101
private void readXml(Version version) throws IOException {

0 commit comments

Comments
 (0)