Skip to content

Commit c16bfd0

Browse files
committed
Use new GRIB2 tables from WMO
1 parent 25259e8 commit c16bfd0

File tree

3 files changed

+12
-186
lines changed

3 files changed

+12
-186
lines changed

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

Lines changed: 6 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@
2121
public class WmoCodeFlagTables {
2222

2323
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(WmoCodeFlagTables.class);
24-
public static final Version standard = Version.GRIB2_22_0_0;
24+
public static final Version standard = Version.GRIB2_34_0_0;
2525

2626
public enum Version {
27-
GRIB2_22_0_0;
27+
GRIB2_34_0_0;
2828

2929
public String getResourceName() {
30-
return "/resources/grib2/wmo/" + this.name() + "_CodeFlag_exp_en.xml";
30+
return "/resources/grib2/wmo/" + this.name() + "_CodeFlag_en.xml";
3131
}
3232

3333
@Nullable
3434
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"};
35+
if (this == GRIB2_34_0_0) {
36+
return new String[] {"GRIB2_CodeFlag_en", "Title_en", "SubTitle_en", "MeaningParameterDescription_en",
37+
"UnitComments_en"};
3838
}
3939

4040
return null;
@@ -107,49 +107,6 @@ public WmoParamTable getParamTable(int discipline, int category) {
107107
return new WmoParamTable(wmoTable);
108108
}
109109

110-
/*
111-
* Param Table:
112-
* <GRIB2_22_0_0_CodeFlag_exp_en>
113-
* <No>524</No>
114-
* <Title_en>Code table 4.2 - Parameter number by product discipline and parameter category</Title_en>
115-
* <SubTitle_en>Product discipline 0 - Meteorological products, parameter category 1: moisture</SubTitle_en>
116-
* <CodeFlag>101</CodeFlag>
117-
* <MeaningParameterDescription_en>Specific number concentration of snow</MeaningParameterDescription_en>
118-
* <UnitComments_en>kg-1</UnitComments_en>
119-
* <ElementDescription_en>Number of particles per unit mass of air</ElementDescription_en>
120-
* <Status>Operational</Status>
121-
* </GRIB2_22_0_0_CodeFlag_exp_en>
122-
*
123-
* Code Table:
124-
* <GRIB2_22_0_0_CodeFlag_exp_en>
125-
* <No>2</No>
126-
* <Title_en>Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table</Title_en>
127-
* <CodeFlag>1</CodeFlag>
128-
* <MeaningParameterDescription_en>Hydrological products</MeaningParameterDescription_en>
129-
* <Status>Operational</Status>
130-
* </GRIB2_22_0_0_CodeFlag_exp_en>
131-
*
132-
* FlagTable:
133-
* <GRIB2_22_0_0_CodeFlag_exp_en>
134-
* <No>168</No>
135-
* <Title_en>Flag table 3.4 - Scanning mode</Title_en>
136-
* <CodeFlag>1</CodeFlag>
137-
* <Value>0</Value>
138-
* <MeaningParameterDescription_en>Points of first row or column scan in the +i (+x)
139-
* direction</MeaningParameterDescription_en>
140-
* <Status>Operational</Status>
141-
* </GRIB2_22_0_0_CodeFlag_exp_en>
142-
* <GRIB2_22_0_0_CodeFlag_exp_en>
143-
* <No>169</No>
144-
* <Title_en>Flag table 3.4 - Scanning mode</Title_en>
145-
* <CodeFlag>1</CodeFlag>
146-
* <Value>1</Value>
147-
* <MeaningParameterDescription_en>Points of first row or column scan in the -i (-x)
148-
* direction</MeaningParameterDescription_en>
149-
* <Status>Operational</Status>
150-
* </GRIB2_22_0_0_CodeFlag_exp_en>
151-
*/
152-
153110
private void readGribCodes(Version version) throws IOException {
154111
String[] elems = version.getElemNames();
155112
if (elems == null) {
@@ -430,124 +387,4 @@ public int getDiscipline() {
430387
}
431388
}
432389
}
433-
434-
/*
435-
*
436-
*
437-
* @Nullable
438-
* public static String getTableValue(String tableId, int value) {
439-
* if (wmoTables == null)
440-
* try {
441-
* wmoTables = getWmoStandard();
442-
* } catch (IOException e) {
443-
* throw new IllegalStateException("cant open WMO tables");
444-
* }
445-
*
446-
* WmoCodeTable table = wmoTables.map.get(tableId);
447-
* if (table == null) return null;
448-
* TableEntry entry = table.get(value);
449-
* if (entry == null) return null;
450-
* return entry.meaning;
451-
* }
452-
*
453-
* @Nullable
454-
* private static TableEntry getTableEntry(String tableId, int value) {
455-
* if (wmoTables == null)
456-
* try {
457-
* wmoTables = getWmoStandard();
458-
* } catch (IOException e) {
459-
* throw new IllegalStateException("cant open wmo tables");
460-
* }
461-
*
462-
* WmoCodeTable table = wmoTables.map.get(tableId);
463-
* if (table == null) return null;
464-
* return table.get(value);
465-
* }
466-
*
467-
* void wtf(Formatter f) {
468-
*
469-
* int total = 0;
470-
* int nsame = 0;
471-
* int nsameIgn = 0;
472-
* int ndiff = 0;
473-
* int unknown = 0;
474-
*
475-
* f.format("DIFFERENCES between %s and %s%n", gt1.name, gt2.name);
476-
* for (WmoCodeTable gc1 : gt1.list) {
477-
*
478-
* WmoCodeTable gc2 = gt2.map.get(gc1.tableName);
479-
* if (gc2 == null) {
480-
* f.format("1 table %s not found in %s%n", gc1.getTableId(), gt2.name);
481-
* continue;
482-
* }
483-
*
484-
* for (TableEntry p1 : gc1.entries) {
485-
* TableEntry p2 = gc2.get(p1.start);
486-
* if (p2 == null) {
487-
* f.format("2 code %s not found in %s%n", p1.getId(), gt2.name);
488-
* continue;
489-
* }
490-
*
491-
* if (showDiff && !p1.equals(p2)) {
492-
* f.format("3 %s not equal%n %s%n%n", p1, p2);
493-
* }
494-
* }
495-
* }
496-
* f.format("Total=%d same=%d sameIgn=%d dif=%d unknown=%d%n", total, nsame, nsameIgn, ndiff, unknown);
497-
* }
498-
*
499-
*
500-
* /* public static void showDiffFromCurrent(List<WmoCodeTable> tlist) throws IOException {
501-
* int total = 0;
502-
* int nsame = 0;
503-
* int nsameIgn = 0;
504-
* int ndiff = 0;
505-
* int unknown = 0;
506-
*
507-
* f.format("DIFFERENCES with current parameter table (now,org) %n");
508-
* for (WmoCodeTable gt : tlist) {
509-
* if (!gt.isParameter) continue;
510-
* for (TableEntry p : gt.entries) {
511-
* if (p.meaning.equalsIgnoreCase("Missing")) continue;
512-
* if (p.start != p.stop) continue;
513-
*
514-
* GridParameter gp = ParameterTable.getParameter(gt.discipline, gt.category, p.start);
515-
* String paramOrg = gp.getDescription();
516-
* if (paramOrg.startsWith("Unknown")) {
517-
* unknown++;
518-
* continue;
519-
* }
520-
*
521-
* String paramOrgM = munge(paramOrg);
522-
* String paramM = munge(p.name);
523-
* boolean same = paramOrgM.equals(paramM);
524-
* if (same) nsame++;
525-
* boolean sameIgnore = paramOrgM.equalsIgnoreCase(paramM);
526-
* if (sameIgnore) nsameIgn++;
527-
* else ndiff++;
528-
* total++;
529-
* String state = same ? " " : (sameIgnore ? "* " : "**");
530-
* if (!same && !sameIgnore)
531-
* f.format("%s%d %d %d%n %s%n %s%n", state, gt.discipline, gt.category, p.start, p.name, paramOrg);
532-
* }
533-
* }
534-
* f.format("Total=%d same=%d sameIgn=%d dif=%d unknown=%d%n", total, nsame, nsameIgn, ndiff, unknown);
535-
* }
536-
*
537-
* static String munge(String org) {
538-
* String result = StringUtil2.remove(org, "_");
539-
* result = StringUtil2.remove(result, "-");
540-
* return result;
541-
* }
542-
*
543-
* public static void showTable(List<WmoCodeTable> tlist, Formatter f) {
544-
* for (WmoCodeTable gt : tlist) {
545-
* f.format("%d.%d (%d,%d) %s %n", gt.m1, gt.m2, gt.discipline, gt.category, gt.tableName);
546-
* for (TableEntry p : gt.entries) {
547-
* f.format(" %s (%d-%d) = %s %n", p.code, p.start, p.stop, p.meaning);
548-
* }
549-
* }
550-
* }
551-
*/
552-
553390
}

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ public class WmoTemplateTables {
5252
convertMap.put("Forecast generating process identifier (defined by originating centre)", "ProcessId");
5353
}
5454

55-
public static final Version standard = Version.GRIB2_22_0_0;
55+
public static final Version standard = Version.GRIB2_34_0_0;
5656

5757
public enum Version {
58-
GRIB2_22_0_0;
58+
GRIB2_34_0_0;
5959

6060
String getResourceName() {
6161
return "/resources/grib2/wmo/" + this.name() + "_Template_en.xml";
6262
}
6363

6464
@Nullable
6565
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"};
66+
if (this == GRIB2_34_0_0) {
67+
return new String[] {"GRIB2_Template_en", "Title_en", "Note_en", "Contents_en"};
6868
}
6969
return null;
7070
}
@@ -85,18 +85,6 @@ public static WmoTemplateTables getInstance() {
8585
return instance;
8686
}
8787

88-
/*
89-
* <GRIB2_22_0_0_Template_en>
90-
* <No>1451</No>
91-
* <Title_en>Product definition template 4.55 - spatio-temporal changing tiles at a horizontal level or horizontal
92-
* layer at a point in time</Title_en>
93-
* <OctetNo>35</OctetNo>
94-
* <Contents_en>Type of second fixed surface</Contents_en>
95-
* <Note_en>(see Code table 4.5)</Note_en>
96-
* <Status>Operational</Status>
97-
* </GRIB2_22_0_0_Template_en>
98-
*/
99-
10088
private void readXml(Version version) throws IOException {
10189
try (InputStream ios = WmoTemplateTables.class.getResourceAsStream(version.getResourceName())) {
10290
if (ios == null) {

grib/src/test/java/ucar/nc2/grib/grib1/tables/EcmwfLocalConcepts.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public EcmwfLocalConcepts() {
5252
sourcesPath = classPath.split(split)[0];
5353
sourcesPath = classPath.split("/grib")[0];
5454
}
55-
ecmwfLocalConceptsLoc = String.join(File.separator, sourcesPath, "grib", "src", "main", "sources", "ecmwfEcCodes", ECCODES_VERSION,"");
55+
ecmwfLocalConceptsLoc =
56+
String.join(File.separator, sourcesPath, "grib", "src", "main", "sources", "ecmwfEcCodes", ECCODES_VERSION, "");
5657
// initialize input streams for reading the localConcept files
5758
try {
5859
parseLocalConcept(ecmwfLocalConceptsLoc + "shortName.def", SHORTNAME_ID);

0 commit comments

Comments
 (0)