BUFR SIGWX files contain observations about various weather events and other natural phenomena. Decoding a BUFR SIGWX file
with the
TLcdBUFRModelDecoder
decoder produces a data model that
contains a data object for each of these events or phenomena in the file. Each data object has properties that correspond
to the
observations about each event or phenomena. You can inspect the data object to see if it has certain properties, and
retrieve the values for those properties, as shown below.
The SIGWX_* constants are defined in the TLcdSIGWXDataTypes
. There
are constants for all potential properties.
String source = "Data/Bufr/sigwx.bufr";
// decode the model
TLcdBUFRModelDecoder decoder = new TLcdBUFRModelDecoder();
ILcdModel model = decoder.decode(source);
if (model instanceof TLcdModelTreeNode) {
// find a child model of type cloud
TLcdModelTreeNode treeModel = (TLcdModelTreeNode)model;
Enumeration treeModelEnumeration = treeModel.models();
while(treeModelEnumeration.hasMoreElements()) {
ILcdModel childModel = (ILcdModel)treeModelEnumeration.nextElement();
Set<TLcdDataType> modelElementTypes = ((ILcdDataModelDescriptor) childModel.getModelDescriptor()).getModelElementTypes();
if (modelElementTypes.contains(SIGWX_CLOUD_TYPE)) {
model = childModel;
break;
}
}
}
// get the first data element in the model and create a map of its properties
ILcdDataObject dataObject = (ILcdDataObject)model.elements().nextElement();
Map<String, Object> map = new HashMap<>();
if (dataObject.hasValue(SIGWX_CLOUD_BASE_HEIGHT_PROPERTY)) {
map.put("base height", dataObject.getValue(SIGWX_CLOUD_BASE_HEIGHT_PROPERTY));
}
if (dataObject.hasValue(SIGWX_CLOUD_TOP_HEIGHT_PROPERTY)) {
map.put("top height", dataObject.getValue(SIGWX_CLOUD_TOP_HEIGHT_PROPERTY));
}
if (dataObject.hasValue(SIGWX_CLOUD_DISTRIBUTION_PROPERTY)) {
map.put("distribution", dataObject.getValue(SIGWX_CLOUD_DISTRIBUTION_PROPERTY));
}
if (dataObject.hasValue(SIGWX_CLOUD_AIRFRAME_ICING_BASE_HEIGHT_PROPERTY)) {
map.put("airframe icing base height", dataObject.getValue(SIGWX_CLOUD_AIRFRAME_ICING_BASE_HEIGHT_PROPERTY));
}
if (dataObject.hasValue(SIGWX_CLOUD_TURBULENCE_DEGREE_PROPERTY)) {
map.put("turbulence", dataObject.getValue(SIGWX_CLOUD_TURBULENCE_DEGREE_PROPERTY));
}
if (dataObject.hasValue(SIGWX_CLOUD_TURBULENCE_BASE_HEIGHT_PROPERTY)) {
map.put("turbulence base height", dataObject.getValue(SIGWX_CLOUD_TURBULENCE_BASE_HEIGHT_PROPERTY));
}
if (dataObject.hasValue(SIGWX_CLOUD_TURBULENCE_TOP_HEIGHT_PROPERTY)) {
map.put("turbulence top height", dataObject.getValue(SIGWX_CLOUD_TURBULENCE_TOP_HEIGHT_PROPERTY));
}
if (dataObject.hasValue(SIGWX_CLOUD_TYPE_PROPERTY)) {
map.put("type", dataObject.getValue(SIGWX_CLOUD_TYPE_PROPERTY));
}
return map;