rm ModelBufr subscriber/localization filter
This commit is contained in:
parent
e952d9dede
commit
eba8154b5e
5 changed files with 29 additions and 367 deletions
|
@ -59,22 +59,6 @@
|
|||
<constructor-arg ref="redbookNdmMappingListener" />
|
||||
</bean>
|
||||
|
||||
<!-- modelsounding -->
|
||||
<bean id="modelBufrListener" class="com.raytheon.uf.edex.ndm.dataplugin.subscriber.ModelBufrSubscriber" />
|
||||
|
||||
<bean factory-bean="ndmProc" factory-method="registerListener">
|
||||
<constructor-arg value="modelBufr.spi" />
|
||||
<constructor-arg ref="modelBufrListener" />
|
||||
</bean>
|
||||
<bean factory-bean="ndmProc" factory-method="registerListener">
|
||||
<constructor-arg value="modelBufrStationInfo.txt" />
|
||||
<constructor-arg ref="modelBufrListener" />
|
||||
</bean>
|
||||
<bean factory-bean="ndmProc" factory-method="registerListener">
|
||||
<constructor-arg value="modelBufrStationList.txt" />
|
||||
<constructor-arg ref="modelBufrListener" />
|
||||
</bean>
|
||||
|
||||
<!-- bufrSounding -->
|
||||
<bean id="poesBufrSoundingListener"
|
||||
class="com.raytheon.uf.edex.ndm.dataplugin.subscriber.PoesBufrSoundingSubscriber" />
|
||||
|
|
|
@ -1,223 +0,0 @@
|
|||
/**
|
||||
* 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.ndm.dataplugin.subscriber;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
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.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.pointdata.vadriver.VA_Driver;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.edex.ndm.dataplugin.ingest.INationalDatasetSubscriber;
|
||||
import com.raytheon.uf.edex.plugin.modelsounding.decoder.ModelSoundingDataAdapter;
|
||||
|
||||
/**
|
||||
* Subscriber to update the local model sounding sites whenever the national spi
|
||||
* file changes.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 29, 2011 bfarmer Initial creation
|
||||
* Dec 02, 2013 2537 bsteffen Ensure streams are closed.
|
||||
* Mar 06, 2014 2876 mpduff New NDM plugin.
|
||||
* Mar 02, 2016 5434 bkowal Relocated to ndm dataplugin.
|
||||
* Jul 11, 2016 5744 mapeters Save to common_static (not edex_static)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bfarmer
|
||||
*/
|
||||
|
||||
public class ModelBufrSubscriber implements INationalDatasetSubscriber {
|
||||
|
||||
private static final String MODEL_STATION_LIST = ModelSoundingDataAdapter.MODEL_STATION_LIST;
|
||||
|
||||
private static final String MODEL_STATION_INFO = "modelBufrStationInfo.txt";
|
||||
|
||||
private static final String MODEL_GOODNESS = "modelBufr.goodness";
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ModelBufrSubscriber.class);
|
||||
|
||||
@Override
|
||||
public void notify(String fileName, File file) {
|
||||
|
||||
statusHandler.handle(Priority.EVENTA,
|
||||
"modelBufr:Processing input file [" + fileName + "]");
|
||||
|
||||
if ("modelBufr.spi".equals(fileName)) {
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pathMgr.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
|
||||
ILocalizationFile outLocFile = pathMgr.getLocalizationFile(lc,
|
||||
ModelSoundingDataAdapter.SPI_FILE);
|
||||
saveFile(file, outLocFile);
|
||||
ModelSoundingDataAdapter.updateSPIData();
|
||||
} else if (MODEL_STATION_LIST.equals(fileName)
|
||||
|| MODEL_STATION_INFO.equals(fileName)) {
|
||||
// Both are saved as MODEL_STATION_LIST in localization
|
||||
processModelStationTxtFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
private void processModelStationTxtFile(File file) {
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pathMgr.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
|
||||
ILocalizationFile outLocFile = pathMgr.getLocalizationFile(lc,
|
||||
MODEL_STATION_LIST);
|
||||
File goodnessFile = pathMgr.getFile(lc, MODEL_GOODNESS);
|
||||
saveFile(file, outLocFile);
|
||||
generateSPI(file, goodnessFile);
|
||||
|
||||
File spiFile = pathMgr.getFile(lc, ModelSoundingDataAdapter.SPI_FILE);
|
||||
if (!spiFile.exists()) {
|
||||
try {
|
||||
spiFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
statusHandler.handle(
|
||||
Priority.SIGNIFICANT,
|
||||
"modelBufr:Could not create spiFile file: "
|
||||
+ spiFile.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
VA_Driver driver = new VA_Driver();
|
||||
driver.setWeight(0.5f);
|
||||
driver.vaStationsFile(goodnessFile, null, spiFile);
|
||||
// updateStationList will reload spi files also
|
||||
ModelSoundingDataAdapter.update();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param file
|
||||
* @param goodnessFile
|
||||
*/
|
||||
private void generateSPI(File file, File goodnessFile) {
|
||||
String line;
|
||||
String[] splitLine;
|
||||
try {
|
||||
try (BufferedReader fis = new BufferedReader(new FileReader(file));
|
||||
BufferedWriter fos = new BufferedWriter(new FileWriter(
|
||||
goodnessFile))) {
|
||||
while ((line = fis.readLine()) != null) {
|
||||
if (line.length() > 0) {
|
||||
// check for commented lines
|
||||
if ('#' != line.charAt(0)) {
|
||||
try {
|
||||
splitLine = line.split("\\|");
|
||||
Integer elevation;
|
||||
Double latitude;
|
||||
Double longitude;
|
||||
String cause = "elevation";
|
||||
try {
|
||||
elevation = Integer.parseInt(splitLine[4]
|
||||
.trim());
|
||||
cause = "latitude";
|
||||
latitude = Double.parseDouble(splitLine[2]
|
||||
.trim());
|
||||
cause = "longitude";
|
||||
longitude = Double.parseDouble(splitLine[3]
|
||||
.trim());
|
||||
} catch (NumberFormatException nfe) {
|
||||
String err = String
|
||||
.format("modelBufr:Invalid %s in data line [%s]",
|
||||
cause, line);
|
||||
statusHandler.handle(Priority.PROBLEM, err);
|
||||
continue;
|
||||
}
|
||||
String stationName = splitLine[1].trim();
|
||||
fos.write("0 ");
|
||||
fos.write(stationName);
|
||||
fos.write(String.format(" %8.4f %9.4f %5d %9d",
|
||||
latitude, longitude, elevation, 0));
|
||||
fos.newLine();
|
||||
} catch (Exception e) {
|
||||
String err = String.format(
|
||||
"modelBufr:Error in data line [%s]",
|
||||
line);
|
||||
statusHandler.handle(Priority.PROBLEM, err, e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
statusHandler.handle(Priority.SIGNIFICANT,
|
||||
"modelBufr:Could not read File ", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the contents of the given File to the given ILocalizationFile
|
||||
*
|
||||
* @param file
|
||||
* @param outFile
|
||||
*/
|
||||
private void saveFile(File file, ILocalizationFile outFile) {
|
||||
if ((file != null) && file.exists()) {
|
||||
try (BufferedReader fis = new BufferedReader(new FileReader(file));
|
||||
BufferedWriter fos = new BufferedWriter(
|
||||
new OutputStreamWriter(outFile.openOutputStream()))) {
|
||||
String line = null;
|
||||
try {
|
||||
while ((line = fis.readLine()) != null) {
|
||||
fos.write(line);
|
||||
fos.newLine();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Could not read file: " + file.getName(), e);
|
||||
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Failed to find file: "
|
||||
+ file.getName(), e);
|
||||
} catch (LocalizationException e) {
|
||||
statusHandler.handle(
|
||||
Priority.PROBLEM,
|
||||
"Failed to open output stream for file: "
|
||||
+ outFile.getPath(), e);
|
||||
} catch (IOException e) {
|
||||
// Error occurred closing fis/fos, ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -85,8 +85,6 @@ import com.raytheon.uf.edex.plugin.modelsounding.decoder.ModelSoundingDataAdapte
|
|||
*/
|
||||
public class ModelSoundingDecoder implements IDescriptorFactorySelector {
|
||||
|
||||
public static final String SPI_FILE = "basemaps/modelBufr.spi";
|
||||
|
||||
// Name of the plugin controlling this decoder.
|
||||
public static final String PLUGIN_NAME = "modelsounding";
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ import com.raytheon.uf.edex.plugin.modelsounding.common.SoundingModels;
|
|||
* Sep 16, 2014 3628 mapeters Replaced static imports.
|
||||
* Jul 12, 2016 5744 mapeters SoundingStations constructor no longer takes
|
||||
* path parameter
|
||||
* Sep 05, 2018 mjames@ucar Remove modelBufr filter.
|
||||
|
||||
*
|
||||
* </pre>
|
||||
|
@ -81,42 +82,10 @@ public class ModelSoundingDataAdapter {
|
|||
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
public static final String SPI_FILE = "basemaps" + IPathManager.SEPARATOR
|
||||
+ "modelBufr.spi";
|
||||
|
||||
public static final String MODEL_STATION_LIST = "modelBufrStationList.txt";
|
||||
|
||||
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.
|
||||
*
|
||||
|
@ -249,8 +218,6 @@ public class ModelSoundingDataAdapter {
|
|||
String stationId = stationsList.mapId(String.format("%010d",
|
||||
wmoStaNum));
|
||||
// Now determine if the station Id is in this localization list.
|
||||
SPIEntry s = SPI_DATA.getEntryById(stationId);
|
||||
if (s != null) {
|
||||
if (stationId != null) {
|
||||
location.setStationId(stationId);
|
||||
obsData.setSiteId(String.format("%06d", wmoStaNum));
|
||||
|
@ -279,11 +246,7 @@ public class ModelSoundingDataAdapter {
|
|||
location.setElevation(stationHeight);
|
||||
}
|
||||
obsData.setLocation(location);
|
||||
|
||||
obsData.setPointDataView(view);
|
||||
} else {
|
||||
obsData = null;
|
||||
}
|
||||
}
|
||||
|
||||
return obsData;
|
||||
|
@ -518,29 +481,4 @@ public class ModelSoundingDataAdapter {
|
|||
return retValue;
|
||||
}
|
||||
|
||||
private static SPIContainer populateSPIData() {
|
||||
SPIContainer container = null;
|
||||
|
||||
PathManager pathMgr = (PathManager) PathManagerFactory.getPathManager();
|
||||
|
||||
LocalizationContext ctx = pathMgr.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
|
||||
String site = ctx.getContextName();
|
||||
|
||||
logger.info("Loading " + SPI_FILE + " for site [" + site + "]");
|
||||
|
||||
File srcFile = pathMgr.getFile(ctx, SPI_FILE);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
0 CHE 43.5000 -95.6000 9999 0.000
|
||||
0 CRL 42.0000 -95.0000 9999 0.000
|
||||
0 RDD 40.6900 -94.4700 9999 0.000
|
||||
0 WSC 44.1000 -93.5000 9999 0.000
|
||||
0 HNR 41.5900 -95.3400 375 0.000
|
||||
0 CNN 38.3700 -93.7900 9999 0.000
|
||||
0 EAX 38.8100 -94.2600 333 0.000
|
||||
0 HSI 40.3200 -98.4400 626 0.000
|
||||
0 KMCI 39.3200 -94.7200 312 0.000
|
||||
0 KMKC 39.1200 -94.6000 231 0.000
|
||||
0 KSTJ 39.7700 -94.9200 249 0.000
|
||||
0 KMHK 39.1300 -96.6700 322 0.000
|
||||
0 KTOP 39.0700 -95.6200 270 0.000
|
||||
0 KFOE 38.9500 -95.6700 329 0.000
|
||||
0 KRSL 38.8700 -98.8200 568 0.000
|
||||
0 KSLN 38.8000 -97.6500 388 0.000
|
||||
0 KDSM 41.5300 -93.6500 294 0.000
|
||||
0 KMCW 43.1500 -93.3300 370 0.000
|
||||
0 SLB 42.6000 -95.2300 454 0.000
|
||||
0 KOMA 41.3000 -95.9000 299 0.000
|
||||
0 KLNK 40.8400 -96.7500 362 0.000
|
||||
0 KGRI 40.9700 -98.3200 566 0.000
|
||||
0 FNB 40.0800 -95.6000 300 0.000
|
||||
0 KOFK 41.9800 -97.4300 473 0.000
|
||||
0 KSUX 42.4000 -96.3800 336 0.000
|
||||
0 OAX 41.3200 -96.3700 350 0.000
|
||||
0 KFSD 43.5800 -96.7300 435 0.000
|
||||
0 KYKN 42.9200 -97.3800 398 0.000
|
||||
0 KMHE 43.7700 -98.0300 397 0.000
|
||||
0 KFRM 43.6500 -94.4200 354 0.000
|
||||
0 P#8 40.1000 -97.3400 433 0.000
|
||||
0 P#9 42.2100 -97.7900 524 0.000
|
||||
0 P#A 41.9000 -93.7000 315 0.000
|
||||
0 P#G 38.3100 -97.3000 447 0.000
|
||||
0 P#I 39.5800 -94.1900 297 0.000
|
Loading…
Add table
Reference in a new issue