Issue #1466 Updated parsing for NCOM, revamped MetaDataParser to make more efficient, unit updates, tests, params

Change-Id: I5177209c25cb08c0ffe74104ceb6e16874ce3208

Former-commit-id: 002ac2eb41 [formerly 9b8169d2523480750bb3cf557fb8902a9cafcc03]
Former-commit-id: 5cf3eee426
This commit is contained in:
Dave Hladky 2013-01-09 12:29:37 -06:00
parent eaf0cbc118
commit 440de708df
21 changed files with 1130 additions and 279 deletions

View file

@ -13,7 +13,7 @@ Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
com.raytheon.uf.common.util
com.raytheon.uf.common.util;bundle-version="1.12.1174"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.common.datadelivery.retrieval.util,

View file

@ -0,0 +1,52 @@
/**
* 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.common.datadelivery.retrieval.util;
import com.raytheon.uf.common.datadelivery.retrieval.xml.LevelLookup;
/**
* Writes out LevelLookup data to xml.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 10, 2013 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public interface LevelXmlWriter {
/**
* Writes the level lookup to XML
*
* @param ll
* @param modelName
* @throws Exception
*/
void writeLevelXml(LevelLookup ll, String modelName) throws Exception;
}

View file

@ -42,6 +42,7 @@ import com.raytheon.uf.common.serialization.SerializationUtil;
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.common.util.ServiceLoaderUtil;
/**
* Lookup table manager
@ -62,6 +63,47 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
public class LookupManager {
/**
* Implementation of the xml writers that writes to localization files.
*/
private class LocalizationXmlWriter implements LevelXmlWriter,
ParameterXmlWriter {
/**
* {@inheritDoc}
*/
@Override
public void writeLevelXml(LevelLookup ll, String modelName)
throws Exception {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext lc = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
String fileName = getLevelFileName(modelName);
LocalizationFile lf = pm.getLocalizationFile(lc, fileName);
File file = lf.getFile();
SerializationUtil.jaxbMarshalToXmlFile(ll, file.getAbsolutePath());
}
/**
*
* {@inheritDoc}
*/
@Override
public void writeParameterXml(ParameterLookup pl, String modelName)
throws Exception {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext lc = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
String fileName = getParamFileName(modelName);
LocalizationFile lf = pm.getLocalizationFile(lc, fileName);
File file = lf.getFile();
SerializationUtil.jaxbMarshalToXmlFile(pl, file.getAbsolutePath());
}
}
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(LookupManager.class);
@ -94,6 +136,12 @@ public class LookupManager {
private UnitLookup unitLookup = null;
private final LevelXmlWriter levelXmlWriter = ServiceLoaderUtil.load(
LevelXmlWriter.class, new LocalizationXmlWriter());
private final ParameterXmlWriter parameterXmlWriter = ServiceLoaderUtil
.load(ParameterXmlWriter.class, new LocalizationXmlWriter());
/* Private Constructor */
private LookupManager() {
@ -371,7 +419,7 @@ public class LookupManager {
}
}
writeLevelXml(ll, modelName);
levelXmlWriter.writeLevelXml(ll, modelName);
levels.put(modelName, ll);
statusHandler.info("Updated/Created level lookup! " + modelName);
@ -412,7 +460,7 @@ public class LookupManager {
params.add(pc);
}
// write out file
writeParameterXml(pl, modelName);
parameterXmlWriter.writeParameterXml(pl, modelName);
parameters.put(modelName, pl);
statusHandler
@ -503,44 +551,4 @@ public class LookupManager {
return unitXml;
}
/**
* Writes the level lookup to XML
*
* @param ll
* @param modelName
* @throws Exception
*/
private void writeLevelXml(LevelLookup ll, String modelName)
throws Exception {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
LocalizationLevel.SITE);
String fileName = getLevelFileName(modelName);
LocalizationFile lf = pm.getLocalizationFile(lc, fileName);
File file = lf.getFile();
SerializationUtil.jaxbMarshalToXmlFile(ll, file.getAbsolutePath());
}
/**
* Writes the parameter lookup to XML
*
* @param pl
* @param modelName
* @throws Exception
*/
private void writeParameterXml(ParameterLookup pl, String modelName)
throws Exception {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
LocalizationLevel.SITE);
String fileName = getParamFileName(modelName);
LocalizationFile lf = pm.getLocalizationFile(lc, fileName);
File file = lf.getFile();
SerializationUtil.jaxbMarshalToXmlFile(pl, file.getAbsolutePath());
}
}

View file

@ -0,0 +1,53 @@
/**
* 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.common.datadelivery.retrieval.util;
import com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterLookup;
/**
* Writes out ParameterLookup data to xml.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 10, 2013 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public interface ParameterXmlWriter {
/**
* Writes the parameter lookup to XML
*
* @param pl
* @param modelName
* @throws Exception
*/
void writeParameterXml(ParameterLookup pl, String modelName)
throws Exception;
}

View file

@ -20,6 +20,7 @@
<pattern name="PATTERN3" dataSetLocation="1,3" cycleLocation="2" regex="(.*)_(\d+z)(_.*)$" />
<!-- SPECIAL DataSet Naming Overrides by CollectionName -->
<dataSetNaming name="naefs" separator="_" expression="collectionName+dataSetName" />
<dataSetNaming name="ncom" separator="_" expression="collectionName+dataSetName" />
<dataSetNaming name="naefs_bc" separator="_" expression="collectionName+dataSetName" />
<dataSetNaming name="naefs_ndgd" separator="_" expression="collectionName+dataSetName" />
<dataSetNaming name="gens" separator="_" expression="collectionName+dataSetName" />
@ -37,13 +38,17 @@
<!-- SPECIAL pattern overrides for certain collections -->
<!-- OFS special case dataSetName = linkkey, no cycle -->
<pattern name="ofs" dataSetLocation="-1" regex="_" />
<!-- RTOFS special case dataSetName = linkkey, no cycle -->
<pattern name="rtofs" dataSetLocation="-1" regex="_" />
<!-- NCOM special case dataSetName = linkkey, no cycle -->
<pattern name="ncom" dataSetLocation="1" regex="_" />
<!-- RTOFS special case dataSetName = where it actually has cycles -->
<pattern name="ofs_hires" dataSetLocation="0" cycleLocation="1" regex="\." />
<!-- RTOFS special case dataSetName = linkkey, no cycle -->
<pattern name="rtofs" dataSetLocation="-1" regex="_" />
</dataSetConfig>
<!-- OPEnDAP service constants -->
<constant name="BLANK" value=""/>
<constant name="UNKNOWN" value="unknown"/>
<constant name="NONE" value="NONE"/>
<constant name="TIME" value="time"/>
<constant name="LON" value="lon"/>
<constant name="LAT" value="lat"/>

View file

@ -3,8 +3,19 @@
<unitLookup>
<unitConfig name="K" providerName="k"/>
<unitConfig name="Pa" providerName="pa"/>
<unitConfig name="Pa" providerName="pascals"/>
<unitConfig name="Pa/s" providerName="pa/s"/>
<unitConfig name="J/kg" providerName="j/kg"/>
<unitConfig name="W/m^2" providerName="w/m^2"/>
<unitConfig name="m/s" providerName="meter/sec"/>
<unitConfig name="N/m^2" providerName="newton/m2"/>
<unitConfig name="N/m^2" providerName="n/m^2"/>
<unitConfig name="C" providerName="degc"/>
<unitConfig name="C-m/s" providerName="degc-m/s"/>
<unitConfig name="kts/200ft" providerName="knots/200feet"/>
<unitConfig name="km^2kg-s^-1" providerName="km2kg-1s-1"/>
<unitConfig name="K/s" providerName="k/s"/>
<unitConfig name="m^2/s" providerName="m2/s"/>
</unitLookup>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ParameterLookup xmlns:ns2="com.raytheon.uf.common.datadelivery.registry" xmlns:ns4="urn:oasis:names:tc:ebxml-regrep:xsd:rim:4.0" xmlns:ns3="group" xmlns:ns9="urn:oasis:names:tc:ebxml-regrep:xsd:spi:4.0" xmlns:ns5="urn:oasis:names:tc:ebxml-regrep:xsd:rs:4.0" xmlns:ns6="http://www.w3.org/1999/xlink" xmlns:ns10="urn:oasis:names:tc:ebxml-regrep:xsd:lcm:4.0" xmlns:ns7="urn:oasis:names:tc:ebxml-regrep:xsd:query:4.0" xmlns:ns8="http://www.w3.org/2005/08/addressing">
<parameterConfig AWIPS="water_u" GrADs="water_u"/>
<parameterConfig AWIPS="tau" GrADs="tau"/>
<parameterConfig AWIPS="surf_atm_press" GrADs="surf_atm_press"/>
<parameterConfig AWIPS="surf_temp_flux" GrADs="surf_temp_flux"/>
<parameterConfig AWIPS="surf_salt_flux" GrADs="surf_salt_flux"/>
<parameterConfig AWIPS="surf_solar_flux" GrADs="surf_solar_flux"/>
<parameterConfig AWIPS="surf_roughness" GrADs="surf_roughness"/>
<parameterConfig AWIPS="swsgx" GrADs="swsgx"/>
<parameterConfig AWIPS="swsgy" GrADs="swsgy"/>
<parameterConfig AWIPS="surf_el" GrADs="surf_el"/>
<parameterConfig AWIPS="water_v" GrADs="water_v"/>
<parameterConfig AWIPS="water_temp" GrADs="water_temp"/>
<parameterConfig AWIPS="salinity" GrADs="salinity"/>
</ParameterLookup>

View file

@ -170,7 +170,7 @@ class OpenDAPMetaDataExtracter extends MetaDataExtracter {
.getAttribute(serviceConfig.getConstantValue("HISTORY"))
.getValueAt(0);
String[] histories = history.split(":");
String time = OpenDAPConstants.trim(histories[0].trim()
String time = OpenDAPParseUtility.getInstance().trim(histories[0].trim()
+ histories[1].trim() + histories[2].trim());
Date dataDate = null;

View file

@ -63,6 +63,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.MetaDataParser;
import com.raytheon.uf.edex.datadelivery.retrieval.opendap.OpenDAPMetaDataExtracter.DAP_TYPE;
import com.vividsolutions.jts.geom.Coordinate;
import dods.dap.AttributeTable;
import dods.dap.DAS;
/**
@ -86,6 +87,7 @@ import dods.dap.DAS;
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Dec 12, 2012 supplement dhladky Restored operation of ensembles.
* Dec 10, 2012 1259 bsteffen Switch Data Delivery from LatLon to referenced envelopes.
* Jan 08, 2013 dhladky Performance enhancements, specific model fixes.
*
* </pre>
*
@ -186,6 +188,7 @@ class OpenDAPMetaDataParser extends MetaDataParser {
double dz = 0.00;
float levMin = 0.0f;
float levMax = 0.0f;
boolean hasLevels = false;
final Coordinate upperLeft = new Coordinate();
final Coordinate lowerRight = new Coordinate();
final GriddedCoverage griddedCoverage = new GriddedCoverage();
@ -222,135 +225,136 @@ class OpenDAPMetaDataParser extends MetaDataParser {
final String fill_value = serviceConfig.getConstantValue("FILL_VALUE");
final String fill = new Float(Util.GRID_FILL_VALUE).toString();
// process globals first
// process time
if (das.getAttributeTable(timecon) != null) {
try {
AttributeTable at = das.getAttributeTable(timecon);
Time time = new Time();
// number of times
time.setNumTimes(new Integer(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(size).getValueAt(0))).intValue());
// minimum time val
time.setStart(OpenDAPParseUtility.getInstance().parseDate(at.getAttribute(
minimum).getValueAt(0)));
// maximum time val
time.setEnd(OpenDAPParseUtility.getInstance().parseDate(at.getAttribute(maximum)
.getValueAt(0)));
// format of time
time.setFormat(dataDateFormat);
// step
List<String> step = OpenDAPParseUtility.getInstance().parseTimeStep(at
.getAttribute(time_step).getValueAt(0));
time.setStep(new Double(step.get(0)).doubleValue());
time.setStepUnit(Time.findStepUnit(step.get(1))
.getDurationUnit());
gdsmd.setTime(time);
} catch (Exception le) {
logParsingException(timecon, "Time", collectionName, url);
}
}
// process latitude
if (das.getAttributeTable(lat) != null) {
try {
AttributeTable at = das.getAttributeTable(lat);
// ny
gridCoverage.setNy(new Integer(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(size).getValueAt(0))).intValue());
// dy
gridCoverage.setDy(new Float(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(resolution).getValueAt(0))).floatValue());
// first latitude point
gridCoverage.setLa1(new Double(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(minimum).getValueAt(0))).doubleValue());
upperLeft.y = new Double(OpenDAPParseUtility.getInstance().trim(at.getAttribute(
maximum).getValueAt(0))).doubleValue();
lowerRight.y = new Double(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(minimum).getValueAt(0))).doubleValue();
} catch (Exception le) {
logParsingException(lat, "Latitude", collectionName, url);
}
}
// process longitude
if (das.getAttributeTable(lon) != null) {
try {
AttributeTable at = das.getAttributeTable(lon);
// nx
gridCoverage.setNx(new Integer(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(size).getValueAt(0))).intValue());
// dx
gridCoverage.setDx(new Float(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(resolution).getValueAt(0))).floatValue());
// min Lon
double minLon = new Double(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(minimum).getValueAt(0))).doubleValue();
// max Lon
double maxLon = new Double(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(maximum).getValueAt(0))).doubleValue();
gridCoverage.setLo1(minLon);
upperLeft.x = minLon;
lowerRight.x = maxLon;
} catch (Exception le) {
logParsingException(lon, "Longitude", collectionName, url);
}
}
// process level settings
if (das.getAttributeTable(lev) != null) {
try {
AttributeTable at = das.getAttributeTable(lev);
dz = new Double(OpenDAPParseUtility.getInstance().trim(at.getAttribute(
resolution).getValueAt(0))).doubleValue();
levMin = new Float(OpenDAPParseUtility.getInstance().trim(at.getAttribute(
minimum).getValueAt(0))).floatValue();
levMax = new Float(OpenDAPParseUtility.getInstance().trim(at.getAttribute(
maximum).getValueAt(0))).floatValue();
hasLevels = true;
} catch (Exception le) {
logParsingException(lev, "Levels", collectionName, url);
}
}
// process any other globals
if (das.getAttributeTable(nc_global) != null) {
try {
AttributeTable at = das.getAttributeTable(nc_global);
dataSet.setDataSetType(DataType
.valueOfIgnoreCase(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(data_type).getValueAt(0))));
String description = at.getAttribute(title).getValueAt(0);
gdsmd.setDataSetDescription(OpenDAPParseUtility.getInstance().trim(description));
} catch (Exception ne) {
logParsingException(nc_global, "Global Dataset Info",
collectionName, url);
}
}
// process ensembles
if (das.getAttributeTable(ens) != null) {
try {
AttributeTable at = das.getAttributeTable(ens);
gdsmd.setEnsemble(OpenDAPParseUtility.getInstance().parseEnsemble(at));
} catch (Exception en) {
logParsingException(ens, "Ensemble", collectionName, url);
}
}
// process the parameters
for (Enumeration<?> e = das.getNames(); e.hasMoreElements();) {
String name = (String) e.nextElement();
// filter out globals
if (!name.equals(ens) && !name.equals(nc_global)
&& !name.equals(lev) && !name.equals(lon)
&& !name.equals(lat) && !name.equals(timecon)) {
// process specific one's
if (name.equals(timecon)) {
try {
Time time = new Time();
// number of times
time.setNumTimes(new Integer(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(size)
.getValueAt(0))).intValue());
// minimum time val
time.setStart(OpenDAPConstants.parseDate(das
.getAttributeTable(name).getAttribute(minimum)
.getValueAt(0)));
// maximum time val
time.setEnd(OpenDAPConstants.parseDate(das
.getAttributeTable(name).getAttribute(maximum)
.getValueAt(0)));
// format of time
time.setFormat(dataDateFormat);
// step
List<String> step = OpenDAPConstants.parseTimeStep(das
.getAttributeTable(name).getAttribute(time_step)
.getValueAt(0));
time.setStep(new Double(step.get(0)).doubleValue());
time.setStepUnit(Time.findStepUnit(step.get(1))
.getDurationUnit());
gdsmd.setTime(time);
} catch (Exception le) {
logParsingException(name, "Time", collectionName, url);
}
} else if (name.equals(lat)) {
try {
// ny
gridCoverage.setNy(new Integer(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(size)
.getValueAt(0))).intValue());
// dy
gridCoverage.setDy(new Float(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(resolution)
.getValueAt(0))).floatValue());
// first latitude point
gridCoverage.setLa1(new Double(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(minimum)
.getValueAt(0))).doubleValue());
upperLeft.y = new Double(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(maximum)
.getValueAt(0))).doubleValue();
lowerRight.y = new Double(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(minimum)
.getValueAt(0))).doubleValue();
} catch (Exception le) {
logParsingException(name, "Latitude", collectionName, url);
}
} else if (name.equals(lon)) {
try {
// nx
gridCoverage.setNx(new Integer(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(size)
.getValueAt(0))).intValue());
// dx
gridCoverage.setDx(new Float(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(resolution)
.getValueAt(0))).floatValue());
// min Lon
double minLon = new Double(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(minimum)
.getValueAt(0))).doubleValue();
double maxLon = new Double(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(maximum)
.getValueAt(0))).doubleValue();
gridCoverage.setLo1(minLon);
upperLeft.x = minLon;
lowerRight.x = maxLon;
} catch (Exception le) {
logParsingException(name, "Longitude", collectionName, url);
}
} else if (name.equals(lev)) {
try {
dz = new Double(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(resolution)
.getValueAt(0))).doubleValue();
levMin = new Float(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(minimum)
.getValueAt(0))).floatValue();
levMax = new Float(OpenDAPConstants.trim(das
.getAttributeTable(name).getAttribute(maximum)
.getValueAt(0))).floatValue();
} catch (Exception le) {
logParsingException(name, "Levels", collectionName, url);
}
} else if (name.equals(nc_global)) {
try {
dataSet.setDataSetType(DataType
.valueOfIgnoreCase(OpenDAPConstants.trim(das
.getAttributeTable(nc_global)
.getAttribute(data_type).getValueAt(0))));
String description = das.getAttributeTable(nc_global)
.getAttribute(title).getValueAt(0);
gdsmd.setDataSetDescription(OpenDAPConstants
.trim(description));
} catch (Exception ne) {
logParsingException(name, "Global Dataset info",
collectionName, url);
}
} else if (name.equals(ens)) {
gdsmd.setEnsemble(OpenDAPConstants.parseEnsemble(das
.getAttributeTable(name)));
} else {
// regular parameter parsing
try {
AttributeTable at = das.getAttributeTable(name);
Parameter parm = new Parameter();
parm.setDataType(dataSet.getDataSetType());
@ -376,8 +380,7 @@ class OpenDAPMetaDataParser extends MetaDataParser {
// descriptions, default fill, or missing vals.
String description = "unknown description";
try {
description = OpenDAPConstants.trim(das
.getAttributeTable(name)
description = OpenDAPParseUtility.getInstance().trim(at
.getAttribute(long_name).getValueAt(0));
} catch (Exception iae) {
@ -386,11 +389,10 @@ class OpenDAPMetaDataParser extends MetaDataParser {
}
parm.setDefinition(description);
parm.setUnits(OpenDAPConstants.parseUnits(description));
parm.setUnits(OpenDAPParseUtility.getInstance().parseUnits(description));
try {
parm.setMissingValue(OpenDAPConstants.trim(das
.getAttributeTable(name)
parm.setMissingValue(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(missing_value).getValueAt(0)));
} catch (Exception iae) {
statusHandler.handle(Priority.PROBLEM,
@ -399,8 +401,7 @@ class OpenDAPMetaDataParser extends MetaDataParser {
}
try {
parm.setFillValue(OpenDAPConstants.trim(das
.getAttributeTable(name)
parm.setFillValue(OpenDAPParseUtility.getInstance().trim(at
.getAttribute(fill_value).getValueAt(0)));
} catch (Exception iae) {
statusHandler.handle(Priority.PROBLEM,
@ -408,7 +409,7 @@ class OpenDAPMetaDataParser extends MetaDataParser {
parm.setMissingValue(fill);
}
DataLevelType type = parseLevelType(parm);
DataLevelType type = parseLevelType(parm, hasLevels);
parm.setLevels(getLevels(type, collectionName, gdsmd, dz,
levMin, levMax));
parm.addLevelType(type);
@ -425,6 +426,7 @@ class OpenDAPMetaDataParser extends MetaDataParser {
}
}
}
// If necessary, update the parameter lookups
if (!newParams.isEmpty()) {
LookupManager.getInstance().modifyParamLookups(collectionName,
@ -467,12 +469,13 @@ class OpenDAPMetaDataParser extends MetaDataParser {
* @param param
* @return
*/
private DataLevelType parseLevelType(Parameter param) {
private DataLevelType parseLevelType(Parameter param, boolean hasLevels) {
// find first word
DataLevelType type = null;
String[] s1 = param.getDefinition().substring(3).split(" ");
// SEA ICE special case
if (param.getDefinition().contains(LevelType.SEAB.getLevelType())) {
type = new DataLevelType(LevelType.SEAB);
}
@ -491,6 +494,7 @@ class OpenDAPMetaDataParser extends MetaDataParser {
type.setUnit(serviceConfig.getConstantValue("METER"));
}
// Really special cases presented by NOMADS data sets
if (type == null) {
String w1 = s1[0];
@ -587,7 +591,21 @@ class OpenDAPMetaDataParser extends MetaDataParser {
}
if (type == null) {
type = new DataLevelType(LevelType.UNKNOWN);
// If description contains surface, make the assumption it is
// surface
if (param.getDefinition().contains(LevelType.SFC.getLevelType())) {
type = new DataLevelType(LevelType.SFC);
}
// We'll make the assumption it is a MB based level for a last gasp
if (hasLevels && type == null) {
type = new DataLevelType(LevelType.MB);
}
if (type == null) {
type = new DataLevelType(LevelType.UNKNOWN);
}
}
return type;
@ -616,7 +634,7 @@ class OpenDAPMetaDataParser extends MetaDataParser {
List<String> vals = null;
try {
vals = OpenDAPConstants.getDataSetNameAndCycle(linkKey,
vals = OpenDAPParseUtility.getInstance().getDataSetNameAndCycle(linkKey,
collection.getName());
} catch (Exception e1) {
statusHandler.handle(Priority.PROBLEM,

View file

@ -41,21 +41,44 @@ import dods.dap.AttributeTable;
* Sep 06, 2012 1125 djohnson Also prepend naefs collection names.
* Oct 28, 2012 1163 dhladky Largely did away with this Class in lieu of configfile.
* Nov 09, 2012 1163 dhladky Made pre-load for service config
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Jan 08, 2013 1466 dhladky NCOM dataset name parsing fix.
* </pre>
*
* @author dhladky
* @version 1.0
*/
final class OpenDAPConstants {
final class OpenDAPParseUtility {
private static final Pattern QUOTES_PATTERN = Pattern.compile("\"");
/** Singleton instance of this class */
private static final OpenDAPConstants instance = new OpenDAPConstants();
private static OpenDAPParseUtility instance = null;
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(OpenDAPConstants.class);
.getHandler(OpenDAPParseUtility.class);
/*
* Service configuration for OPENDAP
*/
private final ServiceConfig serviceConfig;
/* Private Constructor */
private OpenDAPParseUtility() {
serviceConfig = HarvesterServiceManager.getInstance().getServiceConfig(
ServiceType.OPENDAP);
}
/**
* call this to get your instance
* @return
*/
public static OpenDAPParseUtility getInstance() {
if (instance == null) {
instance = new OpenDAPParseUtility();
}
return instance;
}
/**
* Get the dataset name and cycle.
@ -66,15 +89,16 @@ final class OpenDAPConstants {
* the collection name
* @return the dataset name and cycle
*/
public static List<String> getDataSetNameAndCycle(String linkKey,
public List<String> getDataSetNameAndCycle(String linkKey,
String collectionName) throws Exception {
String datasetName = null;
String cycle = "NONE";
String cycle = null;
String numCycle = null;
if (instance.serviceConfig.getDataSetConfig() != null) {
DataSetConfig dsc = instance.serviceConfig.getDataSetConfig();
if (serviceConfig.getDataSetConfig() != null) {
// cycle defaults to none
cycle = serviceConfig.getConstantValue("NONE");
DataSetConfig dsc = serviceConfig.getDataSetConfig();
Map<com.raytheon.uf.common.datadelivery.retrieval.xml.Pattern, Pattern> patterns = dsc
.getPatternMap();
@ -95,6 +119,11 @@ final class OpenDAPConstants {
datasetName = chunks[0];
cycle = chunks[1];
break;
// Special for NCOM, no cycle
} else if (pat.getDataSetLocationAt(0) == 1
&& chunks.length == 3) {
datasetName = chunks[1];
break;
} else {
// most often used
datasetName = linkKey;
@ -149,18 +178,18 @@ final class OpenDAPConstants {
if (dsn != null) {
Constant constant = instance.serviceConfig
Constant constant = serviceConfig
.getNamingSchema(dsn.getExpression());
if (constant != null) {
if (dsn.getExpression()
.equals(instance.serviceConfig
.equals(serviceConfig
.getConstantValue("ALTERNATE_NAMING_SCHEMA1"))) {
datasetName = collectionName + dsn.getSeparator()
+ datasetName;
} else if (dsn
.getExpression()
.equals(instance.serviceConfig
.equals(serviceConfig
.getConstantValue("ALTERNATE_NAMING_SCHEMA2"))) {
datasetName = collectionName;
} else {
@ -185,22 +214,22 @@ final class OpenDAPConstants {
return Arrays.asList(datasetName, cycle, numCycle);
}
public static Pattern getTimeStepPattern() {
public Pattern getTimeStepPattern() {
String timeStep = instance.serviceConfig
String timeStep = serviceConfig
.getConstantValue("TIME_STEP_PATTERN");
return Pattern.compile(timeStep);
}
public static Pattern getUnitPattern() {
String unitPattern = instance.serviceConfig
public Pattern getUnitPattern() {
String unitPattern = serviceConfig
.getConstantValue("UNIT_PATTERN");
return Pattern.compile(unitPattern);
}
public static Pattern getZPattern() {
public Pattern getZPattern() {
String z = instance.serviceConfig.getConstantValue("Z_PATTERN");
String z = serviceConfig.getConstantValue("Z_PATTERN");
return Pattern.compile(z);
}
@ -210,9 +239,9 @@ final class OpenDAPConstants {
* @param date
* @return
*/
public static String parseDate(String date) {
public String parseDate(String date) {
return trim(getZPattern().matcher(date).replaceAll(
instance.serviceConfig.getConstantValue("BLANK")));
serviceConfig.getConstantValue("BLANK")));
}
/**
@ -221,13 +250,13 @@ final class OpenDAPConstants {
* @param table
* @return
*/
public static Ensemble parseEnsemble(AttributeTable table) {
public Ensemble parseEnsemble(AttributeTable table) {
String stime = instance.serviceConfig.getConstantValue("TIMEINIT");
String slength = instance.serviceConfig.getConstantValue("LENGTH");
String sname = instance.serviceConfig.getConstantValue("NAME");
int size = new Integer(OpenDAPConstants.trim(table.getAttribute(
instance.serviceConfig.getConstantValue("SIZE")).getValueAt(0)))
String stime = serviceConfig.getConstantValue("TIMEINIT");
String slength = serviceConfig.getConstantValue("LENGTH");
String sname = serviceConfig.getConstantValue("NAME");
int size = new Integer(trim(table.getAttribute(
serviceConfig.getConstantValue("SIZE")).getValueAt(0)))
.intValue();
String name = null;
String length = null;
@ -260,7 +289,7 @@ final class OpenDAPConstants {
* @param timeStep
* @return
*/
public static List<String> parseTimeStep(String inStep) {
public List<String> parseTimeStep(String inStep) {
List<String> step = new ArrayList<String>();
Matcher matcher = getTimeStepPattern().matcher(trim(inStep));
@ -283,24 +312,32 @@ final class OpenDAPConstants {
* @param description
* @return
*/
public static String parseUnits(String description) {
String runit = "unknown";
public String parseUnits(String description) {
String runit = serviceConfig.getConstantValue("UNKNOWN");
UnitLookup ul = LookupManager.getInstance().getUnits();
if (ul != null) {
if (ul != null) {
// some require no parsing
UnitConfig uc = ul.getUnitByProviderName(description);
Matcher m = getUnitPattern().matcher(description);
if (uc != null) {
// adjusts to correct units
runit = uc.getName();
} else {
if (m.find()) {
runit = m.group(2);
UnitConfig uc = ul.getUnitByProviderName(runit);
if (uc != null) {
// adjusts to correct units
runit = uc.getName();
}
Matcher m = getUnitPattern().matcher(description);
}
}
if (m.find()) {
runit = m.group(2);
uc = ul.getUnitByProviderName(runit);
if (uc != null) {
// adjusts to correct units
runit = uc.getName();
}
}
}
}
return runit;
}
@ -311,21 +348,12 @@ final class OpenDAPConstants {
* @param val
* @return
*/
public static String trim(String val) {
public String trim(String val) {
return QUOTES_PATTERN.matcher(val).replaceAll(
instance.serviceConfig.getConstantValue("BLANK"));
serviceConfig.getConstantValue("BLANK"));
}
/*
* Service configuration for OPENDAP
*/
private final ServiceConfig serviceConfig;
/* Private Constructor */
private OpenDAPConstants() {
serviceConfig = HarvesterServiceManager.getInstance().getServiceConfig(
ServiceType.OPENDAP);
}
}

View file

@ -0,0 +1 @@
com.raytheon.uf.common.datadelivery.retrieval.util.NullXmlWriter

View file

@ -0,0 +1 @@
com.raytheon.uf.common.datadelivery.retrieval.util.NullXmlWriter

View file

@ -0,0 +1,60 @@
/**
* 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.common.datadelivery.retrieval.util;
import com.raytheon.uf.common.datadelivery.retrieval.xml.LevelLookup;
import com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterLookup;
/**
* Makes parser created XML not write out in test
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 10, 2013 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class NullXmlWriter implements LevelXmlWriter, ParameterXmlWriter {
/**
* {@inheritDoc}
*/
@Override
public void writeParameterXml(ParameterLookup pl, String modelName)
throws Exception {
}
/**
* {@inheritDoc}
*/
@Override
public void writeLevelXml(LevelLookup ll, String modelName)
throws Exception {
}
}

View file

@ -98,6 +98,8 @@ public class SerializationUtilTest {
com.raytheon.uf.common.datadelivery.registry.Subscription.class,
com.raytheon.uf.common.datadelivery.registry.SubscriptionBundle.class,
com.raytheon.uf.common.datadelivery.registry.Time.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterLookup.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterConfig.class,
com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao.class,
com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao.class,
com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval.class,

View file

@ -0,0 +1,353 @@
/**
* 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.datadelivery.retrieval.opendap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import com.raytheon.uf.common.datadelivery.registry.Collection;
import com.raytheon.uf.common.datadelivery.registry.DataSet;
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSet;
import com.raytheon.uf.common.datadelivery.registry.Parameter;
import com.raytheon.uf.common.datadelivery.registry.Projection;
import com.raytheon.uf.common.datadelivery.registry.Projection.ProjectionType;
import com.raytheon.uf.common.datadelivery.registry.Provider;
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
import com.raytheon.uf.common.gridcoverage.LatLonGridCoverage;
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
import com.raytheon.uf.common.serialization.SerializationUtilTest;
import com.raytheon.uf.common.time.util.ImmutableDate;
import com.raytheon.uf.common.util.TestUtil;
import com.raytheon.uf.edex.datadelivery.retrieval.Link;
import com.raytheon.uf.edex.datadelivery.retrieval.LinkStore;
import com.raytheon.uf.edex.datadelivery.retrieval.opendap.OpenDAPMetaDataExtracter.DAP_TYPE;
import dods.dap.DAS;
import dods.dap.DASException;
import dods.dap.parser.ParseException;
/**
* Test {@link OpenDAPMetaDataParser}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 09, 2013 1466 dhladky Unit test for NCOM
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class OpenDAPMetaDataParserNCOMTest {
private static final String DAS_FILE = "ncom_amseas_20130109.das";
private static final String COLLECTION_NAME = "ncom";
private static final String DATASET_NAME = "ncom_amseas";
private static final String LINK_URL = "http://nomads.ncep.noaa.gov:9090/dods/ncom/ncom20130109/ncom_amseas_20130109";
private static final String LINK2_URL = "http://nomads.ncep.noaa.gov:9090/dods/ncom/ncom20130109/useast_20130109";
private static final Provider provider = new Provider();
static {
provider.setName("someProvider");
Projection projection = new Projection();
projection.setName(LatLonGridCoverage.PROJECTION_TYPE);
projection.setType(ProjectionType.LatLon);
ArrayList<Projection> projections = new ArrayList<Projection>();
projections.add(projection);
provider.setProjection(projections);
}
private static final Date DATASET_DATE;
static {
DATASET_DATE = new ImmutableDate(1357689600000L);
}
private static DAS DAS = new DAS();
@BeforeClass
public static void classSetUp() throws DASException, ParseException {
SerializationUtilTest.initSerializationUtil();
PathManagerFactoryTest.initLocalization();
ByteArrayInputStream bis = new ByteArrayInputStream(
TestUtil.readResource(OpenDAPMetaDataParserNCOMTest.class, DAS_FILE));
DAS.parse(bis);
RegistryObjectHandlersUtil.init();
}
private final OpenDAPMetaDataParser parser = new OpenDAPMetaDataParser() {
// Override the method to store the result for interrogation
@Override
protected void storeDataSet(final DataSet dataSet) {
OpenDAPMetaDataParserNCOMTest.this.dataSet = (OpenDapGriddedDataSet) dataSet;
}
/**
* {@inheritDoc}
*/
@Override
public void storeMetaData(List<DataSetMetaData> metaDatas,
DataSet dataSet) {
metadatas = metaDatas;
}
};
private OpenDapGriddedDataSet dataSet;
private List<DataSetMetaData> metadatas;
private void performParse() {
Link link = new Link(COLLECTION_NAME, LINK_URL);
link.getLinks().put(DAP_TYPE.DAS.getDapType(), DAS);
String DateFormat = "HHddMMMyyyy";
Collection coll = new Collection(COLLECTION_NAME, "ncom", "yyyyMMdd");
coll.setProjection(ProjectionType.LatLon);
LinkStore linkStore = new LinkStore();
linkStore.addLink(LINK_URL, link);
parser.parseMetaData(provider, linkStore, coll, DateFormat);
}
@Before
public void setUp() throws DASException, ParseException {
PathManagerFactoryTest.initLocalization();
}
@Test
public void testDataSetMetaDataParameterDescriptionIsParsed() {
performParse();
Map<String, Parameter> parameters = dataSet.getParameters();
assertEquals("Incorrect parameter description!",
"salinity [psu] ",
parameters.get("salinity").getDefinition());
assertEquals("Incorrect parameter description!",
"grid y surface wind stress [newton/meter2] ",
parameters.get("swsgy").getDefinition());
assertEquals("Incorrect parameter description!",
"surface atmospherics pressure [pascals] ",
parameters.get("surf_atm_press").getDefinition());
}
@Test
public void testDataSetNameIsParsed() {
performParse();
assertEquals("Incorrect data set name!", DATASET_NAME,
dataSet.getDataSetName());
}
@Test
public void testDataSetTypeIsParsed() {
performParse();
assertEquals("Incorrect data type found!", DataType.GRID,
dataSet.getDataSetType());
}
@Test
public void testParserAddsAllCyclesToDataSet() throws DASException,
ParseException {
// Setup two links for the link store
LinkStore linkStore = new LinkStore();
Link link = new Link(COLLECTION_NAME, LINK_URL);
link.getLinks().put(DAP_TYPE.DAS.getDapType(), DAS);
linkStore.addLink(LINK_URL, link);
DAS das2 = new DAS();
das2.parse(new ByteArrayInputStream(TestUtil.readResource(
OpenDAPMetaDataParserNCOMTest.class, "ncom_amseas_20130109.das")));
Link link2 = new Link(COLLECTION_NAME, LINK2_URL);
link2.getLinks().put(DAP_TYPE.DAS.getDapType(), das2);
linkStore.addLink(LINK2_URL, link2);
String DateFormat = "HHddMMMyyyy";
Collection coll = new Collection(COLLECTION_NAME, "ncom", "yyyyMMdd");
coll.setProjection(ProjectionType.LatLon);
parser.parseMetaData(provider, linkStore, coll, DateFormat);
// NCOM has no cylces
Set<Integer> cycles = dataSet.getCycles();
assertFalse(cycles.contains(Integer.valueOf(0)));
assertFalse(cycles.contains(Integer.valueOf(1)));
}
@Test
public void testParserAddsAllForecastHoursToDataSet() throws DASException,
ParseException {
// Setup two links for the link store
LinkStore linkStore = new LinkStore();
Link link = new Link(COLLECTION_NAME, LINK_URL);
link.getLinks().put(DAP_TYPE.DAS.getDapType(), DAS);
linkStore.addLink(LINK_URL, link);
DAS das2 = new DAS();
das2.parse(new ByteArrayInputStream(TestUtil.readResource(
OpenDAPMetaDataParserNCOMTest.class, "ncom_useast_20130109.das")));
Link link2 = new Link(COLLECTION_NAME, LINK2_URL);
link2.getLinks().put(DAP_TYPE.DAS.getDapType(), das2);
linkStore.addLink(LINK2_URL, link2);
String DateFormat = "HHddMMMyyyy";
Collection coll = new Collection(COLLECTION_NAME, "ncom", "yyyyMMdd");
coll.setProjection(ProjectionType.LatLon);
parser.parseMetaData(provider, linkStore, coll, DateFormat);
}
@Test
public void testParserAddsCycleToDataSet() throws DASException,
ParseException {
// Setup two links for the link store
LinkStore linkStore = new LinkStore();
Link link = new Link(COLLECTION_NAME, LINK_URL);
link.getLinks().put(DAP_TYPE.DAS.getDapType(), DAS);
linkStore.addLink(LINK_URL, link);
DAS das2 = new DAS();
das2.parse(new ByteArrayInputStream(TestUtil.readResource(
OpenDAPMetaDataParserNCOMTest.class, "ncom_amseas_20130109.das")));
Link link2 = new Link(COLLECTION_NAME, LINK2_URL);
link2.getLinks().put(DAP_TYPE.DAS.getDapType(), das2);
linkStore.addLink(LINK2_URL, link2);
String DateFormat = "HHddMMMyyyy";
Collection coll = new Collection(COLLECTION_NAME, "ncom", "yyyyMMdd");
coll.setProjection(ProjectionType.LatLon);
parser.parseMetaData(provider, linkStore, coll, DateFormat);
OpenDapGriddedDataSet griddedDataSet = dataSet;
Set<Integer> keySet = griddedDataSet.getCyclesToUrls().keySet();
assertFalse(keySet.contains(0));
assertFalse(keySet.contains(1));
// NCOM has no cyles
//Iterator<Integer> iter = griddedDataSet.newestToOldestIterator();
//assertEquals(1, iter.next().intValue());
//assertEquals(0, iter.next().intValue());
}
@Test
public void testParserMarksCycleAsUpdated() throws DASException,
ParseException {
performParse();
assertTrue(dataSet instanceof OpenDapGriddedDataSet);
}
@Test
public void testParserReturnsCorrectAmountOfDataSetMetaData()
throws DASException, ParseException {
// Setup two links for the link store
LinkStore linkStore = new LinkStore();
Link link = new Link(COLLECTION_NAME, LINK_URL);
link.getLinks().put(DAP_TYPE.DAS.getDapType(), DAS);
linkStore.addLink(LINK_URL, link);
DAS das2 = new DAS();
das2.parse(new ByteArrayInputStream(TestUtil.readResource(
OpenDAPMetaDataParserNCOMTest.class, "ncom_useast_20130109.das")));
Link link2 = new Link(COLLECTION_NAME, LINK2_URL);
link2.getLinks().put(DAP_TYPE.DAS.getDapType(), das2);
linkStore.addLink(LINK2_URL, link2);
String DateFormat = "HHddMMMyyyy";
Collection coll = new Collection(COLLECTION_NAME, "ncom", "yyyyMMdd");
coll.setProjection(ProjectionType.LatLon);
List<DataSetMetaData> results = parser.parseMetaData(provider,
linkStore, coll, DateFormat);
assertEquals("Expected two DataSetMetaData objects to be parsed!", 2,
results.size());
}
@Test
public void testParserReturnsDataSetMetaDataWithDataDate() {
performParse();
assertEquals("Incorrect date set on MetaData object!", DATASET_DATE,
metadatas.get(0).getDate());
}
@Test
public void testParserReturnsDataSetMetaDataWithDataSetName() {
performParse();
assertEquals("Incorrect dataSetName set on MetaData object!",
DATASET_NAME, metadatas.get(0).getDataSetName());
}
@Test
public void testParserReturnsDataSetMetaDataWithLinkAsUrl() {
performParse();
assertEquals("Incorrect URL found for the data set metadata!",
LINK_URL, metadatas.get(0).getUrl());
}
@Test
public void testParserSetsServiceType() {
performParse();
assertEquals(ServiceType.OPENDAP, dataSet.getServiceType());
}
@Test
public void testParserUpdatesCycleUrl() throws DASException, ParseException {
performParse();
assertTrue(dataSet instanceof OpenDapGriddedDataSet);
}
}

View file

@ -82,7 +82,7 @@ import dods.dap.parser.ParseException;
* @author djohnson
* @version 1.0
*/
public class OpenDAPMetaDataParserTest {
public class OpenDAPMetaDataParserRAPTest {
private static final String DAS_FILE = "rap32_00z.das";
private static final String COLLECTION_NAME = "rap";
@ -118,7 +118,7 @@ public class OpenDAPMetaDataParserTest {
PathManagerFactoryTest.initLocalization();
ByteArrayInputStream bis = new ByteArrayInputStream(
TestUtil.readResource(OpenDAPMetaDataParserTest.class, DAS_FILE));
TestUtil.readResource(OpenDAPMetaDataParserRAPTest.class, DAS_FILE));
DAS.parse(bis);
RegistryObjectHandlersUtil.init();
@ -128,7 +128,7 @@ public class OpenDAPMetaDataParserTest {
// Override the method to store the result for interrogation
@Override
protected void storeDataSet(final DataSet dataSet) {
OpenDAPMetaDataParserTest.this.dataSet = (OpenDapGriddedDataSet) dataSet;
OpenDAPMetaDataParserRAPTest.this.dataSet = (OpenDapGriddedDataSet) dataSet;
}
/**
@ -200,7 +200,7 @@ public class OpenDAPMetaDataParserTest {
DAS das2 = new DAS();
das2.parse(new ByteArrayInputStream(TestUtil.readResource(
OpenDAPMetaDataParserTest.class, "rap32_01z.das")));
OpenDAPMetaDataParserRAPTest.class, "rap32_01z.das")));
Link link2 = new Link(COLLECTION_NAME, LINK2_URL);
link2.getLinks().put(DAP_TYPE.DAS.getDapType(), das2);
linkStore.addLink(LINK2_URL, link2);
@ -228,7 +228,7 @@ public class OpenDAPMetaDataParserTest {
DAS das2 = new DAS();
das2.parse(new ByteArrayInputStream(TestUtil.readResource(
OpenDAPMetaDataParserTest.class, "rap32_01z.das")));
OpenDAPMetaDataParserRAPTest.class, "rap32_01z.das")));
Link link2 = new Link(COLLECTION_NAME, LINK2_URL);
link2.getLinks().put(DAP_TYPE.DAS.getDapType(), das2);
linkStore.addLink(LINK2_URL, link2);
@ -261,7 +261,7 @@ public class OpenDAPMetaDataParserTest {
DAS das2 = new DAS();
das2.parse(new ByteArrayInputStream(TestUtil.readResource(
OpenDAPMetaDataParserTest.class, "rap32_01z.das")));
OpenDAPMetaDataParserRAPTest.class, "rap32_01z.das")));
Link link2 = new Link(COLLECTION_NAME, LINK2_URL);
link2.getLinks().put(DAP_TYPE.DAS.getDapType(), das2);
linkStore.addLink(LINK2_URL, link2);
@ -306,7 +306,7 @@ public class OpenDAPMetaDataParserTest {
DAS das2 = new DAS();
das2.parse(new ByteArrayInputStream(TestUtil.readResource(
OpenDAPMetaDataParserTest.class, "rap32_01z.das")));
OpenDAPMetaDataParserRAPTest.class, "rap32_01z.das")));
Link link2 = new Link(COLLECTION_NAME, LINK2_URL);
link2.getLinks().put(DAP_TYPE.DAS.getDapType(), das2);
linkStore.addLink(LINK2_URL, link2);

View file

@ -32,7 +32,7 @@ import com.raytheon.uf.common.serialization.SerializationUtilTest;
import com.raytheon.uf.common.util.TestUtil;
/**
* Test {@link OpenDAPConstants}.
* Test {@link OpenDAPParseUtility}.
*
* <pre>
*
@ -43,6 +43,7 @@ import com.raytheon.uf.common.util.TestUtil;
* Jul 24, 2012 955 djohnson Initial creation
* Aug 31, 2012 1125 djohnson Rename test method to match tested class method rename.
* Nov 13, 2012 1286 djohnson Ignore two test methods until it can be determined whether they fail because of test or code error.
* Jan 08, 2013 1466 dhladky NCOM dataset name parsing fix.
*
* </pre>
*
@ -50,7 +51,7 @@ import com.raytheon.uf.common.util.TestUtil;
* @version 1.0
*/
public class OpenDAPConstantsTest {
public class OpenDAPParseUtilityTest {
@Before
public void setUp() {
@ -64,7 +65,7 @@ public class OpenDAPConstantsTest {
// the changeset being easily diffed I am leaving it the same (otherwise
// it shows as a brand new file)
List<List<String>> inputsAndOutputs = TestUtil.getInputsAndOutputs(
OpenDAPConstantsTest.class, "getCollectionAndCycle.txt");
OpenDAPParseUtilityTest.class, "getCollectionAndCycle.txt");
List<String> inputs = inputsAndOutputs.get(0);
List<String> outputs = inputsAndOutputs.get(1);
@ -75,8 +76,12 @@ public class OpenDAPConstantsTest {
output[2] = null;
}
String[] actual = null;
if (input[0].equals("ncom_amseas")) {
System.out.println("Stop");
}
actual = OpenDAPConstants
actual = OpenDAPParseUtility.getInstance()
.getDataSetNameAndCycle(input[0], input[1]).toArray(
new String[0]);
@ -87,19 +92,19 @@ public class OpenDAPConstantsTest {
@Test
public void testParseDateRemovesZ() {
final String expected = "07242012";
assertEquals(expected, OpenDAPConstants.parseDate(expected + "z"));
assertEquals(expected, OpenDAPParseUtility.getInstance().parseDate(expected + "z"));
}
@Test
public void testParseTimeStep() throws IOException {
List<List<String>> inputsAndOutputs = TestUtil.getInputsAndOutputs(
OpenDAPConstantsTest.class, "parseTimeStep.txt");
OpenDAPParseUtilityTest.class, "parseTimeStep.txt");
List<String> inputs = inputsAndOutputs.get(0);
List<String> outputs = inputsAndOutputs.get(1);
for (int i = 0; i < inputs.size(); i++) {
String[] expected = TestUtil.COMMA_PATTERN.split(outputs.get(i));
List<String> actual = OpenDAPConstants.parseTimeStep(inputs.get(i));
List<String> actual = OpenDAPParseUtility.getInstance().parseTimeStep(inputs.get(i));
TestUtil.assertArrayEquals(expected,
actual.toArray(new String[actual.size()]));
@ -109,7 +114,7 @@ public class OpenDAPConstantsTest {
@Test
public void testParseUnits() throws IOException {
List<List<String>> inputsAndOutputs = TestUtil.getInputsAndOutputs(
OpenDAPConstantsTest.class, "parseUnits.txt");
OpenDAPParseUtilityTest.class, "parseUnits.txt");
List<String> inputs = inputsAndOutputs.get(0);
List<String> outputs = inputsAndOutputs.get(1);
@ -117,7 +122,7 @@ public class OpenDAPConstantsTest {
String input = inputs.get(i);
String expected = outputs.get(i);
String actual = OpenDAPConstants.parseUnits(input);
String actual = OpenDAPParseUtility.getInstance().parseUnits(input);
assertEquals(expected, actual);
}
@ -127,6 +132,6 @@ public class OpenDAPConstantsTest {
public void testTrimDateRemovesQuotes() {
final String withQuotes = "07\"24\"2012";
final String expected = "07242012";
assertEquals(expected, OpenDAPConstants.trim(withQuotes));
assertEquals(expected, OpenDAPParseUtility.getInstance().trim(withQuotes));
}
}

View file

@ -207,4 +207,8 @@ output=rtofs_native_144_gs,NONE,null
input=nah20120711_00z,wave_nah
output=wave_nah,00z,0
input=rap32_06z,rap
output=rap32,06z,6
output=rap32,06z,6
input=com_amseas_20130109,ncom
output=ncom_amseas,NONE,null
input=ncom_useast_20130109,ncom
output=ncom_useast,NONE,null

View file

@ -0,0 +1,114 @@
Attributes {
NC_GLOBAL {
String title "NCOM Regional American Seas for 00Z09jan2013 Forecast, downloaded Jan 09 15:14 UTC";
String Conventions "COARDS", "GrADS";
String dataType "Grid";
String history "Wed Jan 09 15:50:57 UTC 2013 : imported by GrADS Data Server 2.0";
}
lon {
String grads_dim "x";
String grads_mapping "linear";
String grads_size "1510";
String units "degrees_east";
String long_name "longitude";
Float64 minimum 262.00000000000;
Float64 maximum 305.00650000000;
Float32 resolution 0.0285;
}
lat {
String grads_dim "y";
String grads_mapping "linear";
String grads_size "1000";
String units "degrees_north";
String long_name "latitude";
Float64 minimum 5.00000000000;
Float64 maximum 31.97300000000;
Float32 resolution 0.027;
}
time {
String grads_dim "t";
String grads_mapping "linear";
String grads_size "33";
String grads_min "00z09jan2013";
String grads_step "3hr";
String units "days since 1-1-1 00:00:0.0";
String long_name "time";
String minimum "00z09jan2013";
String maximum "00z13jan2013";
Float32 resolution 0.125;
}
lev {
String grads_dim "z";
String grads_mapping "levels";
String units "millibar";
String long_name "altitude";
Float64 minimum 0.00000000000;
Float64 maximum 5000.00000000000;
Float32 resolution 128.20512;
}
water_u {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "eastward water velocity [meter/sec] ";
}
tau {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "hours since analysis ";
}
surf_atm_press {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "surface atmospherics pressure [pascals] ";
}
surf_temp_flux {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "model surface temperature flux [degc-m/s] ";
}
surf_salt_flux {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "model surface salinity flux [psu-m/s] ";
}
surf_solar_flux {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "model surface shortwave flux [degc-m/s] ";
}
surf_roughness {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "model surface roughness [m] ";
}
swsgx {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "grid x surface wind stress [newton/meter2] ";
}
swsgy {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "grid y surface wind stress [newton/meter2] ";
}
surf_el {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "water surface elevation [m] ";
}
water_v {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "northward water velocity [meter/sec] ";
}
water_temp {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "water temperature [degc] ";
}
salinity {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "salinity [psu] ";
}
}

View file

@ -0,0 +1,114 @@
Attributes {
NC_GLOBAL {
String title "NCOM Regional US East Coast for 00Z09jan2013 Forecast, downloaded Jan 09 13:52 UTC";
String Conventions "COARDS", "GrADS";
String dataType "Grid";
String history "Wed Jan 09 14:00:17 UTC 2013 : imported by GrADS Data Server 2.0";
}
lon {
String grads_dim "x";
String grads_mapping "linear";
String grads_size "571";
String units "degrees_east";
String long_name "longitude";
Float64 minimum 278.00000000000;
Float64 maximum 295.95443000000;
Float32 resolution 0.031499;
}
lat {
String grads_dim "y";
String grads_mapping "linear";
String grads_size "814";
String units "degrees_north";
String long_name "latitude";
Float64 minimum 20.00000000000;
Float64 maximum 41.86970000000;
Float32 resolution 0.0269;
}
time {
String grads_dim "t";
String grads_mapping "linear";
String grads_size "25";
String grads_min "00z09jan2013";
String grads_step "3hr";
String units "days since 1-1-1 00:00:0.0";
String long_name "time";
String minimum "00z09jan2013";
String maximum "00z12jan2013";
Float32 resolution 0.125;
}
lev {
String grads_dim "z";
String grads_mapping "levels";
String units "millibar";
String long_name "altitude";
Float64 minimum 0.00000000000;
Float64 maximum 5000.00000000000;
Float32 resolution 128.20512;
}
water_u {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "eastward water velocity [meter/sec] ";
}
tau {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "hours since analysis ";
}
surf_atm_press {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "surface atmospherics pressure [pascals] ";
}
surf_temp_flux {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "model surface temperature flux [degc-m/s] ";
}
surf_salt_flux {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "model surface salinity flux [psu-m/s] ";
}
surf_solar_flux {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "model surface shortwave flux [degc-m/s] ";
}
surf_roughness {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "model surface roughness [m] ";
}
swsgx {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "grid x surface wind stress [newton/meter2] ";
}
swsgy {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "grid y surface wind stress [newton/meter2] ";
}
surf_el {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "water surface elevation [m] ";
}
water_v {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "northward water velocity [meter/sec] ";
}
water_temp {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "water temperature [degc] ";
}
salinity {
Float32 _FillValue -9.99E8;
Float32 missing_value -9.99E8;
String long_name "salinity [psu] ";
}
}

View file

@ -203,9 +203,9 @@ output=K
input=** entire atmosphere (considered as a single layer) none total ozone [dobson]
output=dobson
input=** surface ave zonal flux of gravity wave stress [n/m^2]
output=n/m^2
output=N/m^2
input=** surface ave momentum flux, u-component [n/m^2]
output=n/m^2
output=N/m^2
input=** (1000 975 950 925 900.. 70 50 30 20 10) none u-component of wind [m/s]
output=m/s
input=** 1829 m above mean sea level none u-component of wind [m/s]
@ -237,9 +237,9 @@ output=W/m^2
input=** top of atmosphere ave upward short-wave rad. flux [w/m^2]
output=W/m^2
input=** surface ave meridional flux of gravity wave stress [n/m^2]
output=n/m^2
output=N/m^2
input=** surface ave momentum flux, v-component [n/m^2]
output=n/m^2
output=N/m^2
input=** (1000 975 950 925 900.. 70 50 30 20 10) none v-component of wind [m/s]
output=m/s
input=** 1829 m above mean sea level none v-component of wind [m/s]
@ -263,9 +263,9 @@ output=m/s
input=** tropopause none v-component of wind [m/s]
output=m/s
input=** (1000 975 950 925 900.. 300 250 200 150 100) none vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** 0.995 sigma level none vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** pv=2e-06 (km^2/kg/s) surface none vertical speed sheer [1/s]
output=1/s
input=** pv=-2e-06 (km^2/kg/s) surface none vertical speed sheer [1/s]
@ -579,9 +579,9 @@ output=K
input=** entire atmosphere (considered as a single layer) total ozone [dobson]
output=dobson
input=** surface zonal flux of gravity wave stress [n/m^2]
output=n/m^2
output=N/m^2
input=** surface momentum flux, u-component [n/m^2]
output=n/m^2
output=N/m^2
input=** (1000 975 950 925 900.. 7 5 3 2 1) u-component of wind [m/s]
output=m/s
input=** 1829 m above mean sea level u-component of wind [m/s]
@ -645,9 +645,9 @@ output=W/m^2
input=** top of atmosphere upward short-wave rad. flux [w/m^2]
output=W/m^2
input=** surface meridional flux of gravity wave stress [n/m^2]
output=n/m^2
output=N/m^2
input=** surface momentum flux, v-component [n/m^2]
output=n/m^2
output=N/m^2
input=** (1000 975 950 925 900.. 7 5 3 2 1) v-component of wind [m/s]
output=m/s
input=** 1829 m above mean sea level v-component of wind [m/s]
@ -703,9 +703,9 @@ output=m/s
input=** tropopause v-component of wind [m/s]
output=m/s
input=** (1000 975 950 925 900.. 200 175 150 125 100) vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** 0.995 sigma level vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** pv=2e-06 (km^2/kg/s) surface vertical speed sheer [1/s]
output=1/s
input=** pv=-2e-06 (km^2/kg/s) surface vertical speed sheer [1/s]
@ -889,7 +889,7 @@ output=integer(0-13)
input=** surface none visibility [m]
output=m
input=** (1000 975 950 925 900.. 150 125 100 75 50) none vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** surface none wilting point [fraction]
output=fraction
input=** (1000 850 700 500 400 250) none absolute vorticity [1/s]
@ -1021,7 +1021,7 @@ output=m/s
input=** 6000 m above ground - 0 m above ground none v-component storm motion [m/s]
output=m/s
input=** 1 hybrid level none vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** surface acc water equivalent of accumulated snow depth [kg/m^2]
output=kg/m^2
input=** surface none water temperature [k]
@ -1063,7 +1063,7 @@ output=kg/kg
input=** 1 hybrid level cloud mixing ratio [kg/kg]
output=kg/kg
input=** entire atmosphere (considered as a single layer) deep convective heating rate [k/s]
output=k/s
output=K/s
input=** surface probability of frozen precipitation [%]
output=%
input=** surface clear sky downward solar flux [w/m^2]
@ -1115,11 +1115,11 @@ output=%
input=** 500-1000 mb surface lifted index [k]
output=K
input=** entire atmosphere (considered as a single layer) large scale condensate heating rate [k/s]
output=k/s
output=K/s
input=** surface lightning [non-dim]
output=non-dim
input=** entire atmosphere (considered as a single layer) long-wave radiative heating rate [k/s]
output=k/s
output=K/s
input=** 2 m above ground maximum relative humidity [%]
output=%
input=** middle cloud layer medium cloud cover [%]
@ -1263,7 +1263,7 @@ output=kg/m^2
input=** 250 mb stream function [m^2/s]
output=m^2/s
input=** entire atmosphere (considered as a single layer) solar radiative heating rate [k/s]
output=k/s
output=K/s
input=** entire atmosphere (considered as a single layer) total column-integrated supercooled liquid water [kg/m^2]
output=kg/m^2
input=** entire atmosphere (considered as a single layer) total column-integrated condensate [kg/m^2]
@ -1349,15 +1349,15 @@ output=m
input=** 6000 m above ground - 0 m above ground v-component storm motion [m/s]
output=m/s
input=** (1000 975 950 925 900.. 75 50 30 20 10) vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** 1 hybrid level vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** 30-0 mb above ground vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** 90-60 mb above ground vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** 180-150 mb above ground vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** surface water temperature [k]
output=K
input=** 1000 m above ground desc [unit]
@ -1399,13 +1399,13 @@ output=J/kg
input=** (1000 975 950 925 900.. 20 10 7 5 2) temperature [k]
output=K
input=** (1000 975 950 925 900.. 20 10 7 5 2) temperature tendency by all radiation [k/s]
output=k/s
output=K/s
input=** (1000 975 950 925 900.. 20 10 7 5 2) u-component of wind [m/s]
output=m/s
input=** (1000 975 950 925 900.. 20 10 7 5 2) v-component of wind [m/s]
output=m/s
input=** (1000 975 950 925 900.. 20 10 7 5 2) vertical velocity (pressure) [pa/s]
output=pa/s
output=Pa/s
input=** entire atmosphere (considered as a single layer) desc [unit]
output=unit
input=** 3000-0 m above ground storm relative helicity [m^2/s^2]
@ -1477,9 +1477,9 @@ output=m/s
input=** (6000 5500 5000 4500 4000.. 20 10 6 3 0) v-component of current [m/s]
output=m/s
input=** (6000 5500 5000 4500 4000.. 20 10 6 3 0) 3-d temperature [degc]
output=degc
output=C
input=** surface montgomery stream function [m2/s]
output=m2/s
output=m^2/s
input=** 1 hybrid level - 2 hybrid level 3-d salinity [-]
output=-
input=** entire ocean (considered as a single layer) barotropic u velocity [m/s]
@ -1491,7 +1491,7 @@ output=m/s
input=** 1 hybrid level - 2 hybrid level v-component of current [m/s]
output=m/s
input=** 1 hybrid level - 2 hybrid level 3-d temperature [degc]
output=degc
output=C
input=** surface none latitude of presure point [deg]
output=deg
input=** surface none latitude of u wind component of velocity [deg]
@ -1501,4 +1501,10 @@ output=deg
input=** surface none longitude of presure point [deg]
output=deg
input=** surface none longitude of u wind component of velocity [deg]
output=deg
output=deg
input=salinity [psu]
output=psu
input=newton/m2
output=N/m^2
input=meter/sec
output=m/s