Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright (c) 2019-2026 John Caron and University Corporation for Atmospheric Research/Unidata
* See LICENSE for license information.
*/

package ucar.nc2.grib.grib2.table;

import com.google.common.collect.ImmutableList;
Expand All @@ -21,20 +26,20 @@
public class WmoCodeFlagTables {

private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(WmoCodeFlagTables.class);
public static final Version standard = Version.GRIB2_22_0_0;
public static final Version standard = Version.GRIB2_37;

public enum Version {
GRIB2_22_0_0;
GRIB2_37;

public String getResourceName() {
return "/resources/grib2/wmo/" + this.name() + "_CodeFlag_exp_en.xml";
return "/resources/grib2/wmo/" + this.name() + "_CodeFlag.xml";
}

@Nullable
String[] getElemNames() {
if (this == GRIB2_22_0_0) {
return new String[] {"GRIB2_22_0_0_CodeFlag_exp_en", "Title_en", "SubTitle_en",
"MeaningParameterDescription_en", "UnitComments_en"};
if (this == GRIB2_37) {
return new String[] {"GRIB2_CodeFlag_en", "Title_en", "SubTitle_en", "MeaningParameterDescription_en",
"UnitComments_en"};
}

return null;
Expand Down Expand Up @@ -109,7 +114,7 @@ public WmoParamTable getParamTable(int discipline, int category) {

/*
* Param Table:
* <GRIB2_22_0_0_CodeFlag_exp_en>
* <GRIB2_CodeFlag_exp_en>
* <No>524</No>
* <Title_en>Code table 4.2 - Parameter number by product discipline and parameter category</Title_en>
* <SubTitle_en>Product discipline 0 - Meteorological products, parameter category 1: moisture</SubTitle_en>
Expand All @@ -118,36 +123,36 @@ public WmoParamTable getParamTable(int discipline, int category) {
* <UnitComments_en>kg-1</UnitComments_en>
* <ElementDescription_en>Number of particles per unit mass of air</ElementDescription_en>
* <Status>Operational</Status>
* </GRIB2_22_0_0_CodeFlag_exp_en>
* </GRIB2_CodeFlag_exp_en>
*
* Code Table:
* <GRIB2_22_0_0_CodeFlag_exp_en>
* <GRIB2_CodeFlag_exp_en>
* <No>2</No>
* <Title_en>Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table</Title_en>
* <CodeFlag>1</CodeFlag>
* <MeaningParameterDescription_en>Hydrological products</MeaningParameterDescription_en>
* <Status>Operational</Status>
* </GRIB2_22_0_0_CodeFlag_exp_en>
* </GRIB2_CodeFlag_exp_en>
*
* FlagTable:
* <GRIB2_22_0_0_CodeFlag_exp_en>
* <GRIB2_CodeFlag_exp_en>
* <No>168</No>
* <Title_en>Flag table 3.4 - Scanning mode</Title_en>
* <CodeFlag>1</CodeFlag>
* <Value>0</Value>
* <MeaningParameterDescription_en>Points of first row or column scan in the +i (+x)
* direction</MeaningParameterDescription_en>
* <Status>Operational</Status>
* </GRIB2_22_0_0_CodeFlag_exp_en>
* <GRIB2_22_0_0_CodeFlag_exp_en>
* </GRIB2_CodeFlag_exp_en>
* <GRIB2_CodeFlag_exp_en>
* <No>169</No>
* <Title_en>Flag table 3.4 - Scanning mode</Title_en>
* <CodeFlag>1</CodeFlag>
* <Value>1</Value>
* <MeaningParameterDescription_en>Points of first row or column scan in the -i (-x)
* direction</MeaningParameterDescription_en>
* <Status>Operational</Status>
* </GRIB2_22_0_0_CodeFlag_exp_en>
* </GRIB2_CodeFlag_exp_en>
*/

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

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

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

if (subtableElem != null) {
if (subtableElem != null && !subtableElem.getTextNormalize().isEmpty()) {
tableName = subtableElem.getTextNormalize();
}

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

wmoTable.addEntry(line, code, value, meaning, unit, status);
line++;
}
ios.close();

Expand Down Expand Up @@ -283,7 +289,7 @@ private WmoTable(String name, TableType type) {
}
}

private WmoEntry addEntry(String line, String code, String value, String meaning, String unit, String status) {
private WmoEntry addEntry(int line, String code, String value, String meaning, String unit, String status) {
WmoEntry entry = new WmoEntry(line, code, value, meaning, unit, status);
boolean isRange = (entry.start != entry.stop);
if (!isRange) {
Expand Down Expand Up @@ -327,8 +333,8 @@ public class WmoEntry {
private final int number, value;
private final String code, meaning, name, unit, status;

WmoEntry(String line, String code, String valueS, String meaning, String unit, String status) {
this.line = Integer.parseInt(line);
WmoEntry(int line, String code, String valueS, String meaning, String unit, String status) {
this.line = line;
this.code = code;
this.meaning = meaning;
this.status = status;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*
* Copyright (c) 1998-2018 John Caron and University Corporation for Atmospheric Research/Unidata
* Copyright (c) 1998-2026 John Caron and University Corporation for Atmospheric Research/Unidata
* See LICENSE for license information.
*/

package ucar.nc2.grib.grib2.table;

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

public static final Version standard = Version.GRIB2_22_0_0;
public static final Version standard = Version.GRIB2_37;

public enum Version {
GRIB2_22_0_0;
GRIB2_37;

String getResourceName() {
return "/resources/grib2/wmo/" + this.name() + "_Template_en.xml";
return "/resources/grib2/wmo/" + this.name() + "_Template.xml";
}

@Nullable
String[] getElemNames() {
if (this == GRIB2_22_0_0) {
return new String[] {"GRIB2_22_0_0_Template_en", "Title_en", "Note_en", "Contents_en"};
if (this == GRIB2_37) {
return new String[] {"GRIB2_Template_en", "Title_en", "Note_en", "Contents_en"};
}
return null;
}
Expand All @@ -86,15 +87,15 @@ public static WmoTemplateTables getInstance() {
}

/*
* <GRIB2_22_0_0_Template_en>
* <GRIB2_Template_en>
* <No>1451</No>
* <Title_en>Product definition template 4.55 - spatio-temporal changing tiles at a horizontal level or horizontal
* layer at a point in time</Title_en>
* <OctetNo>35</OctetNo>
* <Contents_en>Type of second fixed surface</Contents_en>
* <Note_en>(see Code table 4.5)</Note_en>
* <Status>Operational</Status>
* </GRIB2_22_0_0_Template_en>
* </GRIB2_Template_en>
*/

private void readXml(Version version) throws IOException {
Expand Down
Loading