Merge branch 'unidata_18.2.1' of github.com:Unidata/awips2 into docChanges
This commit is contained in:
commit
a9c71e58f6
4 changed files with 106 additions and 139 deletions
|
@ -1,3 +1,2 @@
|
||||||
bin.includes = META-INF/,\
|
bin.includes = META-INF/,\
|
||||||
.,\
|
|
||||||
utility/
|
utility/
|
||||||
|
|
|
@ -2,5 +2,4 @@ source.. = src/
|
||||||
output.. = bin/
|
output.. = bin/
|
||||||
bin.includes = META-INF/,\
|
bin.includes = META-INF/,\
|
||||||
.,\
|
.,\
|
||||||
res/,\
|
res/
|
||||||
utility/
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.edex.plugin.modelsounding.decoder;
|
package com.raytheon.uf.edex.plugin.modelsounding.decoder;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -26,12 +27,11 @@ import com.raytheon.uf.common.dataplugin.modelsounding.SoundingLevel;
|
||||||
import com.raytheon.uf.common.dataplugin.modelsounding.SoundingSite;
|
import com.raytheon.uf.common.dataplugin.modelsounding.SoundingSite;
|
||||||
import com.raytheon.uf.common.geospatial.spi.SPIContainer;
|
import com.raytheon.uf.common.geospatial.spi.SPIContainer;
|
||||||
import com.raytheon.uf.common.geospatial.spi.SPIEntry;
|
import com.raytheon.uf.common.geospatial.spi.SPIEntry;
|
||||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
import com.raytheon.uf.common.localization.LocalizationUtil;
|
import com.raytheon.uf.common.localization.PathManager;
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
import com.raytheon.uf.common.pointdata.PointDataContainer;
|
import com.raytheon.uf.common.pointdata.PointDataContainer;
|
||||||
import com.raytheon.uf.common.pointdata.PointDataDescription;
|
import com.raytheon.uf.common.pointdata.PointDataDescription;
|
||||||
|
@ -43,6 +43,7 @@ import com.raytheon.uf.common.time.DataTime;
|
||||||
import com.raytheon.uf.common.wmo.WMOHeader;
|
import com.raytheon.uf.common.wmo.WMOHeader;
|
||||||
import com.raytheon.uf.edex.bufrtools.BUFRDataDocument;
|
import com.raytheon.uf.edex.bufrtools.BUFRDataDocument;
|
||||||
import com.raytheon.uf.edex.bufrtools.descriptors.BUFRDescriptor;
|
import com.raytheon.uf.edex.bufrtools.descriptors.BUFRDescriptor;
|
||||||
|
import com.raytheon.uf.edex.bufrtools.packets.BUFRStringPacket;
|
||||||
import com.raytheon.uf.edex.bufrtools.packets.BUFRSublistPacket;
|
import com.raytheon.uf.edex.bufrtools.packets.BUFRSublistPacket;
|
||||||
import com.raytheon.uf.edex.bufrtools.packets.DataPacketTypes;
|
import com.raytheon.uf.edex.bufrtools.packets.DataPacketTypes;
|
||||||
import com.raytheon.uf.edex.bufrtools.packets.IBUFRDataPacket;
|
import com.raytheon.uf.edex.bufrtools.packets.IBUFRDataPacket;
|
||||||
|
@ -68,8 +69,10 @@ import com.raytheon.uf.edex.plugin.modelsounding.common.SoundingModels;
|
||||||
* Sep 16, 2014 3628 mapeters Replaced static imports.
|
* Sep 16, 2014 3628 mapeters Replaced static imports.
|
||||||
* Jul 12, 2016 5744 mapeters SoundingStations constructor no longer takes
|
* Jul 12, 2016 5744 mapeters SoundingStations constructor no longer takes
|
||||||
* path parameter
|
* path parameter
|
||||||
* Jan 04, 2018 7100 dgilling Code cleanup, read SPI file from
|
* Sep 05, 2018 mjames@ucar Remove modelBufr filter.
|
||||||
* CONFIGURED level.
|
*
|
||||||
|
* May 19, 2021 22629 mgamazaychikov Fixed the header issue for GFS v16 update
|
||||||
|
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -82,45 +85,10 @@ public class ModelSoundingDataAdapter {
|
||||||
|
|
||||||
private static final Object LOCK = new Object();
|
private static final Object LOCK = new Object();
|
||||||
|
|
||||||
public static final String SPI_FILE = LocalizationUtil.join("basemaps",
|
public static final String MODEL_STATION_LIST = "modelBufrStationList.txt";
|
||||||
"modelBufr.spi");
|
|
||||||
|
|
||||||
public static final String MODEL_STATION_LIST_FILENAME = "modelBufrStationList.txt";
|
|
||||||
|
|
||||||
public static final String MODEL_STATION_LIST_PATH = LocalizationUtil
|
|
||||||
.join("modelsounding", MODEL_STATION_LIST_FILENAME);
|
|
||||||
|
|
||||||
private static SoundingStations stationsList = new SoundingStations();
|
private static SoundingStations stationsList = new SoundingStations();
|
||||||
|
|
||||||
private static SPIContainer SPI_DATA = populateSPIData();
|
|
||||||
|
|
||||||
public static void updateSPIData() {
|
|
||||||
SPIContainer spi = populateSPIData();
|
|
||||||
synchronized (LOCK) {
|
|
||||||
if ((spi != null) && (spi.isLoaded())) {
|
|
||||||
SPI_DATA = spi;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateStationList() {
|
|
||||||
SoundingStations ss = new SoundingStations();
|
|
||||||
synchronized (LOCK) {
|
|
||||||
stationsList = ss;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void update() {
|
|
||||||
SoundingStations ss = new SoundingStations();
|
|
||||||
SPIContainer spi = populateSPIData();
|
|
||||||
synchronized (LOCK) {
|
|
||||||
stationsList = ss;
|
|
||||||
if ((spi != null) && (spi.isLoaded())) {
|
|
||||||
SPI_DATA = spi;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the temporal and model information.
|
* Get the temporal and model information.
|
||||||
*
|
*
|
||||||
|
@ -241,39 +209,43 @@ public class ModelSoundingDataAdapter {
|
||||||
obsData = new SoundingSite();
|
obsData = new SoundingSite();
|
||||||
SurfaceObsLocation location = new SurfaceObsLocation();
|
SurfaceObsLocation location = new SurfaceObsLocation();
|
||||||
|
|
||||||
IBUFRDataPacket dp = dataList.get(index);
|
IBUFRDataPacket dp = dataList.get(index++);
|
||||||
index++;
|
|
||||||
/*
|
/*
|
||||||
* dp is forecastHr packet, already handled in
|
* dp is forecastHr packet, already handled in
|
||||||
* SoundingModelTemporalData
|
* SoundingModelTemporalData
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int wmoStaNum = getInt(dataList.get(index), -9999);
|
int wmoStaNum = getInt(dataList.get(index++), -9999);
|
||||||
index++;
|
|
||||||
view.setInt("wmoStaNum", wmoStaNum);
|
view.setInt("wmoStaNum", wmoStaNum);
|
||||||
// Map the WMO station number to a station Id
|
// Map the WMO station number to a station Id
|
||||||
String stationId = stationsList.mapId(String.format("%010d",
|
String stationId = stationsList.mapId(String.format("%010d",
|
||||||
wmoStaNum));
|
wmoStaNum));
|
||||||
// Now determine if the station Id is in this localization list.
|
// Now determine if the station Id is in this localization list.
|
||||||
SPIEntry s = SPI_DATA.getEntryById(stationId);
|
|
||||||
if (s != null) {
|
|
||||||
if (stationId != null) {
|
if (stationId != null) {
|
||||||
location.setStationId(stationId);
|
location.setStationId(stationId);
|
||||||
obsData.setSiteId(String.format("%06d", wmoStaNum));
|
obsData.setSiteId(String.format("%06d", wmoStaNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.equals(SoundingModels.MODEL_ETA)) {
|
if (model.equals(SoundingModels.MODEL_ETA)) {
|
||||||
index++;
|
index++;
|
||||||
}
|
} else if (model.equals(SoundingModels.MODEL_GFS)) {
|
||||||
Double lat = null;
|
// GFS v16 data headers have station ID just like MODEL_ETA headers
|
||||||
|
// For that type of data index needs to be incremented so the
|
||||||
|
// reading of station ID is skipped.
|
||||||
dp = dataList.get(index);
|
dp = dataList.get(index);
|
||||||
|
if (dp instanceof BUFRStringPacket) {
|
||||||
index++;
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Double lat = null;
|
||||||
|
dp = dataList.get(index++);
|
||||||
int d = dp.getReferencingDescriptor().getDescriptor();
|
int d = dp.getReferencingDescriptor().getDescriptor();
|
||||||
if (d == BUFRDescriptor.createDescriptor(0, 5, 2)) {
|
if (d == BUFRDescriptor.createDescriptor(0, 5, 2)) {
|
||||||
lat = (Double) dp.getValue();
|
lat = (Double) dp.getValue();
|
||||||
}
|
}
|
||||||
Double lon = null;
|
Double lon = null;
|
||||||
dp = dataList.get(index);
|
dp = dataList.get(index++);
|
||||||
index++;
|
|
||||||
d = dp.getReferencingDescriptor().getDescriptor();
|
d = dp.getReferencingDescriptor().getDescriptor();
|
||||||
if (d == BUFRDescriptor.createDescriptor(0, 6, 2)) {
|
if (d == BUFRDescriptor.createDescriptor(0, 6, 2)) {
|
||||||
lon = (Double) dp.getValue();
|
lon = (Double) dp.getValue();
|
||||||
|
@ -287,11 +259,7 @@ public class ModelSoundingDataAdapter {
|
||||||
location.setElevation(stationHeight);
|
location.setElevation(stationHeight);
|
||||||
}
|
}
|
||||||
obsData.setLocation(location);
|
obsData.setLocation(location);
|
||||||
|
|
||||||
obsData.setPointDataView(view);
|
obsData.setPointDataView(view);
|
||||||
} else {
|
|
||||||
obsData = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return obsData;
|
return obsData;
|
||||||
|
@ -310,7 +278,16 @@ public class ModelSoundingDataAdapter {
|
||||||
if ((dataList != null) && (siteData != null)) {
|
if ((dataList != null) && (siteData != null)) {
|
||||||
|
|
||||||
// get the replication sublist for the sounding data
|
// get the replication sublist for the sounding data
|
||||||
IBUFRDataPacket p = dataList.get(5);
|
// istart is the number of header fields in the packet
|
||||||
|
// in the pre v16 GFS the header has 5 fields
|
||||||
|
// in the v16 upgrade the header has 6 fields
|
||||||
|
// use 3rd IBUFRDataPacket to determine the version
|
||||||
|
IBUFRDataPacket dp = dataList.get(2);
|
||||||
|
int istart = 6;
|
||||||
|
if (!(dp instanceof BUFRStringPacket)) {
|
||||||
|
istart = 5;
|
||||||
|
}
|
||||||
|
IBUFRDataPacket p = dataList.get(istart);
|
||||||
if ((p instanceof BUFRSublistPacket)
|
if ((p instanceof BUFRSublistPacket)
|
||||||
&& (DataPacketTypes.RepSubList.getPacketType().equals(p
|
&& (DataPacketTypes.RepSubList.getPacketType().equals(p
|
||||||
.getUnits()))) {
|
.getUnits()))) {
|
||||||
|
@ -526,26 +503,4 @@ public class ModelSoundingDataAdapter {
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SPIContainer populateSPIData() {
|
|
||||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
|
||||||
LocalizationContext ctx = pathMgr.getContext(
|
|
||||||
LocalizationType.COMMON_STATIC, LocalizationLevel.CONFIGURED);
|
|
||||||
String site = ctx.getContextName();
|
|
||||||
|
|
||||||
logger.info("Loading " + SPI_FILE + " for site [" + site + "]");
|
|
||||||
|
|
||||||
ILocalizationFile srcFile = pathMgr.getLocalizationFile(ctx, SPI_FILE);
|
|
||||||
|
|
||||||
SPIContainer container = new SPIContainer(srcFile);
|
|
||||||
if (container.isLoaded()) {
|
|
||||||
logger.info("Loading " + SPI_FILE + " for site [" + site
|
|
||||||
+ "] Successful");
|
|
||||||
} else {
|
|
||||||
logger.error("Loading " + SPI_FILE + " for site [" + site
|
|
||||||
+ "] failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,13 @@ import java.util.Map;
|
||||||
|
|
||||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
|
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||||
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a map from a file (modelBufrStationList.txt) for mapping wmo numbers to
|
* Loads a map from a file (modelBufrStationList.txt) for mapping wmo numbers to
|
||||||
|
@ -46,7 +49,6 @@ import com.raytheon.uf.common.status.UFStatus;
|
||||||
* Dec 02, 2013 2537 bsteffen Switch logger to ufstatus.
|
* Dec 02, 2013 2537 bsteffen Switch logger to ufstatus.
|
||||||
* Jul 08, 2016 5744 mapeters Config file moved from edex_static to
|
* Jul 08, 2016 5744 mapeters Config file moved from edex_static to
|
||||||
* common_static, cleanup
|
* common_static, cleanup
|
||||||
* Jan 04, 2018 7100 dgilling Code cleanup, read from CONFIGURED level.
|
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -55,29 +57,40 @@ import com.raytheon.uf.common.status.UFStatus;
|
||||||
|
|
||||||
public class SoundingStations {
|
public class SoundingStations {
|
||||||
|
|
||||||
|
private static final String STATION_LIST = ModelSoundingDataAdapter.MODEL_STATION_LIST;
|
||||||
|
|
||||||
private static final IUFStatusHandler logger = UFStatus
|
private static final IUFStatusHandler logger = UFStatus
|
||||||
.getHandler(SoundingStations.class);
|
.getHandler(SoundingStations.class);
|
||||||
|
|
||||||
private static final String STATION_LIST = ModelSoundingDataAdapter.MODEL_STATION_LIST_FILENAME;
|
private static Map<String, String> stationMap;
|
||||||
|
|
||||||
private static final String STATION_LIST_PATH = ModelSoundingDataAdapter.MODEL_STATION_LIST_PATH;
|
|
||||||
|
|
||||||
private final Map<String, String> stationMap;
|
|
||||||
|
|
||||||
public SoundingStations() {
|
public SoundingStations() {
|
||||||
this.stationMap = new HashMap<>();
|
stationMap = new HashMap<>();
|
||||||
populateMap();
|
populateMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateMap() {
|
private void populateMap() {
|
||||||
try {
|
try {
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
ILocalizationFile locFile = pm.getStaticLocalizationFile(
|
String fullLocPath = "modelsounding" + IPathManager.SEPARATOR
|
||||||
LocalizationType.COMMON_STATIC, STATION_LIST_PATH);
|
+ STATION_LIST;
|
||||||
|
|
||||||
if (locFile != null) {
|
/*
|
||||||
|
* Check SITE first, as the updated config file is stored there when
|
||||||
|
* NDM files are ingested. If not found, use default BASE file.
|
||||||
|
*/
|
||||||
|
LocalizationContext context = pm.getContext(
|
||||||
|
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
|
||||||
|
ILocalizationFile srcFile = pm.getLocalizationFile(context,
|
||||||
|
fullLocPath);
|
||||||
|
if (srcFile == null || !srcFile.exists()) {
|
||||||
|
context = pm.getContext(LocalizationType.COMMON_STATIC,
|
||||||
|
LocalizationLevel.BASE);
|
||||||
|
srcFile = pm.getLocalizationFile(context, fullLocPath);
|
||||||
|
}
|
||||||
|
if (srcFile != null && srcFile.exists()) {
|
||||||
try (BufferedReader bf = new BufferedReader(
|
try (BufferedReader bf = new BufferedReader(
|
||||||
new InputStreamReader(locFile.openInputStream()))) {
|
new InputStreamReader(srcFile.openInputStream()))) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
String line = null;
|
String line = null;
|
||||||
while ((line = bf.readLine()) != null) {
|
while ((line = bf.readLine()) != null) {
|
||||||
|
@ -92,13 +105,14 @@ public class SoundingStations {
|
||||||
logger.debug(String.format("Read %d stationIds from %s.",
|
logger.debug(String.format("Read %d stationIds from %s.",
|
||||||
count, STATION_LIST));
|
count, STATION_LIST));
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
logger.error("Unable to read sounding stations from ["
|
logger.handle(Priority.PROBLEM, ioe.getLocalizedMessage(),
|
||||||
+ locFile + "].", ioe);
|
ioe);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.error("Localization file " + STATION_LIST_PATH
|
logger.error("Localization file " + fullLocPath
|
||||||
+ " does not exist");
|
+ " does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error reading model sounding station list", e);
|
logger.error("Error reading model sounding station list", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue