Issue #2906 added synoptic obs translation tables

created a command line utility to generate translation table starters
added synoptic table mapped values to bufr translation tables

(cherry picked from commit 467cfe59d0 [formerly f4361b78b6] [formerly 0fa7dfb7df [formerly 7eb9def773f971d5dc0e43d8b191d2b864f290d2]])


Former-commit-id: dc8e25800a [formerly 6e93fd16f4a325d0c3ef4c2abc62a31391a408cd]
Former-commit-id: 1831aa8e63
This commit is contained in:
Brian Clements 2014-03-27 13:37:24 -05:00 committed by Steve Harris
parent 455984c02f
commit 60d00d4e35
10 changed files with 1601 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.plugin.bufrobs</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Bufrobs
Bundle-SymbolicName: com.raytheon.uf.edex.plugin.bufrobs
Bundle-Version: 1.14.0
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: com.raytheon.uf.common.nc.bufr,
com.raytheon.uf.common.nc4,
ucar.nc2,
ucar.nc2.bufrsplitter,
com.raytheon.uf.common.status,
org.geotools

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,180 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.plugin.bufrobs.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.bind.JAXBException;
import javax.xml.stream.XMLStreamException;
import com.raytheon.uf.common.nc.bufr.util.TranslationTableGenerator;
/**
* Command line utility to generate obs translation table base files. The
* resulting files will be edited to add mapping values to synoptic tables.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 24, 2014 2906 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class BaseTranslationTableGenerator {
public static final String PREFIX_OPT = "-p";
public static final String TABLES_OPT = "-t";
public static final String DEST_DIR_OPT = "-d";
public static final Set<String> OPTIONS = new HashSet<String>(
Arrays.asList(PREFIX_OPT, TABLES_OPT, DEST_DIR_OPT));
public static final String DEFAULT_DEST_DIR = "utility/edex_static/base/bufrobs/tables";
public static final String ARGDESC = "Arguments: -p [optional file prefix]"
+ " -d [optional destination directory]"
+ " -t [optional comma separated list of table names in 'F XX YYY' format]"
+ " [WMO BUFR Code Table XML file]";
/**
* Example arguments:
*
* <pre>
* -p synoptic_land -d utility/edex_static/base/bufrobs/tables -t "0 10 063,0 20 011,0 20 012,0 20 003" BUFRCREX_21_0_0_CodeFlag_en.xml
* </pre>
*
* @param args
* @throws XMLStreamException
* @throws JAXBException
* @throws IOException
*/
public static void main(String[] args) throws XMLStreamException,
JAXBException, IOException {
OptArgs optArgs = processArgs(args, OPTIONS);
if (optArgs.args.size() != 1) {
System.out.println(ARGDESC);
System.exit(1);
}
String bufrFile = optArgs.args.get(0);
String dest = optArgs.opts.get(DEST_DIR_OPT);
if (dest == null) {
dest = DEFAULT_DEST_DIR;
}
Set<String> includedTables;
String tablesStr = optArgs.opts.get(TABLES_OPT);
if (tablesStr == null || tablesStr.trim().isEmpty()) {
includedTables = Collections.emptySet();
} else {
includedTables = parseTables(tablesStr);
}
String prefix = optArgs.opts.get(PREFIX_OPT);
if (prefix == null) {
prefix = "";
}
InputStream bufrTables = new FileInputStream(bufrFile);
try {
TranslationTableGenerator.generate(prefix, new File(
dest), includedTables, true, bufrTables);
} finally {
bufrTables.close();
}
}
/**
* Split string by comma and place in set
*
* @param tablesStr
* @return
*/
private static Set<String> parseTables(String tablesStr) {
Set<String> rval = new HashSet<String>();
for (String part : tablesStr.split(",")) {
part = part.trim();
if (!part.isEmpty()) {
rval.add(part);
}
}
return rval;
}
/*
* return value container for options map and list of arguments
*/
private static class OptArgs {
final Map<String, String> opts;
final List<String> args;
public OptArgs(Map<String, String> opts, List<String> args) {
this.opts = opts;
this.args = args;
}
}
/**
* Process list of command line arguments that have option flags with values
* followed by a possible list of additional arguments
*
* @param args
* command line arguments
* @param options
* option flags
* @return
*/
public static OptArgs processArgs(String[] args, Set<String> options) {
Map<String, String> opts = new HashMap<String, String>();
List<String> leftOver = new ArrayList<String>();
for (int i = 0; i < args.length; ++i) {
if (options.contains(args[i])) {
if (i + 1 > args.length || options.contains(args[i + 1])) {
throw new InvalidParameterException("Invalid option: '"
+ args[i]
+ "'. All options must be followed by value");
}
opts.put(args[i], args[i + 1]);
i += 1;
} else {
leftOver.add(args[i]);
}
}
return new OptArgs(opts, leftOver);
}
}

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<translationTable bufrTable="0 10 063" description="Characteristic of pressure tendency">
<!-- mapped value for 'pressChangeChar' comes from the Synoptic Code table 0200 -->
<entry indexRange="0" description="Increasing, then decreasing; atmospheric pressure the same or higher than 3 hours ago">
<mappedValue parameter="pressChangeChar" value="0"/>
</entry>
<entry indexRange="1" description="Increasing, then steady; or increasing, then increasing more slowly">
<mappedValue parameter="pressChangeChar" value="1"/>
</entry>
<entry indexRange="2" description="Increasing (steadily or unsteadily)">
<mappedValue parameter="pressChangeChar" value="2"/>
</entry>
<entry indexRange="3" description="Decreasing or steady, then increasing; or increasing, then increasing more rapidly">
<mappedValue parameter="pressChangeChar" value="3"/>
</entry>
<entry indexRange="4" description="Steady; atmospheric pressure the same as 3 hours ago">
<mappedValue parameter="pressChangeChar" value="4"/>
</entry>
<entry indexRange="5" description="Decreasing, then increasing; atmospheric pressure the same or lower than 3 hours ago">
<mappedValue parameter="pressChangeChar" value="5"/>
</entry>
<entry indexRange="6" description="Decreasing, then steady; or decreasing, then decreasing more slowly">
<mappedValue parameter="pressChangeChar" value="6"/>
</entry>
<entry indexRange="7" description="Decreasing (steadily or unsteadily)">
<mappedValue parameter="pressChangeChar" value="7"/>
</entry>
<entry indexRange="8" description="Steady or increasing, then decreasing; or decreasing, then decreasing more rapidly">
<mappedValue parameter="pressChangeChar" value="8"/>
</entry>
<entry indexRange="9-14" description="Reserved">
<mappedValue parameter="pressChangeChar"/>
</entry>
<entry indexRange="15" description="Missing value">
<mappedValue parameter="pressChangeChar"/>
</entry>
</translationTable>

View file

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<translationTable bufrTable="0 20 011" description="Cloud amount">
<!-- mapped value for 'totCloudAmount' comes from the Synoptic Code table 2700 -->
<entry indexRange="0" description="0">
<mappedValue parameter="totCloudAmount" value="0"/>
</entry>
<entry indexRange="1" description="1 okta or less, but not zero; 1/10 or less, but not zero">
<mappedValue parameter="totCloudAmount" value="1"/>
</entry>
<entry indexRange="2" description="2 oktas; 2/10-3/10">
<mappedValue parameter="totCloudAmount" value="2"/>
</entry>
<entry indexRange="3" description="3 oktas; 4/10">
<mappedValue parameter="totCloudAmount" value="3"/>
</entry>
<entry indexRange="4" description="4 oktas; 5/10">
<mappedValue parameter="totCloudAmount" value="4"/>
</entry>
<entry indexRange="5" description="5 oktas; 6/10">
<mappedValue parameter="totCloudAmount" value="5"/>
</entry>
<entry indexRange="6" description="6 oktas; 7/10-8/10">
<mappedValue parameter="totCloudAmount" value="6"/>
</entry>
<entry indexRange="7" description="7 oktas or more, but not 8 oktas; 9/10 or more, but not 10/10">
<mappedValue parameter="totCloudAmount" value="7"/>
</entry>
<entry indexRange="8" description="8 oktas; 10/10">
<mappedValue parameter="totCloudAmount" value="8"/>
</entry>
<entry indexRange="9" description="Sky obscured by fog and/or other meteorological phenomena">
<mappedValue parameter="totCloudAmount" value="9"/>
</entry>
<entry indexRange="10" description="Sky partially obscured by fog and/or other meteorological phenomena">
<mappedValue parameter="totCloudAmount" value="9"/>
</entry>
<!-- sfc obs does not support these -->
<entry indexRange="11" description="Scattered">
<mappedValue parameter="totCloudAmount"/>
</entry>
<entry indexRange="12" description="Broken">
<mappedValue parameter="totCloudAmount"/>
</entry>
<entry indexRange="13" description="Few">
<mappedValue parameter="totCloudAmount"/>
</entry>
<entry indexRange="14" description="Reserved">
<mappedValue parameter="totCloudAmount"/>
</entry>
<entry indexRange="15" description="Cloud cover is Indiscernible for reasons other than fog or other meteorological phenomena, or observation is not made">
<mappedValue parameter="totCloudAmount"/>
</entry>
</translationTable>

View file

@ -0,0 +1,164 @@
<translationTable bufrTable="0 20 012" description="Cloud type">
<!-- mapped value for 'lowCloudType' comes from the Synoptic Code table 0513 -->
<!-- mapped value for 'midCloudType' comes from the Synoptic Code table 0515 -->
<!-- mapped value for 'hiCloudType' comes from the Synoptic Code table 0509 -->
<entry description="Cirrus (Ci)" indexRange="0">
<mappedValue parameter="hiCloudType" value="1" />
</entry>
<entry description="Cirrocumulus (Cc)" indexRange="1">
<mappedValue parameter="hiCloudType" value="9" />
</entry>
<entry description="Cirrostratus (Cs)" indexRange="2">
<mappedValue parameter="hiCloudType" value="7" />
</entry>
<entry description="Altocumulus (Ac)" indexRange="3">
<mappedValue parameter="midCloudType" value="1" />
</entry>
<entry description="Altostratus (As)" indexRange="4">
<mappedValue parameter="midCloudType" value="2" />
</entry>
<entry description="Nimbostratus (Ns)" indexRange="5">
<mappedValue parameter="midCloudType" value="2" />
</entry>
<entry description="Stratocumulus (Sc)" indexRange="6">
<mappedValue parameter="lowCloudType" value="4" />
</entry>
<entry description="Stratus(St)" indexRange="7">
<mappedValue parameter="lowCloudType" value="6" />
</entry>
<entry description="Cumulus (Cu)" indexRange="8">
<mappedValue parameter="lowCloudType" value="1" />
</entry>
<entry description="Cumulonimbus (Cb)" indexRange="9">
<mappedValue parameter="lowCloudType" value="3" />
</entry>
<entry description="No CHclouds" indexRange="10">
<mappedValue parameter="hiCloudType" value="0" />
</entry>
<entry description="Cirrus fibratus, sometimes uncinus, not progressively invading the sky" indexRange="11">
<mappedValue parameter="hiCloudType" value="1" />
</entry>
<entry description="Cirrus spissatus, in patches or entangled sheaves, which usually do not increase and sometimes seem to be the remains of the upper part of a Cumulonimbus; or Cirrus castellanus or floccus" indexRange="12">
<mappedValue parameter="hiCloudType" value="2" />
</entry>
<entry description="Cirrus spissatus cumulonimbogenitus" indexRange="13">
<mappedValue parameter="hiCloudType" value="3" />
</entry>
<entry description="Cirrus uncinus or fibratus, or both, progressively invading the sky; they generally thicken as a whole" indexRange="14">
<mappedValue parameter="hiCloudType" value="4" />
</entry>
<entry description="Cirrus (often in bands) and Cirrostratus, or Cirrostratus alone, progressively invading the sky; they generallythicken as a whole, but the continuous veil does not reach 45 degrees above the horizon" indexRange="15">
<mappedValue parameter="hiCloudType" value="5" />
</entry>
<entry description="Cirrus (often In bands) and Cirrostratus, or Cirrostratus alone, progressively Invading the sky; they generally thicken as a whole; the continuous veil extends more than 45 degrees above the horizon, without the sky being totally covered" indexRange="16">
<mappedValue parameter="hiCloudType" value="6" />
</entry>
<entry description="Cirrostratus covering the whole sky" indexRange="17">
<mappedValue parameter="hiCloudType" value="7" />
</entry>
<entry description="Cirrostratus not progressively invading the sky and not entirely covering It" indexRange="18">
<mappedValue parameter="hiCloudType" value="8" />
</entry>
<entry description="Cirrocumulus alone, or Cirrocumulus predominant among the CHclouds" indexRange="19">
<mappedValue parameter="hiCloudType" value="9" />
</entry>
<entry description="No CMclouds" indexRange="20">
<mappedValue parameter="midCloudType" value="0" />
</entry>
<entry description="Altostratus translucidus" indexRange="21">
<mappedValue parameter="midCloudType" value="1" />
</entry>
<entry description="Altostratus opacus or Nimbostratus" indexRange="22">
<mappedValue parameter="midCloudType" value="2" />
</entry>
<entry description="Altocumulus translucidus at a single level" indexRange="23">
<mappedValue parameter="midCloudType" value="3" />
</entry>
<entry description="Patches (often Lenticular) of Altocumulus translucidus, continually changing and occurring at one or more levels" indexRange="24">
<mappedValue parameter="midCloudType" value="4" />
</entry>
<entry description="Altocumulus translucidus in bands, or one or more layers of Altocumulus translucidus or opacus, progressively invading the sky;these Altocumulus clouds generally thicken as a whole" indexRange="25">
<mappedValue parameter="midCloudType" value="5" />
</entry>
<entry description="Altocumulus cumulogenitus (or cumulonimbogenitus)" indexRange="26">
<mappedValue parameter="midCloudType" value="6" />
</entry>
<entry description="Altocumulus translucidus or opacus In two or more layers, or Altocumulus opacus In a single layer, not progressively Invading the sky, or Altocumulus with Altostratus or Nimbostratus" indexRange="27">
<mappedValue parameter="midCloudType" value="7" />
</entry>
<entry description="Altocumulus castellanus or floccus" indexRange="28">
<mappedValue parameter="midCloudType" value="8" />
</entry>
<entry description="Altocumulus of a chaotic sky, generally at several levels" indexRange="29">
<mappedValue parameter="midCloudType" value="9" />
</entry>
<entry description="No CL clouds" indexRange="30">
<mappedValue parameter="lowCloudType" value="0" />
</entry>
<entry description="Cumulus humilis or Cumulus fractus other than of bad weather,* or both" indexRange="31">
<mappedValue parameter="lowCloudType" value="1" />
</entry>
<entry description="Cumulus mediocris or congestus, Towering cumulus (TCU), with or without Cumulus of species fractus or humilis or Stratocumulus, all having their bases at the same level" indexRange="32">
<mappedValue parameter="lowCloudType" value="2" />
</entry>
<entry description="Cumulonimbus calvus, with or without Cumulus, Stratocumulus or Stratus" indexRange="33">
<mappedValue parameter="lowCloudType" value="3" />
</entry>
<entry description="Stratocumulus cumulogenitus" indexRange="34">
<mappedValue parameter="lowCloudType" value="4" />
</entry>
<entry description="Stratocumulus other than Stratocumulus cumulogenitus" indexRange="35">
<mappedValue parameter="lowCloudType" value="5" />
</entry>
<entry description="Stratus nebulosus or Stratus fractus other than of bad weather*, or both" indexRange="36">
<mappedValue parameter="lowCloudType" value="6" />
</entry>
<entry description="Stratus fractus or Cumulus fractus of bad weather*, or both (pannus),usually below Altostratus or Nimbostratus" indexRange="37">
<mappedValue parameter="lowCloudType" value="7" />
</entry>
<entry description="Cumulus and Stratocumulus other than Stratocumulus cumulogenitus, with bases at different levels" indexRange="38">
<mappedValue parameter="lowCloudType" value="8" />
</entry>
<entry description="Cumulonimbus capillatus (often with an anvil), with or without Cumulonimbus calvus, Cumulus, Stratocumulus, Stratus or pannus" indexRange="39">
<mappedValue parameter="lowCloudType" value="9" />
</entry>
<entry description="CH" indexRange="40">
<mappedValue parameter="lowCloudType" value="1" />
</entry>
<entry description="CM" indexRange="41">
<mappedValue parameter="lowCloudType" value="1" />
</entry>
<entry description="CL" indexRange="42">
<mappedValue parameter="lowCloudType" value="1" />
</entry>
<entry description="Reserved" indexRange="43-58">
<mappedValue parameter="lowCloudType" />
<mappedValue parameter="midCloudType" />
<mappedValue parameter="hiCloudType" />
</entry>
<entry description="Cloud not visible owing to darkness, fog, duststorm, sandstorm, or other analogous phenomena" indexRange="59">
<mappedValue parameter="lowCloudType" />
<mappedValue parameter="midCloudType" />
<mappedValue parameter="hiCloudType" />
</entry>
<entry description="CH clouds Invisible owing to darkness, fog, blowing dust or sand, or other similar phenomena, or because of a continuous layer of lower clouds" indexRange="60">
<mappedValue parameter="lowCloudType"/>
<mappedValue parameter="midCloudType" />
<mappedValue parameter="hiCloudType"/>
</entry>
<entry description="CM clouds Invisible owing to darkness, fog, blowing dust or sand, or other similar phenomena, or because of continuous layer of lower clouds" indexRange="61">
<mappedValue parameter="lowCloudType" />
<mappedValue parameter="midCloudType" />
<mappedValue parameter="hiCloudType" />
</entry>
<entry description="CL clouds invisible owing to darkness, fog, blowing dust or sand, or other similar phenomena" indexRange="62">
<mappedValue parameter="lowCloudType" />
<mappedValue parameter="midCloudType" />
<mappedValue parameter="hiCloudType" />
</entry>
<entry description="Missing value" indexRange="63">
<mappedValue parameter="lowCloudType" />
<mappedValue parameter="midCloudType" />
<mappedValue parameter="hiCloudType" />
</entry>
</translationTable>