Issue #2473 Remove unneeded ncgrib functionality.
Change-Id: If38138650660c75745091a82c231cd0fe8c92e38 Former-commit-id:d25df40634
[formerly 49a3700d37c07f42991f7ca4a65f0fd4c7010f91] Former-commit-id:51cd71c373
This commit is contained in:
parent
1a62020265
commit
24a6795677
641 changed files with 158 additions and 51401 deletions
|
@ -128,13 +128,6 @@
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="gov.noaa.nws.ncep.common.dataplugin.ncgrib"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="gov.noaa.nws.ncep.common.dataplugin.ncscat"
|
||||
download-size="0"
|
||||
|
|
|
@ -5,8 +5,12 @@ PSQL="/awips2/psql/bin/psql"
|
|||
|
||||
SQL_COMMAND="
|
||||
delete from plugin_info where name = 'grib';
|
||||
delete from plugin_info where name = 'ncgrib';
|
||||
drop table if exists grib, grib_models;
|
||||
drop table if exists ncgrib, ncgrib1_parameter_map, ncgrib_genprocess, ncgrib_models, ncgrib_parameters, ncgrib_surfaces, ncgridcoverage;
|
||||
drop sequence if exists gribseq;
|
||||
drop sequence if exists ncgribseq;
|
||||
|
||||
"
|
||||
|
||||
echo "INFO: Dropping grib tables."
|
||||
|
|
|
@ -81,15 +81,14 @@
|
|||
<exclude>ebxml.*\.xml</exclude>
|
||||
<exclude>.*request.*</exclude>
|
||||
<exclude>grib-decode.xml</exclude>
|
||||
<exclude>ncgrib-file-endpoint.xml</exclude>
|
||||
<exclude>grid-staticdata-process.xml</exclude>
|
||||
<exclude>ncgrib-ingest.xml</exclude>
|
||||
<exclude>.*datadelivery.*</exclude>
|
||||
<exclude>.*bandwidth.*</exclude>
|
||||
<includeMode>excludeDpaAndOgc</includeMode>
|
||||
<!-- ncep excludes until tested -->
|
||||
<exclude>aww-ingest.xml</exclude>
|
||||
<exclude>ncccfp-ingest.xml</exclude>
|
||||
<exclude>ncgrib-distribution.xml</exclude>
|
||||
<exclude>ncep-util-on-edex-ingest</exclude>
|
||||
<exclude>ncep-util-on-edex-ingestGrib</exclude>
|
||||
<exclude>ncscd-ingest.xml</exclude>
|
||||
|
@ -168,6 +167,7 @@
|
|||
<include>auth-common.xml</include>
|
||||
<include>nwsauth-request.xml</include>
|
||||
<include>grib-decode.xml</include>
|
||||
<include>ncgrib-file-endpoint.xml</include>
|
||||
<include>grid-staticdata-process.xml</include>
|
||||
<include>level-common.xml</include>
|
||||
<include>grid-common.xml</include>
|
||||
|
@ -178,8 +178,6 @@
|
|||
<include>database-common.xml</include>
|
||||
<include>event-ingest.xml</include>
|
||||
<!-- ncep excludes until tested -->
|
||||
<exclude>ncgrib-common.xml</exclude>
|
||||
<exclude>ncgrib-ingest.xml</exclude>
|
||||
<exclude>ncep-util-on-edex-ingestGrib</exclude>
|
||||
<exclude>h5uair-ingest.xml</exclude>
|
||||
<exclude>h5uair-common.xml</exclude>
|
||||
|
@ -229,7 +227,6 @@
|
|||
<include>fssobs-common.xml</include>
|
||||
<include>ldadmesonet-common.xml</include>
|
||||
<include>dataaccess-common.xml</include>
|
||||
<exclude>ncgrib-common.xml</exclude>
|
||||
<exclude>nctext-common.xml</exclude>
|
||||
<includeMode>excludeDpaAndOgc</includeMode>
|
||||
<includeMode>statsTemplate</includeMode>
|
||||
|
|
|
@ -8,5 +8,4 @@ com.raytheon.edex.util.grib.CompositeModel
|
|||
com.raytheon.edex.plugin.grib.spatial.FileData
|
||||
com.raytheon.edex.plugin.grib.spatial.FileDataList
|
||||
com.raytheon.edex.plugin.grib.decoderpostprocessors.PostProcessedModelSet
|
||||
com.raytheon.edex.plugin.grib.decoderpostprocessors.PostProcessedModel
|
||||
com.raytheon.edex.plugin.grib.filenameprocessor.NcgribModelNameMap
|
||||
com.raytheon.edex.plugin.grib.decoderpostprocessors.PostProcessedModel
|
|
@ -48,26 +48,12 @@
|
|||
class="com.raytheon.edex.plugin.grib.spatial.GribSpatialCache"
|
||||
factory-method="getInstance" depends-on="gridcoveragelookup"/>
|
||||
|
||||
<bean id="ncgribFilenameProcessor" class="com.raytheon.edex.plugin.grib.filenameprocessor.NcgribFileNameProcessor" />
|
||||
|
||||
<camelContext id="grib-decode" xmlns="http://camel.apache.org/schema/spring"
|
||||
errorHandlerRef="errorHandler"
|
||||
autoStartup="false">
|
||||
|
||||
<endpoint id="gribFileEndpoint" uri="file:${edex.home}/data/sbn/grib?noop=true&idempotent=false" />
|
||||
<endpoint id="gribSplitJmsEndpoint" uri="jms-durable:queue:Ingest.GribSplit?concurrentConsumers=${grib-split.count.threads}"/>
|
||||
<endpoint id="gribDecodeJmsEndpoint" uri="ingest-grib:queue:Ingest.GribDecode?concurrentConsumers=${grib-decode.count.threads}"/>
|
||||
|
||||
|
||||
<route id="gribFileConsumerRoute">
|
||||
<from ref="gribFileEndpoint" />
|
||||
<bean ref="fileToString" />
|
||||
<bean ref="ncgribFilenameProcessor" />
|
||||
<setHeader headerName="pluginName">
|
||||
<constant>grid</constant>
|
||||
</setHeader>
|
||||
<to uri="jms-durable:queue:Ingest.GribSplit" />
|
||||
</route>
|
||||
|
||||
<!-- Begin Grib Decode Route -->
|
||||
<route id="gribSplitIngestRoute">
|
||||
|
|
|
@ -1,144 +0,0 @@
|
|||
package com.raytheon.edex.plugin.grib.filenameprocessor;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Processor;
|
||||
|
||||
/**
|
||||
*
|
||||
* Processor for ncep grib files, this processor has lots of hard coded
|
||||
* assumptions about file naming that need to be more generic based off ncep
|
||||
* file names.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 1, 2012 bsteffen Initial creation
|
||||
* May 29, 2013 995 B. Yin Get model name from NcgribModelNameMap
|
||||
* June, 2013 T. Lee Added NFCENS
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class NcgribFileNameProcessor implements Processor {
|
||||
|
||||
// grab all known ensemble ids; mainly SREF
|
||||
private static final Pattern ENSEMBLE_ID_PATTERN = Pattern
|
||||
.compile("^(p|n|ctl)\\d{0,2}$");
|
||||
|
||||
// grab global wind and wave ensemble IDs
|
||||
private static final Pattern ENSEMBLE_WAVE_PATTERN = Pattern
|
||||
.compile("^\\d{8}_gep(\\d{0,2}{2})$");
|
||||
|
||||
// grab global wind and wave ensemble IDs
|
||||
private static final Pattern ENSEMBLE_NFC_PATTERN = Pattern
|
||||
.compile("^\\d{8}_HTSGW_(\\d{2})$");
|
||||
// anything that ends in nest is assumed to be a nested grid identifier
|
||||
// might add alaska fire weather later...
|
||||
private static final Pattern FIREWXNEST_ID_PATTERN = Pattern
|
||||
.compile("^firewxnest$");
|
||||
|
||||
// anything that ends in nest is assumed to be a nested grid identifier
|
||||
//private static final Pattern NEST_ID_PATTERN = Pattern.compile("^.*nest$");
|
||||
|
||||
// SREF gets special handling, does this apply to other models?
|
||||
//private static final Pattern SREF_PATTERN = Pattern.compile("^sref_.*$");
|
||||
|
||||
// This is the least generic pattern ever, are there any constraints on
|
||||
// event names, who knows?
|
||||
private static final Pattern HURRICANE_PATTERN = Pattern
|
||||
.compile("^\\d{10}_([a-z]*)\\d{1,2}[lewcs]$");
|
||||
|
||||
private static NcgribModelNameMap modelMap = null;
|
||||
|
||||
@Override
|
||||
public void process(Exchange exchange) throws Exception {
|
||||
String flName = (String) exchange.getIn()
|
||||
.getHeader("CamelFileNameOnly");
|
||||
String datasetid = null;
|
||||
String secondaryid = null;
|
||||
String ensembleid = null;
|
||||
String[] nameTokens = flName.split("\\.");
|
||||
|
||||
for (String token : nameTokens) {
|
||||
if (ENSEMBLE_ID_PATTERN.matcher(token).find()) {
|
||||
ensembleid = token;
|
||||
} else if (ENSEMBLE_WAVE_PATTERN.matcher(token).find()) {
|
||||
Matcher matcher = ENSEMBLE_WAVE_PATTERN.matcher(token);
|
||||
matcher.find();
|
||||
ensembleid = matcher.group(1);
|
||||
} else if (ENSEMBLE_NFC_PATTERN.matcher(token).find()) {
|
||||
Matcher matcher = ENSEMBLE_NFC_PATTERN.matcher(token);
|
||||
datasetid = "nfcens";
|
||||
matcher.find();
|
||||
ensembleid = matcher.group(1);
|
||||
} else if (FIREWXNEST_ID_PATTERN.matcher(token).find()) {
|
||||
//datasetid = "NAMFIREWX";
|
||||
datasetid = "fireWxNAM";
|
||||
//secondaryid = token;
|
||||
//} else if (NEST_ID_PATTERN.matcher(token).find()) {
|
||||
// secondaryid = token;
|
||||
//} else if (SREF_PATTERN.matcher(token).find()) {
|
||||
// String[] tokens = token.split("_");
|
||||
// datasetid = tokens[0].toUpperCase();
|
||||
//secondaryid = tokens[1].toUpperCase();
|
||||
} else if (HURRICANE_PATTERN.matcher(token).find()) {
|
||||
Matcher matcher = HURRICANE_PATTERN.matcher(token);
|
||||
matcher.find();
|
||||
secondaryid = matcher.group(1);
|
||||
datasetid = "GHM";
|
||||
|
||||
if (nameTokens[3].equalsIgnoreCase("gribn3")) {
|
||||
datasetid = "GHMNEST";
|
||||
} else if (nameTokens[3].equalsIgnoreCase("grib6th")) {
|
||||
datasetid = "GHM6TH";
|
||||
} else if (nameTokens[3].equalsIgnoreCase("hwrfprs_n")) {
|
||||
datasetid = "HWRFNEST";
|
||||
} else if (nameTokens[3].equalsIgnoreCase("hwrfprs_p")) {
|
||||
datasetid = "HWRF";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( modelMap == null ) {
|
||||
modelMap = NcgribModelNameMap.load();
|
||||
}
|
||||
|
||||
// Get model name from grib file template
|
||||
if (datasetid == null) {
|
||||
datasetid = modelMap.getModelName(flName);
|
||||
}
|
||||
|
||||
exchange.getIn().setHeader("datasetid", datasetid);
|
||||
exchange.getIn().setHeader("secondaryid", secondaryid);
|
||||
exchange.getIn().setHeader("ensembleid", ensembleid);
|
||||
}
|
||||
|
||||
}
|
|
@ -255,13 +255,6 @@
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="gov.noaa.nws.ncep.common.dataplugin.ncgrib"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="gov.noaa.nws.ncep.common.dataplugin.ncpafm"
|
||||
download-size="0"
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>gov.noaa.nws.ncep.common.dataplugin.ncgrib</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?>
|
||||
|
||||
<pydev_project>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.5</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
</pydev_project>
|
|
@ -1,7 +0,0 @@
|
|||
#Tue Apr 13 10:05:15 EDT 2010
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,31 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Ncgrib Plug-in
|
||||
Bundle-SymbolicName: gov.noaa.nws.ncep.common.dataplugin.ncgrib
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
|
||||
Bundle-Vendor: NOAA.NWS.NCEP
|
||||
Require-Bundle: javax.measure,
|
||||
javax.persistence,
|
||||
org.apache.commons.lang,
|
||||
org.geotools,
|
||||
com.raytheon.edex.common,
|
||||
com.raytheon.uf.common.dataplugin,
|
||||
com.raytheon.uf.common.serialization,
|
||||
com.raytheon.uf.common.serialization.comm,
|
||||
com.raytheon.uf.common.status,
|
||||
com.raytheon.uf.common.localization,
|
||||
gov.noaa.nws.ncep.common;bundle-version="1.0.0",
|
||||
gov.noaa.nws.ncep.edex.common;bundle-version="1.0.0"
|
||||
Import-Package: com.raytheon.uf.common.dataplugin.level,
|
||||
com.raytheon.uf.common.derivparam.tree,
|
||||
com.raytheon.uf.common.geospatial,
|
||||
org.apache.commons.logging
|
||||
Export-Package: gov.noaa.nws.ncep.common.dataplugin.ncgrib,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.ncdatatree,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.request,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.util
|
|
@ -1,14 +0,0 @@
|
|||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcGenProcess
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribLevel
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribParameter
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LatLonNcgridCoverage
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.MercatorNcgridCoverage
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.PolarStereoNcgridCoverage
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LambertConformalNcgridCoverage
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModelSet
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.Ncgrib1Parameter
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.Ncgrib1ParameterSet
|
|
@ -1,5 +0,0 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
res
|
|
@ -1,64 +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.
|
||||
**/
|
||||
CREATE INDEX "ncgribEventName_idx"
|
||||
ON ncgrib
|
||||
USING btree
|
||||
(eventname);
|
||||
|
||||
CREATE INDEX "ncgribModelName_idx"
|
||||
ON ncgrib
|
||||
USING btree
|
||||
(modelname);
|
||||
|
||||
CREATE INDEX "ncgribParm_idx"
|
||||
ON ncgrib
|
||||
USING btree
|
||||
(parm);
|
||||
|
||||
CREATE INDEX "ncgribRecordQuery_idx"
|
||||
ON ncgrib
|
||||
USING btree
|
||||
(modelName, parm, vcord, glevel1, glevel2, refTime, forecastTime);
|
||||
|
||||
CREATE INDEX "ncgribRecordEventRangeQuery_idx"
|
||||
ON ncgrib
|
||||
USING btree
|
||||
(refTime, forecastTime, utilityFlags, rangeStart, rangeEnd, eventName);
|
||||
|
||||
CREATE INDEX "ncgribModelsModelName_idx"
|
||||
ON ncgrib_models
|
||||
USING btree
|
||||
(modelname);
|
||||
|
||||
CREATE INDEX "ncgribModelsLevelId_idx"
|
||||
ON ncgrib_models
|
||||
USING btree
|
||||
(level_id);
|
||||
|
||||
CREATE INDEX "ncgribCoverageType_idx"
|
||||
ON ncgridcoverage
|
||||
USING btree
|
||||
(dtype);
|
||||
|
||||
CREATE INDEX "ncgribCoverageLookup_idx"
|
||||
ON ncgridcoverage
|
||||
USING btree
|
||||
(dx, dy, la1, lo1, nx, ny);
|
||||
|
|
@ -1,261 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* Class encapsulating information about the generating process extracted from
|
||||
* the PDS section of the grib file.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ncgrib_genprocess")
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class NcGenProcess implements ISerializableObject {
|
||||
|
||||
/**
|
||||
* A generated identification number to uniquely identify this generating
|
||||
* process
|
||||
*/
|
||||
@Id
|
||||
private int id;
|
||||
|
||||
/** The originating center which defined this generating process */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int center;
|
||||
|
||||
/** The originating subcenter which defined this generating process */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int subcenter;
|
||||
|
||||
/** The number of the generating process */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int number;
|
||||
|
||||
/** The short name of this generating process */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String name;
|
||||
|
||||
/** Description of the generating process */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* Creates an empty GenProcess object
|
||||
*/
|
||||
public NcGenProcess() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a GenProcess object with provided information
|
||||
*
|
||||
* @param center
|
||||
* The center associated with this generating process
|
||||
* @param number
|
||||
* The number of the generating process
|
||||
* @param name
|
||||
* The short name of the generating process
|
||||
* @param description
|
||||
* The description of the generating process
|
||||
*/
|
||||
public NcGenProcess(int center, int subcenter, int number, String name, String description) {
|
||||
this.center = center;
|
||||
this.subcenter = subcenter;
|
||||
this.number = number;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
id = hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" center: ").append(center).append("\n");
|
||||
sb.append(" number: ").append(number).append("\n");
|
||||
sb.append(" name: ").append(name).append("\n");
|
||||
sb.append("description: ").append(description).append("\n");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = PRIME * result + center;
|
||||
result = PRIME * result + number;
|
||||
result = PRIME * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = PRIME * result
|
||||
+ ((description == null) ? 0 : description.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the center
|
||||
*
|
||||
* @return The center id
|
||||
*/
|
||||
public int getCenter() {
|
||||
return center;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the center id
|
||||
*
|
||||
* @param center
|
||||
* The center id
|
||||
*/
|
||||
public void setCenter(int center) {
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the generating process number
|
||||
*
|
||||
* @return The generating process number
|
||||
*/
|
||||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the generating process number
|
||||
*
|
||||
* @param number
|
||||
* The generating process number
|
||||
*/
|
||||
public void setNumber(int number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the short name of the generating process
|
||||
*
|
||||
* @return The name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the short name of the generating process
|
||||
*
|
||||
* @param name
|
||||
* The name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description of the generating process
|
||||
*
|
||||
* @return The description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description of the generating process
|
||||
*
|
||||
* @param description
|
||||
* The description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id
|
||||
*
|
||||
* @return The id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id
|
||||
*
|
||||
* @param id
|
||||
* The id
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the subcenter id
|
||||
*
|
||||
* @return The subcenter id
|
||||
*/
|
||||
public int getSubcenter() {
|
||||
return subcenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subcenter id
|
||||
*
|
||||
* @param subcenter
|
||||
* The subcenter id
|
||||
*/
|
||||
public void setSubcenter(int subcenter) {
|
||||
this.subcenter = subcenter;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,244 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* A class representing a grib 1 parameter
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 3/9/10 4758 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ncgrib1_parameter_map")
|
||||
@XmlRootElement
|
||||
@DynamicSerialize
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class Ncgrib1Parameter implements ISerializableObject {
|
||||
|
||||
/** The id assigned from the hashcode of this object */
|
||||
@Id
|
||||
private int id;
|
||||
|
||||
/** The center defining this parameter */
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int center;
|
||||
|
||||
/** The grib 1 parameter table version */
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int grib1TableVersion;
|
||||
|
||||
/** The grib 1 parameter parameter value */
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int grib1Value;
|
||||
|
||||
/** The grib 2 Discipline of this parameter */
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int grib2discipline;
|
||||
|
||||
/** The grib 2 Category of this parameter */
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int grib2category;
|
||||
|
||||
/** The grib 2 Parameter number of this parameter */
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int grib2Value;
|
||||
|
||||
/**
|
||||
* Creates an empty Grib1Parameter
|
||||
*/
|
||||
public Ncgrib1Parameter() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Grib1Parameter
|
||||
*
|
||||
* @param center
|
||||
* The center ID
|
||||
* @param grib1TableVersion
|
||||
* The grib 1 table version
|
||||
* @param grib1Value
|
||||
* The grib 1 table value
|
||||
* @param grib2Discipline
|
||||
* The equivalent grib 2 discipline
|
||||
* @param grib2Category
|
||||
* The equivalent grib 2 category
|
||||
* @param grib2Value
|
||||
* The equivalent grib 2 table value
|
||||
*/
|
||||
public Ncgrib1Parameter(int center, int grib1TableVersion, int grib1Value,
|
||||
int grib2Discipline, int grib2Category, int grib2Value) {
|
||||
this.center = center;
|
||||
this.grib1TableVersion = grib1TableVersion;
|
||||
this.grib1Value = grib1Value;
|
||||
this.grib2discipline = grib2Discipline;
|
||||
this.grib2category = grib2Category;
|
||||
this.grib2Value = grib2Value;
|
||||
this.id = hashCode();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the unique id using the hashCode
|
||||
*/
|
||||
public void generateId() {
|
||||
this.id = hashCode();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
HashCodeBuilder builder = new HashCodeBuilder();
|
||||
builder.append(center);
|
||||
builder.append(grib1TableVersion);
|
||||
builder.append(grib1Value);
|
||||
builder.append(grib2discipline);
|
||||
builder.append(grib2category);
|
||||
builder.append(grib2Value);
|
||||
return builder.toHashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the center
|
||||
*/
|
||||
public int getCenter() {
|
||||
return center;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param center
|
||||
* the center to set
|
||||
*/
|
||||
public void setCenter(int center) {
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the grib1TableVersion
|
||||
*/
|
||||
public int getGrib1TableVersion() {
|
||||
return grib1TableVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param grib1TableVersion
|
||||
* the grib1TableVersion to set
|
||||
*/
|
||||
public void setGrib1TableVersion(int grib1TableVersion) {
|
||||
this.grib1TableVersion = grib1TableVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the grib1Value
|
||||
*/
|
||||
public int getGrib1Value() {
|
||||
return grib1Value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param grib1Value
|
||||
* the grib1Value to set
|
||||
*/
|
||||
public void setGrib1Value(int grib1Value) {
|
||||
this.grib1Value = grib1Value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the grib2discipline
|
||||
*/
|
||||
public int getGrib2discipline() {
|
||||
return grib2discipline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param grib2discipline
|
||||
* the grib2discipline to set
|
||||
*/
|
||||
public void setGrib2discipline(int grib2discipline) {
|
||||
this.grib2discipline = grib2discipline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the grib2category
|
||||
*/
|
||||
public int getGrib2category() {
|
||||
return grib2category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param grib2category
|
||||
* the grib2category to set
|
||||
*/
|
||||
public void setGrib2category(int grib2category) {
|
||||
this.grib2category = grib2category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the grib2Value
|
||||
*/
|
||||
public int getGrib2Value() {
|
||||
return grib2Value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param grib2Value
|
||||
* the grib2Value to set
|
||||
*/
|
||||
public void setGrib2Value(int grib2Value) {
|
||||
this.grib2Value = grib2Value;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,298 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* Class encapsulating information about a grib surface.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ncgrib_surfaces")
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class NcgribLevel implements ISerializableObject {
|
||||
|
||||
/** The id generated from the hashcode of this object */
|
||||
@Id
|
||||
private int id;
|
||||
|
||||
/** The defining center */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int center;
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int subcenter;
|
||||
|
||||
/** The surface number */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int number;
|
||||
|
||||
/** The surface name */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String name;
|
||||
|
||||
/** The surface abbreviation */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String abbreviation;
|
||||
|
||||
/** The D2D surface abbreviation */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String d2dAbbrev;
|
||||
|
||||
/** The surface unit */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* Creates an empty GribSurface object
|
||||
*/
|
||||
public NcgribLevel() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a GribSurface object with the provided information
|
||||
*
|
||||
* @param center
|
||||
* The defining center
|
||||
* @param number
|
||||
* The surface number
|
||||
* @param name
|
||||
* The surface name
|
||||
* @param unit
|
||||
* The surface unit
|
||||
* @param abbreviation
|
||||
* The surface abbreviation
|
||||
*/
|
||||
public NcgribLevel(int center, int subcenter, int number, String name, String unit,
|
||||
String abbreviation, String d2dAbbrev) {
|
||||
this.center = center;
|
||||
this.subcenter = subcenter;
|
||||
this.number = number;
|
||||
this.name = name;
|
||||
this.unit = unit;
|
||||
this.abbreviation = abbreviation;
|
||||
this.d2dAbbrev = d2dAbbrev;
|
||||
this.id = hashCode();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
HashCodeBuilder builder = new HashCodeBuilder();
|
||||
builder.append(center);
|
||||
builder.append(number);
|
||||
return builder.toHashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id
|
||||
*
|
||||
* @return The id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id
|
||||
*
|
||||
* @param id
|
||||
* The id
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the defining center
|
||||
*
|
||||
* @return The defining center
|
||||
*/
|
||||
public int getCenter() {
|
||||
return center;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the defining center
|
||||
*
|
||||
* @param center
|
||||
* The defining center
|
||||
*/
|
||||
public void setCenter(int center) {
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the surface number
|
||||
*
|
||||
* @return The surface number
|
||||
*/
|
||||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the surface number
|
||||
*
|
||||
* @param number
|
||||
* The surface number
|
||||
*/
|
||||
public void setNumber(int number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the surface name
|
||||
*
|
||||
* @return The surface name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the surface name
|
||||
*
|
||||
* @param name
|
||||
* The surface name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the surface abbreviation
|
||||
*
|
||||
* @return The surface abbreviation
|
||||
*/
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the surface abbreviation
|
||||
*
|
||||
* @param abbreviation
|
||||
* The surface abbreviation
|
||||
*/
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the surface unit
|
||||
*
|
||||
* @return The surface unit
|
||||
*/
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the surface unit
|
||||
*
|
||||
* @param unit
|
||||
* The surface unit
|
||||
*/
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the d2d abbreviation for this level if one exists
|
||||
*
|
||||
* @return The d2d abbreviation
|
||||
*/
|
||||
public String getD2dAbbrev() {
|
||||
return d2dAbbrev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the d2d abbreviation for this level
|
||||
*
|
||||
* @param abbrev
|
||||
* The d2d abbreviation
|
||||
*/
|
||||
public void setD2dAbbrev(String abbrev) {
|
||||
d2dAbbrev = abbrev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the subcenter id for this level
|
||||
*
|
||||
* @return The subcenter id
|
||||
*/
|
||||
public int getSubcenter() {
|
||||
return subcenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subcenter id for this level
|
||||
*
|
||||
* @param subcenter
|
||||
* The subcenter id
|
||||
*/
|
||||
public void setSubcenter(int subcenter) {
|
||||
this.subcenter = subcenter;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,864 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib;
|
||||
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.measure.unit.Unit;
|
||||
import javax.measure.unit.UnitFormat;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgribModelLookup;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel;
|
||||
|
||||
/**
|
||||
* Class encapsulating parameter, level, and spatial information of the grib
|
||||
* record.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
* 1/31/11 M. Li Add eventName for dynamic model name
|
||||
* 9/08/11 X. Guo Check file size to create hash code
|
||||
* 11/17/11 X. Guo Fixed hash generator problem
|
||||
* 3/2012 T. Lee Added grib file template
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ncgrib_models")
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class NcgribModel extends PersistableDataObject {
|
||||
|
||||
private static final long serialVersionUID = 4417959632479870000L;
|
||||
|
||||
/** The id */
|
||||
@Id
|
||||
private Integer id;
|
||||
|
||||
/** The originating center ID - 7 for NCEP
|
||||
* information from ON388 - table 0
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int centerid;
|
||||
|
||||
/** The national subcenter ID - 0 for now
|
||||
* information from ON388 - table c for grib2 section 1,
|
||||
* octets 8-9 */
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int subcenterid;
|
||||
|
||||
/** The generating process number : 96 for gfs pgrb files:
|
||||
* 114 for NAEFS, 84 for meso NAM 12KM, 86 for RUC, 81 for GFS analysis,
|
||||
* 82 for analysis GDAS, etc...
|
||||
* information form ON388 - table A
|
||||
* Generating Process or Model from originating center 7
|
||||
* which is NCEP
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int genprocess;
|
||||
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private String template;
|
||||
|
||||
/** The backgenprocess number (currently gfs is 0)
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int backGenprocess;
|
||||
|
||||
/** The name of the grib parameter
|
||||
* such as temperatioure, pressure, ...etc*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private String parameterName;
|
||||
|
||||
/**
|
||||
* The abbreviation for the grib parameter. For accumulation and probability
|
||||
* parameters, the duration is appended such as T, P, ...etc.
|
||||
*/
|
||||
@Column
|
||||
@DataURI(position = 1)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private String parameterAbbreviation;
|
||||
|
||||
/** The unit for this grib parameter */
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private String parameterUnit;
|
||||
|
||||
/** The grid number : 4 for gfs pgrb 1.0, 2 for 2.5, ...etc */
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private String gridid;
|
||||
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int gridNumber;
|
||||
|
||||
/**
|
||||
* The pds template number (grib 2) from which this information was
|
||||
* extracted
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int pdsTemplate;
|
||||
|
||||
/** The type of ensemble forecast (See Code table 4.6) */
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@DataURI(position = 3)
|
||||
private Integer typeEnsemble;
|
||||
|
||||
/** The perturbation number of the ensemble */
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@DataURI(position = 4)
|
||||
private String perturbationNumber;
|
||||
|
||||
/** The number of forecasts in the ensemble */
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private Integer numForecasts;
|
||||
|
||||
/** The unique model name (i.e.NAM212) */
|
||||
/** The short model name (i.e.NAM80) This should be interpreted from
|
||||
* the generating process number and grid id : 96 for gfs,
|
||||
* 114 for NAEFS, 84 for meso NAM 12KM, 86 for RUC, 81 for GFS analysis,
|
||||
* 82 for analysis GDAS, etc...
|
||||
* information form ON388 - table A
|
||||
* Generating Process or Model from originating center 7
|
||||
* which is NCEP
|
||||
*/
|
||||
@Column
|
||||
@DataURI(position = 0)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private String modelName;
|
||||
|
||||
/** The name of event
|
||||
* such as hurricane name ...etc*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private String eventName;
|
||||
|
||||
/** The database insert time of the object */
|
||||
@Column(columnDefinition = "timestamp without time zone default now()", insertable = false, updatable = true)
|
||||
private Calendar insertTime;
|
||||
|
||||
/** The spatial information */
|
||||
@ManyToOne
|
||||
@PrimaryKeyJoinColumn
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private NcgridCoverage location;
|
||||
|
||||
@ManyToOne
|
||||
@PrimaryKeyJoinColumn
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
@DataURI(position = 2, embedded = true)
|
||||
private Level level;
|
||||
|
||||
/**
|
||||
* Creates and empty GribModel object
|
||||
*/
|
||||
public NcgribModel() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
*/
|
||||
public NcgribModel(NcgribModel copy) {
|
||||
this.backGenprocess = copy.backGenprocess;
|
||||
this.centerid = copy.centerid;
|
||||
this.genprocess = copy.genprocess;
|
||||
this.template = copy.template;
|
||||
this.gridid = copy.gridid;
|
||||
this.gridNumber = copy.gridNumber;
|
||||
this.id = copy.id;
|
||||
if (copy.insertTime != null) {
|
||||
this.insertTime = (Calendar) copy.insertTime.clone();
|
||||
}
|
||||
this.level = copy.level;
|
||||
this.location = copy.location;
|
||||
this.modelName = copy.modelName;
|
||||
this.eventName = copy.eventName;
|
||||
this.numForecasts = copy.numForecasts;
|
||||
this.parameterAbbreviation = copy.parameterAbbreviation;
|
||||
this.parameterName = copy.parameterName;
|
||||
this.parameterUnit = copy.parameterUnit;
|
||||
this.pdsTemplate = copy.pdsTemplate;
|
||||
this.perturbationNumber = copy.perturbationNumber;
|
||||
this.subcenterid = copy.subcenterid;
|
||||
this.typeEnsemble = copy.typeEnsemble;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
buffer.append(" Id: ").append(id).append("\n");
|
||||
buffer.append(" PDS Template: ").append(pdsTemplate).append(
|
||||
"\n");
|
||||
buffer.append(" Center: ").append(centerid).append("\n");
|
||||
buffer.append(" Subcenter: ").append(subcenterid).append(
|
||||
"\n");
|
||||
buffer.append(" Model Name: ").append(modelName)
|
||||
.append("\n");
|
||||
buffer.append(" Event Name: ").append(eventName)
|
||||
.append("\n");
|
||||
buffer.append(" Generating Process: ").append(genprocess).append(
|
||||
"\n");
|
||||
buffer.append(" Grib File Template: ").append(template).append(
|
||||
"\n");
|
||||
buffer.append(" Parameter Name: ").append(parameterName).append(
|
||||
"\n");
|
||||
buffer.append("Parameter Abbreviation: ").append(parameterAbbreviation)
|
||||
.append("\n");
|
||||
buffer.append(" Parameter Unit: ").append(
|
||||
getParamterUnitPrettyString()).append("\n");
|
||||
|
||||
if (level != null) {
|
||||
buffer.append(" Level Name: ").append(
|
||||
level.getMasterLevel().getName()).append("\n");
|
||||
buffer.append(" Level One Value: ").append(
|
||||
level.getLevelonevalue()).append("\n");
|
||||
buffer.append(" Level Two Value: ").append(
|
||||
level.getLeveltwovalue()).append("\n");
|
||||
buffer.append(" Level Unit: ").append(
|
||||
getLevelUnitPrettyString()).append("\n");
|
||||
} else {
|
||||
|
||||
}
|
||||
buffer.append(" Type Ensemble: ").append(typeEnsemble).append(
|
||||
"\n");
|
||||
buffer.append(" Perturbation Number: ").append(perturbationNumber)
|
||||
.append("\n");
|
||||
buffer.append(" Num Forecasts: ").append(numForecasts).append(
|
||||
"\n");
|
||||
if (location == null) {
|
||||
buffer.append("Location is NULL").append("\n");
|
||||
} else {
|
||||
buffer.append(location.toString()).append("\n");
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
HashCodeBuilder builder = new HashCodeBuilder();
|
||||
builder.append(modelName);
|
||||
builder.append(eventName);
|
||||
builder.append(parameterName);
|
||||
builder.append(parameterAbbreviation);
|
||||
builder.append(level);
|
||||
builder.append(typeEnsemble);
|
||||
builder.append(perturbationNumber);
|
||||
return builder.toHashCode();
|
||||
}
|
||||
|
||||
public int hashCode(String afileName) {
|
||||
HashCodeBuilder builder = new HashCodeBuilder();
|
||||
// String[] tokens = afileName.split("\\.");
|
||||
String tmp = afileName;
|
||||
if ( tmp.contains(".")) {
|
||||
tmp = tmp.replace(".", "_");
|
||||
}
|
||||
builder.append(modelName + "_" + tmp);
|
||||
builder.append(eventName);
|
||||
builder.append(parameterName);
|
||||
builder.append(parameterAbbreviation);
|
||||
builder.append(level);
|
||||
builder.append(typeEnsemble);
|
||||
builder.append(perturbationNumber);
|
||||
return builder.toHashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique id from the hashcode of this object
|
||||
*/
|
||||
public void generateId(String afileName) {
|
||||
this.id = hashCode(afileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique id from the hashcode of this object
|
||||
*/
|
||||
public void generateId() {
|
||||
this.id = hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level unit as a javax.measure.Unit<?> object. If the level unit
|
||||
* string cannot be successfully converted to a javax.measure.Unit<?>
|
||||
* object, Unit.ONE is returned
|
||||
*
|
||||
* @return The level unit as a javax.measure.Unit<?> object
|
||||
*/
|
||||
public Unit<?> getLevelUnitObject() {
|
||||
Unit<?> retVal = Unit.ONE;
|
||||
|
||||
if (level != null) {
|
||||
Unit<?> tmp = level.getMasterLevel().getUnit();
|
||||
if (tmp != null) {
|
||||
retVal = tmp;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level unit as a pretty string meaning superscripts and
|
||||
* subscripts are printed accordingly
|
||||
*
|
||||
* @return The level unit as a pretty string
|
||||
*/
|
||||
public String getLevelUnitPrettyString() {
|
||||
Unit<?> unitObj = getLevelUnitObject();
|
||||
if (unitObj.equals(Unit.ONE)) {
|
||||
return "";
|
||||
} else {
|
||||
return unitObj.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter unit as a javax.measure.Unit<?> object. If the
|
||||
* parameter unit string cannot be successfully converted to a
|
||||
* javax.measure.Unit<?> object, Unit.ONE is returned
|
||||
*
|
||||
* @return The parameter unit as a javax.measure.Unit<?> object
|
||||
*/
|
||||
public Unit<?> getParameterUnitObject() {
|
||||
Unit<?> retVal = Unit.ONE;
|
||||
|
||||
if (this.parameterUnit != null) {
|
||||
try {
|
||||
retVal = UnitFormat.getUCUMInstance().parseProductUnit(
|
||||
this.parameterUnit, new ParsePosition(0));
|
||||
} catch (Exception e) {
|
||||
// Unable to parse
|
||||
retVal = Unit.ONE;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter unit as a pretty string meaning superscripts and
|
||||
* subscripts are printed accordingly
|
||||
*
|
||||
* @return The parameter unit as a pretty string
|
||||
*/
|
||||
public String getParamterUnitPrettyString() {
|
||||
Unit<?> unitObj = getParameterUnitObject();
|
||||
if (unitObj.equals(Unit.ONE)) {
|
||||
return this.parameterUnit;
|
||||
} else {
|
||||
return unitObj.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id
|
||||
*
|
||||
* @return The id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id
|
||||
*
|
||||
* @param id
|
||||
* The id
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the center id
|
||||
*
|
||||
* @return The center id
|
||||
*/
|
||||
public int getCenterid() {
|
||||
return centerid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subcenter id
|
||||
*
|
||||
* @param centerid
|
||||
* The subcenter id
|
||||
*/
|
||||
public void setCenterid(int centerid) {
|
||||
this.centerid = centerid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the subcenter id
|
||||
*
|
||||
* @return The subcenter id
|
||||
*/
|
||||
public int getSubcenterid() {
|
||||
return subcenterid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subcenter id
|
||||
*
|
||||
* @param subcenterid
|
||||
* The subcenter id
|
||||
*/
|
||||
public void setSubcenterid(int subcenterid) {
|
||||
this.subcenterid = subcenterid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the genprocess
|
||||
*
|
||||
* @return The genprocess
|
||||
*/
|
||||
public int getGenprocess() {
|
||||
return genprocess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file template
|
||||
*
|
||||
* @param fileTemplate
|
||||
* The fileTemplate
|
||||
*/
|
||||
public void setTemplate(String template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file template
|
||||
*
|
||||
* @return The fileTemplate
|
||||
*/
|
||||
public String getTemplate() {
|
||||
return template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the genproces
|
||||
*
|
||||
* @param genprocess
|
||||
* The genprocess
|
||||
*/
|
||||
public void setGenprocess(int genprocess) {
|
||||
this.genprocess = genprocess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter name
|
||||
*
|
||||
* @return parameterName
|
||||
*/
|
||||
public String getParameterName() {
|
||||
return parameterName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parameter name
|
||||
*
|
||||
* @param parameterName
|
||||
* The parameter nam
|
||||
*/
|
||||
public void setParameterName(String parameterName) {
|
||||
this.parameterName = parameterName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter abbreviation
|
||||
*
|
||||
* @return The parameter abbreviation
|
||||
*/
|
||||
public String getParameterAbbreviation() {
|
||||
return parameterAbbreviation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parameter abbreviation
|
||||
*
|
||||
* @param parameterAbbreviation
|
||||
* The parameter abbreviation
|
||||
*/
|
||||
public void setParameterAbbreviation(String parameterAbbreviation) {
|
||||
this.parameterAbbreviation = parameterAbbreviation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter unit
|
||||
*
|
||||
* @return The parameter unit
|
||||
*/
|
||||
public String getParameterUnit() {
|
||||
return parameterUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parameter unit
|
||||
*
|
||||
* @param parameterUnit
|
||||
* The parameter unit
|
||||
*/
|
||||
public void setParameterUnit(String parameterUnit) {
|
||||
this.parameterUnit = parameterUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level name
|
||||
*
|
||||
* @return The level name
|
||||
*/
|
||||
public String getLevelName() {
|
||||
String rval = null;
|
||||
if (level != null) {
|
||||
rval = level.getMasterLevel().getName();
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level one value
|
||||
*
|
||||
* @return The level one value
|
||||
*/
|
||||
public Double getLevelOneValue() {
|
||||
Double rval = null;
|
||||
if (level != null) {
|
||||
rval = level.getLevelonevalue();
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level two value
|
||||
*
|
||||
* @return The level two value
|
||||
*/
|
||||
public Double getLevelTwoValue() {
|
||||
Double rval = null;
|
||||
if (level != null) {
|
||||
rval = level.getLeveltwovalue();
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level unit
|
||||
*
|
||||
* @return The level unit
|
||||
*/
|
||||
public String getLevelUnit() {
|
||||
String rval = null;
|
||||
if (level != null) {
|
||||
rval = level.getMasterLevel().getUnitString();
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level info
|
||||
*
|
||||
* @return The level info
|
||||
*/
|
||||
public String getLevelInfo() {
|
||||
String rval = null;
|
||||
if (level != null) {
|
||||
rval = level.getLevelInfo();
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the grid id
|
||||
*
|
||||
* @return The grid id
|
||||
*/
|
||||
public String getGridid() {
|
||||
return gridid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the grid id
|
||||
*
|
||||
* @param gridid
|
||||
* The grid id
|
||||
*/
|
||||
public void setGridid(String gridid) {
|
||||
this.gridid = gridid;
|
||||
try {
|
||||
gridNumber = Integer.parseInt(gridid);
|
||||
} catch (NumberFormatException e) {
|
||||
gridNumber = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database insert time
|
||||
*
|
||||
* @return The database insert time
|
||||
*/
|
||||
public Calendar getInsertTime() {
|
||||
return insertTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the database insert time
|
||||
*
|
||||
* @param insertTime
|
||||
* The database insert time
|
||||
*/
|
||||
public void setInsertTime(Calendar insertTime) {
|
||||
this.insertTime = insertTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the spatial information
|
||||
*
|
||||
* @return The spatial information
|
||||
*/
|
||||
public NcgridCoverage getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the spatial information
|
||||
*
|
||||
* @param location
|
||||
* The spatial information
|
||||
*/
|
||||
public void setLocation(NcgridCoverage location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level information
|
||||
*
|
||||
* @return The level information
|
||||
*/
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level information
|
||||
*
|
||||
* @param level
|
||||
* The level information
|
||||
*/
|
||||
public void setLevel(Level level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ensemble type
|
||||
*
|
||||
* @return The ensemble type
|
||||
*/
|
||||
public Integer getTypeEnsemble() {
|
||||
return typeEnsemble;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ensemble type
|
||||
*
|
||||
* @param typeEnsemble
|
||||
* The ensemble type
|
||||
*/
|
||||
public void setTypeEnsemble(Integer typeEnsemble) {
|
||||
this.typeEnsemble = typeEnsemble;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the perturbation number
|
||||
*
|
||||
* @return The perturbation number
|
||||
*/
|
||||
public String getPerturbationNumber() {
|
||||
return perturbationNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the perturbation number
|
||||
*
|
||||
* @param perturbationNumber
|
||||
* The perturbation number
|
||||
*/
|
||||
public void setPerturbationNumber(String perturbationNumber) {
|
||||
this.perturbationNumber = perturbationNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of ensemble forecasts
|
||||
*
|
||||
* @return The number of ensemble forecasts
|
||||
*/
|
||||
public Integer getNumForecasts() {
|
||||
return numForecasts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of ensemble forecasts
|
||||
*
|
||||
* @param numForecasts
|
||||
* The number of ensemble forecasts
|
||||
*/
|
||||
public void setNumForecasts(Integer numForecasts) {
|
||||
this.numForecasts = numForecasts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the background generating process
|
||||
*
|
||||
* @return The background generating process
|
||||
*/
|
||||
public int getBackGenprocess() {
|
||||
return backGenprocess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the background generating process
|
||||
*
|
||||
* @param backGenprocess
|
||||
* The background generating process
|
||||
*/
|
||||
public void setBackGenprocess(int backGenprocess) {
|
||||
this.backGenprocess = backGenprocess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pds template number
|
||||
*
|
||||
* @return The pds template number
|
||||
*/
|
||||
public int getPdsTemplate() {
|
||||
return pdsTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pds template number
|
||||
*
|
||||
* @param pdsTemplate
|
||||
* The pds template number
|
||||
*/
|
||||
public void setPdsTemplate(int pdsTemplate) {
|
||||
this.pdsTemplate = pdsTemplate;
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public String getModelTitle() {
|
||||
String rval = null;
|
||||
|
||||
if (modelName != null) {
|
||||
NcgridModel model = NcgribModelLookup.getInstance().getModelByName(
|
||||
modelName);
|
||||
|
||||
if (model != null) {
|
||||
rval = model.getTitle();
|
||||
} else {
|
||||
rval = modelName;
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
public void setModelName(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
public int getGridNumber() {
|
||||
return gridNumber;
|
||||
}
|
||||
|
||||
public void setGridNumber(int gridNumber) {
|
||||
this.gridNumber = gridNumber;
|
||||
}
|
||||
|
||||
public String getEventName() {
|
||||
return eventName;
|
||||
}
|
||||
|
||||
public void setEventName(String eventName) {
|
||||
this.eventName = eventName;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,370 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* Class encapsulating information about a grib parameter
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ncgrib_parameters")
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class NcgribParameter implements ISerializableObject {
|
||||
|
||||
/** No subcenter id number */
|
||||
public static final int NO_SUBCENTER = -1;
|
||||
|
||||
/** The id assigned from the hashcode of this object */
|
||||
@Id
|
||||
private int id;
|
||||
|
||||
/** The center which defined this parameter */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int center;
|
||||
|
||||
/** The subcenter which defined this parameter */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int subcenter;
|
||||
|
||||
/** The grib discipline number (See Table 0.0) */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int discipline;
|
||||
|
||||
/** The grib category number (See Table 4.1) */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int category;
|
||||
|
||||
/** The grib parameter number (See tables 4.2.x) */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private int number;
|
||||
|
||||
/** The name of the parameter */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String name;
|
||||
|
||||
/** The abbreviation of the parameter */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String abbreviation;
|
||||
|
||||
/** The D2D abbreviation of the parameter */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String d2dAbbrev;
|
||||
|
||||
/** The unit associated with the parameter, if any */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* Creates and empty GribParameter object
|
||||
*/
|
||||
public NcgribParameter() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a GribParameter object with the provided values
|
||||
*
|
||||
* @param center
|
||||
* The defining center
|
||||
* @param subcenter
|
||||
* The defining subcenter
|
||||
* @param discipline
|
||||
* The parameter discipline
|
||||
* @param category
|
||||
* The parameter category
|
||||
* @param number
|
||||
* The parameter number
|
||||
* @param name
|
||||
* The parameter name
|
||||
* @param abbreviation
|
||||
* The parameter abbreviation
|
||||
* @param unit
|
||||
* The parameter unit
|
||||
*/
|
||||
public NcgribParameter(int center, int subcenter, int discipline,
|
||||
int category, int number, String name, String abbreviation,
|
||||
String unit,String d2dAbbrev) {
|
||||
this.name = name;
|
||||
this.abbreviation = abbreviation;
|
||||
this.d2dAbbrev = d2dAbbrev;
|
||||
this.unit = unit;
|
||||
this.discipline = discipline;
|
||||
this.category = category;
|
||||
this.number = number;
|
||||
this.center = center;
|
||||
this.subcenter = subcenter;
|
||||
this.id = hashCode();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = PRIME * result + center;
|
||||
result = PRIME * result + subcenter;
|
||||
result = PRIME * result + discipline;
|
||||
result = PRIME * result + category;
|
||||
result = PRIME * result + number;
|
||||
result = PRIME * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = PRIME * result
|
||||
+ ((abbreviation == null) ? 0 : abbreviation.hashCode());
|
||||
result = PRIME * result + ((unit == null) ? 0 : unit.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(" Id: ").append(id).append("\n");
|
||||
buf.append(" Center: ").append(center).append("\n");
|
||||
buf.append(" Subcenter: ").append(subcenter).append("\n");
|
||||
buf.append("Discipline: ").append(discipline).append("\n");
|
||||
buf.append(" Category: ").append(category).append("\n");
|
||||
buf.append(" Number: ").append(number).append("\n");
|
||||
buf.append(" Name: ").append(name).append("\n");
|
||||
buf.append(" Abbrev: ").append(abbreviation).append("\n");
|
||||
buf.append(" unit: ").append(unit).append("\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name
|
||||
*
|
||||
* @return The name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name
|
||||
*
|
||||
* @param name
|
||||
* The name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the abbreviation
|
||||
*
|
||||
* @return The abbreviation
|
||||
*/
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the abbreviation
|
||||
*
|
||||
* @param abbreviation
|
||||
* The abbreviation
|
||||
*/
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the unit
|
||||
*
|
||||
* @return The unit
|
||||
*/
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the unit
|
||||
*
|
||||
* @param unit
|
||||
* The unit
|
||||
*/
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the defining center
|
||||
*
|
||||
* @return The defining center
|
||||
*/
|
||||
public int getCenter() {
|
||||
return center;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the defining center
|
||||
*
|
||||
* @param center
|
||||
* The defining center
|
||||
*/
|
||||
public void setCenter(int center) {
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the defining subcenter
|
||||
*
|
||||
* @return The definign subcenter
|
||||
*/
|
||||
public int getSubcenter() {
|
||||
return subcenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the defining subcenter
|
||||
*
|
||||
* @param subcenter
|
||||
* The definign subcenter
|
||||
*/
|
||||
public void setSubcenter(int subcenter) {
|
||||
this.subcenter = subcenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter discipline
|
||||
*
|
||||
* @return The parameter discipline
|
||||
*/
|
||||
public int getDiscipline() {
|
||||
return discipline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parameter discipline
|
||||
*
|
||||
* @param discipline
|
||||
* The parameter discipline
|
||||
*/
|
||||
public void setDiscipline(int discipline) {
|
||||
this.discipline = discipline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter category
|
||||
*
|
||||
* @return The parameter category
|
||||
*/
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parameter category
|
||||
*
|
||||
* @param category
|
||||
*/
|
||||
public void setCategory(int category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter number
|
||||
*
|
||||
* @return The parameter number
|
||||
*/
|
||||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parameter number
|
||||
*
|
||||
* @param number
|
||||
* The parameter number
|
||||
*/
|
||||
public void setNumber(int number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id
|
||||
*
|
||||
* @return The id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id
|
||||
*
|
||||
* @param id
|
||||
* The id
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getD2dAbbrev() {
|
||||
return d2dAbbrev;
|
||||
}
|
||||
|
||||
public void setD2dAbbrev(String abbrev) {
|
||||
d2dAbbrev = abbrev;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.persist.DefaultPathProvider;
|
||||
import com.raytheon.uf.common.dataplugin.persist.IPersistable;
|
||||
|
||||
/**
|
||||
* Path provider for storing grib data to HDF5
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/24/09 1994 bphillip Initial Creation
|
||||
* 1/12/12 xguo Create new HDF5 file name
|
||||
* yyyy-MM-dd-HH-fhrs-ensNumber.h5
|
||||
* 3/2012 T. Lee changed pN to String
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class NcgribPathProvider extends DefaultPathProvider {
|
||||
|
||||
private static final SimpleDateFormat gribHdf5FileNameFormat = new SimpleDateFormat(
|
||||
"yyyy-MM-dd-HH");
|
||||
static {
|
||||
gribHdf5FileNameFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
}
|
||||
|
||||
private static NcgribPathProvider instance = new NcgribPathProvider();
|
||||
|
||||
public static NcgribPathProvider getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected NcgribPathProvider() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHDFPath(String pluginName, IPersistable persistable) {
|
||||
if (persistable != null) {
|
||||
NcgribRecord record = (NcgribRecord) persistable;
|
||||
return record.getModelInfo().getModelName();
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Persistable object is null. Unable to generate HDF5 path");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHDFFileName(String pluginName, IPersistable persistable) {
|
||||
// Integer partition = persistable.getHdfFileId();
|
||||
|
||||
if (persistable == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Expected argument persistable is null");
|
||||
}
|
||||
|
||||
if (!(persistable instanceof NcgribRecord)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Argument persistable is of wrong type. Expected "
|
||||
+ NcgribRecord.class + " but got "
|
||||
+ persistable.getClass());
|
||||
} else if (pluginName == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Expected argument pluginName not set on object "
|
||||
+ persistable.toString());
|
||||
}
|
||||
|
||||
NcgribRecord pdo = (NcgribRecord) persistable;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
Date refTime = pdo.getDataTime().getRefTime();
|
||||
int fhrs = pdo.getDataTime().getFcstTime()/3600;
|
||||
String refTimeString = null;
|
||||
synchronized (gribHdf5FileNameFormat) {
|
||||
refTimeString = gribHdf5FileNameFormat.format(refTime);
|
||||
}
|
||||
String pbNum = "0";
|
||||
if ( pdo.getModelInfo().getPerturbationNumber() != null){
|
||||
pbNum = pdo.getModelInfo().getPerturbationNumber();
|
||||
}
|
||||
sb.append(refTimeString);
|
||||
sb.append(String.format("-%d", fhrs));
|
||||
sb.append(String.format("-%s", pbNum));
|
||||
sb.append(".h5");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String formatTime(Date date) {
|
||||
String retVal = null;
|
||||
synchronized (gribHdf5FileNameFormat) {
|
||||
retVal = gribHdf5FileNameFormat.format(date);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
|
@ -1,830 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.annotations.Index;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.IDecoderGettable;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
|
||||
import com.raytheon.uf.common.dataplugin.persist.IHDFFilePathProvider;
|
||||
import com.raytheon.uf.common.dataplugin.persist.PersistablePluginDataObject;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialEnabled;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* Record class for the ncgrib plugin.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 07, 2009 1994 bphillip Initial Creation
|
||||
* Oct 13, 2010 276 llin Modified for NC GRIB.
|
||||
* Mar 07, 2012 606 ghull Added eventName to URI for NcInventory
|
||||
* updating.
|
||||
* Apr 04, 2013 1846 bkowal Added an index on refTime and
|
||||
* forecastTime
|
||||
* Apr 08, 2013 1293 bkowal Removed references to hdffileid.
|
||||
* Apr 12, 2013 1857 bgonzale Added SequenceGenerator annotation.
|
||||
* May 07, 2013 1869 bsteffen Remove dataURI column from
|
||||
* PluginDataObject.
|
||||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "ncgribseq")
|
||||
@Table(name = "ncgrib", uniqueConstraints = { @UniqueConstraint(columnNames = { "dataURI" }) })
|
||||
/*
|
||||
* Both refTime and forecastTime are included in the refTimeIndex since
|
||||
* forecastTime is unlikely to be used.
|
||||
*/
|
||||
@org.hibernate.annotations.Table(appliesTo = "ncgrib", indexes = { @Index(name = "ncgrib_refTimeIndex", columnNames = {
|
||||
"refTime", "forecastTime" }) })
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class NcgribRecord extends PersistablePluginDataObject implements
|
||||
ISpatialEnabled {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** GRIB master tables version number (currently 2) (See Table 1.0) */
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int masterTableVersion;
|
||||
|
||||
/**
|
||||
* Version number of GRIB local tables used to augment Master Tables (See
|
||||
* Table 1.1) 0 - local tables not used, only table entries and templates
|
||||
* the current master table are valid. (Currently 1)
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int localTableVersion;
|
||||
|
||||
/**
|
||||
* Significance of reference time (See Table 1.2) 0 for analysis, 1 for
|
||||
* forecast, 2 for verifying time, and 3 for observation time
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int refTimeSignificance;
|
||||
|
||||
/**
|
||||
* Processed data type in this GRIB message (See Table 1.4) 0 for analysis,
|
||||
* 1 for forecast, 2 for both, .... or PDT in table 4.3 This refers to PDT#
|
||||
* in GEMPAK output
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int processedDataType;
|
||||
|
||||
/** Denotes if local section is present (currently false) */
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private boolean localSectionUsed;
|
||||
|
||||
/** The values extracted from the local section (in hdf5) */
|
||||
@Transient
|
||||
@DynamicSerializeElement
|
||||
private int[] localSection;
|
||||
|
||||
/**
|
||||
* Denotes if this is a thinned grid, therefore containing a list of thinned
|
||||
* points per row (currently false)
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private boolean thinnedGrid;
|
||||
|
||||
/**
|
||||
* The number of points in each row of a quasi-regular grid, if applicable
|
||||
* (if yes, store in hdf5)
|
||||
*/
|
||||
@Transient
|
||||
@DynamicSerializeElement
|
||||
private int[] thinnedPts;
|
||||
|
||||
/**
|
||||
* Denotes if this grid is a hybrid level grid, therefore containing a list
|
||||
* of hybrid level information (currently false)
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private boolean hybridGrid;
|
||||
|
||||
/**
|
||||
* The values of the optional coordinate list provided with hybrid level
|
||||
* parameters (if yes, store in hdf5)
|
||||
*/
|
||||
@Transient
|
||||
@DynamicSerializeElement
|
||||
private float[] hybridCoordList;
|
||||
|
||||
/** The model information in ncgrib_models child table */
|
||||
@ManyToOne(cascade = { CascadeType.REFRESH }, fetch = FetchType.EAGER)
|
||||
@PrimaryKeyJoinColumn
|
||||
@Fetch(FetchMode.SELECT)
|
||||
@DataURI(position = 1, embedded = true)
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private NcgribModel modelInfo;
|
||||
|
||||
private boolean isVector = false;
|
||||
|
||||
/**
|
||||
* The short model name (i.e.NAM80) This should be interpreted from the
|
||||
* generating process number and grid id : 96 for gfs, 114 for NAEFS, 84 for
|
||||
* meso NAM 12KM, 86 for RUC, 81 for GFS analysis, 82 for analysis GDAS,
|
||||
* etc... information form ON388 - table A Generating Process or Model from
|
||||
* originating center 7 which is NCEP
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@DataURI(position = 2)
|
||||
private String modelName;
|
||||
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@DataURI(position = 3)
|
||||
private int gridVersion = 0;
|
||||
|
||||
/**
|
||||
* The name of ingested file
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@DataURI(position = 4)
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* The name of event such as Hurricane or Volcano
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@DataURI(position = 8)
|
||||
private String eventName;
|
||||
|
||||
/**
|
||||
* Type of Generating Process
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@DataURI(position = 7)
|
||||
private int processType;
|
||||
|
||||
/**
|
||||
* Resolution and componet flags (See Table 3.3)
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private Integer resCompFlags;
|
||||
|
||||
/**
|
||||
* Indicate the discipline of the processed data contained within a GRIB
|
||||
* message - 0 for Meteorological products in table 0.0 This refers to DIS#
|
||||
* in GEMPAK output
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int discipline;
|
||||
|
||||
/**
|
||||
* Parameter category by product discipline 0 for temperature in table 4.1
|
||||
* by discipline 0
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int category;
|
||||
|
||||
/**
|
||||
* Parameter number by product discipline and parameter category 9 for
|
||||
* temperature anomaly in table 4.2-0-0 for discipline 0 and category 0 This
|
||||
* refers to ID# in GEMPAK output
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int parameterId;
|
||||
|
||||
/**
|
||||
* pdt - Product definition template number.
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int pdt;
|
||||
|
||||
/**
|
||||
* Fixed surface types or vertical coordinate ID 1 2 for cloud base level
|
||||
* and 100 for isobaric surface in table 4.5 or VCRDGRID1.TBL for NCEP This
|
||||
* refers to VCD# in GEMPAK output The location in pds[9]
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int vcrdId1;
|
||||
|
||||
/**
|
||||
* Fixed surface types or vertical coordinate ID 2 2 for cloud base level
|
||||
* and 100 for isobaric surface in table 4.5 or VCRDGRID1.TBL for NCEP This
|
||||
* refers to VCD# in GEMPAK output The location in pds[12]
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int vcrdId2;
|
||||
|
||||
/**
|
||||
* Scaled value of first fixed surface in GRIB2- TEMPLATE 4.1 This refers to
|
||||
* LEVEL1 in GEMPAK output
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int glevel1;
|
||||
|
||||
private float decodedLevel1;
|
||||
|
||||
/**
|
||||
* Scaled value of second fixed surface in GRIB2- TEMPLATE 4.1 This refers
|
||||
* to LEVEL2 in GEMPAK output
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int glevel2;
|
||||
|
||||
private float decodedLevel2;
|
||||
|
||||
/**
|
||||
* The gempak vertical coordinate grid name
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@DataURI(position = 6)
|
||||
private String vcord;
|
||||
|
||||
/**
|
||||
* The gempak abbreviation grid name
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@DataURI(position = 5)
|
||||
private String parm;
|
||||
|
||||
/**
|
||||
* The gempak scale for decoding the grid field
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private String scale;
|
||||
|
||||
/**
|
||||
* The forecast interval
|
||||
*/
|
||||
@Column
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private int interval;
|
||||
|
||||
/**
|
||||
* Creates an empty NcgribRecord
|
||||
*/
|
||||
public NcgribRecord() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a NcgribRecord from the provided uri
|
||||
*
|
||||
* @param uri
|
||||
* The dataURI used to construct the record
|
||||
*/
|
||||
public NcgribRecord(String uri) {
|
||||
super(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
*/
|
||||
public NcgribRecord(NcgribRecord recordToCopy) {
|
||||
if (recordToCopy.dataTime != null) {
|
||||
this.dataTime = recordToCopy.dataTime.clone();
|
||||
}
|
||||
this.dataURI = recordToCopy.dataURI;
|
||||
this.id = recordToCopy.id;
|
||||
this.identifier = recordToCopy.identifier;
|
||||
if (recordToCopy.insertTime != null) {
|
||||
this.insertTime = (Calendar) recordToCopy.insertTime.clone();
|
||||
}
|
||||
this.messageData = recordToCopy.messageData;
|
||||
this.gridVersion = recordToCopy.gridVersion;
|
||||
if (recordToCopy.hybridCoordList != null) {
|
||||
this.hybridCoordList = Arrays.copyOf(recordToCopy.hybridCoordList,
|
||||
recordToCopy.hybridCoordList.length);
|
||||
}
|
||||
this.hybridGrid = recordToCopy.hybridGrid;
|
||||
this.isVector = recordToCopy.isVector;
|
||||
if (recordToCopy.localSection != null) {
|
||||
this.localSection = Arrays.copyOf(recordToCopy.localSection,
|
||||
recordToCopy.localSection.length);
|
||||
}
|
||||
this.localSectionUsed = recordToCopy.localSectionUsed;
|
||||
this.localTableVersion = recordToCopy.localTableVersion;
|
||||
this.masterTableVersion = recordToCopy.masterTableVersion;
|
||||
this.modelInfo = new NcgribModel(recordToCopy.getModelInfo());
|
||||
this.processedDataType = recordToCopy.processedDataType;
|
||||
this.refTimeSignificance = recordToCopy.refTimeSignificance;
|
||||
this.resCompFlags = recordToCopy.resCompFlags;
|
||||
this.thinnedGrid = recordToCopy.thinnedGrid;
|
||||
if (recordToCopy.thinnedPts != null) {
|
||||
this.thinnedPts = Arrays.copyOf(recordToCopy.thinnedPts,
|
||||
recordToCopy.thinnedPts.length);
|
||||
}
|
||||
this.modelName = recordToCopy.modelName;
|
||||
this.fileName = recordToCopy.fileName;
|
||||
this.eventName = recordToCopy.eventName;
|
||||
this.processType = recordToCopy.processType;
|
||||
this.discipline = recordToCopy.discipline;
|
||||
this.category = recordToCopy.category;
|
||||
this.parameterId = recordToCopy.parameterId;
|
||||
this.pdt = recordToCopy.pdt;
|
||||
this.vcrdId1 = recordToCopy.vcrdId1;
|
||||
this.vcrdId2 = recordToCopy.vcrdId2;
|
||||
this.vcord = recordToCopy.vcord;
|
||||
this.glevel1 = recordToCopy.glevel1;
|
||||
this.glevel2 = recordToCopy.glevel2;
|
||||
this.parm = recordToCopy.parm;
|
||||
this.scale = recordToCopy.scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHDFFilePathProvider getHDFPathProvider() {
|
||||
return NcgribPathProvider.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDecoderGettable getDecoderGettable() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpatialObject getSpatialObject() {
|
||||
return modelInfo.getLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* public void setSpatialObject(NcgridCoverage location) {
|
||||
* modelInfo.setLocation(location); }
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets the model information
|
||||
*
|
||||
* @return The model information
|
||||
*/
|
||||
public NcgribModel getModelInfo() {
|
||||
return modelInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the model information
|
||||
*
|
||||
* @param modelInfo
|
||||
* The model information
|
||||
*/
|
||||
public void setModelInfo(NcgribModel modelInfo) {
|
||||
this.modelInfo = modelInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the master table version
|
||||
*
|
||||
* @return The master table version
|
||||
*/
|
||||
public int getMasterTableVersion() {
|
||||
return masterTableVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master table version
|
||||
*
|
||||
* @param masterTableVersion
|
||||
* The master table version
|
||||
*/
|
||||
public void setMasterTableVersion(int masterTableVersion) {
|
||||
this.masterTableVersion = masterTableVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local table version
|
||||
*
|
||||
* @return The local table version
|
||||
*/
|
||||
public int getLocalTableVersion() {
|
||||
return localTableVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the local table version
|
||||
*
|
||||
* @param localTableVersion
|
||||
* The local table version
|
||||
*/
|
||||
public void setLocalTableVersion(int localTableVersion) {
|
||||
this.localTableVersion = localTableVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the reference time significance
|
||||
*
|
||||
* @return The reference time significance
|
||||
*/
|
||||
public int getRefTimeSignificance() {
|
||||
return refTimeSignificance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the reference time significance
|
||||
*
|
||||
* @param refTimeSignificance
|
||||
* The reference time significance
|
||||
*/
|
||||
public void setRefTimeSignificance(int refTimeSignificance) {
|
||||
this.refTimeSignificance = refTimeSignificance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ths processed data type
|
||||
*
|
||||
* @return The processed data type
|
||||
*/
|
||||
public int getProcessedDataType() {
|
||||
return processedDataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the processed data type
|
||||
*
|
||||
* @param processedDataType
|
||||
* The processed data type
|
||||
*/
|
||||
public void setProcessedDataType(int processedDataType) {
|
||||
this.processedDataType = processedDataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if local section is present
|
||||
*
|
||||
* @return localSectionUsed
|
||||
*/
|
||||
public boolean isLocalSectionUsed() {
|
||||
return localSectionUsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets localSectionUsed
|
||||
*
|
||||
* @param localSectionUsed
|
||||
* True if localsection if used, else false
|
||||
*/
|
||||
public void setLocalSectionUsed(boolean localSectionUsed) {
|
||||
this.localSectionUsed = localSectionUsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local section data
|
||||
*
|
||||
* @return The local section data
|
||||
*/
|
||||
public int[] getLocalSection() {
|
||||
return localSection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the local section data
|
||||
*
|
||||
* @param localSection
|
||||
* The local section data
|
||||
*/
|
||||
public void setLocalSection(int[] localSection) {
|
||||
this.localSection = localSection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Hybrid coordinate list
|
||||
*
|
||||
* @return The hybrid coordinate list
|
||||
*/
|
||||
public float[] getHybridCoordList() {
|
||||
return hybridCoordList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the hybrid coordinate list
|
||||
*
|
||||
* @param hybridCoordList
|
||||
* The hybrid coordinate list
|
||||
*/
|
||||
public void setHybridCoordList(float[] hybridCoordList) {
|
||||
this.hybridCoordList = hybridCoordList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of points in each row for a thinned grid
|
||||
*
|
||||
* @return The thinned row points
|
||||
*/
|
||||
public int[] getThinnedPts() {
|
||||
return thinnedPts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of points in each row for a thinned grid
|
||||
*
|
||||
* @param thinnedPts
|
||||
* The thinned row points
|
||||
*/
|
||||
public void setThinnedPts(int[] thinnedPts) {
|
||||
this.thinnedPts = thinnedPts;
|
||||
}
|
||||
|
||||
public boolean isThinnedGrid() {
|
||||
return thinnedGrid;
|
||||
}
|
||||
|
||||
public void setThinnedGrid(boolean thinnedGrid) {
|
||||
this.thinnedGrid = thinnedGrid;
|
||||
}
|
||||
|
||||
public boolean isHybridGrid() {
|
||||
return hybridGrid;
|
||||
}
|
||||
|
||||
public void setHybridGrid(boolean hybridGrid) {
|
||||
this.hybridGrid = hybridGrid;
|
||||
}
|
||||
|
||||
public boolean isVector() {
|
||||
return this.isVector;
|
||||
}
|
||||
|
||||
public void setVector(boolean isVector) {
|
||||
this.isVector = isVector;
|
||||
}
|
||||
|
||||
public int getGridVersion() {
|
||||
return gridVersion;
|
||||
}
|
||||
|
||||
public void setGridVersion(int gridVersion) {
|
||||
this.gridVersion = gridVersion;
|
||||
}
|
||||
|
||||
public Integer getResCompFlags() {
|
||||
return resCompFlags;
|
||||
}
|
||||
|
||||
public void setResCompFlags(Integer resCompFlags) {
|
||||
this.resCompFlags = resCompFlags;
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public void setModelName(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
public int getDiscipline() {
|
||||
return discipline;
|
||||
}
|
||||
|
||||
public void setDiscipline(int discipline) {
|
||||
this.discipline = discipline;
|
||||
}
|
||||
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(int category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public int getParameterId() {
|
||||
return parameterId;
|
||||
}
|
||||
|
||||
public void setParameterId(int parameterId) {
|
||||
this.parameterId = parameterId;
|
||||
}
|
||||
|
||||
public int getPdt() {
|
||||
return pdt;
|
||||
}
|
||||
|
||||
public void setPdt(int pdt) {
|
||||
this.pdt = pdt;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getEventName() {
|
||||
return eventName;
|
||||
}
|
||||
|
||||
public void setEventName(String eventName) {
|
||||
this.eventName = eventName;
|
||||
}
|
||||
|
||||
public int getProcessType() {
|
||||
return processType;
|
||||
}
|
||||
|
||||
public void setProcessType(int processType) {
|
||||
this.processType = processType;
|
||||
}
|
||||
|
||||
public int getVcrdId1() {
|
||||
return vcrdId1;
|
||||
}
|
||||
|
||||
public void setVcrdId1(int vcrdId1) {
|
||||
this.vcrdId1 = vcrdId1;
|
||||
}
|
||||
|
||||
public int getVcrdId2() {
|
||||
return vcrdId2;
|
||||
}
|
||||
|
||||
public void setVcrdId2(int vcrdId2) {
|
||||
this.vcrdId2 = vcrdId2;
|
||||
}
|
||||
|
||||
public int getGlevel1() {
|
||||
return glevel1;
|
||||
}
|
||||
|
||||
public void setGlevel1(int glevel1) {
|
||||
this.glevel1 = glevel1;
|
||||
}
|
||||
|
||||
public int getGlevel2() {
|
||||
return glevel2;
|
||||
}
|
||||
|
||||
public void setGlevel2(int glevel2) {
|
||||
this.glevel2 = glevel2;
|
||||
}
|
||||
|
||||
public String getVcord() {
|
||||
return vcord;
|
||||
}
|
||||
|
||||
public void setVcord(String vcord) {
|
||||
this.vcord = vcord;
|
||||
}
|
||||
|
||||
public String getParm() {
|
||||
return parm;
|
||||
}
|
||||
|
||||
public void setParm(String parm) {
|
||||
this.parm = parm;
|
||||
}
|
||||
|
||||
public String getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public void setScale(String scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public int getInterval() {
|
||||
return interval;
|
||||
}
|
||||
|
||||
public void setInterval(int interval) {
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the decodedLevel1
|
||||
*/
|
||||
public float getDecodedLevel1() {
|
||||
return decodedLevel1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param decodedLevel1
|
||||
* the decodedLevel1 to set
|
||||
*/
|
||||
public void setDecodedLevel1(float decodedLevel1) {
|
||||
this.decodedLevel1 = decodedLevel1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the decodedLevel2
|
||||
*/
|
||||
public float getDecodedLevel2() {
|
||||
return decodedLevel2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param decodedLevel2
|
||||
* the decodedLevel2 to set
|
||||
*/
|
||||
public void setDecodedLevel2(float decodedLevel2) {
|
||||
this.decodedLevel2 = decodedLevel2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Column
|
||||
@Access(AccessType.PROPERTY)
|
||||
public String getDataURI() {
|
||||
return super.getDataURI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "ncgrib";
|
||||
}
|
||||
}
|
|
@ -1,70 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 9, 2010 brockwoo Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author brockwoo
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class NcgribThriftContainer {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private int numOfRecords;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private NcgribThriftRecord[] records;
|
||||
|
||||
public NcgribThriftContainer() {
|
||||
this.numOfRecords = 0;
|
||||
}
|
||||
|
||||
public int getNumOfRecords() {
|
||||
return numOfRecords;
|
||||
}
|
||||
|
||||
public void setNumOfRecords(int numOfRecords) {
|
||||
this.numOfRecords = numOfRecords;
|
||||
}
|
||||
|
||||
public NcgribThriftRecord[] getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public void setRecords(NcgribThriftRecord[] records) {
|
||||
this.records = records;
|
||||
this.numOfRecords = this.records.length;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,153 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.request.NcgridDataRequestMessage;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 9, 2010 brockwoo Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author brockwoo
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class NcgribThriftRecord {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private NcgridDataRequestMessage message;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float[] data;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private boolean localSection = false;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private int[] localSectionData;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private boolean hybridGrid = false;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float[] hybridGridData;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private boolean thinnedGrid = false;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private int[] thinnedGridData;
|
||||
|
||||
public NcgridDataRequestMessage getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(NcgridDataRequestMessage message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public float[] getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(float[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean isLocalSection() {
|
||||
return localSection;
|
||||
}
|
||||
|
||||
public void setLocalSection(boolean localSection) {
|
||||
this.localSection = localSection;
|
||||
}
|
||||
|
||||
public int[] getLocalSectionData() {
|
||||
return localSectionData;
|
||||
}
|
||||
|
||||
public void setLocalSectionData(int[] localSectionData) {
|
||||
this.localSectionData = localSectionData;
|
||||
}
|
||||
|
||||
public boolean isHybridGrid() {
|
||||
return hybridGrid;
|
||||
}
|
||||
|
||||
public void setHybridGrid(boolean hybridGrid) {
|
||||
this.hybridGrid = hybridGrid;
|
||||
}
|
||||
|
||||
public float[] getHybridGridData() {
|
||||
return hybridGridData;
|
||||
}
|
||||
|
||||
public void setHybridGridData(float[] hybridGridData) {
|
||||
this.hybridGridData = hybridGridData;
|
||||
}
|
||||
|
||||
public boolean isThinnedGrid() {
|
||||
return thinnedGrid;
|
||||
}
|
||||
|
||||
public void setThinnedGrid(boolean thinnedGrid) {
|
||||
this.thinnedGrid = thinnedGrid;
|
||||
}
|
||||
|
||||
public int[] getThinnedGridData() {
|
||||
return thinnedGridData;
|
||||
}
|
||||
|
||||
public void setThinnedGridData(int[] thinnedGridData) {
|
||||
this.thinnedGridData = thinnedGridData;
|
||||
}
|
||||
|
||||
public void setDataFields(IDataRecord[] data) {
|
||||
if (data[0] != null) {
|
||||
this.data = ((FloatDataRecord) data[0]).getFloatData();
|
||||
}
|
||||
if (data[1] != null) {
|
||||
this.localSectionData = ((IntegerDataRecord) data[1]).getIntData();
|
||||
this.localSection = true;
|
||||
}
|
||||
if (data[2] != null) {
|
||||
this.hybridGridData = ((FloatDataRecord) data[2]).getFloatData();
|
||||
this.hybridGrid = true;
|
||||
}
|
||||
if (data[3] != null) {
|
||||
this.thinnedGridData = ((IntegerDataRecord) data[3]).getIntData();
|
||||
this.thinnedGrid = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
|
||||
/**
|
||||
* Exception class for wrapping errors that occur with GribDecoder
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class GribException extends PluginException {
|
||||
|
||||
/**
|
||||
* Default serial version id
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Parser exception set with a cause.
|
||||
*
|
||||
* @param aCause
|
||||
* The cause of the exception
|
||||
*/
|
||||
public GribException(String aCause) {
|
||||
super(aCause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parser exception set with a cause and an existing exception. Used for
|
||||
* exception chaining to preserve state.
|
||||
*
|
||||
* @param aCause
|
||||
* The cause of the exception
|
||||
* @param anException
|
||||
* The exception object
|
||||
*/
|
||||
public GribException(String aCause, Exception anException) {
|
||||
super(aCause, anException);
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* Exception classes for grib plugin
|
||||
*/
|
||||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception;
|
|
@ -1,234 +0,0 @@
|
|||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.ncdatatree;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
//import com.raytheon.uf.common.derivparam.tree.DataTree;
|
||||
//import com.raytheon.uf.common.derivparam.tree.LevelNode;
|
||||
//import com.raytheon.uf.common.derivparam.tree.ParameterNode;
|
||||
//import com.raytheon.uf.common.derivparam.tree.SourceNode;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
@DynamicSerialize
|
||||
public class NcDataTree implements ISerializableObject,
|
||||
Cloneable {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Map<String, NcSourceNode> ncSourceNodes = new HashMap<String, NcSourceNode>();
|
||||
|
||||
|
||||
public Map<String, NcSourceNode> getNcSourceNodes() {
|
||||
return ncSourceNodes;
|
||||
}
|
||||
|
||||
public void setNcSourceNodes(Map<String, NcSourceNode> ncSourceNodes) {
|
||||
this.ncSourceNodes = ncSourceNodes;
|
||||
}
|
||||
|
||||
public NcDataTree clone() {
|
||||
NcDataTree tree = new NcDataTree();
|
||||
Map<String, NcSourceNode> clonedNodes = tree.getNcSourceNodes();
|
||||
|
||||
for (NcSourceNode node : ncSourceNodes.values()) {
|
||||
clonedNodes.put(node.getValue(), node.clone());
|
||||
}
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
// public int mergeGridTree(NcDataTree tree) {
|
||||
// for (NcSourceNode sourceNode : tree.getNcSourceNodes().values()) {
|
||||
// NcSourceNode thisNcSourceNode = ncSourceNodes.get(sourceNode.getValue());
|
||||
//
|
||||
// if (thisNcSourceNode == null) {
|
||||
// ncSourceNodes.put(sourceNode.getValue(), (NcSourceNode) ncSourceNodes);
|
||||
// } else {
|
||||
// thisNcSourceNode.mergeNode(ncSourceNodes);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return tree.getNcSourceNodes().size();
|
||||
// }
|
||||
|
||||
// public void addBranch(String source,
|
||||
// String parameterName,
|
||||
// String levelName, String levelValue, Map<String, RequestConstraint> rcMap) {
|
||||
// addBranch(source, null, parameterName,
|
||||
// levelName, levelValue, null, rcMap);
|
||||
// }
|
||||
|
||||
/**
|
||||
* A convenience method that adds a new branch to the grid tree. This is for
|
||||
* the GridCatalog script task and expects the list to contain the following
|
||||
* metadata parameters in the same order:
|
||||
* <p>
|
||||
* modelName, parameterAbbreviation, parameterName, parameterUnit, level.id
|
||||
* </p>
|
||||
*
|
||||
* @param gridInfo
|
||||
* A List object that contains the above list
|
||||
*/
|
||||
public void addBranch(String source, String eventName,
|
||||
String parameterName, String levelName,
|
||||
String level1Value, String level2Value, Map<String, RequestConstraint> rcMap) {
|
||||
NcSourceNode sourceNode = ncSourceNodes.get(source);
|
||||
if (sourceNode == null) {
|
||||
sourceNode = new NcSourceNode();
|
||||
sourceNode.setValue(source);
|
||||
ncSourceNodes.put(source, sourceNode);
|
||||
}
|
||||
|
||||
NcEventNode eventNode = sourceNode.getChildNode(eventName);
|
||||
if (eventNode == null) {
|
||||
eventNode = new NcEventNode();
|
||||
eventNode.setValue(eventName);
|
||||
sourceNode.addChildNode(eventNode);
|
||||
}
|
||||
|
||||
|
||||
NcParameterNode paramNode = eventNode
|
||||
.getChildNode(parameterName);
|
||||
if (paramNode == null) {
|
||||
paramNode = new NcParameterNode();
|
||||
paramNode.setValue(parameterName);
|
||||
eventNode.addChildNode(paramNode);
|
||||
}
|
||||
|
||||
String levelId = null;
|
||||
if ( level2Value.equals("-9999") )
|
||||
levelId = levelName + ":" + level1Value;
|
||||
else
|
||||
levelId = levelName + ":" + level1Value + ":" + level2Value;
|
||||
NcLevelNode levelNode = paramNode.getChildNode(levelId);
|
||||
if (levelNode == null) {
|
||||
levelNode = new NcLevelNode();
|
||||
levelNode.setValue(levelId);
|
||||
//levelNode.setLevelName(levelName);
|
||||
levelNode.setRcmap(rcMap);
|
||||
paramNode.addChildNode(levelNode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of available model names.
|
||||
*
|
||||
* @return The center id
|
||||
*/
|
||||
public Set<String> getNcSources() {
|
||||
return ncSourceNodes.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the specified model name node.
|
||||
*
|
||||
* @param modelNameId
|
||||
* @return The center node
|
||||
*/
|
||||
public NcSourceNode getNcSourceNode(String modelNameId) {
|
||||
return ncSourceNodes.get(modelNameId);
|
||||
}
|
||||
|
||||
public Set<String> getNcEvents(String modelName) {
|
||||
NcSourceNode node = getNcSourceNode(modelName);
|
||||
return node != null ? node.getChildNodeIds() : new HashSet<String>();
|
||||
}
|
||||
|
||||
public NcEventNode getNcEventNode(String modelName, String event) {
|
||||
NcEventNode rval = null;
|
||||
NcSourceNode node = getNcSourceNode(modelName);
|
||||
|
||||
if (node != null) {
|
||||
rval = node.getChildNode(event);
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
/**
|
||||
* Returns a list of available parameters for the specified criteria. If not
|
||||
* found, an empty string array is returned.
|
||||
*
|
||||
* @param modelName
|
||||
* The target model name
|
||||
* @return A string array of available parameter nodes
|
||||
*/
|
||||
public Set<String> getNcParameters(String modelName, String eventName) {
|
||||
NcEventNode node = getNcEventNode(modelName, eventName);
|
||||
return node != null ? node.getChildNodeIds() : new HashSet<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the specified parameter node.
|
||||
*
|
||||
* @param modelName
|
||||
* The target model name
|
||||
* @param param
|
||||
* The target parameter
|
||||
* @return The parameter node
|
||||
*/
|
||||
public NcParameterNode getNcParameterNode(String modelName, String eventName, String parameterName) {
|
||||
NcParameterNode rval = null;
|
||||
NcEventNode node = getNcEventNode(modelName, eventName);
|
||||
|
||||
if (node != null) {
|
||||
rval = node.getChildNode(parameterName);
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of available levels for the specified criteria. If not
|
||||
* found, an empty string array is returned.
|
||||
*
|
||||
* @param modelName
|
||||
* The target model name
|
||||
* @param param
|
||||
* The target parameter
|
||||
* @return A string array of available level nodes
|
||||
*/
|
||||
public Set<String> getNcLevels(String modelName, String eventName, String paramName) {
|
||||
NcParameterNode parameter = getNcParameterNode(modelName, eventName, paramName);
|
||||
return parameter != null ? parameter.getChildNodeIds()
|
||||
: new HashSet<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the specified level node.
|
||||
*
|
||||
* @param modelName
|
||||
* The target model name
|
||||
* @param param
|
||||
* The target parameter
|
||||
* @param level
|
||||
* The target level
|
||||
* @return The level node or null if not found
|
||||
*/
|
||||
public NcLevelNode getNcLevelNode(String modelName, String eventName, String paramName, String level) {
|
||||
NcLevelNode rval = null;
|
||||
NcParameterNode parameter = getNcParameterNode(modelName, eventName, paramName);
|
||||
|
||||
if (parameter != null) {
|
||||
rval = parameter.getChildNode(level);
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder tmp = new StringBuilder();
|
||||
|
||||
for (NcSourceNode node : ncSourceNodes.values()) {
|
||||
tmp.append(node.toString());
|
||||
}
|
||||
|
||||
return tmp.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.ncdatatree;
|
||||
|
||||
import com.raytheon.uf.common.derivparam.tree.AbstractNode;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
@DynamicSerialize
|
||||
public class NcEventNode extends AbstractNode<NcParameterNode> {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String eventName;
|
||||
|
||||
|
||||
public String getEventName() {
|
||||
return eventName;
|
||||
}
|
||||
|
||||
|
||||
public void setEventName(String eventName) {
|
||||
this.eventName = eventName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NcEventNode clone() {
|
||||
NcEventNode node = new NcEventNode();
|
||||
node.setValue(this.getValue());
|
||||
node.setEventName(eventName);
|
||||
|
||||
for (NcParameterNode child : this.getChildNodes().values()) {
|
||||
node.addChildNode((NcParameterNode) child.clone());
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.ncdatatree;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.derivparam.tree.AbstractNode;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
@DynamicSerialize
|
||||
public class NcLevelNode extends AbstractNode<NcLevelNode> {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String levelName;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Map<String, RequestConstraint> rcmap;
|
||||
|
||||
public Map<String, RequestConstraint> getRcmap() {
|
||||
return rcmap;
|
||||
}
|
||||
|
||||
public void setRcmap(Map<String, RequestConstraint> rcmap) {
|
||||
this.rcmap = rcmap;
|
||||
}
|
||||
|
||||
public String getLevelName() {
|
||||
return levelName;
|
||||
}
|
||||
|
||||
public void setLevelName(String levelName) {
|
||||
this.levelName = levelName;
|
||||
}
|
||||
|
||||
// public NcLevelNode(NcLevelNode that) {
|
||||
// this.value = that.value;
|
||||
// this.levelName = that.levelName;
|
||||
//
|
||||
// for (NcLevelNode child : that.getChildNodes().values()) {
|
||||
// addChildNode((NcLevelNode) child.clone());
|
||||
// }
|
||||
// }
|
||||
|
||||
public NcLevelNode() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NcLevelNode clone() {
|
||||
NcLevelNode node = new NcLevelNode();
|
||||
node.setValue(this.getValue());
|
||||
node.setLevelName(levelName);
|
||||
node.setRcmap(rcmap);
|
||||
|
||||
for (NcLevelNode child : this.getChildNodes().values()) {
|
||||
node.addChildNode((NcLevelNode) child.clone());
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.ncdatatree;
|
||||
|
||||
import com.raytheon.uf.common.derivparam.tree.AbstractNode;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
@DynamicSerialize
|
||||
public class NcParameterNode extends AbstractNode<NcLevelNode> {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String parameterName;
|
||||
|
||||
public String getParameterName() {
|
||||
return parameterName;
|
||||
}
|
||||
|
||||
public void setParameterName(String parameterName) {
|
||||
this.parameterName = parameterName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NcParameterNode clone() {
|
||||
NcParameterNode node = new NcParameterNode();
|
||||
node.setValue(this.getValue());
|
||||
node.setParameterName(parameterName);
|
||||
|
||||
for (NcLevelNode child : this.getChildNodes().values()) {
|
||||
node.addChildNode((NcLevelNode) child.clone());
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.ncdatatree;
|
||||
|
||||
import com.raytheon.uf.common.derivparam.tree.AbstractNode;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
|
||||
@DynamicSerialize
|
||||
public class NcSourceNode extends AbstractNode<NcEventNode> {
|
||||
|
||||
@Override
|
||||
public NcSourceNode clone() {
|
||||
NcSourceNode node = new NcSourceNode();
|
||||
node.setValue(this.getValue());
|
||||
|
||||
for (NcEventNode child : this.getChildNodes().values()) {
|
||||
node.addChildNode((NcEventNode) child.clone());
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* Contains the core classes for decoding, storing, and accessing grib data.
|
||||
*/
|
||||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib;
|
|
@ -1,54 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib.request;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.serialization.comm.IServerRequest;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 8, 2010 rjpeter Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class GetNcCoverageRequest implements IServerRequest {
|
||||
@DynamicSerializeElement
|
||||
private String modelName;
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public void setModelName(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,165 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib.request;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.serialization.comm.IServerRequest;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 12, 2010 brockwoo Initial creation
|
||||
* 3/2012 T. Lee Changed perturbation number to String
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author brockwoo
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class NcgridDataRequestMessage implements IServerRequest {
|
||||
|
||||
public static final long MISSING = -999l;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String modelName;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private double levelOne = Level.INVALID_VALUE;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private double levelTwo = Level.INVALID_VALUE;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String levelType;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private long startTime = -999l;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private int forecastTime = 0;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String parameterAbbreviation;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String pert = "";
|
||||
|
||||
@DynamicSerializeElement
|
||||
private int version = -999;
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public void setModelName(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
public double getLevelOne() {
|
||||
return levelOne;
|
||||
}
|
||||
|
||||
public void setLevelOne(double levelOne) {
|
||||
this.levelOne = levelOne;
|
||||
}
|
||||
|
||||
public double getLevelTwo() {
|
||||
return levelTwo;
|
||||
}
|
||||
|
||||
public void setLevelTwo(double levelTwo) {
|
||||
this.levelTwo = levelTwo;
|
||||
}
|
||||
|
||||
public String getLevelType() {
|
||||
return levelType;
|
||||
}
|
||||
|
||||
public void setLevelType(String levelType) {
|
||||
this.levelType = levelType;
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public int getForecastTime() {
|
||||
return forecastTime;
|
||||
}
|
||||
|
||||
public void setForecastTime(int forecastTime) {
|
||||
this.forecastTime = forecastTime;
|
||||
}
|
||||
|
||||
public String getParameterAbbreviation() {
|
||||
return parameterAbbreviation;
|
||||
}
|
||||
|
||||
public void setParameterAbbreviation(String parameterAbbreviation) {
|
||||
this.parameterAbbreviation = parameterAbbreviation;
|
||||
}
|
||||
|
||||
public String getPert() {
|
||||
return pert;
|
||||
}
|
||||
|
||||
public void setPert(String pert) {
|
||||
this.pert = pert;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public void setInfoFromRecord(NcgribRecord record) {
|
||||
NcgribModel info = record.getModelInfo();
|
||||
DataTime time = record.getDataTime();
|
||||
this.modelName = info.getModelName();
|
||||
this.levelOne = info.getLevel().getLevelonevalue();
|
||||
this.levelTwo = info.getLevel().getLeveltwovalue();
|
||||
this.levelType = info.getLevel().getMasterLevel().getName();
|
||||
this.parameterAbbreviation = info.getParameterAbbreviation();
|
||||
if (info.getPerturbationNumber() != null) {
|
||||
this.pert = info.getPerturbationNumber();
|
||||
}
|
||||
this.version = record.getGridVersion();
|
||||
this.startTime = time.getRefTime().getTime();
|
||||
this.forecastTime = time.getFcstTime();
|
||||
}
|
||||
}
|
|
@ -1,539 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.SI;
|
||||
import javax.measure.unit.Unit;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* Defines a Lambert Conformal grid coverage. This class is generally used to
|
||||
* describe grids described by GDS Template 30 as specified in Table 3.1
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ncgrib_lambertconformal_coverages")
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class LambertConformalNcgridCoverage extends NcgridCoverage {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(LambertConformalNcgridCoverage.class);
|
||||
|
||||
private static final long serialVersionUID = 5113332463602932317L;
|
||||
|
||||
/** The name of the projectio */
|
||||
public static final String PROJECTION_TYPE = "Lambert Conformal";
|
||||
|
||||
/** The minor axis of the Earth */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double minorAxis;
|
||||
|
||||
/** The major axis of the Earth */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double majorAxis;
|
||||
|
||||
/** Number of points along the x-axis */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private Integer nx;
|
||||
|
||||
/** Number of points along the y-axis */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private Integer ny;
|
||||
|
||||
/** Latitude of the first grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double la1;
|
||||
|
||||
/** Longitude of the first grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double lo1;
|
||||
|
||||
/**
|
||||
* Longitude of meridian parallel to y-axis along which latitude increases
|
||||
* as the y-coordinate increases
|
||||
*/
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double lov;
|
||||
|
||||
/** X-direction grid length in units specified by spacingUnit **/
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double dx;
|
||||
|
||||
/** Y-direction grid length in units specified by spacingUnit **/
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double dy;
|
||||
|
||||
/** Spacing unit of dx and dy */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String spacingUnit;
|
||||
|
||||
/** First latitude from the pole at which the secant cone cuts the sphere **/
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double latin1;
|
||||
|
||||
/** Second latitude from the pole at which the secant cone cuts the sphere **/
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double latin2;
|
||||
|
||||
@Override
|
||||
public int generateHash() {
|
||||
HashCodeBuilder hashBuilder = new HashCodeBuilder();
|
||||
hashBuilder.append(nx);
|
||||
hashBuilder.append(ny);
|
||||
hashBuilder.append(la1);
|
||||
hashBuilder.append(lo1);
|
||||
hashBuilder.append(lov);
|
||||
hashBuilder.append(latin1);
|
||||
hashBuilder.append(latin2);
|
||||
return hashBuilder.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() throws GribException {
|
||||
crs = MapUtil.constructLambertConformal(majorAxis, minorAxis, latin1,
|
||||
latin2, lov);
|
||||
crsWKT = crs.toWKT();
|
||||
try {
|
||||
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
|
||||
if (spacingUnitObj.isCompatible(SI.METRE)) {
|
||||
UnitConverter converter = spacingUnitObj
|
||||
.getConverterTo(SI.METRE);
|
||||
geometry = MapUtil.createGeometry(crs, la1, lo1, converter
|
||||
.convert(dx), converter.convert(dy), nx, ny);
|
||||
} else {
|
||||
throw new GribException("Unable to convert " + spacingUnit
|
||||
+ " to meters while creating geometry!");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new GribException("Error creating geometry", e);
|
||||
}
|
||||
id = generateHash();
|
||||
|
||||
}
|
||||
|
||||
public void generateName() {
|
||||
String nameAndDescription = "Unknown " + nx + " X " + ny + " "
|
||||
+ Math.round(dx) + " " + spacingUnit + " "
|
||||
+ getProjectionType() + " grid";
|
||||
String nameModel_gridid = "" + nx + ny + Integer.toString((int) (la1+lo1+lov));
|
||||
this.setName(nameModel_gridid);
|
||||
//this.setName(nameAndDescription);
|
||||
this.setDescription(nameAndDescription);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NcgridCoverage trim(SubNcgrid subGrid) {
|
||||
LambertConformalNcgridCoverage rval = new LambertConformalNcgridCoverage();
|
||||
rval.description = this.description;
|
||||
rval.dx = this.dx;
|
||||
rval.dy = this.dy;
|
||||
rval.spacingUnit = this.spacingUnit;
|
||||
rval.latin1 = this.latin1;
|
||||
rval.latin2 = this.latin2;
|
||||
rval.lov = this.lov;
|
||||
rval.majorAxis = this.majorAxis;
|
||||
rval.minorAxis = this.minorAxis;
|
||||
int startX = subGrid.getStartX();
|
||||
int startY = subGrid.getStartY();
|
||||
rval.nx = subGrid.getNX();
|
||||
rval.ny = subGrid.getNY();
|
||||
|
||||
// validate bounds are ok
|
||||
if (startX + rval.nx > this.nx) {
|
||||
rval.nx = this.nx - startX;
|
||||
}
|
||||
if (startY + rval.ny > this.ny) {
|
||||
rval.ny = this.ny - startY;
|
||||
}
|
||||
|
||||
rval.setName(this.name + "SubGrid");
|
||||
|
||||
try {
|
||||
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
|
||||
if (spacingUnitObj.isCompatible(SI.METRE)) {
|
||||
UnitConverter converter = spacingUnitObj
|
||||
.getConverterTo(SI.METRE);
|
||||
double dxMeter = converter.convert(dx);
|
||||
double dyMeter = converter.convert(dy);
|
||||
MathTransform fromLatLon = MapUtil.getTransformFromLatLon(crs);
|
||||
MathTransform toLatLon = fromLatLon.inverse();
|
||||
// thisLL, subgrid defined in UL
|
||||
double[] tmp1 = new double[] { this.lo1, this.la1 };
|
||||
double[] tmp2 = new double[2];
|
||||
fromLatLon.transform(tmp1, 0, tmp2, 0, 1);
|
||||
tmp2[0] += dxMeter * startX;
|
||||
// need to determine max lat and decrement from there
|
||||
tmp2[1] += dyMeter * (this.ny - (startY + rval.ny));
|
||||
toLatLon.transform(tmp2, 0, tmp1, 0, 1);
|
||||
rval.setLo1(tmp1[0]);
|
||||
rval.setLa1(tmp1[1]);
|
||||
rval.setId(rval.hashCode());
|
||||
} else {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error creating sub grid definition ["
|
||||
+ subGrid.getModelName()
|
||||
+ "], units are not compatible with meter ["
|
||||
+ spacingUnit + "]");
|
||||
rval = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error creating sub grid definition", e);
|
||||
rval = null;
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectionType() {
|
||||
return PROJECTION_TYPE;
|
||||
}
|
||||
|
||||
public Integer getNx() {
|
||||
return nx;
|
||||
}
|
||||
|
||||
public Integer getNy() {
|
||||
return ny;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minor axis
|
||||
*
|
||||
* @return The minor axis
|
||||
*/
|
||||
public double getMinorAxis() {
|
||||
return minorAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minor axis
|
||||
*
|
||||
* @param minorAxis
|
||||
* The minor axis
|
||||
*/
|
||||
public void setMinorAxis(double minorAxis) {
|
||||
this.minorAxis = minorAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the major axis
|
||||
*
|
||||
* @return The major axis
|
||||
*/
|
||||
public double getMajorAxis() {
|
||||
return majorAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the major axis
|
||||
*
|
||||
* @param majorAxis
|
||||
* The major axis
|
||||
*/
|
||||
public void setMajorAxis(double majorAxis) {
|
||||
this.majorAxis = majorAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets nx
|
||||
*
|
||||
* @param nx
|
||||
* The nx value
|
||||
*/
|
||||
public void setNx(Integer nx) {
|
||||
this.nx = nx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets ny
|
||||
*
|
||||
* @param ny
|
||||
* The ny value
|
||||
*/
|
||||
public void setNy(Integer ny) {
|
||||
this.ny = ny;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets la1
|
||||
*
|
||||
* @return la1 latitude value
|
||||
*/
|
||||
public double getLa1() {
|
||||
return la1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets la1
|
||||
*
|
||||
* @param la1
|
||||
* la1 latitude value
|
||||
*/
|
||||
public void setLa1(double la1) {
|
||||
this.la1 = la1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets lo1
|
||||
*
|
||||
* @return lo1 longitude value
|
||||
*/
|
||||
public double getLo1() {
|
||||
return lo1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets lo1
|
||||
*
|
||||
* @param lo1
|
||||
* lo1 longitude value
|
||||
*/
|
||||
public void setLo1(double lo1) {
|
||||
this.lo1 = lo1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets lov
|
||||
*
|
||||
* @return Lov longitude value
|
||||
*/
|
||||
public double getLov() {
|
||||
return lov;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets lov
|
||||
*
|
||||
* @param lov
|
||||
* lov longitude value
|
||||
*/
|
||||
public void setLov(double lov) {
|
||||
this.lov = lov;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dx
|
||||
*
|
||||
* @return The dx value
|
||||
*/
|
||||
public double getDx() {
|
||||
return dx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dx
|
||||
*
|
||||
* @param dx
|
||||
* The dx value
|
||||
*/
|
||||
public void setDx(double dx) {
|
||||
this.dx = dx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dy
|
||||
*
|
||||
* @return The dy value
|
||||
*/
|
||||
public double getDy() {
|
||||
return dy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dy
|
||||
*
|
||||
* @param dy
|
||||
* The dy value
|
||||
*/
|
||||
public void setDy(double dy) {
|
||||
this.dy = dy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets latin1
|
||||
*
|
||||
* @return Gets the latin1 latitude value
|
||||
*/
|
||||
public double getLatin1() {
|
||||
return latin1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets latin1
|
||||
*
|
||||
* @param latin1
|
||||
* The latin1 latitude value
|
||||
*/
|
||||
public void setLatin1(double latin1) {
|
||||
this.latin1 = latin1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets latin2
|
||||
*
|
||||
* @return The latin2 latitude value
|
||||
*/
|
||||
public double getLatin2() {
|
||||
return latin2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets latin2
|
||||
*
|
||||
* @param latin2
|
||||
* The latin2 latitude value
|
||||
*/
|
||||
public void setLatin2(double latin2) {
|
||||
this.latin2 = latin2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dx/dy spacing unit
|
||||
*
|
||||
* @return The dx/dy spacing unit
|
||||
*/
|
||||
public String getSpacingUnit() {
|
||||
return spacingUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dx/dy spacing unit
|
||||
*
|
||||
* @param spacingUnit
|
||||
* The dx/dy spacing unit
|
||||
*/
|
||||
public void setSpacingUnit(String spacingUnit) {
|
||||
this.spacingUnit = spacingUnit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
LambertConformalNcgridCoverage other = (LambertConformalNcgridCoverage) obj;
|
||||
if (Double.doubleToLongBits(dx) != Double.doubleToLongBits(other.dx))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(dy) != Double.doubleToLongBits(other.dy))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(la1) != Double.doubleToLongBits(other.la1))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(latin1) != Double
|
||||
.doubleToLongBits(other.latin1))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(latin2) != Double
|
||||
.doubleToLongBits(other.latin2))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(lo1) != Double.doubleToLongBits(other.lo1))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(lov) != Double.doubleToLongBits(other.lov))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(majorAxis) != Double
|
||||
.doubleToLongBits(other.majorAxis))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(minorAxis) != Double
|
||||
.doubleToLongBits(other.minorAxis))
|
||||
return false;
|
||||
if (nx == null) {
|
||||
if (other.nx != null)
|
||||
return false;
|
||||
} else if (!nx.equals(other.nx))
|
||||
return false;
|
||||
if (ny == null) {
|
||||
if (other.ny != null)
|
||||
return false;
|
||||
} else if (!ny.equals(other.ny))
|
||||
return false;
|
||||
if (spacingUnit == null) {
|
||||
if (other.spacingUnit != null)
|
||||
return false;
|
||||
} else if (!spacingUnit.equals(other.spacingUnit))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,497 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.SI;
|
||||
import javax.measure.unit.Unit;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.geotools.referencing.crs.DefaultGeographicCRS;
|
||||
import org.geotools.referencing.datum.DefaultGeodeticDatum;
|
||||
import org.geotools.referencing.datum.DefaultPrimeMeridian;
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* Defines a Lat/Lon grid coverage. This class is generally used to describe
|
||||
* grids described by GDS Template 0 as specified in Table 3.1
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
* 9/08/11 X. Guo Skip correct Lon value after add new column
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ncgrib_latlon_coverages")
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class LatLonNcgridCoverage extends NcgridCoverage {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(LatLonNcgridCoverage.class);
|
||||
|
||||
private static final long serialVersionUID = 8371251040172233074L;
|
||||
|
||||
private static final DefaultGeographicCRS WGS84 = DefaultGeographicCRS.WGS84;
|
||||
|
||||
/** The name of the projection */
|
||||
public static final String PROJECTION_TYPE = "LatLon";
|
||||
|
||||
/** Number of points along a parallel */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private Integer nx;
|
||||
|
||||
/** Number of points along a meridian */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private Integer ny;
|
||||
|
||||
/** Latitude of first grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double la1;
|
||||
|
||||
/** Longitude of the first grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double lo1;
|
||||
|
||||
/** Latitude of the last grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double la2;
|
||||
|
||||
/** Longitude of the last grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double lo2;
|
||||
|
||||
/** I direction increment */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double dx;
|
||||
|
||||
/** J direction increment */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double dy;
|
||||
|
||||
/** Spacing unit of dx and dy */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String spacingUnit;
|
||||
|
||||
@Override
|
||||
public int generateHash() {
|
||||
HashCodeBuilder hashBuilder = new HashCodeBuilder();
|
||||
if (getName() == null) {
|
||||
generateName();
|
||||
}
|
||||
hashBuilder.append(name);
|
||||
hashBuilder.append(nx);
|
||||
hashBuilder.append(ny);
|
||||
hashBuilder.append(la1);
|
||||
hashBuilder.append(lo1);
|
||||
hashBuilder.append(la2);
|
||||
hashBuilder.append(lo2);
|
||||
return hashBuilder.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() throws GribException {
|
||||
double maxLon;
|
||||
double minLat = MapUtil.correctLat(la1);
|
||||
double maxLat = MapUtil.correctLat(la2);
|
||||
double minLon = MapUtil.correctLon(lo1);
|
||||
if (lo2 >= 360.0) {
|
||||
maxLon = lo2;
|
||||
} else {
|
||||
maxLon = MapUtil.correctLon(lo2);
|
||||
}
|
||||
if (maxLon < minLon) {
|
||||
maxLon += 360.0;
|
||||
}
|
||||
if (maxLon > 180) {
|
||||
crs = new DefaultGeographicCRS(new DefaultGeodeticDatum("WGS84",
|
||||
WGS84.getDatum().getEllipsoid(), new DefaultPrimeMeridian(
|
||||
"DateLine", 180.0)), WGS84.getCoordinateSystem());
|
||||
} else {
|
||||
crs = WGS84;
|
||||
}
|
||||
crsWKT = crs.toWKT();
|
||||
try {
|
||||
double xOffset = dx * 0.5;
|
||||
double yOffset = dy * 0.5;
|
||||
geometry = MapUtil.createGeometry(minLat + yOffset, minLon
|
||||
- xOffset, maxLat - yOffset, maxLon + xOffset);
|
||||
} catch (Exception e) {
|
||||
throw new GribException("Error creating geometry", e);
|
||||
}
|
||||
id = generateHash();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateName() {
|
||||
|
||||
String nameModel_gridid = "" + (int) (la1 * 10.)
|
||||
+ (int) ((lo1 + la2 + lo2) * 100.);
|
||||
String nameAndDescription = "Unknown LatLon " + nx + " X " + ny + " "
|
||||
+ nameModel_gridid + " " + getProjectionType() + " grid";
|
||||
// System.out.println(" nameModel_gridid=" + nameModel_gridid);
|
||||
this.setName(nameModel_gridid);
|
||||
// this.setName(nameAndDescription);
|
||||
this.setDescription(nameAndDescription);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectionType() {
|
||||
return PROJECTION_TYPE;
|
||||
}
|
||||
|
||||
public Integer getNx() {
|
||||
return nx;
|
||||
}
|
||||
|
||||
public Integer getNy() {
|
||||
return ny;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NcgridCoverage trim(SubNcgrid subGrid) {
|
||||
LatLonNcgridCoverage rval = new LatLonNcgridCoverage();
|
||||
rval.description = this.description;
|
||||
rval.dx = this.dx;
|
||||
rval.dy = this.dy;
|
||||
rval.spacingUnit = this.spacingUnit;
|
||||
int startX = subGrid.getStartX();
|
||||
int startY = subGrid.getStartY();
|
||||
rval.nx = subGrid.getNX();
|
||||
rval.ny = subGrid.getNY();
|
||||
|
||||
// validate bounds are ok
|
||||
if (startX + rval.nx > this.nx) {
|
||||
rval.nx = this.nx - startX;
|
||||
}
|
||||
if (startY + rval.ny > this.ny) {
|
||||
rval.ny = this.ny - startY;
|
||||
}
|
||||
|
||||
rval.name = this.name + "SubGrid";
|
||||
|
||||
try {
|
||||
if (spacingUnit.equals("degree")) {
|
||||
// refigure corner points directly using degrees
|
||||
rval.lo1 = this.lo1 + dx * startX;
|
||||
rval.lo2 = rval.lo1 + dx * rval.nx;
|
||||
|
||||
if (this.la1 < this.la2) {
|
||||
// this is LL, subgrid is UL
|
||||
rval.la1 = this.la2 - dy * (startY + rval.ny);
|
||||
rval.la2 = rval.la1 + dy * rval.ny;
|
||||
} else {
|
||||
// this is UL, subgrid is UL
|
||||
rval.la1 = this.la1 - dy * startY;
|
||||
rval.la2 = rval.la1 - dy * rval.ny;
|
||||
}
|
||||
} else {
|
||||
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
|
||||
if (spacingUnitObj.isCompatible(SI.METRE)) {
|
||||
UnitConverter converter = spacingUnitObj
|
||||
.getConverterTo(SI.METRE);
|
||||
double dxMeter = converter.convert(dx);
|
||||
double dyMeter = converter.convert(dy);
|
||||
MathTransform fromLatLon = MapUtil
|
||||
.getTransformFromLatLon(crs);
|
||||
MathTransform toLatLon = fromLatLon.inverse();
|
||||
// get UL
|
||||
boolean thisLL = (this.la1 < this.la2);
|
||||
double upperLat = thisLL ? this.la2 : this.la1;
|
||||
double[] tmp1 = new double[] { this.lo1, upperLat, 0.0, 0.0 };
|
||||
double[] tmp2 = new double[4];
|
||||
fromLatLon.transform(tmp1, 0, tmp2, 0, 1);
|
||||
// tmp[0/1] is UL
|
||||
tmp2[0] += dxMeter * startX;
|
||||
tmp2[1] -= dyMeter * startY;
|
||||
// tmp[2/3] is LR
|
||||
tmp2[2] = tmp2[0] + dxMeter * rval.nx;
|
||||
tmp2[3] = tmp2[1] - dyMeter * rval.ny;
|
||||
toLatLon.transform(tmp2, 0, tmp1, 0, 2);
|
||||
rval.setLo1(tmp1[0]);
|
||||
rval.setLo2(tmp1[2]);
|
||||
|
||||
if (thisLL) {
|
||||
rval.setLa1(tmp1[3]);
|
||||
rval.setLa2(tmp1[1]);
|
||||
} else {
|
||||
rval.setLa1(tmp1[1]);
|
||||
rval.setLa2(tmp1[3]);
|
||||
}
|
||||
rval.setId(rval.hashCode());
|
||||
} else {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Error creating sub grid definition ["
|
||||
+ subGrid.getModelName()
|
||||
+ "], units are not compatible with meter ["
|
||||
+ spacingUnit + "]");
|
||||
rval = null;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error creating sub grid definition", e);
|
||||
rval = null;
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets nx
|
||||
*
|
||||
* @param nx
|
||||
* The nx value
|
||||
*/
|
||||
public void setNx(Integer nx) {
|
||||
this.nx = nx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets ny
|
||||
*
|
||||
* @param ny
|
||||
* The ny value
|
||||
*/
|
||||
public void setNy(Integer ny) {
|
||||
this.ny = ny;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets la1
|
||||
*
|
||||
* @return The la1 latitude value
|
||||
*/
|
||||
public double getLa1() {
|
||||
return la1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets la1
|
||||
*
|
||||
* @param la1
|
||||
* The la1 latitude value
|
||||
*/
|
||||
public void setLa1(double la1) {
|
||||
this.la1 = la1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets lo1
|
||||
*
|
||||
* @return The lo1 longitude value
|
||||
*/
|
||||
public double getLo1() {
|
||||
return lo1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets lo1
|
||||
*
|
||||
* @param lo1
|
||||
* The lo1 longitude value
|
||||
*/
|
||||
public void setLo1(double lo1) {
|
||||
this.lo1 = lo1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets la2
|
||||
*
|
||||
* @return The la2 latitude value
|
||||
*/
|
||||
public double getLa2() {
|
||||
return la2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets la1
|
||||
*
|
||||
* @param la2
|
||||
* The la2 latitude value
|
||||
*/
|
||||
public void setLa2(double la2) {
|
||||
this.la2 = la2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets lo2
|
||||
*
|
||||
* @return The lo2 longitude value
|
||||
*/
|
||||
public double getLo2() {
|
||||
return lo2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets lo2
|
||||
*
|
||||
* @param lo2
|
||||
* The lo2 longitude value
|
||||
*/
|
||||
public void setLo2(double lo2) {
|
||||
this.lo2 = lo2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dx
|
||||
*
|
||||
* @return The dx value
|
||||
*/
|
||||
public double getDx() {
|
||||
return dx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dx
|
||||
*
|
||||
* @param dx
|
||||
* The dx value
|
||||
*/
|
||||
public void setDx(double dx) {
|
||||
this.dx = dx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dy
|
||||
*
|
||||
* @return The dy value
|
||||
*/
|
||||
public double getDy() {
|
||||
return dy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dy
|
||||
*
|
||||
* @param dy
|
||||
* The dy value
|
||||
*/
|
||||
public void setDy(double dy) {
|
||||
this.dy = dy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dx/dy spacing unit
|
||||
*
|
||||
* @return The dx/dy spacing unit
|
||||
*/
|
||||
public String getSpacingUnit() {
|
||||
return spacingUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dx/dy spacing unit
|
||||
*
|
||||
* @param spacingUnit
|
||||
*/
|
||||
public void setSpacingUnit(String spacingUnit) {
|
||||
this.spacingUnit = spacingUnit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
LatLonNcgridCoverage other = (LatLonNcgridCoverage) obj;
|
||||
if (Double.doubleToLongBits(dx) != Double.doubleToLongBits(other.dx))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(dy) != Double.doubleToLongBits(other.dy))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(la1) != Double.doubleToLongBits(other.la1))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(la2) != Double.doubleToLongBits(other.la2))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(lo1) != Double.doubleToLongBits(other.lo1))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(lo2) != Double.doubleToLongBits(other.lo2))
|
||||
return false;
|
||||
if (nx == null) {
|
||||
if (other.nx != null)
|
||||
return false;
|
||||
} else if (!nx.equals(other.nx))
|
||||
return false;
|
||||
if (ny == null) {
|
||||
if (other.ny != null)
|
||||
return false;
|
||||
} else if (!ny.equals(other.ny))
|
||||
return false;
|
||||
if (spacingUnit == null) {
|
||||
if (other.spacingUnit != null)
|
||||
return false;
|
||||
} else if (!spacingUnit.equals(other.spacingUnit))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,560 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.SI;
|
||||
import javax.measure.unit.Unit;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* Defines a Mercator grid coverage. This class is generally used to describe
|
||||
* grids described by GDS Template 10 as specified in Table 3.1
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ncgrib_mercator_coverages")
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class MercatorNcgridCoverage extends NcgridCoverage {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(MercatorNcgridCoverage.class);
|
||||
|
||||
private static final long serialVersionUID = 3140441023975157052L;
|
||||
|
||||
/** The name of the projection */
|
||||
public static final String PROJECTION_TYPE = "Mercator";
|
||||
|
||||
/** The minor axis of the earth */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double minorAxis;
|
||||
|
||||
/** The major axis of the earth */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double majorAxis;
|
||||
|
||||
/** Number of points along a parallel */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private Integer nx;
|
||||
|
||||
/** Number of points along a meridian */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private Integer ny;
|
||||
|
||||
/** Latitude of the first grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double la1;
|
||||
|
||||
/** Longitude of the first grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double lo1;
|
||||
|
||||
/**
|
||||
* latitude at which the Mercator projection intersects the Earth (Latitude
|
||||
* where Di and Dj are specified)
|
||||
*/
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double latin;
|
||||
|
||||
/** Latitude of the last grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double la2;
|
||||
|
||||
/** Longitude of the last grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double lo2;
|
||||
|
||||
/** Longitudinal direction grid length */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double dx;
|
||||
|
||||
/** Latitudinal direction grid length */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double dy;
|
||||
|
||||
/** Spacing unit of dx and dy */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String spacingUnit;
|
||||
|
||||
@Override
|
||||
public int generateHash() {
|
||||
HashCodeBuilder hashBuilder = new HashCodeBuilder();
|
||||
hashBuilder.append(nx);
|
||||
hashBuilder.append(ny);
|
||||
hashBuilder.append(la1);
|
||||
hashBuilder.append(lo1);
|
||||
hashBuilder.append(latin);
|
||||
hashBuilder.append(la2);
|
||||
hashBuilder.append(lo2);
|
||||
hashBuilder.append(dx);
|
||||
hashBuilder.append(dy);
|
||||
return hashBuilder.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() throws GribException {
|
||||
double meridian = (lo1 + lo2) / 2;
|
||||
if (lo2 < lo1) {
|
||||
meridian += 180;
|
||||
}
|
||||
if (meridian > 180) {
|
||||
meridian -= 360;
|
||||
}
|
||||
crs = MapUtil.constructMercator(majorAxis, minorAxis, latin, meridian);
|
||||
crsWKT = crs.toWKT();
|
||||
try {
|
||||
// geometry = MapUtil.createGeometry(la1, lo1, la2, lo2);
|
||||
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
|
||||
if (spacingUnitObj.isCompatible(SI.METRE)) {
|
||||
UnitConverter converter = spacingUnitObj
|
||||
.getConverterTo(SI.METRE);
|
||||
geometry = MapUtil.createGeometry(crs, la1, lo1,
|
||||
converter.convert(dx), converter.convert(dy), nx, ny);
|
||||
} else {
|
||||
throw new GribException("Unable to convert " + spacingUnit
|
||||
+ " to meters while creating geometry!");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new GribException("Error creating geometry", e);
|
||||
}
|
||||
id = generateHash();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateName() {
|
||||
String nameAndDescription = "Unknown Mercator " + nx + " X " + ny + " "
|
||||
+ Math.round(dx) + " " + spacingUnit + " "
|
||||
+ getProjectionType() + " grid";
|
||||
String nameModel_gridid = "" + nx + ny
|
||||
+ Integer.toString((int) (la1 + la2 + lo1 + lo2));
|
||||
this.setName(nameModel_gridid);
|
||||
// this.setName(nameAndDescription);
|
||||
this.setDescription(nameAndDescription);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NcgridCoverage trim(SubNcgrid subGrid) {
|
||||
MercatorNcgridCoverage rval = new MercatorNcgridCoverage();
|
||||
rval.description = this.description;
|
||||
rval.dx = this.dx;
|
||||
rval.dy = this.dy;
|
||||
rval.spacingUnit = this.spacingUnit;
|
||||
rval.latin = this.latin;
|
||||
rval.majorAxis = this.majorAxis;
|
||||
rval.minorAxis = this.minorAxis;
|
||||
int startX = subGrid.getStartX();
|
||||
int startY = subGrid.getStartY();
|
||||
rval.nx = subGrid.getNX();
|
||||
rval.ny = subGrid.getNY();
|
||||
|
||||
// validate bounds are ok
|
||||
if (startX + rval.nx > this.nx) {
|
||||
rval.nx = this.nx - startX;
|
||||
}
|
||||
if (startY + rval.ny > this.ny) {
|
||||
rval.ny = this.ny - startY;
|
||||
}
|
||||
|
||||
rval.setName(this.name + "SubGrid");
|
||||
|
||||
try {
|
||||
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
|
||||
if (spacingUnitObj.isCompatible(SI.METRE)) {
|
||||
UnitConverter converter = spacingUnitObj
|
||||
.getConverterTo(SI.METRE);
|
||||
double dxMeter = converter.convert(dx);
|
||||
double dyMeter = converter.convert(dy);
|
||||
MathTransform fromLatLon = MapUtil.getTransformFromLatLon(crs);
|
||||
MathTransform toLatLon = fromLatLon.inverse();
|
||||
// get UL
|
||||
boolean thisLL = (this.la1 < this.la2);
|
||||
double upperLat = thisLL ? this.la2 : this.la1;
|
||||
double[] tmp1 = new double[] { this.lo1, upperLat, 0.0, 0.0 };
|
||||
double[] tmp2 = new double[4];
|
||||
fromLatLon.transform(tmp1, 0, tmp2, 0, 1);
|
||||
// tmp[0/1] is UL
|
||||
tmp2[0] += dxMeter * startX;
|
||||
tmp2[1] -= dyMeter * startY;
|
||||
// tmp[2/3] is LR
|
||||
tmp2[2] = tmp2[0] + dxMeter * rval.nx;
|
||||
tmp2[3] = tmp2[1] - dyMeter * rval.ny;
|
||||
toLatLon.transform(tmp2, 0, tmp1, 0, 2);
|
||||
rval.setLo1(tmp1[0]);
|
||||
rval.setLo2(tmp1[2]);
|
||||
|
||||
if (thisLL) {
|
||||
rval.setLa1(tmp1[3]);
|
||||
rval.setLa2(tmp1[1]);
|
||||
} else {
|
||||
rval.setLa1(tmp1[1]);
|
||||
rval.setLa2(tmp1[3]);
|
||||
}
|
||||
rval.setId(rval.hashCode());
|
||||
} else {
|
||||
statusHandler.handle(
|
||||
Priority.PROBLEM,
|
||||
"Error creating sub grid definition ["
|
||||
+ subGrid.getModelName()
|
||||
+ "], units are not compatible with meter ["
|
||||
+ spacingUnit + "]");
|
||||
rval = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error creating sub grid definition", e);
|
||||
rval = null;
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectionType() {
|
||||
return PROJECTION_TYPE;
|
||||
}
|
||||
|
||||
public Integer getNx() {
|
||||
return nx;
|
||||
}
|
||||
|
||||
public Integer getNy() {
|
||||
return ny;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets nx
|
||||
*
|
||||
* @param nx
|
||||
* The nx value
|
||||
*/
|
||||
public void setNx(Integer nx) {
|
||||
this.nx = nx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ny
|
||||
*
|
||||
* @param ny
|
||||
* The ny value
|
||||
*/
|
||||
public void setNy(Integer ny) {
|
||||
this.ny = ny;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets la1
|
||||
*
|
||||
* @return The la1 latitude value
|
||||
*/
|
||||
public double getLa1() {
|
||||
return la1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set la1
|
||||
*
|
||||
* @param la1
|
||||
* The la1 latitude value
|
||||
*/
|
||||
public void setLa1(double la1) {
|
||||
this.la1 = la1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets lo1
|
||||
*
|
||||
* @return The lo1 value
|
||||
*/
|
||||
public double getLo1() {
|
||||
return lo1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets lo1
|
||||
*
|
||||
* @param lo1
|
||||
* The l1 value
|
||||
*/
|
||||
public void setLo1(double lo1) {
|
||||
this.lo1 = lo1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets latin
|
||||
*
|
||||
* @return The latin latitude value
|
||||
*/
|
||||
public double getLatin() {
|
||||
return latin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets latin
|
||||
*
|
||||
* @param latin
|
||||
* The latin latitude value
|
||||
*/
|
||||
public void setLatin(double latin) {
|
||||
this.latin = latin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets la2
|
||||
*
|
||||
* @return The la2 latitude value
|
||||
*/
|
||||
public double getLa2() {
|
||||
return la2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets la2
|
||||
*
|
||||
* @param la2
|
||||
* The la2 latitude value
|
||||
*/
|
||||
public void setLa2(double la2) {
|
||||
this.la2 = la2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets lo2
|
||||
*
|
||||
* @return The lo2 latitude value
|
||||
*/
|
||||
public double getLo2() {
|
||||
return lo2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets lo2
|
||||
*
|
||||
* @param lo2
|
||||
* The lo2 longitude value
|
||||
*/
|
||||
public void setLo2(double lo2) {
|
||||
this.lo2 = lo2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dx
|
||||
*
|
||||
* @return The dx value
|
||||
*/
|
||||
public double getDx() {
|
||||
return dx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dx
|
||||
*
|
||||
* @param dx
|
||||
* The dx value
|
||||
*/
|
||||
public void setDx(double dx) {
|
||||
this.dx = dx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dy
|
||||
*
|
||||
* @return The dy value
|
||||
*/
|
||||
public double getDy() {
|
||||
return dy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dy
|
||||
*
|
||||
* @param dy
|
||||
* The dy value
|
||||
*/
|
||||
public void setDy(double dy) {
|
||||
this.dy = dy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dx/dy spacing unit
|
||||
*
|
||||
* @return The dx/dy spacing unit
|
||||
*/
|
||||
public String getSpacingUnit() {
|
||||
return spacingUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dx/dy spacing unit
|
||||
*
|
||||
* @param spacingUnit
|
||||
* The dx/dy spacing unit
|
||||
*/
|
||||
public void setSpacingUnit(String spacingUnit) {
|
||||
this.spacingUnit = spacingUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minor axis
|
||||
*
|
||||
* @return The minor axis value
|
||||
*/
|
||||
public double getMinorAxis() {
|
||||
return minorAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minor axis
|
||||
*
|
||||
* @param minorAxis
|
||||
* The minor axis value
|
||||
*/
|
||||
public void setMinorAxis(double minorAxis) {
|
||||
this.minorAxis = minorAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the major axis
|
||||
*
|
||||
* @return The major axis value
|
||||
*/
|
||||
public double getMajorAxis() {
|
||||
return majorAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the major axis
|
||||
*
|
||||
* @param majorAxis
|
||||
* The major axis value
|
||||
*/
|
||||
public void setMajorAxis(double majorAxis) {
|
||||
this.majorAxis = majorAxis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
MercatorNcgridCoverage other = (MercatorNcgridCoverage) obj;
|
||||
if (Double.doubleToLongBits(dx) != Double.doubleToLongBits(other.dx))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(dy) != Double.doubleToLongBits(other.dy))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(la1) != Double.doubleToLongBits(other.la1))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(la2) != Double.doubleToLongBits(other.la2))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(latin) != Double
|
||||
.doubleToLongBits(other.latin))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(lo1) != Double.doubleToLongBits(other.lo1))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(lo2) != Double.doubleToLongBits(other.lo2))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(majorAxis) != Double
|
||||
.doubleToLongBits(other.majorAxis))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(minorAxis) != Double
|
||||
.doubleToLongBits(other.minorAxis))
|
||||
return false;
|
||||
if (nx == null) {
|
||||
if (other.nx != null)
|
||||
return false;
|
||||
} else if (!nx.equals(other.nx))
|
||||
return false;
|
||||
if (ny == null) {
|
||||
if (other.ny != null)
|
||||
return false;
|
||||
} else if (!ny.equals(other.ny))
|
||||
return false;
|
||||
if (spacingUnit == null) {
|
||||
if (other.spacingUnit != null)
|
||||
return false;
|
||||
} else if (!spacingUnit.equals(other.spacingUnit))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,295 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.Transient;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.referencing.CRS;
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.Polygon;
|
||||
|
||||
/**
|
||||
* Base class for encapsulating grib spatial information
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 07, 2009 1994 bphillip Initial Creation
|
||||
* May 23, 2012 xguo Merged 4 coverage tables into one
|
||||
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
|
||||
* spatial
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public abstract class NcgridCoverage extends PersistableDataObject implements
|
||||
ISpatialObject {
|
||||
|
||||
private static final long serialVersionUID = -1355232934065074837L;
|
||||
|
||||
/** The id for this grid. This value is generated in the initialize method **/
|
||||
@Id
|
||||
@DynamicSerializeElement
|
||||
protected int id;
|
||||
|
||||
/** The name of the grid */
|
||||
@Column(length = 2047)
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
protected String name;
|
||||
|
||||
/** A description of the grid coverage */
|
||||
@Column(length = 3071)
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
protected String description;
|
||||
|
||||
/** Geometry object holding the corner points of the grid */
|
||||
@Column(name = "the_geom")
|
||||
@Type(type = "org.hibernatespatial.GeometryUserType")
|
||||
@DynamicSerializeElement
|
||||
protected Polygon geometry;
|
||||
|
||||
/** The CRS as a WKT String */
|
||||
@Column(name = "crs", length = 2047)
|
||||
@DynamicSerializeElement
|
||||
protected String crsWKT;
|
||||
|
||||
/** The CRS object */
|
||||
@Transient
|
||||
protected CoordinateReferenceSystem crs;
|
||||
|
||||
/** The Grid geometry */
|
||||
@Transient
|
||||
protected transient GridGeometry2D gridGeometry;
|
||||
|
||||
/**
|
||||
* Creates an empty GridCoverage object
|
||||
*/
|
||||
protected NcgridCoverage() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Coverage Information Not Specified yet";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return generateHash();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a hash code based on selected fields in the grid coverage
|
||||
* object. The fields used will vary among different projections.
|
||||
*
|
||||
* @return The hash code generated from selected fields in the object
|
||||
*/
|
||||
public abstract int generateHash();
|
||||
|
||||
/**
|
||||
* Initializes the grib coverage object. Initialization should entail
|
||||
* creation of the crs and geometry object as well as assigning the id field
|
||||
*
|
||||
* @throws GribException
|
||||
* If problems occur while creating the crs, geometry, or the id
|
||||
*/
|
||||
public abstract void initialize() throws GribException;
|
||||
|
||||
/**
|
||||
* Gets the name of the projection. The projection type is specified by each
|
||||
* subclass and accessed through this method.
|
||||
*
|
||||
* @return The name/type of the projection
|
||||
*/
|
||||
public abstract String getProjectionType();
|
||||
|
||||
/**
|
||||
* If this grid coverage object describes a grid that is not predefined,
|
||||
* this method is used to generate and assign a descriptive name.
|
||||
*/
|
||||
public abstract void generateName();
|
||||
|
||||
/**
|
||||
* Trim this GridCoverage to a sub grid.
|
||||
*
|
||||
* @param subGrid
|
||||
* @return
|
||||
*/
|
||||
public abstract NcgridCoverage trim(SubNcgrid subGrid);
|
||||
|
||||
public Polygon getGeometry() {
|
||||
return geometry;
|
||||
}
|
||||
|
||||
public CoordinateReferenceSystem getCrs() {
|
||||
if (crs == null) {
|
||||
try {
|
||||
this.crs = CRS.parseWKT(crsWKT);
|
||||
} catch (FactoryException e) {
|
||||
this.crs = null;
|
||||
}
|
||||
}
|
||||
return crs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id
|
||||
*
|
||||
* @return The id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id
|
||||
*
|
||||
* @param id
|
||||
* The id
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name
|
||||
*
|
||||
* @return The name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name
|
||||
*
|
||||
* @param name
|
||||
* The name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the geometry
|
||||
*
|
||||
* @param geometry
|
||||
* The geometry
|
||||
*/
|
||||
public void setGeometry(Geometry geometry) {
|
||||
this.geometry = (Polygon) geometry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the CRS object
|
||||
*
|
||||
* @param crs
|
||||
* The crs object
|
||||
*/
|
||||
public void setCrs(CoordinateReferenceSystem crs) {
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CRS WKT object
|
||||
*
|
||||
* @return The CRS WKT object
|
||||
*/
|
||||
public String getCrsWKT() {
|
||||
return crsWKT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the CRS WKT object
|
||||
*
|
||||
* @param crsWKT
|
||||
*/
|
||||
public void setCrsWKT(String crsWKT) {
|
||||
this.crsWKT = crsWKT;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description
|
||||
*
|
||||
* @return The description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description
|
||||
*
|
||||
* @param description
|
||||
* The description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public GridGeometry2D getGridGeometry() {
|
||||
if (gridGeometry == null) {
|
||||
gridGeometry = MapUtil.getGridGeometry(this);
|
||||
}
|
||||
|
||||
return gridGeometry;
|
||||
}
|
||||
|
||||
public void setGridGeometry(GridGeometry2D gridGeometry) {
|
||||
this.gridGeometry = gridGeometry;
|
||||
}
|
||||
}
|
|
@ -1,472 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.SI;
|
||||
import javax.measure.unit.Unit;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* Defines a Polar Stereographic grid coverage. This class is generally used to
|
||||
* describe grids described by GDS Template 20 as specified in Table 3.1
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ncgrib_polarstereo_coverages")
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class PolarStereoNcgridCoverage extends NcgridCoverage {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(PolarStereoNcgridCoverage.class);
|
||||
|
||||
private static final long serialVersionUID = 2640862310607194072L;
|
||||
|
||||
/** The name of the projection */
|
||||
public static final String PROJECTION_TYPE = "Polar Stereographic";
|
||||
|
||||
/** The minor axis of the earth */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double minorAxis;
|
||||
|
||||
/** The major axis of the earth */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double majorAxis;
|
||||
|
||||
/** Number of points along the x-axis */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private Integer nx;
|
||||
|
||||
/** Number of points along the y-axis */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private Integer ny;
|
||||
|
||||
/** Latitude of the first grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double la1;
|
||||
|
||||
/** Longitude of the first grid point */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double lo1;
|
||||
|
||||
/** Orientation of the grid */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double lov;
|
||||
|
||||
/** X-direction grid length */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double dx;
|
||||
|
||||
/** Y-direction grid length */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private double dy;
|
||||
|
||||
/** Spacing unit of dx and dy */
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
private String spacingUnit;
|
||||
|
||||
@Override
|
||||
public int generateHash() {
|
||||
HashCodeBuilder hashBuilder = new HashCodeBuilder();
|
||||
hashBuilder.append(nx);
|
||||
hashBuilder.append(ny);
|
||||
hashBuilder.append(la1);
|
||||
hashBuilder.append(lo1);
|
||||
hashBuilder.append(lov);
|
||||
return hashBuilder.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() throws GribException {
|
||||
crs = MapUtil
|
||||
.constructNorthPolarStereo(majorAxis, minorAxis, 60.0, lov);
|
||||
crsWKT = crs.toWKT();
|
||||
try {
|
||||
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
|
||||
if (spacingUnitObj.isCompatible(SI.METRE)) {
|
||||
UnitConverter converter = spacingUnitObj
|
||||
.getConverterTo(SI.METRE);
|
||||
geometry = MapUtil.createGeometry(crs, la1, lo1, converter
|
||||
.convert(dx), converter.convert(dy), nx, ny);
|
||||
} else {
|
||||
throw new GribException("Unable to convert " + spacingUnit
|
||||
+ " to meters while creating geometry!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GribException("Error creating geometry", e);
|
||||
}
|
||||
id = generateHash();
|
||||
}
|
||||
|
||||
public void generateName() {
|
||||
String nameAndDescription = "Unknown " + nx + " X " + ny + " "
|
||||
+ Math.round(dx) + " " + spacingUnit + " "
|
||||
+ getProjectionType() + " grid";
|
||||
String nameModel_gridid = "" + (int)(la1*10.) + (int)(lo1*10.) + (int) ((la1+lo1+lov)*1000.);
|
||||
//System.out.println(" nameModel_gridid=" + nameModel_gridid);
|
||||
this.setName(nameModel_gridid);
|
||||
//this.setName(nameAndDescription);
|
||||
this.setDescription(nameAndDescription);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NcgridCoverage trim(SubNcgrid subGrid) {
|
||||
PolarStereoNcgridCoverage rval = new PolarStereoNcgridCoverage();
|
||||
rval.description = this.description;
|
||||
rval.dx = this.dx;
|
||||
rval.dy = this.dy;
|
||||
rval.spacingUnit = this.spacingUnit;
|
||||
rval.lov = this.lov;
|
||||
rval.majorAxis = this.majorAxis;
|
||||
rval.minorAxis = this.minorAxis;
|
||||
int startX = subGrid.getStartX();
|
||||
int startY = subGrid.getStartY();
|
||||
rval.nx = subGrid.getNX();
|
||||
rval.ny = subGrid.getNY();
|
||||
|
||||
// validate bounds are ok
|
||||
if (startX + rval.nx > this.nx) {
|
||||
rval.nx = this.nx - startX;
|
||||
}
|
||||
if (startY + rval.ny > this.ny) {
|
||||
rval.ny = this.ny - startY;
|
||||
}
|
||||
|
||||
rval.setName(this.name + "SubGrid");
|
||||
|
||||
try {
|
||||
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
|
||||
if (spacingUnitObj.isCompatible(SI.METRE)) {
|
||||
UnitConverter converter = spacingUnitObj
|
||||
.getConverterTo(SI.METRE);
|
||||
double dxMeter = converter.convert(dx);
|
||||
double dyMeter = converter.convert(dy);
|
||||
MathTransform fromLatLon = MapUtil.getTransformFromLatLon(crs);
|
||||
MathTransform toLatLon = fromLatLon.inverse();
|
||||
// this LL, subgrid defined in UL
|
||||
double[] tmp1 = new double[] { this.lo1, this.la1 };
|
||||
double[] tmp2 = new double[2];
|
||||
fromLatLon.transform(tmp1, 0, tmp2, 0, 1);
|
||||
tmp2[0] += dxMeter * startX;
|
||||
// need to determine max lat and decrement from there
|
||||
tmp2[1] += dyMeter * (this.ny - (startY + rval.ny));
|
||||
toLatLon.transform(tmp2, 0, tmp1, 0, 1);
|
||||
rval.setLo1(tmp1[0]);
|
||||
rval.setLa1(tmp1[1]);
|
||||
rval.setId(rval.hashCode());
|
||||
} else {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error creating sub grid definition ["
|
||||
+ subGrid.getModelName()
|
||||
+ "], units are not compatible with meter ["
|
||||
+ spacingUnit + "]");
|
||||
rval = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error creating sub grid definition", e);
|
||||
rval = null;
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
public String getProjectionType() {
|
||||
return PROJECTION_TYPE;
|
||||
}
|
||||
|
||||
public Integer getNx() {
|
||||
return nx;
|
||||
}
|
||||
|
||||
public Integer getNy() {
|
||||
return ny;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets nx
|
||||
*
|
||||
* @param nx
|
||||
* The nx value
|
||||
*/
|
||||
public void setNx(Integer nx) {
|
||||
this.nx = nx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets ny
|
||||
*
|
||||
* @param ny
|
||||
* The ny value
|
||||
*/
|
||||
public void setNy(Integer ny) {
|
||||
this.ny = ny;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets la1
|
||||
*
|
||||
* @return The la1 latitude value
|
||||
*/
|
||||
public double getLa1() {
|
||||
return la1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets la1
|
||||
*
|
||||
* @param la1
|
||||
* The la1 latitude value
|
||||
*/
|
||||
public void setLa1(double la1) {
|
||||
this.la1 = la1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets lo1
|
||||
*
|
||||
* @return The lo1 longitude value
|
||||
*/
|
||||
public double getLo1() {
|
||||
return lo1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets lo1
|
||||
*
|
||||
* @param lo1
|
||||
* The lo1 longitude value
|
||||
*/
|
||||
public void setLo1(double lo1) {
|
||||
this.lo1 = lo1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets lov
|
||||
*
|
||||
* @return The lov longitude value
|
||||
*/
|
||||
public double getLov() {
|
||||
return lov;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets lov
|
||||
*
|
||||
* @param lov
|
||||
* The lov longitude value
|
||||
*/
|
||||
public void setLov(double lov) {
|
||||
this.lov = lov;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dx
|
||||
*
|
||||
* @return The dx value
|
||||
*/
|
||||
public double getDx() {
|
||||
return dx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dx
|
||||
*
|
||||
* @param dx
|
||||
* The dx value
|
||||
*/
|
||||
public void setDx(double dx) {
|
||||
this.dx = dx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dy
|
||||
*
|
||||
* @return The dy value
|
||||
*/
|
||||
public double getDy() {
|
||||
return dy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dy
|
||||
*
|
||||
* @param dy
|
||||
* The dy value
|
||||
*/
|
||||
public void setDy(double dy) {
|
||||
this.dy = dy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dx/dy spacing unit
|
||||
*
|
||||
* @return The dx/dy spacing unit
|
||||
*/
|
||||
public String getSpacingUnit() {
|
||||
return spacingUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dx/dy spacing unit
|
||||
*
|
||||
* @param spacingUnit
|
||||
* The dx/dy spacing unit
|
||||
*/
|
||||
public void setSpacingUnit(String spacingUnit) {
|
||||
this.spacingUnit = spacingUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minor axis
|
||||
*
|
||||
* @return The minor axis value
|
||||
*/
|
||||
public double getMinorAxis() {
|
||||
return minorAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minor axis
|
||||
*
|
||||
* @param minorAxis
|
||||
* The minor axis value
|
||||
*/
|
||||
public void setMinorAxis(double minorAxis) {
|
||||
this.minorAxis = minorAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the major axis
|
||||
*
|
||||
* @return The major axis value
|
||||
*/
|
||||
public double getMajorAxis() {
|
||||
return majorAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the major axis
|
||||
*
|
||||
* @param majorAxis
|
||||
* The major axis value
|
||||
*/
|
||||
public void setMajorAxis(double majorAxis) {
|
||||
this.majorAxis = majorAxis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
PolarStereoNcgridCoverage other = (PolarStereoNcgridCoverage) obj;
|
||||
if (Double.doubleToLongBits(dx) != Double.doubleToLongBits(other.dx))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(dy) != Double.doubleToLongBits(other.dy))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(la1) != Double.doubleToLongBits(other.la1))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(lo1) != Double.doubleToLongBits(other.lo1))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(lov) != Double.doubleToLongBits(other.lov))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(majorAxis) != Double
|
||||
.doubleToLongBits(other.majorAxis))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(minorAxis) != Double
|
||||
.doubleToLongBits(other.minorAxis))
|
||||
return false;
|
||||
if (nx == null) {
|
||||
if (other.nx != null)
|
||||
return false;
|
||||
} else if (!nx.equals(other.nx))
|
||||
return false;
|
||||
if (ny == null) {
|
||||
if (other.ny != null)
|
||||
return false;
|
||||
} else if (!ny.equals(other.ny))
|
||||
return false;
|
||||
if (spacingUnit == null) {
|
||||
if (other.spacingUnit != null)
|
||||
return false;
|
||||
} else if (!spacingUnit.equals(other.spacingUnit))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* Objects describing various projections used with grib data
|
||||
*/
|
||||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections;
|
|
@ -1,106 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2006-2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
|
||||
/**
|
||||
* A sub grid definition
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 08, 2009 3177 rjpeter Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class SubNcgrid implements ISerializableObject {
|
||||
/** The model name */
|
||||
@XmlElement(required = true)
|
||||
private String modelName;
|
||||
|
||||
/** the upper left x the subgrid will start with */
|
||||
@XmlElement(required = true)
|
||||
private int startX;
|
||||
|
||||
/** the upper left y the subgrid will start with */
|
||||
@XmlElement(required = true)
|
||||
private int startY;
|
||||
|
||||
/** the width of the sub grid */
|
||||
@XmlElement(required = true)
|
||||
private int nX;
|
||||
|
||||
/** the height of the sub grid */
|
||||
@XmlElement(required = true)
|
||||
private int nY;
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public void setModelName(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
public int getStartX() {
|
||||
return startX;
|
||||
}
|
||||
|
||||
public void setStartX(int startX) {
|
||||
this.startX = startX;
|
||||
}
|
||||
|
||||
public int getStartY() {
|
||||
return startY;
|
||||
}
|
||||
|
||||
public void setStartY(int startY) {
|
||||
this.startY = startY;
|
||||
}
|
||||
|
||||
public int getNX() {
|
||||
return nX;
|
||||
}
|
||||
|
||||
public void setNX(int nx) {
|
||||
nX = nx;
|
||||
}
|
||||
|
||||
public int getNY() {
|
||||
return nY;
|
||||
}
|
||||
|
||||
public void setNY(int ny) {
|
||||
nY = ny;
|
||||
}
|
||||
}
|
|
@ -1,189 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib.util;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.Ncgrib1Parameter;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
|
||||
/**
|
||||
* Utility class for looking up Grib 1 Parameters
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 3/9/10 4758 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class Ncgrib1ParameterLookup {
|
||||
|
||||
/** The logger */
|
||||
protected transient Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
/** The singleton instance */
|
||||
private static Ncgrib1ParameterLookup instance;
|
||||
|
||||
/** The map of Grib 1 parameters */
|
||||
private Map<String, Ncgrib1Parameter> parameterMap;
|
||||
|
||||
/**
|
||||
* Gets the singleton instance of the Grib1ParameterLookup
|
||||
*
|
||||
* @return The singleton instance
|
||||
*/
|
||||
public static synchronized Ncgrib1ParameterLookup getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Ncgrib1ParameterLookup();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private constructor
|
||||
*/
|
||||
private Ncgrib1ParameterLookup() {
|
||||
parameterMap = new HashMap<String, Ncgrib1Parameter>();
|
||||
try {
|
||||
initParameterMap();
|
||||
} catch (GribException e) {
|
||||
logger.error("Unable to initialize ncgrib 1 parameter list!", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a grib 1 parameter
|
||||
*
|
||||
* @param center
|
||||
* The center
|
||||
* @param grib1TableVersion
|
||||
* The table version
|
||||
* @param grib1Value
|
||||
* The table value
|
||||
* @return The Grib1Parameter
|
||||
*/
|
||||
public Ncgrib1Parameter getParameter(int center, int grib1TableVersion,
|
||||
int grib1Value) {
|
||||
return parameterMap.get(getGrib1Hash(center, grib1TableVersion,
|
||||
grib1Value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the parameter map
|
||||
*
|
||||
* @throws GribException
|
||||
* If problems occur while creating the map
|
||||
*/
|
||||
private void initParameterMap() throws GribException {
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext commonStaticBase = pathMgr.getContext(
|
||||
LocalizationContext.LocalizationType.COMMON_STATIC,
|
||||
LocalizationContext.LocalizationLevel.BASE);
|
||||
|
||||
String path = "";
|
||||
try {
|
||||
path = pathMgr
|
||||
.getFile(
|
||||
commonStaticBase,
|
||||
"ncgrid" + File.separator
|
||||
+ "ncgrib1ParameterConvTable.xml")
|
||||
.getCanonicalPath();
|
||||
// System.out.println(" ncgrib1 path=" + path);
|
||||
} catch (IOException e) {
|
||||
throw new GribException("Error getting ncgrib1 model definitions",
|
||||
e);
|
||||
}
|
||||
|
||||
File parameterFile = new File(path);
|
||||
Ncgrib1ParameterSet parameterSet = null;
|
||||
try {
|
||||
if (parameterFile.exists()) {
|
||||
parameterSet = (Ncgrib1ParameterSet) SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(parameterFile.getPath());
|
||||
} else {
|
||||
ArrayList<Ncgrib1Parameter> emptyList = new ArrayList<Ncgrib1Parameter>();
|
||||
parameterSet = new Ncgrib1ParameterSet();
|
||||
parameterSet.setParameters(emptyList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GribException(
|
||||
"Unable to unmarshal ncgrib 1 parameters file");
|
||||
}
|
||||
|
||||
CoreDao dao = new CoreDao(DaoConfig.DEFAULT);
|
||||
for (Ncgrib1Parameter param : parameterSet.getParameters()) {
|
||||
parameterMap.put(getGrib1Hash(param), param);
|
||||
param.generateId();
|
||||
dao.persist(param);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a map key using the center ID, table version, and table value
|
||||
*
|
||||
* @param center
|
||||
* The center ID
|
||||
* @param grib1TableVersion
|
||||
* The table version
|
||||
* @param grib1Value
|
||||
* The table value
|
||||
* @return The hash key
|
||||
*/
|
||||
private String getGrib1Hash(int center, int grib1TableVersion,
|
||||
int grib1Value) {
|
||||
return String.valueOf(center) + "-" + String.valueOf(grib1TableVersion)
|
||||
+ "-" + String.valueOf(grib1Value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a map key using a Grib1Parameter
|
||||
*
|
||||
* @param param
|
||||
* The grib 1 parameter
|
||||
* @return The hash key
|
||||
*/
|
||||
private String getGrib1Hash(Ncgrib1Parameter param) {
|
||||
return getGrib1Hash(param.getCenter(), param.getGrib1TableVersion(),
|
||||
param.getGrib1Value());
|
||||
|
||||
}
|
||||
}
|
|
@ -1,74 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.Ncgrib1Parameter;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
|
||||
/**
|
||||
* The class used for unmarshalling the grib1 parameter conversion XML file.
|
||||
* ncgrib1ParameterConvTable.xml
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 3/9/10 4758 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
@XmlRootElement(name = "ncgrib1ParameterSet")
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class Ncgrib1ParameterSet implements ISerializableObject {
|
||||
|
||||
/** The unmarshalled grib 1 parameters */
|
||||
@XmlElements( { @XmlElement(name = "ncgrib1Parameter", type = Ncgrib1Parameter.class) })
|
||||
private ArrayList<Ncgrib1Parameter> parameters;
|
||||
|
||||
/**
|
||||
* @return the parameters
|
||||
*/
|
||||
public ArrayList<Ncgrib1Parameter> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parameters
|
||||
* the parameters to set
|
||||
*/
|
||||
public void setParameters(ArrayList<Ncgrib1Parameter> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
}
|
|
@ -1,196 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib.util;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
|
||||
/**
|
||||
* Load the ncgrib model xml file.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 3/12/10 4758 bphillip Initial creation
|
||||
* 10/13/10 276 llin Modified for NC GRIB.
|
||||
* 11/02/11 xguo Updated gridid
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class NcgribModelLookup {
|
||||
|
||||
/** The logger */
|
||||
protected transient Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
/** The singleton instance of NcgribModelLookup **/
|
||||
private static NcgribModelLookup instance;
|
||||
|
||||
/**
|
||||
* A map of the models. The key is a hash of the center, grid, and process
|
||||
* id
|
||||
*/
|
||||
private Map<Integer, NcgridModel> models;
|
||||
|
||||
/** A map of the models. The key is the title of the model */
|
||||
private Map<String, NcgridModel> modelsByName;
|
||||
|
||||
public static synchronized NcgribModelLookup getInstance() {
|
||||
if (instance == null) {
|
||||
// System.out.println("in reloading ncgribMolels.xml ....");
|
||||
instance = new NcgribModelLookup();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* If file has been modified, then reload it again
|
||||
*
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static void ReloadInstance() {
|
||||
instance = null;
|
||||
}
|
||||
|
||||
private NcgribModelLookup() {
|
||||
models = new HashMap<Integer, NcgridModel>();
|
||||
modelsByName = new HashMap<String, NcgridModel>();
|
||||
try {
|
||||
initModelList();
|
||||
} catch (GribException e) {
|
||||
logger.error("Unable to initialize model list!", e);
|
||||
}
|
||||
}
|
||||
|
||||
public NcgridModel getModel(int center, int subcenter, String grid,
|
||||
int process) {
|
||||
return models.get(toHash(center, subcenter, grid, process));
|
||||
}
|
||||
|
||||
public void setModel(int center, int subcenter, String grid, int process,
|
||||
String modelName) {
|
||||
NcgridModel model = new NcgridModel();
|
||||
modelsByName.put(modelName, model);
|
||||
models.put(toHash(center, subcenter, grid, process), model);
|
||||
}
|
||||
|
||||
public NcgridModel getModel(int center, int subcenter, int gridid,
|
||||
int process) {
|
||||
return getModel(center, subcenter, String.valueOf(gridid), process);
|
||||
}
|
||||
|
||||
public NcgridModel getModelByName(String name) {
|
||||
return modelsByName.get(name);
|
||||
}
|
||||
|
||||
public Map<String, NcgridModel> getModelByNameMap() {
|
||||
return modelsByName;
|
||||
}
|
||||
|
||||
private void initModelList() throws GribException {
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
|
||||
LocalizationContext commonStaticBase = pathMgr.getContext(
|
||||
LocalizationContext.LocalizationType.COMMON_STATIC,
|
||||
LocalizationContext.LocalizationLevel.BASE);
|
||||
|
||||
LocalizationContext commonStaticSite = pathMgr.getContext(
|
||||
LocalizationContext.LocalizationType.COMMON_STATIC,
|
||||
LocalizationContext.LocalizationLevel.SITE);
|
||||
|
||||
String path = "";
|
||||
String sitePath = "";
|
||||
try {
|
||||
path = pathMgr.getFile(commonStaticBase,
|
||||
"ncgrid" + File.separator + "ncgribModels.xml")
|
||||
.getCanonicalPath();
|
||||
// System.out.println("ncgribModels path=" + path);
|
||||
sitePath = pathMgr.getFile(commonStaticSite,
|
||||
"ncgrid" + File.separator + "ncgribModels.xml")
|
||||
.getCanonicalPath();
|
||||
} catch (IOException e) {
|
||||
logger.error("Error getting ncep grib model definitions", e);
|
||||
}
|
||||
File modelFile = new File(path);
|
||||
File siteModelFile = new File(sitePath);
|
||||
NcgridModelSet modelSet = null;
|
||||
try {
|
||||
if (modelFile.exists()) {
|
||||
modelSet = (NcgridModelSet) SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(modelFile.getPath());
|
||||
} else {
|
||||
ArrayList<NcgridModel> emptyList = new ArrayList<NcgridModel>();
|
||||
modelSet = new NcgridModelSet();
|
||||
modelSet.setModels(emptyList);
|
||||
}
|
||||
|
||||
// Add any models defined by the site
|
||||
if (siteModelFile.exists()) {
|
||||
List<NcgridModel> siteModels = ((NcgridModelSet) SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(siteModelFile.getPath()))
|
||||
.getModels();
|
||||
modelSet.addModels(siteModels);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GribException("Unable to unmarshal ncep grib models file");
|
||||
}
|
||||
|
||||
for (NcgridModel model : modelSet.getModels()) {
|
||||
modelsByName.put(model.getName(), model);
|
||||
Integer center = model.getCenter();
|
||||
Integer subCenter = Integer.parseInt(model.getSubCenter());
|
||||
String grid = model.getGrid();
|
||||
for (int process : model.getProcess()) {
|
||||
models.put(toHash(center, subCenter, grid, process), model);
|
||||
}
|
||||
}
|
||||
// System.out.println(" reload and init ncgribMolels.xml successfully ....");
|
||||
}
|
||||
|
||||
private int toHash(Integer center, Integer subcenter, String grid,
|
||||
Integer process) {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = PRIME * result + ((center == null) ? 0 : center.hashCode());
|
||||
result = PRIME * result + ((subcenter == null) ? 0 : center.hashCode());
|
||||
result = PRIME * result + ((grid == null) ? 0 : grid.hashCode());
|
||||
result = PRIME * result + ((process == null) ? 0 : process.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,154 +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 gov.noaa.nws.ncep.common.dataplugin.ncgrib.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
|
||||
/**
|
||||
* NcgridModel
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 3/12 T. Lee Initialized template
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class NcgridModel implements ISerializableObject {
|
||||
|
||||
/** The title of the model */
|
||||
@XmlElement
|
||||
private String title;
|
||||
|
||||
/** The model name */
|
||||
@XmlElement
|
||||
private String name;
|
||||
|
||||
/** The center associated with this model */
|
||||
@XmlElement
|
||||
private Integer center;
|
||||
|
||||
/** The NCEP grid associated with this model */
|
||||
@XmlElement
|
||||
private String grid;
|
||||
|
||||
@XmlElement
|
||||
private String subcenter;
|
||||
|
||||
/** The generating processes associated with this model */
|
||||
@XmlElementWrapper(name = "process")
|
||||
@XmlElement(name = "id")
|
||||
private ArrayList<Integer> process;
|
||||
|
||||
@XmlElement
|
||||
private String template = "NONE";
|
||||
|
||||
@XmlElement
|
||||
private String alias;
|
||||
|
||||
/**
|
||||
* The intrinsic temporal resolution of the data.
|
||||
*/
|
||||
@XmlElement
|
||||
private Integer dt;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getGrid() {
|
||||
return grid;
|
||||
}
|
||||
|
||||
public void setGrid(String grid) {
|
||||
this.grid = grid;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getProcess() {
|
||||
return process;
|
||||
}
|
||||
|
||||
public void setProcess(ArrayList<Integer> process) {
|
||||
this.process = process;
|
||||
}
|
||||
|
||||
public Integer getCenter() {
|
||||
return center;
|
||||
}
|
||||
|
||||
public void setCenter(Integer center) {
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
public String getSubCenter() {
|
||||
return this.subcenter;
|
||||
}
|
||||
|
||||
public void setSubCenter(String subcenter) {
|
||||
this.subcenter = subcenter;
|
||||
}
|
||||
|
||||
public String getTemplate() {
|
||||
return this.template;
|
||||
}
|
||||
|
||||
public void setTemplate(String template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public Integer getDt() {
|
||||
return dt;
|
||||
}
|
||||
|
||||
public void setDt(Integer dt) {
|
||||
this.dt = dt;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
|
||||
@XmlRootElement(name = "ncgribModelSet")
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class NcgridModelSet implements ISerializableObject {
|
||||
|
||||
/**
|
||||
* List of models for/from the XML.
|
||||
*/
|
||||
@XmlElements( { @XmlElement(name = "model", type = NcgridModel.class) })
|
||||
private ArrayList<NcgridModel> models;
|
||||
|
||||
/**
|
||||
* Returns the list of models.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public synchronized ArrayList<NcgridModel> getModels() {
|
||||
return models;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of models.
|
||||
*
|
||||
* @param models
|
||||
*/
|
||||
public synchronized void setModels(ArrayList<NcgridModel> models) {
|
||||
this.models = models;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds models to this set
|
||||
* @param models The models to add
|
||||
*/
|
||||
public synchronized void addModels(Collection<NcgridModel> models){
|
||||
this.models.addAll(models);
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@
|
|||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -5,38 +5,8 @@ Bundle-SymbolicName: gov.noaa.nws.ncep.edex.plugin.ncgrib
|
|||
Bundle-Version: 1.0.0.qualifier
|
||||
Eclipse-RegisterBuddy: com.raytheon.edex.common, com.raytheon.uf.common.serialization
|
||||
Bundle-Vendor: NOAA/NWS/NCEP
|
||||
Require-Bundle: javax.measure,
|
||||
javax.persistence,
|
||||
com.raytheon.edex.common,
|
||||
com.raytheon.uf.edex.decodertools;bundle-version="1.0.0",
|
||||
org.geotools,
|
||||
com.raytheon.edex.uengine,
|
||||
org.apache.commons.lang,
|
||||
org.apache.commons.configuration,
|
||||
org.apache.commons.beanutils,
|
||||
com.raytheon.uf.common.localization,
|
||||
com.raytheon.uf.common.serialization.comm,
|
||||
com.raytheon.uf.edex.python.decoder;bundle-version="1.11.26",
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib;bundle-version="1.0.0",
|
||||
ucar.nc2
|
||||
Import-Package: com.raytheon.uf.common.comm,
|
||||
com.raytheon.uf.common.dataplugin.level,
|
||||
com.raytheon.uf.common.derivparam.tree,
|
||||
com.raytheon.uf.common.status,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.request,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid,
|
||||
gov.noaa.nws.ncep.common.dataplugin.ncgrib.util,
|
||||
gov.noaa.nws.ncep.edex.common.dao,
|
||||
org.apache.camel,
|
||||
org.apache.commons.logging
|
||||
Export-Package: gov.noaa.nws.ncep.edex.objects.hibernate.ncgrib,
|
||||
gov.noaa.nws.ncep.edex.plugin.ncgrib,
|
||||
gov.noaa.nws.ncep.edex.plugin.ncgrib.dao,
|
||||
gov.noaa.nws.ncep.edex.plugin.ncgrib.notify,
|
||||
gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial,
|
||||
gov.noaa.nws.ncep.edex.uengine.tasks.ncgrib,
|
||||
gov.noaa.nws.ncep.edex.util.ncgrib
|
||||
Export-Package: gov.noaa.nws.ncep.edex.plugin.ncgrib
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Require-Bundle: org.apache.camel,
|
||||
com.raytheon.uf.common.localization,
|
||||
com.raytheon.uf.common.serialization
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
gov.noaa.nws.ncep.edex.util.ncgrib.NcgridLevels
|
||||
gov.noaa.nws.ncep.edex.util.ncgrib.Ncgrib1TableMap
|
||||
gov.noaa.nws.ncep.edex.util.ncgrib.NccompositeModel
|
||||
gov.noaa.nws.ncep.edex.util.grib1vcrd.Grib1Vcrd
|
||||
gov.noaa.nws.ncep.edex.util.grib1vcrd.Grib1VcrdList
|
File diff suppressed because it is too large
Load diff
|
@ -2,5 +2,4 @@ source.. = src/
|
|||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
res/,\
|
||||
NcgribDecoder.py
|
||||
res/
|
|
@ -1,38 +0,0 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
|
||||
<bean id="ncgribPathProvider" class="gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribPathProvider" />
|
||||
|
||||
<bean id="ncgribProperties" class="com.raytheon.uf.common.dataplugin.PluginProperties">
|
||||
<property name="pluginName" value="ncgrib" />
|
||||
<property name="pluginFQN" value="gov.noaa.nws.ncep.common.dataplugin.ncgrib" />
|
||||
<property name="dao" value="gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcgribDao" />
|
||||
<property name="record" value="gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord" />
|
||||
<property name="initializer"
|
||||
value="gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgribInitializer" />
|
||||
<property name="dependencyFQNs">
|
||||
<list>
|
||||
<value>com.raytheon.uf.common.dataplugin.level</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="pathProvider">
|
||||
<ref bean="ncgribPathProvider"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="ncgribRegistered" factory-bean="pluginRegistry" factory-method="register"
|
||||
depends-on="levelRegistered">
|
||||
<constructor-arg value="ncgrib"/>
|
||||
<constructor-arg ref="ncgribProperties"/>
|
||||
</bean>
|
||||
|
||||
<bean id="ncgribDecoder" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgribDecoder"/>
|
||||
|
||||
<bean id="NcLatLonDao" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcLatLonDao" />
|
||||
<bean id="NcMercatorDao" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcMercatorDao" />
|
||||
<bean id="NcPolarStereographicDao" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcPolarStereoDao" />
|
||||
<bean id="NcLambertConformalDao" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcLambertConformalDao" />
|
||||
<bean id="ncgribNotifyTransform" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.notify.NcgribNotifyTransform" />
|
||||
|
||||
<bean id="ncgridAssembler" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgridAssembler"/>
|
||||
</beans>
|
|
@ -1,10 +0,0 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
<bean id="gribDistRegistry" factory-bean="distributionSrv"
|
||||
factory-method="register">
|
||||
<constructor-arg value="ncgrib" />
|
||||
<constructor-arg value="jms-dist:queue:Ingest.Ncgrib" />
|
||||
</bean>
|
||||
</beans>
|
|
@ -0,0 +1,30 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean id="ncgribFilenameProcessor" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgribFileNameProcessor" />
|
||||
|
||||
<camelContext id="ncgrib-file-endpoint" xmlns="http://camel.apache.org/schema/spring"
|
||||
errorHandlerRef="errorHandler"
|
||||
autoStartup=false>
|
||||
|
||||
<endpoint id="gribFileEndpoint" uri="file:${edex.home}/data/sbn/grib?noop=true&idempotent=false" />
|
||||
|
||||
<route id="gribFileConsumerRoute">
|
||||
<from ref="gribFileEndpoint" />
|
||||
<bean ref="fileToString" />
|
||||
<bean ref="ncgribFilenameProcessor" />
|
||||
<setHeader headerName="pluginName">
|
||||
<constant>grid</constant>
|
||||
</setHeader>
|
||||
<to uri="jms-durable:queue:Ingest.GribSplit" />
|
||||
</route>
|
||||
|
||||
</camelContext>
|
||||
|
||||
<bean factory-bean="clusteredCamelContextMgr"
|
||||
factory-method="register">
|
||||
<constructor-arg ref="ncgrib-file-endpoint" />
|
||||
</bean>
|
||||
</beans>
|
|
@ -1,116 +0,0 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<!-- Done to force instantiation of the NcgribTables -->
|
||||
<bean id="ncgribTableLookup" class="gov.noaa.nws.ncep.edex.util.ncgrib.NcgribTableLookup" factory-method="getInstance" depends-on="ncgribRegistered" />
|
||||
|
||||
<bean id="ncgribNotifyTransform" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.notify.NcgribNotifyTransform" />
|
||||
|
||||
<bean id="ncgribDecoder" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgribDecoder"/>
|
||||
|
||||
<bean id="ncgridAssembler" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgridAssembler"/>
|
||||
|
||||
<bean id="ncgribDecodeThreads" class="java.lang.Integer">
|
||||
<constructor-arg value="${ncgrib-decode.count.threads}" />
|
||||
</bean>
|
||||
|
||||
<bean id="ingest-ncgrib" class="org.apache.camel.component.jms.JmsComponent">
|
||||
<constructor-arg ref="jmsNcgribConfig" />
|
||||
<property name="taskExecutor" ref="ncgribThreadPool" />
|
||||
</bean>
|
||||
<bean id="jmsNcgribConfig" class="org.apache.camel.component.jms.JmsConfiguration"
|
||||
factory-bean="jmsDurableConfig" factory-method="copy"/>
|
||||
<bean id="ncgribThreadPool"
|
||||
class="com.raytheon.uf.edex.esb.camel.spring.JmsThreadPoolTaskExecutor">
|
||||
<property name="corePoolSize" ref="ncgribDecodeThreads" />
|
||||
<property name="maxPoolSize" ref="ncgribDecodeThreads" />
|
||||
</bean>
|
||||
|
||||
<bean id="ncgribLargeFileChecker" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgribLargeFileChecker" />
|
||||
<bean id="ncgribLargeFileLockRelease" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgribLockRelease" />
|
||||
|
||||
<bean id="ncgribCamelRegistered" factory-bean="contextManager"
|
||||
factory-method="register" depends-on="persistCamelRegistered">
|
||||
<constructor-arg ref="ncgrib-camel"/>
|
||||
</bean>
|
||||
|
||||
<bean id="ncgribFilenameProcessor" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgribFileNameProcessor" />
|
||||
|
||||
<camelContext id="ncgrib-camel"
|
||||
xmlns="http://camel.apache.org/schema/spring"
|
||||
errorHandlerRef="errorHandler"
|
||||
autoStartup="false">
|
||||
<endpoint id="ncgribFileEndpoint" uri="file:${edex.home}/data/sbn/ncgrib?noop=true&idempotent=false" />
|
||||
|
||||
<!-- Begin Ncgrib-grid Routes -->
|
||||
<endpoint id="ncgribGridFileEndpoint" uri="file:${edex.home}/data/sbn/ncgrib-grid?noop=true&idempotent=false" />
|
||||
|
||||
<route id="ncgribGridFileConsumerRoute">
|
||||
<from ref="ncgribGridFileEndpoint" />
|
||||
<bean ref="fileToString" />
|
||||
<bean ref="ncgribFilenameProcessor" />
|
||||
<setHeader headerName="pluginName">
|
||||
<constant>grid</constant>
|
||||
</setHeader>
|
||||
<to uri="ingest-grib:queue:Ingest.Grib" />
|
||||
</route>
|
||||
<!-- End Ncgrib-grid Routes -->
|
||||
|
||||
<!-- Begin Ncgrib Routes -->
|
||||
<route id="ncgribFileConsumerRoute">
|
||||
<from ref="ncgribFileEndpoint" />
|
||||
<bean ref="fileToString" />
|
||||
<setHeader headerName="pluginName">
|
||||
<constant>ncgrib</constant>
|
||||
</setHeader>
|
||||
<to uri="ingest-ncgrib:queue:Ingest.Ncgrib" />
|
||||
</route>
|
||||
|
||||
|
||||
<route id="ncgribIngestRoute">
|
||||
<from uri="ingest-ncgrib:queue:Ingest.Ncgrib?concurrentConsumers=#ncgribDecodeThreads" />
|
||||
<setHeader headerName="pluginName">
|
||||
<constant>ncgrib</constant>
|
||||
</setHeader>
|
||||
<doTry>
|
||||
<pipeline>
|
||||
<bean ref="stringToFile" />
|
||||
<bean ref="ncgribLargeFileChecker" />
|
||||
<bean ref="ncgribDecoder" method="decode" />
|
||||
<bean ref="persist" method="persist" />
|
||||
<bean ref="index" method="index" />
|
||||
<bean ref="ncgridAssembler" method="process"/>
|
||||
<multicast parallelProcessing="false">
|
||||
<to uri="direct-vm:ncgribIngestAlert" />
|
||||
<to uri="vm:ncgribNotification" />
|
||||
</multicast>
|
||||
</pipeline>
|
||||
<doCatch>
|
||||
<exception>java.lang.Throwable</exception>
|
||||
<to uri="log:ncgrib?level=ERROR" />
|
||||
</doCatch>
|
||||
<doFinally>
|
||||
<bean ref="ncgribLargeFileLockRelease" />
|
||||
</doFinally>
|
||||
</doTry>
|
||||
</route>
|
||||
|
||||
<route id="ncgribIngestAlert">
|
||||
<from uri="direct-vm:ncgribIngestAlert" />
|
||||
<bean ref="toDataURI" method="toDataURI" />
|
||||
<bean ref="processUtil" method="log" />
|
||||
<to uri="vm:stageNotification" />
|
||||
</route>
|
||||
|
||||
<route id="ncgribNotification">
|
||||
<from uri="vm:ncgribNotification?concurrentConsumers=4" />
|
||||
<bean ref="ncgribNotifyTransform" method="transformToMessages" />
|
||||
<bean ref="serializationUtil" method="transformToThrift" />
|
||||
<to uri="jms-generic:topic:ncgribNotification?timeToLive=15000" />
|
||||
</route>
|
||||
|
||||
</camelContext>
|
||||
|
||||
</beans>
|
|
@ -1,19 +0,0 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
|
||||
|
||||
<bean id="ncgridDataQueryHandler" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.handler.NcgridDataHandler" />
|
||||
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg value="gov.noaa.nws.ncep.common.dataplugin.ncgrib.request.NcgridDataRequestMessage"/>
|
||||
<constructor-arg ref="ncgridDataQueryHandler"/>
|
||||
</bean>
|
||||
|
||||
<bean id="getNcCoverageHandler" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.handler.GetNcCoverageHandler" />
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg value="gov.noaa.nws.ncep.common.dataplugin.ncgrib.request.GetNcCoverageRequest"/>
|
||||
<constructor-arg ref="getNcCoverageHandler"/>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
|
@ -1,2 +0,0 @@
|
|||
# the number of ncgrib decode threads.
|
||||
ncgrib-decode.count.threads=4
|
|
@ -1,100 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.objects.hibernate.ncgrib;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import javax.measure.unit.Unit;
|
||||
import javax.measure.unit.UnitFormat;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
public class UnitType implements UserType {
|
||||
|
||||
private static final int[] SQL_TYPES = { Types.VARCHAR };
|
||||
|
||||
@Override
|
||||
public Object assemble(Serializable cached, Object owner)
|
||||
throws HibernateException {
|
||||
return cached;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deepCopy(Object value) throws HibernateException {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable disassemble(Object value) throws HibernateException {
|
||||
return (Serializable) value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object x, Object y) throws HibernateException {
|
||||
if (x == null) {
|
||||
return false;
|
||||
} else {
|
||||
return ((Unit<?>) x).equals(y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode(Object x) throws HibernateException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner)
|
||||
throws HibernateException, SQLException {
|
||||
Unit<?> unit = null;
|
||||
try {
|
||||
String unitName = resultSet.getString(names[0]);
|
||||
if (unitName == null) {
|
||||
unit = Unit.ONE;
|
||||
} else if (unitName.equals("")) {
|
||||
unit = Unit.ONE;
|
||||
} else {
|
||||
unit = (Unit<?>) UnitFormat.getUCUMInstance().parseObject(
|
||||
unitName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nullSafeSet(PreparedStatement statement, Object value, int index)
|
||||
throws HibernateException, SQLException {
|
||||
if (value == null) {
|
||||
statement.setString(index, null);
|
||||
} else {
|
||||
statement.setString(index, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replace(Object original, Object target, Object owner)
|
||||
throws HibernateException {
|
||||
return original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> returnedClass() {
|
||||
return Unit.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] sqlTypes() {
|
||||
return UnitType.SQL_TYPES;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.ncgrib;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class GridLookupFileName {
|
||||
/** The singleton instance of GridLookupFileName **/
|
||||
private static GridLookupFileName instance;
|
||||
|
||||
private String[] modelNames = { "cmce", "gefs", "gww", "naefsBC",
|
||||
"naefsUS", "naefsAK", "sref" };
|
||||
|
||||
private String[] template = {
|
||||
"cmc_gep.*|cmce;cmc_gec.*|cmcec;cmc_geavg.*|cmceMean;cmc_gespr.*|cmceSpread",
|
||||
"gec00.*bc.*|gefscBC;gec00.*anl|gefscAnal;gec00.*[0-9]|gefsc;gep.*anl|gefsAnal;gep.*bc.*|gefsBC;geavg.*bc.*|gefsMeanBC;gespr.*bc.*|gefsSpreadBC;gespr.*|gefsSpread",
|
||||
"mean.*|gwwMean;probab.*|gwwProb;spread.*|gwwSpread",
|
||||
"naefs_geavg.*bc.*|naefsMeanBC;naefs_geavg.*anv.*|naefsMean;naefs_gespr.*bc.*|naefsSpreadBC;naefs_ge10pt.*bc.*|naefs10ptBC;naefs_ge50pt.*bc.*|naefs50ptBC;naefs_ge90pt.*bc.*|naefs90ptBC;naefs_gemode.*bc.*|naefsModeBC",
|
||||
"naefs_geavg.*conus.*grib2|naefsMeanUS;naefs_ge10pt.*conus.*grib2|naefs10ptUS;naefs_ge50pt.*conus.*grib2|naefs50ptUS;naefs_ge90pt.*conus.*grib2|naefs90ptUS;naefs_gemode.*conus.*grib2|naefsModeUS",
|
||||
"naefs_geavg.*alaska.*grib2|naefsMeanAK;naefs_ge10pt.*alaska.*grib2|naefs10ptAK;naefs_ge50pt.*alaska.*grib2|naefs50ptAK;naefs_ge90pt.*alaska.*grib2|naefs90ptAK;naefs_gemode.*alaska.*grib2|naefsModeAK",
|
||||
"nam.*.awip3d00.*tm00|nam40;sref_nam.*ctl1.*|srefNamCtl1;sref_nam.*ctl2.*|srefNamCtl2;sref_nam.*[pn][1-9].*|srefNam;sref_eta.*[pn][1-9].*|srefEta;sref_eta.*ctl1.*|srefEtaCtl1;sref_eta.*ctl2.*|srefEtaCtl2;sref_rsm.*ctl.*|srefRsmCtl;sref_rsm.*[pn][1-9].*|srefRsm;sref_nmm.*ctl.*|srefNmmCtl;sref_nmm.*[pn][1-9].*|srefNmm;sref_em.*ctl.*|srefEmCtl;sref_em.*[pn][1-9].*|srefEm" };
|
||||
|
||||
private final Map<String, String> models;
|
||||
|
||||
public static GridLookupFileName getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new GridLookupFileName();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private GridLookupFileName() {
|
||||
models = new HashMap<String, String>();
|
||||
|
||||
initModels();
|
||||
}
|
||||
|
||||
private void initModels() {
|
||||
for (int i = 0; i < modelNames.length; i++) {
|
||||
models.put(modelNames[i].toUpperCase(), template[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public String getModelName(String filename) {
|
||||
String modelname = null;
|
||||
|
||||
// if (model.equalsIgnoreCase("gww") && gridId.equalsIgnoreCase("229"))
|
||||
// {
|
||||
// return modelname;
|
||||
// }
|
||||
//
|
||||
// String template = models.get(model.toUpperCase());
|
||||
for (String template : this.template) {
|
||||
String[] tokens = template.split(";");
|
||||
// System.out.println ( " CMC ensemble " + "!!!\n");
|
||||
|
||||
for (String token : tokens) {
|
||||
String[] alias = token.split("\\|");
|
||||
if (Pattern.matches(alias[0], filename)) {
|
||||
modelname = alias[1];
|
||||
|
||||
// perturbation number
|
||||
// String[] pert = filename.split("\\.");
|
||||
// if ( pert[3].startsWith("p") || pert[3].startsWith("n"))
|
||||
// {
|
||||
// nbm.setPerturbationNumber(pert[3]);
|
||||
// }
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return modelname;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,294 +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 gov.noaa.nws.ncep.edex.plugin.ncgrib;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.util.TableTimeStamp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ucar.grib.GribChecker;
|
||||
import ucar.grib.grib1.Grib1Input;
|
||||
import ucar.grib.grib1.Grib1Record;
|
||||
import ucar.grib.grib2.Grib2Input;
|
||||
import ucar.grib.grib2.Grib2Record;
|
||||
import ucar.unidata.io.RandomAccessFile;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
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.core.EDEXUtil;
|
||||
import com.raytheon.uf.edex.python.decoder.PythonDecoder;
|
||||
|
||||
/**
|
||||
* Generic decoder for decoding grib files
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 3/12/10 4758 bphillip Initial creation
|
||||
* 10/13/10 276 llin Modified for NC GRIB.
|
||||
* 01/19/12 xguo Split large files
|
||||
* 05/23/12 xguo Split large file to each record file
|
||||
* 06/12/12 00609 djohnson Use EDEXUtil for EDEX_HOME.
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class NcgribDecoder {
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(NcgribDecoder.class);
|
||||
|
||||
private static final long TEN_MEGABYTES = 10485760;
|
||||
|
||||
private static final long FIVE_MEGABYTES = 5242880;
|
||||
|
||||
public NcgribDecoder() {
|
||||
|
||||
}
|
||||
|
||||
public NcgribRecord[] decode(File file) throws GribException {
|
||||
|
||||
NcgribRecord[] records = null;
|
||||
RandomAccessFile raf = null;
|
||||
int edition = 0;
|
||||
List<Long> recordLengths = new ArrayList<Long>();
|
||||
try {
|
||||
raf = new RandomAccessFile(file.getAbsolutePath(), "r");
|
||||
raf.order(RandomAccessFile.BIG_ENDIAN);
|
||||
edition = GribChecker.getEdition(raf);
|
||||
|
||||
// If the file is greater than ten megs, split it
|
||||
if (file.length() > TEN_MEGABYTES) {
|
||||
raf.seek(0);
|
||||
if (edition == 1) {
|
||||
Grib1Input g1i = new Grib1Input(raf);
|
||||
g1i.scan(false, false);
|
||||
List<Grib1Record> gribRecords = g1i.getRecords();
|
||||
for (int i = 0; i < gribRecords.size(); i++) {
|
||||
recordLengths.add(gribRecords.get(i).getIs()
|
||||
.getGribLength());
|
||||
}
|
||||
} else if (edition == 2) {
|
||||
Grib2Input g2i = new Grib2Input(raf);
|
||||
try {
|
||||
g2i.scan(false, false);
|
||||
} catch (Exception e) {
|
||||
throw new Exception(
|
||||
"Error determining grib record count.", e);
|
||||
}
|
||||
List<Grib2Record> gribRecords = g2i.getRecords();
|
||||
|
||||
for (int i = 0; i < gribRecords.size(); i++) {
|
||||
recordLengths.add(gribRecords.get(i).getIs()
|
||||
.getGribLength());
|
||||
}
|
||||
}
|
||||
|
||||
if (recordLengths.size() > 1) {
|
||||
raf.seek(0);
|
||||
splitFile(file.getName(), raf, recordLengths);
|
||||
try {
|
||||
if (raf != null) {
|
||||
raf.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new GribException("", e);
|
||||
}
|
||||
return new NcgribRecord[] {};
|
||||
}
|
||||
}
|
||||
if (edition == 1) {
|
||||
records = new Ncgrib1Decoder().decode(file.getAbsolutePath());
|
||||
} else if (edition == 2) {
|
||||
//System.out.println("In decoder class edition 2, to update xml tables if necessary...");
|
||||
TableTimeStamp.updateXmlTables();
|
||||
PythonDecoder pythonDecoder = new PythonDecoder();
|
||||
pythonDecoder.setPluginName("ncgrib");
|
||||
pythonDecoder.setPluginFQN("gov.noaa.nws.ncep.edex.plugin.ncgrib");
|
||||
pythonDecoder.setModuleName("NcgribDecoder");
|
||||
pythonDecoder.setRecordClassname(NcgribRecord.class.toString());
|
||||
pythonDecoder.setCache(true);
|
||||
try {
|
||||
PluginDataObject[] ncpdos = pythonDecoder.decode(file);
|
||||
records = new NcgribRecord[ncpdos.length];
|
||||
for (int i = 0; i < ncpdos.length; i++) {
|
||||
records[i] = (NcgribRecord) ncpdos[i];
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GribException("Error decoding ncgrib file!", e);
|
||||
}
|
||||
|
||||
} else {
|
||||
statusHandler.handle(Priority.ERROR,"Unknown ncgrib version detected [" + edition
|
||||
+ "]");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.ERROR, "Failed to decode file: ["
|
||||
+ file.getAbsolutePath() + "]", e);
|
||||
records = new NcgribRecord[0];
|
||||
} finally {
|
||||
try {
|
||||
if (raf != null) {
|
||||
raf.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new GribException("", e);
|
||||
}
|
||||
}
|
||||
|
||||
return records;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits a collective file into individual records.
|
||||
*
|
||||
* @param fileName
|
||||
* The name of the file being split
|
||||
* @param raf
|
||||
* The Random Access File object
|
||||
* @param sizes
|
||||
* The sizes of the individual records inside the collection
|
||||
* @throws IOException
|
||||
*/
|
||||
private void splitFile(String fileName, RandomAccessFile raf,
|
||||
List<Long> sizes) throws IOException {
|
||||
FileOutputStream out = null;
|
||||
byte[] transfer = null;
|
||||
long rdSize=0;
|
||||
int num = 0;
|
||||
for (int i = 0; i < sizes.size(); i++) {
|
||||
if ( rdSize == sizes.get(i).longValue() ) continue;
|
||||
num ++;
|
||||
rdSize = sizes.get(i).longValue();
|
||||
transfer = new byte[(int) sizes.get(i).longValue()];
|
||||
raf.seek(seekRecordStart(raf, raf.length()));
|
||||
raf.read(transfer);
|
||||
|
||||
try {
|
||||
out = new FileOutputStream(EDEXUtil.EDEX_HOME
|
||||
+ "/data/sbn/ncgrib/" + fileName + "_" + num);
|
||||
out.write(transfer);
|
||||
out.close();
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
private void splitFile(String fileName, RandomAccessFile raf,
|
||||
List<Long> sizes) throws IOException {
|
||||
FileOutputStream out = null;
|
||||
byte[] transfer = null;
|
||||
long fileSize = 0,seekLoc;
|
||||
int num = 0;
|
||||
for (int i = 0; i < sizes.size(); i++) {
|
||||
fileSize += sizes.get(i).longValue();
|
||||
if ( (i < sizes.size() -1 ) &&
|
||||
((fileSize + sizes.get(i+1).longValue())>FIVE_MEGABYTES)) {
|
||||
num ++;
|
||||
seekLoc = seekRecordStart(raf, raf.length());
|
||||
if ( seekLoc < 0 ) return;
|
||||
transfer = new byte[(int) fileSize];
|
||||
raf.seek(seekLoc);
|
||||
raf.read(transfer);
|
||||
|
||||
try {
|
||||
out = new FileOutputStream(EDEXUtil.EDEX_HOME
|
||||
+ "/data/sbn/ncgrib/" + fileName + "_" + num);
|
||||
out.write(transfer);
|
||||
out.close();
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
fileSize = 0;
|
||||
}
|
||||
}
|
||||
if ( fileSize > 0 ) {
|
||||
num ++;
|
||||
seekLoc = seekRecordStart(raf, raf.length());
|
||||
if ( seekLoc < 0 ) return;
|
||||
transfer = new byte[(int) fileSize];
|
||||
raf.seek(seekLoc);
|
||||
raf.read(transfer);
|
||||
|
||||
try {
|
||||
out = new FileOutputStream(EDEXUtil.EDEX_HOME
|
||||
+ "/data/sbn/ncgrib/" + fileName + "_" + num);
|
||||
out.write(transfer);
|
||||
out.close();
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Moves the filepointer on the random access file to the beginning of the
|
||||
* next grib record in the file
|
||||
*
|
||||
* @param raf
|
||||
* The random access file
|
||||
* @param fileLength
|
||||
* The total length of the file
|
||||
* @return The index to the next grib record in the collection. -1 is
|
||||
* returned if there are no more records in the file
|
||||
* @throws IOException
|
||||
*/
|
||||
private long seekRecordStart(RandomAccessFile raf, long fileLength)
|
||||
throws IOException {
|
||||
int matches = 0;
|
||||
while (raf.getFilePointer() < fileLength) {
|
||||
char c = (char) raf.readByte();
|
||||
if (c == 'G') {
|
||||
matches = 1;
|
||||
} else if ((c == 'R') && (matches == 1)) {
|
||||
matches = 2;
|
||||
} else if ((c == 'I') && (matches == 2)) {
|
||||
matches = 3;
|
||||
} else if ((c == 'B') && (matches == 3)) {
|
||||
matches = 4;
|
||||
// Subtract 4 because we want the absolute beginning of the grib
|
||||
// file
|
||||
return raf.getFilePointer() - 4;
|
||||
} else {
|
||||
matches = 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.ncgrib;
|
||||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
|
@ -17,7 +18,6 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -37,7 +37,10 @@ import org.apache.camel.Processor;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 1, 2012 bsteffen Initial creation
|
||||
* Mar 01, 2012 bsteffen Initial creation
|
||||
* May 29, 2013 995 B. Yin Get model name from NcgribModelNameMap
|
||||
* June, 2013 T. Lee Added NFCENS
|
||||
* Oct 15, 2012 2473 bsteffen Move to ncgrib plugin
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -46,24 +49,34 @@ import org.apache.camel.Processor;
|
|||
*/
|
||||
public class NcgribFileNameProcessor implements Processor {
|
||||
|
||||
// grab all known ensemble ids
|
||||
// grab all known ensemble ids; mainly SREF
|
||||
private static final Pattern ENSEMBLE_ID_PATTERN = Pattern
|
||||
.compile("^(p|n|ctl)\\d{0,2}$");
|
||||
|
||||
// grab global wind and wave ensemble IDs
|
||||
private static final Pattern ENSEMBLE_WAVE_PATTERN = Pattern
|
||||
.compile("^\\d{8}_gep(\\d{0,2}{2})$");
|
||||
|
||||
// grab global wind and wave ensemble IDs
|
||||
private static final Pattern ENSEMBLE_NFC_PATTERN = Pattern
|
||||
.compile("^\\d{8}_HTSGW_(\\d{2})$");
|
||||
// anything that ends in nest is assumed to be a nested grid identifier
|
||||
// might add alaska fire weather later...
|
||||
private static final Pattern FIREWXNEST_ID_PATTERN = Pattern
|
||||
.compile("^firewxnest$");
|
||||
|
||||
// anything that ends in nest is assumed to be a nested grid identifier
|
||||
private static final Pattern NEST_ID_PATTERN = Pattern.compile("^.*nest$");
|
||||
//private static final Pattern NEST_ID_PATTERN = Pattern.compile("^.*nest$");
|
||||
|
||||
// SREF gets special handling, does this apply to other models?
|
||||
private static final Pattern SREF_PATTERN = Pattern.compile("^sref_.*$");
|
||||
//private static final Pattern SREF_PATTERN = Pattern.compile("^sref_.*$");
|
||||
|
||||
// This is the least generic pattern ever, are there any constraints on
|
||||
// event names, who knows?
|
||||
private static final Pattern HURRICANE_PATTERN = Pattern
|
||||
.compile("^([a-z]*)\\d{1,2}[lewcs]$");
|
||||
.compile("^\\d{10}_([a-z]*)\\d{1,2}[lewcs]$");
|
||||
|
||||
private static NcgribModelNameMap modelMap = null;
|
||||
|
||||
@Override
|
||||
public void process(Exchange exchange) throws Exception {
|
||||
|
@ -73,45 +86,63 @@ public class NcgribFileNameProcessor implements Processor {
|
|||
String secondaryid = null;
|
||||
String ensembleid = null;
|
||||
String[] nameTokens = flName.split("\\.");
|
||||
|
||||
for (String token : nameTokens) {
|
||||
if (ENSEMBLE_ID_PATTERN.matcher(token).find()) {
|
||||
ensembleid = token;
|
||||
} else if (ENSEMBLE_WAVE_PATTERN.matcher(token).find()) {
|
||||
Matcher matcher = ENSEMBLE_WAVE_PATTERN.matcher(token);
|
||||
matcher.find();
|
||||
ensembleid = matcher.group(1);
|
||||
} else if (ENSEMBLE_NFC_PATTERN.matcher(token).find()) {
|
||||
Matcher matcher = ENSEMBLE_NFC_PATTERN.matcher(token);
|
||||
datasetid = "nfcens";
|
||||
matcher.find();
|
||||
ensembleid = matcher.group(1);
|
||||
} else if (FIREWXNEST_ID_PATTERN.matcher(token).find()) {
|
||||
datasetid = "NAMFIREWX";
|
||||
secondaryid = token;
|
||||
} else if (NEST_ID_PATTERN.matcher(token).find()) {
|
||||
secondaryid = token;
|
||||
} else if (SREF_PATTERN.matcher(token).find()) {
|
||||
String[] tokens = token.split("_");
|
||||
datasetid = tokens[0].toUpperCase();
|
||||
secondaryid = tokens[1].toUpperCase();
|
||||
//datasetid = "NAMFIREWX";
|
||||
datasetid = "fireWxNAM";
|
||||
//secondaryid = token;
|
||||
//} else if (NEST_ID_PATTERN.matcher(token).find()) {
|
||||
// secondaryid = token;
|
||||
//} else if (SREF_PATTERN.matcher(token).find()) {
|
||||
// String[] tokens = token.split("_");
|
||||
// datasetid = tokens[0].toUpperCase();
|
||||
//secondaryid = tokens[1].toUpperCase();
|
||||
} else if (HURRICANE_PATTERN.matcher(token).find()) {
|
||||
Matcher matcher = HURRICANE_PATTERN.matcher(token);
|
||||
matcher.find();
|
||||
secondaryid = matcher.group(1);
|
||||
datasetid = "GHM";
|
||||
if (nameTokens[2].equalsIgnoreCase("gribn3")) {
|
||||
|
||||
if (nameTokens[3].equalsIgnoreCase("gribn3")) {
|
||||
datasetid = "GHMNEST";
|
||||
} else if (nameTokens[2].equalsIgnoreCase("grib6th")) {
|
||||
} else if (nameTokens[3].equalsIgnoreCase("grib6th")) {
|
||||
datasetid = "GHM6TH";
|
||||
} else if (nameTokens[2].equalsIgnoreCase("hwrfprs_n")) {
|
||||
} else if (nameTokens[3].equalsIgnoreCase("hwrfprs_n")) {
|
||||
datasetid = "HWRFNEST";
|
||||
} else if (nameTokens[2].equalsIgnoreCase("hwrfprs_p")) {
|
||||
} else if (nameTokens[3].equalsIgnoreCase("hwrfprs_p")) {
|
||||
datasetid = "HWRF";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// datasetid = GridLookupFileName.getInstance().getModelName(flName);
|
||||
|
||||
if ( modelMap == null ) {
|
||||
modelMap = NcgribModelNameMap.load();
|
||||
}
|
||||
|
||||
// Get model name from grib file template
|
||||
if (datasetid == null) {
|
||||
datasetid = modelMap.getModelName(flName);
|
||||
}
|
||||
|
||||
if (datasetid != null) {
|
||||
exchange.getIn().setHeader("datasetid", datasetid);
|
||||
}
|
||||
else {
|
||||
datasetid = GridLookupFileName.getInstance().getModelName(flName);
|
||||
if (secondaryid != null) {
|
||||
exchange.getIn().setHeader("secondaryid", secondaryid);
|
||||
}
|
||||
if (secondaryid == null) {
|
||||
secondaryid = nameTokens[0];
|
||||
}
|
||||
exchange.getIn().setHeader("secondaryid", secondaryid);
|
||||
if (ensembleid != null) {
|
||||
exchange.getIn().setHeader("ensembleid", ensembleid);
|
||||
}
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib;
|
||||
|
||||
import com.raytheon.edex.plugin.DefaultPluginInitializer;
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial.NcgribSpatialCache;
|
||||
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribModelLookup;
|
||||
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribTableLookup;
|
||||
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgridTranslator;
|
||||
|
||||
/**
|
||||
* Initializer implementation for the grib plugin
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class NcgribInitializer extends DefaultPluginInitializer {
|
||||
|
||||
/**
|
||||
* Creates a new GribInitializer instance
|
||||
* @param pluginName "ncgrib"
|
||||
*/
|
||||
public NcgribInitializer(String pluginName) {
|
||||
super(pluginName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePlugin() throws Exception {
|
||||
super.initializePlugin();
|
||||
NcgribTableLookup.getInstance();
|
||||
NcgribSpatialCache.getInstance();
|
||||
NcgribModelLookup.getInstance();
|
||||
NcgridTranslator.getInstance();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.ncgrib;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Processor;
|
||||
|
||||
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.database.cluster.ClusterLockUtils;
|
||||
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils.LockState;
|
||||
import com.raytheon.uf.edex.database.cluster.ClusterTask;
|
||||
|
||||
/**
|
||||
* Implementation of a Camel Message Processor to check if the ingested ncgrib
|
||||
* file is larger than 8Mb, all other ncgrib ingest threads will block to wait for
|
||||
* this file to finish processing. Cluster locking is used. The lock is obtained
|
||||
* in this Processor. A second processor, NcgribLockRelease, is used to release
|
||||
* the lock once the file is done being processed.
|
||||
* <p>
|
||||
* This processor was put in place to ensure large ncgrib files will not throw out
|
||||
* of memory exceptions while processing.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 08/08/11 Xilin Guo Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author xguo
|
||||
* @version 1
|
||||
* @see gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgribLockRelease
|
||||
*/
|
||||
public class NcgribLargeFileChecker implements Processor {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(NcgribLargeFileChecker.class);
|
||||
|
||||
/**
|
||||
* The header attribute attached to the message to denote whether this file
|
||||
* will receive single threaded handling
|
||||
*/
|
||||
public static final String LARGE_FILE_HEADER = "ncgribLargeFile";
|
||||
|
||||
/** The cluster task name used for cluster locking */
|
||||
public static final String CLUSTER_TASK_NAME = "NcgribIngestLargeFile";
|
||||
|
||||
public static final String CLUSTER_TASK_DETAILS;
|
||||
|
||||
/**
|
||||
* The default large file size is 10Mb.
|
||||
*/
|
||||
private static long LARGE_FILE_SIZE = 10485760L;
|
||||
|
||||
/**
|
||||
* The default timing out of large file is 240000 milliseconds
|
||||
*/
|
||||
private static long LARGE_FILE_WAITING_TIME = 240000L;
|
||||
|
||||
static {
|
||||
String host = null;
|
||||
try {
|
||||
// Initialize the cluster task name with the host name
|
||||
host = InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
host = "";
|
||||
}
|
||||
CLUSTER_TASK_DETAILS = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(Exchange exchange) throws Exception {
|
||||
boolean isLargeFile = false;
|
||||
|
||||
File gribFile = (File) exchange.getIn().getBody();
|
||||
|
||||
if ( gribFile.length() > LARGE_FILE_SIZE ) {
|
||||
isLargeFile = true;
|
||||
}
|
||||
|
||||
ClusterTask task = ClusterLockUtils.lookupLock(CLUSTER_TASK_NAME,
|
||||
CLUSTER_TASK_DETAILS);
|
||||
|
||||
boolean waitForLargeNcgrib = task.isRunning();
|
||||
while (waitForLargeNcgrib) {
|
||||
Thread.sleep(500);
|
||||
task = ClusterLockUtils.lookupLock(CLUSTER_TASK_NAME,
|
||||
CLUSTER_TASK_DETAILS);
|
||||
waitForLargeNcgrib = task.isRunning();
|
||||
// need to handle timing out of large ncgrib file process manually
|
||||
if (waitForLargeNcgrib
|
||||
&& (System.currentTimeMillis() - task.getLastExecution()) > LARGE_FILE_WAITING_TIME) {
|
||||
|
||||
statusHandler.handle(Priority.EVENTA,
|
||||
"Large Ncgrib file process timed out. Clearing lock and resuming processing");
|
||||
ClusterLockUtils
|
||||
.unlock(CLUSTER_TASK_NAME, CLUSTER_TASK_DETAILS);
|
||||
waitForLargeNcgrib = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isLargeFile) {
|
||||
statusHandler.handle(Priority.EVENTA,
|
||||
"Large Ncgrib file detected. Establishing lock.");
|
||||
while (!ClusterLockUtils
|
||||
.lock(CLUSTER_TASK_NAME, CLUSTER_TASK_DETAILS, LARGE_FILE_WAITING_TIME, true)
|
||||
.getLockState().equals(LockState.SUCCESSFUL)) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
statusHandler.handle(Priority.EVENTA,
|
||||
"Large Ncgrib file lock established.");
|
||||
// Wait for other threads to complete processing before we proceed
|
||||
Thread.sleep(1000);
|
||||
exchange.getIn().setHeader(LARGE_FILE_HEADER, true);
|
||||
|
||||
} else {
|
||||
exchange.getIn().setHeader(LARGE_FILE_HEADER, false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.ncgrib;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Processor;
|
||||
|
||||
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.database.cluster.ClusterLockUtils;
|
||||
|
||||
/**
|
||||
* Releases lock obtained in the NcgribLargeFileChecker class if one was
|
||||
* established.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 08/08/11 Xilin Guo Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author xguo
|
||||
* @version 1
|
||||
* @see gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgribLargeFileChecker
|
||||
*/
|
||||
public class NcgribLockRelease implements Processor {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(NcgribLockRelease.class);
|
||||
|
||||
@Override
|
||||
public void process(Exchange exchange) throws Exception {
|
||||
Boolean isLargeFile = (Boolean) exchange.getIn().getHeader(
|
||||
NcgribLargeFileChecker.LARGE_FILE_HEADER);
|
||||
if (isLargeFile) {
|
||||
boolean success = ClusterLockUtils.unlock(
|
||||
NcgribLargeFileChecker.CLUSTER_TASK_NAME,
|
||||
NcgribLargeFileChecker.CLUSTER_TASK_DETAILS);
|
||||
if (success) {
|
||||
statusHandler.handle(Priority.EVENTA,
|
||||
"Large Ncgrib file lock released!");
|
||||
} else {
|
||||
statusHandler.handle(Priority.CRITICAL,
|
||||
"Large Ncgrib file lock could not be released!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,9 +6,8 @@
|
|||
* This code has been developed by the NCEP/SIB for use in the AWIPS2 system.
|
||||
*/
|
||||
|
||||
package com.raytheon.edex.plugin.grib.filenameprocessor;
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -18,18 +17,20 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
|
||||
/**
|
||||
* Class to hold the model name look up map for ncgrib data file
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 05/13 995 B. Yin Initial Creation.
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 05/13 995 B. Yin Initial Creation.
|
||||
* Oct 15, 2012 2473 bsteffen Move to ncgrib plugin
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author B. Yin
|
||||
|
@ -37,7 +38,7 @@ import com.raytheon.uf.common.serialization.SerializationUtil;
|
|||
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class NcgribModelNameMap implements ISerializableObject {
|
||||
public class NcgribModelNameMap {
|
||||
|
||||
/*
|
||||
* Mapping between file name templates and model names
|
||||
|
@ -56,13 +57,11 @@ public class NcgribModelNameMap implements ISerializableObject {
|
|||
LocalizationContext.LocalizationLevel.BASE);
|
||||
|
||||
NcgribModelNameMap map = null;
|
||||
try {
|
||||
File xmlFile = pathMgr.getFile(ctx, "/grib/ncgrib/ncgribModelNameMap.xml");
|
||||
map = (NcgribModelNameMap) SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(NcgribModelNameMap.class, xmlFile.getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
LocalizationFile xmlFile = pathMgr.getLocalizationFile(ctx,
|
||||
"/grib/ncgrib/ncgribModelNameMap.xml");
|
||||
|
||||
map = xmlFile.jaxbUnmarshal(NcgribModelNameMap.class, new JAXBManager(
|
||||
NcgribModelNameMap.class));
|
||||
return map;
|
||||
}
|
||||
|
|
@ -1,345 +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 gov.noaa.nws.ncep.edex.plugin.ncgrib;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LatLonNcgridCoverage;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcgribDao;
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial.NcgribSpatialCache;
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.util.NcgribModelCache;
|
||||
import gov.noaa.nws.ncep.edex.util.ncgrib.NccompositeModel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.edex.util.Util;
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
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.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.uf.common.util.GridUtil;
|
||||
import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.plugin.PluginFactory;
|
||||
|
||||
/**
|
||||
* The GridAssmebler class is part of the ingest process for grib data. Some
|
||||
* grib model come in as octants. This class will combine those octants into a
|
||||
* single grid
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 09, 2010 4638 bphillip Initial Creation
|
||||
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
|
||||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class NcgridAssembler {
|
||||
|
||||
/** The map of the models that come in sections */
|
||||
private Map<String, NccompositeModel> ncthinnedModels;
|
||||
|
||||
/**
|
||||
* Creates a new NcgridAssemble instance
|
||||
*/
|
||||
public NcgridAssembler() {
|
||||
if (ncthinnedModels == null) {
|
||||
// System.out.println(" load nc thin models commonPath:");
|
||||
|
||||
loadNcThinnedModels();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the models from the localization store and stores them in memory
|
||||
*/
|
||||
private void loadNcThinnedModels() {
|
||||
ncthinnedModels = new HashMap<String, NccompositeModel>();
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
File commonPath = pm.getFile(pm.getContext(
|
||||
LocalizationType.EDEX_STATIC, LocalizationLevel.BASE),
|
||||
"/ncgrib/ncthinnedModels");
|
||||
|
||||
// System.out.println(" load thin models commonPath=" + commonPath);
|
||||
|
||||
FilenameFilter filter = FilenameFilters.byFilters(
|
||||
FilenameFilters.ACCEPT_FILES,
|
||||
FilenameFilters.byFileExtension(".xml"));
|
||||
|
||||
List<File> thinnedModelFiles = FileUtil.listFiles(commonPath, filter,
|
||||
false);
|
||||
|
||||
for (File file : thinnedModelFiles) {
|
||||
// System.out.println(" load thin models file=" + file.getName());
|
||||
|
||||
try {
|
||||
NccompositeModel model = (NccompositeModel) SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(file.getPath());
|
||||
// System.out.println(" load thin models model=" +
|
||||
// model.getModelName());
|
||||
|
||||
ncthinnedModels.put(model.getModelName(), model);
|
||||
} catch (SerializationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a list of ingested GribRecords
|
||||
*
|
||||
* @param records
|
||||
* The records to process
|
||||
* @return An array of NcgribRecords
|
||||
*/
|
||||
public synchronized NcgribRecord[] process(NcgribRecord[] records) {
|
||||
|
||||
Map<Integer, NcgribRecord> newRecords = new HashMap<Integer, NcgribRecord>();
|
||||
String compositeModel = null;
|
||||
for (NcgribRecord rec : records) {
|
||||
compositeModel = getNccompositeModel(rec.getModelInfo()
|
||||
.getModelName());
|
||||
if (compositeModel != null) {
|
||||
try {
|
||||
NcgribRecord newRec = processGrid(rec,
|
||||
getNccompositeModelObject(compositeModel));
|
||||
newRecords.put(newRec.getId(), newRec);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NcgribRecord[] recs = new NcgribRecord[records.length
|
||||
+ newRecords.keySet().size()];
|
||||
for (int i = 0; i < records.length; i++) {
|
||||
recs[i] = records[i];
|
||||
if (i == (records.length - 1)) {
|
||||
for (NcgribRecord newRecord : newRecords.values()) {
|
||||
i++;
|
||||
recs[i] = newRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return recs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the composite model name for which the provided model name is a part
|
||||
* of
|
||||
*
|
||||
* @param modelName
|
||||
* The model name to determine the composite model name for
|
||||
* @return The composite model name. Null if not found
|
||||
*/
|
||||
private String getNccompositeModel(String modelName) {
|
||||
for (NccompositeModel mod : ncthinnedModels.values()) {
|
||||
if (mod.getModelList().contains(modelName)) {
|
||||
return mod.getModelName();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the composite model object
|
||||
*
|
||||
* @param modelName
|
||||
* The model name to get the composite model object for
|
||||
* @return The composite model object
|
||||
*/
|
||||
private NccompositeModel getNccompositeModelObject(String modelName) {
|
||||
return ncthinnedModels.get(modelName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a single NcgribRecord
|
||||
*
|
||||
* @param record
|
||||
* The NcgribRecord to process
|
||||
* @param thinned
|
||||
* The composite model for which the NcgribRecord is a part of
|
||||
* @return The new grib record
|
||||
* @throws Exception
|
||||
*/
|
||||
private NcgribRecord processGrid(NcgribRecord record,
|
||||
NccompositeModel thinned) throws Exception {
|
||||
|
||||
NcgribDao dao = (NcgribDao) PluginFactory.getInstance().getPluginDao(
|
||||
"ncgrib");
|
||||
String modelName = record.getModelInfo().getModelName();
|
||||
String dataURI = record.getDataURI();
|
||||
String assembledDataURI = dataURI.replace(modelName,
|
||||
thinned.getModelName());
|
||||
|
||||
List<?> result = dao.queryBySingleCriteria("dataURI", assembledDataURI);
|
||||
NcgribRecord assembledRecord = null;
|
||||
if (result.isEmpty()) {
|
||||
assembledRecord = createRecord(record, dao, thinned);
|
||||
} else {
|
||||
assembledRecord = (NcgribRecord) result.get(0);
|
||||
FloatDataRecord rec = (FloatDataRecord) dao.getHDF5Data(
|
||||
assembledRecord, 0)[0];
|
||||
assembledRecord.setMessageData(rec);
|
||||
}
|
||||
|
||||
mergeData(record, assembledRecord, dao, thinned);
|
||||
return assembledRecord;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the data from a NcgribRecord into the composite NcgribRecord
|
||||
*
|
||||
* @param record
|
||||
* The NcgribRecord containing the data to add
|
||||
* @param assembledRecord
|
||||
* The composite NcgribRecord
|
||||
* @param dao
|
||||
* An instance of the grib data access object
|
||||
* @param thinned
|
||||
* The composite model definition
|
||||
* @return The composite NcgribRecord
|
||||
* @throws Exception
|
||||
*/
|
||||
private NcgribRecord mergeData(NcgribRecord record,
|
||||
NcgribRecord assembledRecord, NcgribDao dao,
|
||||
NccompositeModel thinned) throws Exception {
|
||||
|
||||
String modelName = record.getModelInfo().getModelName();
|
||||
NcgridCoverage coverage = record.getModelInfo().getLocation();
|
||||
|
||||
long[] sizes = ((FloatDataRecord) assembledRecord.getMessageData())
|
||||
.getSizes();
|
||||
|
||||
float[][] assembledData = Util.resizeDataTo2D(
|
||||
((FloatDataRecord) assembledRecord.getMessageData())
|
||||
.getFloatData(), (int) sizes[0], (int) sizes[1]);
|
||||
|
||||
int nx = coverage.getNx();
|
||||
int ny = coverage.getNy();
|
||||
|
||||
List<String> compModels = thinned.getModelList();
|
||||
|
||||
int modIndex = compModels.indexOf(modelName);
|
||||
if (modIndex == -1) {
|
||||
throw new GribException(
|
||||
"Error assembling ncgrids. Thinned ncgrid definition does not contain "
|
||||
+ modelName);
|
||||
}
|
||||
Util.insertSubgrid(
|
||||
assembledData,
|
||||
Util.resizeDataTo2D((float[]) record.getMessageData(),
|
||||
coverage.getNx(), coverage.getNy()), nx * modIndex, 0,
|
||||
nx, ny);
|
||||
|
||||
assembledRecord.setMessageData(Util.resizeDataTo1D(assembledData,
|
||||
(int) sizes[1], (int) sizes[0]));
|
||||
dao.replaceRecord(assembledRecord);
|
||||
return assembledRecord;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the composite grib record and stores it to the HDF5 repository
|
||||
*
|
||||
* @param record
|
||||
* The recieved NcgribRecord used to initialize the composite
|
||||
* grid with
|
||||
* @param dao
|
||||
* An instance of the grib data access object
|
||||
* @param thinned
|
||||
* The composite grid definition
|
||||
* @return The composite record
|
||||
* @throws GribException
|
||||
*/
|
||||
private NcgribRecord createRecord(NcgribRecord record, NcgribDao dao,
|
||||
NccompositeModel thinned) throws GribException {
|
||||
LatLonNcgridCoverage coverage = (LatLonNcgridCoverage) NcgribSpatialCache
|
||||
.getInstance().getGridByName(thinned.getGrid());
|
||||
|
||||
NcgridCoverage gridLoc = record.getModelInfo().getLocation();
|
||||
|
||||
float[] data = new float[(gridLoc.getNx() * 4) * gridLoc.getNy()];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = GridUtil.GRID_FILL_VALUE;
|
||||
}
|
||||
NcgribRecord newRecord = new NcgribRecord();
|
||||
NcgribModel newModel = new NcgribModel(record.getModelInfo());
|
||||
newModel.setGridid(coverage.getName());
|
||||
newModel.setGridNumber(Integer.parseInt(coverage.getName()));
|
||||
newModel.setModelName(thinned.getModelName());
|
||||
newModel.setLocation(coverage);
|
||||
newModel.generateId();
|
||||
|
||||
try {
|
||||
newModel = NcgribModelCache.getInstance().getModel(newModel);
|
||||
} catch (DataAccessLayerException e) {
|
||||
throw new GribException(
|
||||
"Unable to get ncep model info from the cache!", e);
|
||||
}
|
||||
newRecord.setModelInfo(newModel);
|
||||
newRecord.setMessageData(data);
|
||||
newRecord.setDataTime(record.getDataTime());
|
||||
newRecord.setDataURI(null);
|
||||
newRecord.setInsertTime(Calendar.getInstance());
|
||||
|
||||
try {
|
||||
newRecord.constructDataURI();
|
||||
} catch (PluginException e) {
|
||||
throw new GribException(
|
||||
"Error constructing DataURI for ncgrib record", e);
|
||||
}
|
||||
try {
|
||||
dao.persistToHDF5(newRecord);
|
||||
dao.persistToDatabase(newRecord);
|
||||
newRecord = (NcgribRecord) dao.getMetadata(newRecord.getDataURI());
|
||||
FloatDataRecord rec = (FloatDataRecord) dao.getHDF5Data(newRecord,
|
||||
0)[0];
|
||||
newRecord.setMessageData(rec);
|
||||
} catch (PluginException e) {
|
||||
throw new GribException("Error storing new ncrecord to HDF5", e);
|
||||
}
|
||||
return newRecord;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib.dao;
|
||||
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||
|
||||
/**
|
||||
* Interface implemented by grid coverage data access objects
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public interface INcgridCoverageDao {
|
||||
|
||||
public NcgridCoverage checkGrid(NcgridCoverage grid)
|
||||
throws DataAccessLayerException;
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LambertConformalNcgridCoverage;
|
||||
|
||||
/**
|
||||
* Data Access Object for retrieving LambertConforamlGridCoverage objects
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class NcLambertConformalDao extends NcgridCoverageDao implements INcgridCoverageDao {
|
||||
|
||||
/**
|
||||
* Creates new MercatorDao
|
||||
*/
|
||||
public NcLambertConformalDao() {
|
||||
super(DaoConfig.forClass(LambertConformalNcgridCoverage.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that database to see if a grid exists in the database which very
|
||||
* closely resembles the provided coverage
|
||||
*
|
||||
* @param coverage
|
||||
* The PolarStereoGridCoverage to check against
|
||||
* @return The Grid from the database or null if not found
|
||||
* @throws DataAccessLayerException
|
||||
* If problems during query
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public NcgridCoverage checkGrid(NcgridCoverage grid)
|
||||
throws DataAccessLayerException {
|
||||
|
||||
LambertConformalNcgridCoverage coverage = (LambertConformalNcgridCoverage)grid;
|
||||
DatabaseQuery query = new DatabaseQuery(this.daoClass);
|
||||
query.addQueryParam(addQueryTolerance("dx", coverage.getDx()));
|
||||
query.addQueryParam(addQueryTolerance("dy", coverage.getDy()));
|
||||
query.addQueryParam(addQueryTolerance("la1", coverage.getLa1()));
|
||||
query.addQueryParam(addQueryTolerance("lo1", coverage.getLo1()));
|
||||
query.addQueryParam(addQueryTolerance("latin1", coverage.getLatin1()));
|
||||
query.addQueryParam(addQueryTolerance("latin2", coverage.getLatin2()));
|
||||
query.addQueryParam(addQueryTolerance("lov", coverage.getLov()));
|
||||
query.addQueryParam("nx", coverage.getNx());
|
||||
query.addQueryParam("ny", coverage.getNy());
|
||||
List<LambertConformalNcgridCoverage> result = (List<LambertConformalNcgridCoverage>) queryByCriteria(query);
|
||||
|
||||
if (result.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return result.get(0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,141 +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 gov.noaa.nws.ncep.edex.plugin.ncgrib.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LatLonNcgridCoverage;
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.Ncgrib1Decoder;
|
||||
|
||||
/**
|
||||
* Data Access Object for retrieving LatLonNcgridCoverage objects
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class NcLatLonDao extends NcgridCoverageDao implements INcgridCoverageDao {
|
||||
|
||||
/**
|
||||
* Creates a new NcLatLonDao
|
||||
*/
|
||||
public NcLatLonDao() {
|
||||
super(DaoConfig.forClass(LatLonNcgridCoverage.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that database to see if a grid exists in the database which very
|
||||
* closely resembles the provided coverage
|
||||
*
|
||||
* @param coverage
|
||||
* The LatLonNcgridCoverage to check against
|
||||
* @return The Grid from the database or null if not found
|
||||
* @throws DataAccessLayerException
|
||||
* If problems during query
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public NcgridCoverage checkGrid(NcgridCoverage grid)
|
||||
throws DataAccessLayerException {
|
||||
|
||||
LatLonNcgridCoverage coverage = (LatLonNcgridCoverage) grid;
|
||||
DatabaseQuery query = new DatabaseQuery(this.daoClass);
|
||||
|
||||
// If dx and dy are present, use them
|
||||
if (coverage.getDx() != 65.535) {
|
||||
query.addQueryParam(addQueryTolerance("dx", coverage.getDx()));
|
||||
}
|
||||
if (coverage.getDy() != 65.535) {
|
||||
query.addQueryParam(addQueryTolerance("dy", coverage.getDy()));
|
||||
}
|
||||
query.addQueryParam(addQueryTolerance("la1", coverage.getLa1()));
|
||||
query.addQueryParam(addQueryTolerance("lo1", coverage.getLo1()));
|
||||
query.addQueryParam(addQueryTolerance("la2", coverage.getLa2()));
|
||||
query.addQueryParam(addQueryTolerance("lo2", coverage.getLo2()));
|
||||
query.addQueryParam("nx", coverage.getNx());
|
||||
query.addQueryParam("ny", coverage.getNy());
|
||||
List<LatLonNcgridCoverage> result = (List<LatLonNcgridCoverage>) queryByCriteria(query);
|
||||
|
||||
if (result.isEmpty()) {
|
||||
return manualCheck(coverage);
|
||||
} else {
|
||||
return result.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private NcgridCoverage manualCheck(LatLonNcgridCoverage coverage)
|
||||
throws DataAccessLayerException {
|
||||
|
||||
DatabaseQuery query = new DatabaseQuery(this.daoClass);
|
||||
query.addQueryParam("nx", coverage.getNx());
|
||||
query.addQueryParam("ny", coverage.getNy());
|
||||
List<LatLonNcgridCoverage> result = (List<LatLonNcgridCoverage>) queryByCriteria(query);
|
||||
|
||||
for (LatLonNcgridCoverage gridToCheck : result) {
|
||||
if (checkLat(coverage.getLa1(), gridToCheck.getLa1())
|
||||
&& checkLat(coverage.getLa2(), gridToCheck.getLa2())
|
||||
&& checkLon(coverage.getLo1(), gridToCheck.getLo1())
|
||||
&& checkLon(coverage.getLo2(), gridToCheck.getLo2())) {
|
||||
return gridToCheck;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean checkLat(double reference, double latToCheck) {
|
||||
double correctedRef = Ncgrib1Decoder.correctLat((float) reference);
|
||||
double correctedLat = Ncgrib1Decoder.correctLat((float) latToCheck);
|
||||
|
||||
if (Math.abs(correctedRef - correctedLat) < QUERY_TOLERANCE
|
||||
|| Math.abs(correctedLat - correctedRef) < QUERY_TOLERANCE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkLon(double reference, double lonToCheck) {
|
||||
double correctedRef = Ncgrib1Decoder.correctLon((float) reference);
|
||||
double correctedLon = Ncgrib1Decoder.correctLon((float) lonToCheck);
|
||||
|
||||
if (Math.abs(correctedRef - correctedLon) < QUERY_TOLERANCE
|
||||
|| Math.abs(correctedLon - correctedRef) < QUERY_TOLERANCE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,93 +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 gov.noaa.nws.ncep.edex.plugin.ncgrib.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.MercatorNcgridCoverage;
|
||||
|
||||
/**
|
||||
* Data Access Object for retrieving MercatorCoverage objects
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class NcMercatorDao extends NcgridCoverageDao implements INcgridCoverageDao{
|
||||
|
||||
/**
|
||||
* Creates new MercatorDao
|
||||
*/
|
||||
public NcMercatorDao() {
|
||||
super(DaoConfig.forClass(MercatorNcgridCoverage.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that database to see if a grid exists in the database which very
|
||||
* closely resembles the provided coverage
|
||||
*
|
||||
* @param coverage
|
||||
* The MercatorCoverage to check against
|
||||
* @return The Grid from the database or null if not found
|
||||
* @throws DataAccessLayerException
|
||||
* If problems during query
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public NcgridCoverage checkGrid(NcgridCoverage grid)
|
||||
throws DataAccessLayerException {
|
||||
|
||||
MercatorNcgridCoverage coverage = (MercatorNcgridCoverage)grid;
|
||||
|
||||
DatabaseQuery query = new DatabaseQuery(this.daoClass);
|
||||
query.addQueryParam(addQueryTolerance("dx", coverage.getDx()));
|
||||
query.addQueryParam(addQueryTolerance("dy", coverage.getDy()));
|
||||
query.addQueryParam(addQueryTolerance("la1", coverage.getLa1()));
|
||||
query.addQueryParam(addQueryTolerance("lo1", coverage.getLo1()));
|
||||
query.addQueryParam(addQueryTolerance("latin", coverage.getLatin()));
|
||||
query.addQueryParam(addQueryTolerance("la2", coverage.getLa2()));
|
||||
query.addQueryParam(addQueryTolerance("lo2", coverage.getLo2()));
|
||||
query.addQueryParam("nx", coverage.getNx());
|
||||
query.addQueryParam("ny", coverage.getNy());
|
||||
List<MercatorNcgridCoverage> result = (List<MercatorNcgridCoverage>) queryByCriteria(query);
|
||||
|
||||
if (result.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return result.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,90 +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 gov.noaa.nws.ncep.edex.plugin.ncgrib.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.PolarStereoNcgridCoverage;
|
||||
|
||||
/**
|
||||
* Data Access Object for retrieving PolarStereoNcgridCoverage objects
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class NcPolarStereoDao extends NcgridCoverageDao implements INcgridCoverageDao {
|
||||
|
||||
/**
|
||||
* Creates new MercatorDao
|
||||
*/
|
||||
public NcPolarStereoDao() {
|
||||
super(DaoConfig.forClass(PolarStereoNcgridCoverage.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that database to see if a grid exists in the database which very
|
||||
* closely resembles the provided coverage
|
||||
*
|
||||
* @param coverage
|
||||
* The PolarStereoNcgridCoverage to check against
|
||||
* @return The Grid from the database or null if not found
|
||||
* @throws DataAccessLayerException
|
||||
* If problems during query
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public NcgridCoverage checkGrid(NcgridCoverage grid)
|
||||
throws DataAccessLayerException {
|
||||
|
||||
PolarStereoNcgridCoverage coverage = (PolarStereoNcgridCoverage) grid;
|
||||
|
||||
DatabaseQuery query = new DatabaseQuery(this.daoClass);
|
||||
query.addQueryParam(addQueryTolerance("dx", coverage.getDx()));
|
||||
query.addQueryParam(addQueryTolerance("dy", coverage.getDy()));
|
||||
query.addQueryParam(addQueryTolerance("la1", coverage.getLa1()));
|
||||
query.addQueryParam(addQueryTolerance("lo1", coverage.getLo1()));
|
||||
query.addQueryParam(addQueryTolerance("lov", coverage.getLov()));
|
||||
query.addQueryParam("nx", coverage.getNx());
|
||||
query.addQueryParam("ny", coverage.getNy());
|
||||
List<PolarStereoNcgridCoverage> result = (List<PolarStereoNcgridCoverage>) queryByCriteria(query);
|
||||
|
||||
if (result.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return result.get(0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,430 +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 gov.noaa.nws.ncep.edex.plugin.ncgrib.dao;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
|
||||
import gov.noaa.nws.ncep.edex.common.dao.NcepDefaultPluginDao;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
|
||||
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
|
||||
import com.raytheon.uf.common.dataplugin.persist.IPersistable;
|
||||
import com.raytheon.uf.common.datastorage.DataStoreFactory;
|
||||
import com.raytheon.uf.common.datastorage.IDataStore;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.StorageException;
|
||||
import com.raytheon.uf.common.datastorage.StorageProperties;
|
||||
import com.raytheon.uf.common.datastorage.StorageStatus;
|
||||
import com.raytheon.uf.common.datastorage.IDataStore.StoreOp;
|
||||
import com.raytheon.uf.common.datastorage.StorageProperties.Compression;
|
||||
import com.raytheon.uf.common.datastorage.records.AbstractStorageRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.edex.core.hdf5.HDF5PluginFilenameFilter;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
|
||||
/**
|
||||
* Data access object for accessing Grib records from the database
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
* 12/16/10 mli extend NcepDefaultPluginDao to enable purge
|
||||
* 01/14/13 1469 bkowal Removed the hdf5 data directory.
|
||||
* 04/08/13 1293 bkowal Removed references to hdffileid.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class NcgribDao extends NcepDefaultPluginDao {
|
||||
|
||||
// FIXME: Add rules for purging
|
||||
/** Temporary value of how many models to keep */
|
||||
private static final int MODELCOUNT = 2;
|
||||
|
||||
private static final String MODEL_QUERY = "select distinct modelname from awips.ncgrib_models";
|
||||
|
||||
private static final String REFTIME_QUERY = "select distinct reftime from awips.ncgrib where modelinfo_id in (select id from awips.ncgrib_models where modelname='?') order by reftime desc";
|
||||
|
||||
private static final String PURGE_SQL = "delete from awips.ncgrib where refTime='?' and modelinfo_id in(select id from awips.ncgrib_models where modelname='?')";
|
||||
|
||||
private static final String LOCAL_SECTION = "localSection";
|
||||
|
||||
private static final String HYBRID_LEVELS = "hybridLevels";
|
||||
|
||||
private static final String THINNED_PTS = "thinnedPts";
|
||||
|
||||
private static final HDF5PluginFilenameFilter fileFilter = new HDF5PluginFilenameFilter(
|
||||
"ncgrib");
|
||||
|
||||
/**
|
||||
* Creates a new NcgribPyDao object
|
||||
*
|
||||
* @param pluginName
|
||||
* The name of the plugin. In this case, ncgrib.
|
||||
* @throws PluginException
|
||||
* If problems occur instantiating dao
|
||||
*/
|
||||
public NcgribDao(String pluginName) throws PluginException {
|
||||
super(pluginName);
|
||||
}
|
||||
|
||||
public NcgribDao() throws PluginException {
|
||||
this("ncgrib");
|
||||
}
|
||||
|
||||
// public void purgeExpiredData() {
|
||||
// QueryResult models = null;
|
||||
// try {
|
||||
// models = (QueryResult) executeNativeSql(MODEL_QUERY);
|
||||
// } catch (DataAccessLayerException e) {
|
||||
// logger.error("Error purging ncgrib data. Unable to get models", e);
|
||||
// }
|
||||
//
|
||||
// String currentModel = null;
|
||||
// for (int i = 0; i < models.getResultCount(); i++) {
|
||||
// currentModel = (String) models.getRowColumnValue(i, 0);
|
||||
// QueryResult refTimes = null;
|
||||
// try {
|
||||
// refTimes = (QueryResult) executeNativeSql(REFTIME_QUERY
|
||||
// .replace("?", currentModel));
|
||||
// } catch (DataAccessLayerException e) {
|
||||
// logger
|
||||
// .error("Error purging ncgrib data. Unable to get reference times for model ["
|
||||
// + currentModel + "]");
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// // FIXME: Add rules for purging here instead of just keeping 2
|
||||
// // runs
|
||||
// List<String> filesKept = new ArrayList<String>();
|
||||
// File modelDirectory = new File(PLUGIN_HDF5_DIR + File.separator
|
||||
// + currentModel);
|
||||
//
|
||||
// for (int j = 0; j < refTimes.getResultCount(); j++) {
|
||||
// Date time = (Date) refTimes.getRowColumnValue(j, 0);
|
||||
// File hdf5File = new File(modelDirectory.getAbsolutePath()
|
||||
// + File.separator
|
||||
// + ((NcgribPathProvider) pathProvider).formatTime(time)
|
||||
// + ".h5");
|
||||
//
|
||||
// if (j < MODELCOUNT) {
|
||||
// filesKept.add(hdf5File.getAbsolutePath());
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// purgeDb(time, currentModel);
|
||||
// } catch (DataAccessLayerException e) {
|
||||
// logger.error("Error purging database for ncgrib model ["
|
||||
// + currentModel + "]");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<File> files = FileUtil.listFiles(modelDirectory, fileFilter,
|
||||
// false);
|
||||
//
|
||||
// for (File file : files) {
|
||||
// if (!filesKept.contains(file.getAbsolutePath())) {
|
||||
// if (!file.delete()) {
|
||||
// logger
|
||||
// .error("Error purging HDF5 files for ncgrib model ["
|
||||
// + currentModel + "]");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
private int purgeDb(final Date date, String modelName)
|
||||
throws DataAccessLayerException {
|
||||
String sql = PURGE_SQL.replaceFirst("\\?", TimeUtil.formatDate(date))
|
||||
.replaceFirst("\\?", modelName);
|
||||
Integer results = null;
|
||||
results = (Integer) this.executeNativeSql(sql);
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IDataStore populateDataStore(IDataStore dataStore,
|
||||
IPersistable obj) throws Exception {
|
||||
NcgribRecord gribRec = (NcgribRecord) obj;
|
||||
|
||||
if (gribRec.getMessageData() != null
|
||||
&& !gribRec.getModelInfo().getParameterName().equals("Missing")) {
|
||||
AbstractStorageRecord storageRecord = null;
|
||||
AbstractStorageRecord localSection = null;
|
||||
AbstractStorageRecord hybridLevels = null;
|
||||
AbstractStorageRecord thinnedPts = null;
|
||||
|
||||
// System.out.println (" good data to be populated, rec datauri=" +
|
||||
// gribRec.getDataURI());
|
||||
// System.out.println
|
||||
// (" good data to be populated, rec messagedata=" +
|
||||
// gribRec.getMessageData());
|
||||
|
||||
/*
|
||||
* Stores the binary data to the HDF5 data store
|
||||
*/
|
||||
if (gribRec.getMessageData() instanceof float[]) {
|
||||
if (gribRec.getSpatialObject() != null
|
||||
&& gribRec.getMessageData() != null) {
|
||||
long[] sizes = new long[] {
|
||||
(gribRec.getSpatialObject()).getNx(),
|
||||
(gribRec.getSpatialObject()).getNy() };
|
||||
storageRecord = new FloatDataRecord("Data",
|
||||
gribRec.getDataURI(),
|
||||
(float[]) gribRec.getMessageData(), 2, sizes);
|
||||
} else
|
||||
throw new Exception(
|
||||
"Cannot create data record, spatialData = "
|
||||
+ gribRec.getSpatialObject()
|
||||
+ " and messageData = "
|
||||
+ gribRec.getMessageData());
|
||||
} else if (gribRec.getMessageData() instanceof byte[]) {
|
||||
storageRecord = new ByteDataRecord("Data",
|
||||
gribRec.getDataURI(), (byte[]) gribRec.getMessageData());
|
||||
} else {
|
||||
throw new PluginException("Invalid message data type: "
|
||||
+ gribRec.getMessageData().getClass());
|
||||
}
|
||||
|
||||
/*
|
||||
* Stores any data from the local section if present
|
||||
*/
|
||||
if (gribRec.isLocalSectionUsed()) {
|
||||
localSection = new IntegerDataRecord(LOCAL_SECTION,
|
||||
gribRec.getDataURI(), gribRec.getLocalSection());
|
||||
localSection.setCorrelationObject(gribRec);
|
||||
dataStore.addDataRecord(localSection);
|
||||
}
|
||||
|
||||
/*
|
||||
* Stores any hybrid coordinate data if present
|
||||
*/
|
||||
if (gribRec.isHybridGrid()) {
|
||||
hybridLevels = new FloatDataRecord(HYBRID_LEVELS,
|
||||
gribRec.getDataURI(), gribRec.getHybridCoordList());
|
||||
hybridLevels.setCorrelationObject(gribRec);
|
||||
dataStore.addDataRecord(hybridLevels);
|
||||
}
|
||||
|
||||
/*
|
||||
* Stores any thinned point data for quasi-regular grids if present
|
||||
*/
|
||||
if (gribRec.isThinnedGrid()) {
|
||||
thinnedPts = new IntegerDataRecord(THINNED_PTS,
|
||||
gribRec.getDataURI(), gribRec.getThinnedPts());
|
||||
thinnedPts.setCorrelationObject(gribRec);
|
||||
dataStore.addDataRecord(thinnedPts);
|
||||
}
|
||||
|
||||
storageRecord.setCorrelationObject(gribRec);
|
||||
StorageProperties sp = new StorageProperties();
|
||||
sp.setCompression(Compression.LZF);
|
||||
sp.setChunked(true);
|
||||
dataStore.addDataRecord(storageRecord, sp);
|
||||
}
|
||||
return dataStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IDataRecord[]> getHDF5Data(List<PluginDataObject> objects,
|
||||
int tileSet) throws PluginException {
|
||||
|
||||
List<IDataRecord[]> retVal = new ArrayList<IDataRecord[]>();
|
||||
|
||||
for (PluginDataObject rec : objects) {
|
||||
IDataRecord[] record = null;
|
||||
|
||||
if (rec instanceof NcgribRecord) {
|
||||
NcgribRecord obj = (NcgribRecord) rec;
|
||||
/* connect to the data store and retrieve the data */
|
||||
IDataStore dataStore = getDataStore(obj);
|
||||
record = new IDataRecord[4];
|
||||
try {
|
||||
|
||||
record[0] = dataStore.retrieve(obj.getDataURI(), "Data",
|
||||
Request.ALL);
|
||||
|
||||
if (obj.isLocalSectionUsed()) {
|
||||
record[1] = dataStore.retrieve(obj.getDataURI(),
|
||||
LOCAL_SECTION, Request.ALL);
|
||||
}
|
||||
if (obj.isHybridGrid()) {
|
||||
record[2] = dataStore.retrieve(obj.getDataURI(),
|
||||
HYBRID_LEVELS, Request.ALL);
|
||||
}
|
||||
if (obj.isThinnedGrid()) {
|
||||
record[3] = dataStore.retrieve(obj.getDataURI(),
|
||||
THINNED_PTS, Request.ALL);
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
throw new PluginException("Error getting HDF5 data", e);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new PluginException("Error getting HDF5 data", e);
|
||||
}
|
||||
retVal.add(record);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void persistRecords(PluginDataObject... records)
|
||||
throws PluginException {
|
||||
List<PluginDataObject> toPersist = new ArrayList<PluginDataObject>();
|
||||
for (PluginDataObject record : records) {
|
||||
NcgribRecord rec = (NcgribRecord) record;
|
||||
NcgribModel model = rec.getModelInfo();
|
||||
if (model.getParameterName() == null
|
||||
|| model.getParameterName().equals("Missing")) {
|
||||
// System.out.println (" persist missing or null, rec datauri="
|
||||
// + rec.getDataURI());
|
||||
|
||||
logger.info("Discarding record due to missing or unknown parameter mapping: "
|
||||
+ record);
|
||||
} else {
|
||||
boolean validLevel = false;
|
||||
Level level = model.getLevel();
|
||||
|
||||
if (level != null) {
|
||||
MasterLevel ml = level.getMasterLevel();
|
||||
|
||||
if (ml != null
|
||||
&& !LevelFactory.UNKNOWN_LEVEL.equals(ml.getName())) {
|
||||
validLevel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (validLevel) {
|
||||
toPersist.add(rec);
|
||||
} else {
|
||||
logger.info("Discarding record due to missing or unknown level mapping: "
|
||||
+ record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.persistRecords(toPersist.toArray(new PluginDataObject[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginDataObject[] persistToDatabase(PluginDataObject... records) {
|
||||
return super.persistToDatabase(verifyRecords(records));
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageStatus persistToHDF5(PluginDataObject... records)
|
||||
throws PluginException {
|
||||
return super.persistToHDF5(verifyRecords(records));
|
||||
}
|
||||
|
||||
private PluginDataObject[] verifyRecords(PluginDataObject... records) {
|
||||
List<PluginDataObject> toPersist = new ArrayList<PluginDataObject>();
|
||||
for (PluginDataObject record : records) {
|
||||
NcgribRecord rec = (NcgribRecord) record;
|
||||
NcgribModel model = rec.getModelInfo();
|
||||
if (model.getParameterName() == null
|
||||
|| model.getParameterName().equals("Missing")) {
|
||||
// System.out.println (" verify missing or null, rec datauri=" +
|
||||
// rec.getDataURI());
|
||||
|
||||
logger.info("Discarding record due to missing or unknown parameter mapping: "
|
||||
+ record);
|
||||
} else {
|
||||
boolean validLevel = false;
|
||||
Level level = model.getLevel();
|
||||
|
||||
if (level != null) {
|
||||
MasterLevel ml = level.getMasterLevel();
|
||||
|
||||
if (ml != null
|
||||
&& !LevelFactory.UNKNOWN_LEVEL.equals(ml.getName())) {
|
||||
validLevel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (validLevel) {
|
||||
toPersist.add(rec);
|
||||
} else {
|
||||
logger.info("Discarding record due to missing or unknown level mapping: "
|
||||
+ record);
|
||||
}
|
||||
}
|
||||
}
|
||||
return toPersist.toArray(new NcgribRecord[0]);
|
||||
}
|
||||
|
||||
public List<StorageException> replaceRecord(NcgribRecord pdo)
|
||||
throws PluginException {
|
||||
List<StorageException> exceptions = new ArrayList<StorageException>();
|
||||
IPersistable persistable = (IPersistable) pdo;
|
||||
|
||||
// get the directory
|
||||
String directory = pdo.getPluginName() + File.separator
|
||||
+ pathProvider.getHDFPath(this.pluginName, persistable);
|
||||
File dataStoreFile = new File(directory + File.separator
|
||||
+ pathProvider.getHDFFileName(pdo.getPluginName(), persistable));
|
||||
|
||||
IDataStore dataStore = DataStoreFactory.getDataStore(dataStoreFile);
|
||||
|
||||
try {
|
||||
populateDataStore(dataStore, persistable);
|
||||
} catch (Exception e) {
|
||||
throw new PluginException("Error populating data store", e);
|
||||
}
|
||||
|
||||
StorageStatus s = null;
|
||||
try {
|
||||
s = dataStore.store(StoreOp.REPLACE);
|
||||
|
||||
// add exceptions to a list for aggregation
|
||||
exceptions.addAll(Arrays.asList(s.getExceptions()));
|
||||
} catch (StorageException e) {
|
||||
logger.error("Error persisting to HDF5", e);
|
||||
}
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib.dao;
|
||||
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
|
||||
|
||||
/**
|
||||
* Data access object for retrieving GribModel objects from the database
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class NcgribModelDao extends CoreDao {
|
||||
|
||||
/**
|
||||
* Creates a new GribModelDao
|
||||
*/
|
||||
public NcgribModelDao() {
|
||||
super(DaoConfig.forClass(NcgribModel.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the database to see if a model matching the provided model exists
|
||||
* already
|
||||
*
|
||||
* @param model
|
||||
* The model to check
|
||||
* @return The model object from the database.
|
||||
* @throws DataAccessLayerException
|
||||
* If problems occur while querying
|
||||
*/
|
||||
public NcgribModel checkModel(NcgribModel model)
|
||||
throws DataAccessLayerException {
|
||||
if (model.getId() == null) {
|
||||
model.generateId();
|
||||
}
|
||||
return (NcgribModel) this.queryById(model.getId());
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.dataquery.db.QueryParam;
|
||||
import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||
|
||||
/**
|
||||
* Data access object for retrieving GridCoverage objects
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class NcgridCoverageDao extends CoreDao {
|
||||
|
||||
protected static final float QUERY_TOLERANCE = 0.1f;
|
||||
|
||||
public NcgridCoverageDao() {
|
||||
super(DaoConfig.forClass(NcgridCoverage.class));
|
||||
}
|
||||
|
||||
public NcgridCoverageDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
protected QueryParam addQueryTolerance(String field, double value) {
|
||||
String between = String.valueOf(value - QUERY_TOLERANCE) + "--"
|
||||
+ String.valueOf(value + QUERY_TOLERANCE);
|
||||
return new QueryParam(field, between, QueryOperand.BETWEEN);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public NcgridCoverage queryByGridNumber(Integer number)
|
||||
throws DataAccessLayerException {
|
||||
List<NcgridCoverage> coverages = (List<NcgridCoverage>)this.queryBySingleCriteria("name",
|
||||
String.valueOf(number));
|
||||
if(coverages.isEmpty()){
|
||||
return null;
|
||||
}else{
|
||||
return coverages.get(0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* Data access objects for accessing and manipulating grib data.
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib.dao;
|
|
@ -1,49 +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 gov.noaa.nws.ncep.edex.plugin.ncgrib.handler;
|
||||
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial.NcgribSpatialCache;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.request.GetNcCoverageRequest;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 8, 2010 rjpeter Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GetNcCoverageHandler implements IRequestHandler<GetNcCoverageRequest> {
|
||||
|
||||
@Override
|
||||
public NcgridCoverage handleRequest(GetNcCoverageRequest request) {
|
||||
return NcgribSpatialCache.getInstance().getGrid(request.getModelName());
|
||||
}
|
||||
}
|
|
@ -1,119 +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 gov.noaa.nws.ncep.edex.plugin.ncgrib.handler;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcgribDao;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribThriftContainer;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribThriftRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.request.NcgridDataRequestMessage;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 12, 2010 brockwoo Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author brockwoo
|
||||
* @version 1.0
|
||||
*/
|
||||
public class NcgridDataHandler implements IRequestHandler<NcgridDataRequestMessage> {
|
||||
|
||||
@Override
|
||||
public Object handleRequest(NcgridDataRequestMessage request)
|
||||
throws Exception {
|
||||
|
||||
NcgribDao dao = new NcgribDao();
|
||||
DatabaseQuery query = new DatabaseQuery(NcgribRecord.class);
|
||||
|
||||
if (request.getModelName() != null) {
|
||||
query.addQueryParam("modelInfo.modelName", request.getModelName(),
|
||||
QueryOperand.EQUALS);
|
||||
}
|
||||
|
||||
if (request.getLevelOne() != Level.INVALID_VALUE) {
|
||||
query.addQueryParam("modelInfo.level.levelonevalue", request
|
||||
.getLevelOne(), QueryOperand.EQUALS);
|
||||
if (request.getLevelType() != null) {
|
||||
query.addQueryParam("modelInfo.level.masterLevel.name", request
|
||||
.getLevelType(), QueryOperand.EQUALS);
|
||||
}
|
||||
query.addQueryParam("modelInfo.level.leveltwovalue", request
|
||||
.getLevelTwo(), QueryOperand.EQUALS);
|
||||
}
|
||||
|
||||
if (request.getParameterAbbreviation() != null) {
|
||||
query.addQueryParam("modelInfo.parameterAbbreviation", request
|
||||
.getParameterAbbreviation(), QueryOperand.EQUALS);
|
||||
}
|
||||
|
||||
if (request.getStartTime() != NcgridDataRequestMessage.MISSING) {
|
||||
Timestamp stamp = new Timestamp(request.getStartTime());
|
||||
DataTime newTime = new DataTime(stamp, request.getForecastTime());
|
||||
query.addQueryParam("dataTime", newTime, QueryOperand.EQUALS);
|
||||
}
|
||||
|
||||
NcgribThriftContainer container = new NcgribThriftContainer();
|
||||
try {
|
||||
PluginDataObject[] records = null;
|
||||
records = dao.getFullRecord(query, -1);
|
||||
|
||||
if (records != null && records.length > 0) {
|
||||
List<IDataRecord[]> hdfRecords = dao.getHDF5Data(Arrays
|
||||
.asList(records), -1);
|
||||
if (hdfRecords.size() != records.length) {
|
||||
container.setNumOfRecords(-1);
|
||||
return container;
|
||||
}
|
||||
NcgribThriftRecord thriftRecords[] = new NcgribThriftRecord[records.length];
|
||||
for (int i = 0; i < records.length; i++) {
|
||||
thriftRecords[i] = new NcgribThriftRecord();
|
||||
IDataRecord[] data = hdfRecords.get(i);
|
||||
NcgribRecord thisGribRecord = (NcgribRecord) records[i];
|
||||
NcgridDataRequestMessage thisGribInfo = new NcgridDataRequestMessage();
|
||||
thisGribInfo.setInfoFromRecord(thisGribRecord);
|
||||
thriftRecords[i].setMessage(thisGribInfo);
|
||||
thriftRecords[i].setDataFields(data);
|
||||
}
|
||||
container.setRecords(thriftRecords);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
container.setNumOfRecords(-1);
|
||||
}
|
||||
return container;
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2006-2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib.notify;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 6, 2009 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@DynamicSerialize
|
||||
public class NcgribNotifyContainer implements ISerializableObject {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private NcgribNotifyMessage[] messages;
|
||||
|
||||
public NcgribNotifyMessage[] getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public void setMessages(NcgribNotifyMessage[] messages) {
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2006-2009, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib.notify;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* A message representing a grib record that was ingested, but only the basic
|
||||
* human-readable information.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 6, 2009 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@DynamicSerialize
|
||||
public class NcgribNotifyMessage implements ISerializableObject {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String model;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Date modelTime;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String paramAbbreviation;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String levelAbbreviation;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Date insertTime;
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public Date getModelTime() {
|
||||
return modelTime;
|
||||
}
|
||||
|
||||
public void setModelTime(Date modelTime) {
|
||||
this.modelTime = modelTime;
|
||||
}
|
||||
|
||||
public String getParamAbbreviation() {
|
||||
return paramAbbreviation;
|
||||
}
|
||||
|
||||
public void setParamAbbreviation(String paramAbbreviation) {
|
||||
this.paramAbbreviation = paramAbbreviation;
|
||||
}
|
||||
|
||||
public String getLevelAbbreviation() {
|
||||
return levelAbbreviation;
|
||||
}
|
||||
|
||||
public void setLevelAbbreviation(String levelAbbreviation) {
|
||||
this.levelAbbreviation = levelAbbreviation;
|
||||
}
|
||||
|
||||
public Date getInsertTime() {
|
||||
return insertTime;
|
||||
}
|
||||
|
||||
public void setInsertTime(Date insertTime) {
|
||||
this.insertTime = insertTime;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,85 +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 gov.noaa.nws.ncep.edex.plugin.ncgrib.notify;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
|
||||
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribModelLookup;
|
||||
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgridTranslator;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel;
|
||||
/**
|
||||
* Translates a NcgribRecord into a NcgribNotifyMessage
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 5, 2009 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class NcgribNotifyTransform {
|
||||
|
||||
/**
|
||||
* Translates the grib records into messages that have specific readable
|
||||
* data about what was ingested.
|
||||
*
|
||||
* @param gribs
|
||||
* @return
|
||||
*/
|
||||
public static NcgribNotifyContainer transformToMessages(
|
||||
PluginDataObject[] gribs) {
|
||||
NcgribNotifyContainer container = new NcgribNotifyContainer();
|
||||
List<NcgribNotifyMessage> msgList = new ArrayList<NcgribNotifyMessage>();
|
||||
for (PluginDataObject pdo : gribs) {
|
||||
NcgribRecord grib = (NcgribRecord) pdo;
|
||||
NcgribModel modelInfo = grib.getModelInfo();
|
||||
String level = NcgridTranslator.getInstance().getShortLevelName(
|
||||
modelInfo.getLevelName(), modelInfo.getLevelOneValue(),
|
||||
modelInfo.getLevelTwoValue());
|
||||
|
||||
// currently the consumers of this data (GFE) don't care about it
|
||||
// if we can't identify a model name and level
|
||||
if (level != null) {
|
||||
NcgribNotifyMessage msg = new NcgribNotifyMessage();
|
||||
msg.setInsertTime(grib.getInsertTime().getTime());
|
||||
msg.setModelTime(grib.getDataTime().getRefTime());
|
||||
msg.setModel(modelInfo.getModelName());
|
||||
msg.setLevelAbbreviation(level);
|
||||
msg.setParamAbbreviation(grib.getModelInfo()
|
||||
.getParameterAbbreviation());
|
||||
msgList.add(msg);
|
||||
}
|
||||
}
|
||||
container.setMessages(msgList.toArray(new NcgribNotifyMessage[msgList
|
||||
.size()]));
|
||||
return container;
|
||||
}
|
||||
}
|
|
@ -1,391 +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 gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel;
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.INcgridCoverageDao;
|
||||
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribModelLookup;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
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.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
|
||||
/**
|
||||
* Cache used for holding GridCoverage objects. Since creating geometries and
|
||||
* CRS objects are expensive operations, this cache is used to store
|
||||
* GridCoverages as the are produced.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 4/7/09 1994 bphillip Initial Creation
|
||||
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
public class NcgribSpatialCache {
|
||||
|
||||
/** The logger */
|
||||
protected transient Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
/** The singleton instance */
|
||||
private static NcgribSpatialCache instance;
|
||||
|
||||
/**
|
||||
* Map containing the GridCoverages<br>
|
||||
* The key for this map is the id field of the GridCoverage object stored as
|
||||
* the value of the map
|
||||
*/
|
||||
private final Map<Integer, NcgridCoverage> ncspatialMap;
|
||||
|
||||
/**
|
||||
* Map containing the GridCoverages<br>
|
||||
* The key for this map is the name field of the GridCoverage object stored
|
||||
* as the value of the map. This is only used internally for lookup of a
|
||||
* coverage by name aka gridId.
|
||||
*/
|
||||
private final Map<String, NcgridCoverage> ncspatialNameMap;
|
||||
|
||||
/**
|
||||
* Map containing the subGrid coverage based on a model name.
|
||||
*/
|
||||
private final Map<String, Integer> subNcgridCoverageMap;
|
||||
|
||||
/**
|
||||
* Map containing the subGrid definition based on a model name.
|
||||
*/
|
||||
private final Map<String, SubNcgrid> definedSubNcgridMap;
|
||||
|
||||
/**
|
||||
* Gets the singleton instance of NcgribSpatialCache
|
||||
*
|
||||
* @return The singleton instance of the NcgribSpatialCache
|
||||
*/
|
||||
public static synchronized NcgribSpatialCache getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new NcgribSpatialCache();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new NcgribSpatialCache
|
||||
*/
|
||||
private NcgribSpatialCache() {
|
||||
//System.out.println("ncep spatial grid coverage initial=");
|
||||
ncspatialMap = new HashMap<Integer, NcgridCoverage>();
|
||||
ncspatialNameMap = new HashMap<String, NcgridCoverage>();
|
||||
definedSubNcgridMap = new HashMap<String, SubNcgrid>();
|
||||
subNcgridCoverageMap = new HashMap<String, Integer>();
|
||||
initializeDefaultGrids();
|
||||
initializeDefaultSubGrids();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a grid from the map. If the grid does not exist, null is
|
||||
* returned
|
||||
*
|
||||
* @param id
|
||||
* The id of the NcgridCoverage to retrieve
|
||||
* @return The NcgridCoverage object, null if not present
|
||||
* @throws GribException
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
public NcgridCoverage getGrid(NcgridCoverage coverage) throws GribException {
|
||||
|
||||
//System.out.println("ncep grid coverage getid=" + coverage.getId());
|
||||
|
||||
NcgridCoverage retVal = ncspatialMap.get(coverage.getId());
|
||||
//System.out.println("N grid coverage retVal=" + retVal);
|
||||
|
||||
if (retVal == null) {
|
||||
/*
|
||||
* Coverage not found in cache, but the values provided in the GDS
|
||||
* may be slightly different than those for the grid in the cache.
|
||||
* Check the database to be sure.
|
||||
*/
|
||||
try {
|
||||
String where = "Nc" + coverage.getProjectionType().replaceAll(" ", "") + "Dao";
|
||||
//System.out.println("ncep where=" + where);
|
||||
|
||||
retVal = ((INcgridCoverageDao) EDEXUtil.getESBComponent("Nc" + coverage
|
||||
.getProjectionType().replaceAll(" ", "")
|
||||
+ "Dao")).checkGrid(coverage);
|
||||
//System.out.println("ncep grid coverage=" + retVal);
|
||||
|
||||
} catch (DataAccessLayerException e) {
|
||||
throw new GribException("Error querying for ncgrib coverage!", e);
|
||||
}
|
||||
if (retVal != null) {
|
||||
putGrid(retVal, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public NcgridCoverage getGrid(int id) {
|
||||
return ncspatialMap.get(id);
|
||||
}
|
||||
|
||||
public NcgridCoverage getGrid(String modelName) {
|
||||
NcgridCoverage rval = null;
|
||||
|
||||
//System.out.println("ncep get grid coverage, model Name=" + modelName);
|
||||
|
||||
if (modelName != null) {
|
||||
if (subNcgridCoverageMap.containsKey(modelName)) {
|
||||
rval = ncspatialMap.get(subNcgridCoverageMap.get(modelName));
|
||||
} else {
|
||||
NcgridModel model = NcgribModelLookup.getInstance().getModelByName(
|
||||
modelName);
|
||||
if (model != null) {
|
||||
rval = ncspatialNameMap.get(model.getGrid().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
//System.out.println("ncep get grid coverage, return coverage=" + rval);
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
public NcgridCoverage getGridByName(String name){
|
||||
return ncspatialNameMap.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a grid into the NcgribSpatialCache.
|
||||
*
|
||||
* @param grid
|
||||
* The grid to store
|
||||
* @param persistToDb
|
||||
* True if this NcgridCoverage object is to be persisted to the
|
||||
* database
|
||||
* @throws GribException
|
||||
* If problems occur while initializing the grid
|
||||
*/
|
||||
public void putGrid(NcgridCoverage grid, boolean persistToDb)
|
||||
throws GribException {
|
||||
|
||||
/*
|
||||
* Prepare the grid to be stored into the cache. Initializes the
|
||||
* geometry and crs objects and generates the id field
|
||||
*/
|
||||
grid.initialize();
|
||||
if (grid.getName() == null) {
|
||||
grid.generateName();
|
||||
}
|
||||
ncspatialMap.put(grid.getId(), grid);
|
||||
ncspatialNameMap.put(grid.getName(), grid);
|
||||
|
||||
// Persist to the database if desired
|
||||
if (persistToDb) {
|
||||
new CoreDao(DaoConfig.DEFAULT).saveOrUpdate(grid);
|
||||
}
|
||||
}
|
||||
|
||||
public SubNcgrid getSubGrid(String modelName) {
|
||||
return definedSubNcgridMap.get(modelName);
|
||||
}
|
||||
|
||||
public NcgridCoverage getSubGridCoverage(String modelName) {
|
||||
NcgridCoverage rval = null;
|
||||
|
||||
if (subNcgridCoverageMap.containsKey(modelName)) {
|
||||
rval = ncspatialMap.get(subNcgridCoverageMap.get(modelName));
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the predefined set of grids. The grids are stored in xml
|
||||
* format in the utility folder so the localization service has access to
|
||||
* them.<br>
|
||||
* NcgridCoverage are created from the xml via JaxB and placed in the cache
|
||||
*/
|
||||
private void initializeDefaultGrids() {
|
||||
|
||||
/*
|
||||
* Retrieve the list of files from the localization service
|
||||
*/
|
||||
FilenameFilter filter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.trim().endsWith(".xml");
|
||||
}
|
||||
};
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
String basePath = pm.getFile(
|
||||
pm.getContext(LocalizationType.EDEX_STATIC,
|
||||
LocalizationLevel.BASE), "/ncgrib/ncgrids").getPath();
|
||||
|
||||
//System.out.println("ncep default basePath=" + basePath);
|
||||
|
||||
String sitePath = pm.getFile(
|
||||
pm.getContext(LocalizationType.EDEX_STATIC,
|
||||
LocalizationLevel.SITE), "/ncgrib/ncgrids").getPath();
|
||||
|
||||
//System.out.println("ncep default sitePah=" + sitePath);
|
||||
|
||||
List<File> files = FileUtil.listFiles(new File(basePath), filter,
|
||||
true);
|
||||
|
||||
// Add any spatial information defined by the site
|
||||
files.addAll(FileUtil.listFiles(new File(sitePath), filter, true));
|
||||
|
||||
/*
|
||||
* Iterate over file list. Unmarshal to NcgridCoverage object Persist to
|
||||
* cache and database
|
||||
*/
|
||||
for (File file : files) {
|
||||
try {
|
||||
//System.out.println ("ncep default filePath=" + file.getPath());
|
||||
NcgridCoverage grid = SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(NcgridCoverage.class,
|
||||
file.getPath());
|
||||
putGrid(grid, true);
|
||||
} catch (Exception e) {
|
||||
// Log error but do not throw exception
|
||||
logger.error("Unable to read default NCEP grids file: " + file, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the predefined set of sub grids. The grids are stored in xml
|
||||
* format in the utility folder so the localization service has access to
|
||||
* them.<br>
|
||||
* NcgridCoverage are created from the xml via JaxB and placed in the cache
|
||||
*/
|
||||
private void initializeDefaultSubGrids() {
|
||||
|
||||
/*
|
||||
* Retrieve the list of files from the localization service
|
||||
*/
|
||||
FilenameFilter filter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
//System.out.println ("default nc init dir=" + dir);
|
||||
//System.out.println ("default nc init name=" + name);
|
||||
//System.out.println ("default nc init return=" + name.trim().endsWith(".xml"));
|
||||
return name.trim().endsWith(".xml");
|
||||
}
|
||||
};
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
|
||||
// load base sub grid definitions
|
||||
File path = pm.getFile(pm.getContext(LocalizationType.EDEX_STATIC,
|
||||
LocalizationLevel.BASE), "/ncgrib/subncgrids");
|
||||
|
||||
//System.out.println("default init ncgrib Path1=" + path);
|
||||
|
||||
if (path.exists() && path.isDirectory()) {
|
||||
loadSubGridFiles(FileUtil.listFiles(path, filter, true));
|
||||
}
|
||||
|
||||
// load site sub grid definitions
|
||||
path = pm.getFile(pm.getContext(LocalizationType.EDEX_STATIC,
|
||||
LocalizationLevel.SITE), "/ncgrib/subncgrids");
|
||||
|
||||
//System.out.println("default init ncgrib Path2=" + path);
|
||||
|
||||
if (path.exists() && path.isDirectory()) {
|
||||
loadSubGridFiles(FileUtil.listFiles(path, filter, true));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSubGridFiles(List<File> files) {
|
||||
NcgribModelLookup gribModelLUT = NcgribModelLookup.getInstance();
|
||||
|
||||
for (File file : files) {
|
||||
//System.out.println (" load nc subgrid file=" + file );
|
||||
try {
|
||||
SubNcgrid subGrid = (SubNcgrid) SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(file.getPath());
|
||||
|
||||
// do a reverse lookup of the model name to get its associated
|
||||
// grid id
|
||||
String modelName = subGrid.getModelName();
|
||||
//System.out.println (" load nc subgrid file model=" + modelName );
|
||||
|
||||
NcgridModel model = gribModelLUT.getModelByName(modelName);
|
||||
if (model != null) {
|
||||
NcgridCoverage baseCoverage = ncspatialNameMap.get(model
|
||||
.getGrid().toString());
|
||||
|
||||
//System.out.println (" load nc subgrid baseCoverage=" + baseCoverage );
|
||||
|
||||
if (baseCoverage != null) {
|
||||
NcgridCoverage subGridCoverage = baseCoverage
|
||||
.trim(subGrid);
|
||||
|
||||
//System.out.println (" load nc subgrid subGridCoverage=" + subGridCoverage );
|
||||
|
||||
if (subGridCoverage != null) {
|
||||
NcgridCoverage storedCoverage = getGrid(subGridCoverage);
|
||||
if (storedCoverage == null) {
|
||||
putGrid(subGridCoverage, true);
|
||||
storedCoverage = subGridCoverage;
|
||||
}
|
||||
//System.out.println (" load nc subgrid after store coverage" );
|
||||
|
||||
definedSubNcgridMap.put(modelName, subGrid);
|
||||
subNcgridCoverageMap.put(modelName, storedCoverage
|
||||
.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Log error but do not throw exception
|
||||
logger
|
||||
.error("Unable to read default sub ncgrid file: " + file,
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* Objects used for describing and storing spatial information for grib data
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial;
|
|
@ -1,123 +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 gov.noaa.nws.ncep.edex.plugin.ncgrib.util;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcgribModelDao;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
|
||||
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 29, 2010 rjpeter Initial creation
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class NcgribModelCache {
|
||||
private static NcgribModelCache instance;
|
||||
|
||||
private Map<Integer, WeakReference<NcgribModel>> modelMap = new WeakHashMap<Integer, WeakReference<NcgribModel>>();
|
||||
|
||||
private Map<Integer, Object> threadSyncMap = new WeakHashMap<Integer, Object>();
|
||||
|
||||
private NcgribModelCache() {
|
||||
|
||||
}
|
||||
|
||||
public static synchronized NcgribModelCache getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new NcgribModelCache();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public NcgribModel getModel(NcgribModel modelToLookup)
|
||||
throws DataAccessLayerException {
|
||||
if (modelToLookup.getId() == null) {
|
||||
modelToLookup.generateId();
|
||||
}
|
||||
|
||||
Integer key = modelToLookup.getId();
|
||||
|
||||
NcgribModel rval = null;
|
||||
WeakReference<NcgribModel> reference = modelMap.get(key);
|
||||
|
||||
if (reference == null || (rval = reference.get()) == null) {
|
||||
// quick check for in memory reference failed, grab sync lock and
|
||||
// check database
|
||||
synchronized (getThreadSyncObject(key)) {
|
||||
// due to sync lock need to double check map
|
||||
reference = modelMap.get(key);
|
||||
|
||||
if (reference == null || (rval = reference.get()) == null) {
|
||||
// was no prior sync'd thread
|
||||
NcgribModelDao dao = new NcgribModelDao();
|
||||
rval = dao.checkModel(modelToLookup);
|
||||
|
||||
if (rval == null) {
|
||||
rval = modelToLookup;
|
||||
dao.saveOrUpdate(rval);
|
||||
}
|
||||
|
||||
modelMap.put(rval.getId(), new WeakReference<NcgribModel>(
|
||||
rval));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// double check the location information hasn't changed
|
||||
if (modelToLookup.getLocation().getId() != rval.getLocation().getId()) {
|
||||
synchronized (getThreadSyncObject(key)) {
|
||||
rval = modelToLookup;
|
||||
NcgribModelDao dao = new NcgribModelDao();
|
||||
dao.saveOrUpdate(rval);
|
||||
modelMap.put(rval.getId(), new WeakReference<NcgribModel>(rval));
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
private synchronized Object getThreadSyncObject(Integer key) {
|
||||
Object rval = threadSyncMap.get(key);
|
||||
|
||||
if (rval == null) {
|
||||
rval = new Object();
|
||||
threadSyncMap.put(key, rval);
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
/**
|
||||
* TableTimeStamp - A Java class to update some known
|
||||
* ncep grib2 vars.xml and vcrd.xml and ncgribmodel.xml.
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 10/2010 276 L. Lin Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* This code has been developed by the SIB for use in the AWIPS2 system.
|
||||
* @author L. Lin
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib.util;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
import gov.noaa.nws.ncep.edex.util.grib2vars.Grib2VarsTableLookup;
|
||||
import gov.noaa.nws.ncep.edex.util.grib2vcrd.Grib2VcrdTableLookup;
|
||||
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribModelLookup;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
|
||||
public class TableTimeStamp {
|
||||
|
||||
private static long ncepVarsTimeStamp;
|
||||
|
||||
private static long ncepVcrdTimeStamp;
|
||||
|
||||
private static long ncepNcgribModelTimeStamp;
|
||||
|
||||
public TableTimeStamp() {
|
||||
}
|
||||
|
||||
public static synchronized void updateXmlTables() throws GribException {
|
||||
|
||||
long ncepVarsFileTime = 0;
|
||||
long ncepVcrdFileTime = 0;
|
||||
long ncepGribModelFileTime = 0;
|
||||
|
||||
/*
|
||||
* Gets all predefined found in the utility directory
|
||||
*/
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext commonStaticBase = pathMgr.getContext(
|
||||
LocalizationContext.LocalizationType.COMMON_STATIC,
|
||||
LocalizationContext.LocalizationLevel.BASE);
|
||||
|
||||
/* check NCEP VARS control file */
|
||||
String ncepVarsPath = "";
|
||||
|
||||
try {
|
||||
ncepVarsPath = pathMgr.getFile(commonStaticBase,
|
||||
"ncgrid" + File.separator + "grib2vars.xml")
|
||||
.getCanonicalPath();
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new GribException(
|
||||
"Unable to unmarshal ncep grib2vars.xml file");
|
||||
}
|
||||
|
||||
File ncepVarsTable = new File(ncepVarsPath);
|
||||
try {
|
||||
if (ncepVarsTable.exists()) {
|
||||
ncepVarsFileTime = ncepVarsTable.lastModified();
|
||||
if (ncepVarsFileTime != getNcepVarsTimeStamp()) {
|
||||
System.out
|
||||
.println("NCEP grib2vars.xml has been modified or the first time, so load it ...");
|
||||
Grib2VarsTableLookup.readG2varsTable();
|
||||
setNcepVarsTimeStamp(ncepVarsFileTime);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GribException("Unable to read ncep grib2vars file");
|
||||
}
|
||||
|
||||
/* check NCEP VCRD control file */
|
||||
String ncepVcrdPath = "";
|
||||
|
||||
try {
|
||||
ncepVcrdPath = pathMgr.getFile(commonStaticBase,
|
||||
"ncgrid" + File.separator + "grib2vcrd.xml")
|
||||
.getCanonicalPath();
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new GribException(
|
||||
"Unable to unmarshal ncep grib2vcrd.xml file");
|
||||
}
|
||||
|
||||
File ncepVcrdTable = new File(ncepVcrdPath);
|
||||
try {
|
||||
if (ncepVcrdTable.exists()) {
|
||||
ncepVcrdFileTime = ncepVcrdTable.lastModified();
|
||||
if (ncepVcrdFileTime != getNcepVcrdTimeStamp()) {
|
||||
System.out
|
||||
.println("NCEP grib2vcrd.xml has been modified or the first time, so load it ...");
|
||||
Grib2VcrdTableLookup.readG2vcrdTable();
|
||||
setNcepVcrdTimeStamp(ncepVcrdFileTime);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GribException("Unable to read ncep grib2vcrd file");
|
||||
}
|
||||
|
||||
/* check NCEP Grib Model control file */
|
||||
String ncepGridModelPath = "";
|
||||
|
||||
try {
|
||||
ncepGridModelPath = pathMgr.getFile(commonStaticBase,
|
||||
"ncgrid" + File.separator + "ncgribModels.xml")
|
||||
.getCanonicalPath();
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new GribException(
|
||||
"Unable to unmarshal ncep ncgribModels.xml file");
|
||||
}
|
||||
|
||||
File ncepGribModelTable = new File(ncepGridModelPath);
|
||||
try {
|
||||
if (ncepGribModelTable.exists()) {
|
||||
ncepGribModelFileTime = ncepGribModelTable.lastModified();
|
||||
if (ncepGribModelFileTime != getNcepNcgribModelTimeStamp()) {
|
||||
System.out
|
||||
.println("NCEP ncgribModels.xml has been modified or the first time, so load it ...");
|
||||
NcgribModelLookup.ReloadInstance();
|
||||
setNcepNcgribModelTimeStamp(ncepGribModelFileTime);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GribException("Unable to read ncep grib2vcrd file");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static long getNcepVarsTimeStamp() {
|
||||
return ncepVarsTimeStamp;
|
||||
}
|
||||
|
||||
public static void setNcepVarsTimeStamp(long ncepVarsTimeStamp) {
|
||||
TableTimeStamp.ncepVarsTimeStamp = ncepVarsTimeStamp;
|
||||
}
|
||||
|
||||
public static long getNcepVcrdTimeStamp() {
|
||||
return ncepVcrdTimeStamp;
|
||||
}
|
||||
|
||||
public static void setNcepVcrdTimeStamp(long ncepVcrdTimeStamp) {
|
||||
TableTimeStamp.ncepVcrdTimeStamp = ncepVcrdTimeStamp;
|
||||
}
|
||||
|
||||
public static long getNcepNcgribModelTimeStamp() {
|
||||
return ncepNcgribModelTimeStamp;
|
||||
}
|
||||
|
||||
public static void setNcepNcgribModelTimeStamp(long ncepNcgribModelTimeStamp) {
|
||||
TableTimeStamp.ncepNcgribModelTimeStamp = ncepNcgribModelTimeStamp;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,256 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2007, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.uengine.tasks.ncgrib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.referencing.operation.DefaultMathTransformFactory;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
||||
import com.raytheon.edex.uengine.exception.MicroEngineException;
|
||||
import com.raytheon.edex.uengine.tasks.ScriptTask;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.CoordinateSequence;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.GeometryCollection;
|
||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||
import com.vividsolutions.jts.geom.LinearRing;
|
||||
import com.vividsolutions.jts.geom.Polygon;
|
||||
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence;
|
||||
|
||||
/**
|
||||
* GribImpacts task derived from original uEngine GribImpacts task.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date PR# Engineer Description
|
||||
* ----------- ---------- ------------ --------------------------
|
||||
* Apr 12, 2007 njensen Initial Creation
|
||||
* </PRE>
|
||||
*
|
||||
*/
|
||||
public class NcgribImpacts extends ScriptTask {
|
||||
|
||||
private CoordinateReferenceSystem crs;
|
||||
|
||||
private GridGeometry2D geom;
|
||||
|
||||
private float[] gribData;
|
||||
|
||||
private int minValue = -1;
|
||||
|
||||
private List<Integer> keys = new ArrayList<Integer>();
|
||||
|
||||
public NcgribImpacts(float[] aGribData, GridGeometry2D aGeometry,
|
||||
CoordinateReferenceSystem aCrs) {
|
||||
gribData = aGribData;
|
||||
geom = aGeometry;
|
||||
crs = aCrs;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.edex.uengine.js.tasks.ScriptTask#execute()
|
||||
*/
|
||||
@Override
|
||||
public Object execute() {
|
||||
Coordinate[] coords = null;
|
||||
GeometryFactory factory = new GeometryFactory();
|
||||
Map<Integer, Geometry> polygons = new HashMap<Integer, Geometry>();
|
||||
|
||||
// set up the transform from grid coordinates to lon/lat
|
||||
|
||||
MathTransform fullTransform = null;
|
||||
try {
|
||||
DefaultMathTransformFactory dmtf = new DefaultMathTransformFactory();
|
||||
fullTransform = dmtf.createConcatenatedTransform(
|
||||
geom.getGridToCRS(), MapUtil.getTransformToLatLon(crs));
|
||||
|
||||
} catch (FactoryException e) {
|
||||
logger.error("Unable to create MathTransform instances - "
|
||||
+ "cannot transform from GRID space to Lat/Lon", e);
|
||||
throw new MicroEngineException(
|
||||
"Unable to create MathTransform instances - cannot transform from GRID space to Lat/Lon",
|
||||
e);
|
||||
}
|
||||
|
||||
// determine the grid width and length
|
||||
int nx = geom.getGridRange().getSpan(0);
|
||||
int ny = geom.getGridRange().getSpan(1);
|
||||
|
||||
// verify that the grib data length matches the
|
||||
// grid dimensions
|
||||
if (gribData.length != (nx * ny)) {
|
||||
throw new MicroEngineException("Data is corrupt - dx: " + nx
|
||||
+ ", dy:" + ny + ", size:" + gribData.length);
|
||||
}
|
||||
|
||||
// create an array to hold the max number of verices for a row
|
||||
double[] xyCoord = new double[4 * (nx + 1)];
|
||||
|
||||
int gribIdx = 0; // index of the first cell in the current row
|
||||
int v; // value of the current cell
|
||||
int n; // number of adjacent cells with the same value
|
||||
int x; // x coordinate of the first cell in the current string
|
||||
|
||||
// for each row in the grid
|
||||
for (int y = ny - 1; y >= 0; --y) {
|
||||
// set x to the first cell in the row
|
||||
x = 0;
|
||||
|
||||
// loop over the cells in the row
|
||||
do { // while x < nx
|
||||
|
||||
// skip over cells with vales < the minValue
|
||||
do {
|
||||
v = (int) gribData[gribIdx + x];
|
||||
if (v >= minValue) {
|
||||
break;
|
||||
}
|
||||
x++;
|
||||
} while (x < nx);
|
||||
|
||||
// if we're at the end of the row get out of this loop
|
||||
if (x >= nx) {
|
||||
break;
|
||||
}
|
||||
|
||||
// count up adjacent cells with the same value
|
||||
n = 1;
|
||||
while ((x + n < nx) && (v == (int) gribData[gribIdx + x + n])) {
|
||||
n++;
|
||||
}
|
||||
|
||||
// compute the grid coordinates of the vertices surrounding
|
||||
// this string of adjacent cells
|
||||
for (int j = 0; j <= n; j++) {
|
||||
xyCoord[4 * j] = x + j - .5;
|
||||
xyCoord[4 * j + 1] = y + .5;
|
||||
|
||||
xyCoord[4 * j + 2] = x + j - .5;
|
||||
xyCoord[4 * j + 3] = y - .5;
|
||||
}
|
||||
|
||||
// move x to the next cell after the current string
|
||||
x += n;
|
||||
|
||||
// transform the grid coordinates to lon/lat
|
||||
try {
|
||||
fullTransform
|
||||
.transform(xyCoord, 0, xyCoord, 0, 2 * (n + 1));
|
||||
} catch (TransformException e) {
|
||||
logger.error("Unable to create a polygon", e);
|
||||
throw new MicroEngineException(
|
||||
"Unable to create a polygon", e);
|
||||
}
|
||||
|
||||
// convert the lon/lats to coordinates
|
||||
int m = 2 * (n + 1);
|
||||
coords = new Coordinate[m + 1];
|
||||
for (int j = 0; j <= n; j++) {
|
||||
coords[j] = new Coordinate(xyCoord[4 * j],
|
||||
xyCoord[4 * j + 1]);
|
||||
coords[m - j - 1] = new Coordinate(xyCoord[4 * j + 2],
|
||||
xyCoord[4 * j + 3]);
|
||||
}
|
||||
// duplicate the first point as the last to close the
|
||||
// polygon
|
||||
coords[m] = new Coordinate(coords[0]);
|
||||
|
||||
// create a coordinate sequence
|
||||
CoordinateSequence cs = new CoordinateArraySequence(coords);
|
||||
|
||||
// create a polygon and add it to the list
|
||||
LinearRing linearRing = new LinearRing(cs, factory);
|
||||
Polygon polygon = new Polygon(linearRing, null, factory);
|
||||
|
||||
// see if we already have a polygon for this cell value
|
||||
Geometry g = polygons.get(v);
|
||||
if (g == null) {
|
||||
// if not then add a new polygon
|
||||
polygons.put(v, polygon);
|
||||
} else {
|
||||
// if so then merge this polygon with the existing one
|
||||
g = g.union(polygon);
|
||||
polygons.put(v, g);
|
||||
}
|
||||
} while (x < nx);
|
||||
|
||||
// increment the grib data index to the next row
|
||||
gribIdx += nx;
|
||||
}
|
||||
|
||||
// create a geometry collection from the polygon map
|
||||
// and put it in the chain data
|
||||
GeometryCollection collection = new GeometryCollection(polygons
|
||||
.values().toArray(new Geometry[] {}), factory);
|
||||
|
||||
// create a map of attribute names/values
|
||||
keys = new ArrayList<Integer>(polygons.keySet());
|
||||
return collection;
|
||||
}
|
||||
|
||||
public CoordinateReferenceSystem getCrs() {
|
||||
return crs;
|
||||
}
|
||||
|
||||
public void setCrs(CoordinateReferenceSystem aCrs) {
|
||||
crs = aCrs;
|
||||
}
|
||||
|
||||
public GridGeometry2D getGeom() {
|
||||
return geom;
|
||||
}
|
||||
|
||||
public void setGeom(GridGeometry2D aGeom) {
|
||||
geom = aGeom;
|
||||
}
|
||||
|
||||
public float[] getGribData() {
|
||||
return gribData;
|
||||
}
|
||||
|
||||
public void setGribData(float[] aGribData) {
|
||||
gribData = aGribData;
|
||||
}
|
||||
|
||||
public int getMinValue() {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
public void setMinValue(int aMinValue) {
|
||||
minValue = aMinValue;
|
||||
}
|
||||
|
||||
public List<Integer> getKeys() {
|
||||
return keys;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,296 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2007, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.uengine.tasks.ncgrib;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DataBufferFloat;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.SampleModel;
|
||||
|
||||
import javax.media.jai.BorderExtender;
|
||||
import javax.media.jai.Interpolation;
|
||||
import javax.media.jai.JAI;
|
||||
import javax.media.jai.ParameterBlockJAI;
|
||||
import javax.media.jai.PlanarImage;
|
||||
import javax.media.jai.RasterFactory;
|
||||
import javax.media.jai.TiledImage;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridEnvelope;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.edex.colormap.ColorMapManager;
|
||||
import com.raytheon.edex.uengine.tasks.ScriptTask;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.util.GridUtil;
|
||||
|
||||
/**
|
||||
* GribMap task derived from original uEngine GribMap task. Maps grid data to an
|
||||
* image.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date PR# Engineer Description
|
||||
* ----------- ---------- ------------ --------------------------
|
||||
* Mar 29, 2007 njensen Initial Creation
|
||||
* </PRE>
|
||||
*
|
||||
*/
|
||||
public class NcgribMap extends ScriptTask {
|
||||
|
||||
private String colorMapName;
|
||||
|
||||
private int scaleFactor = 1;
|
||||
|
||||
private IDataRecord dataRecord;
|
||||
|
||||
private GridGeometry2D gridGeometry;
|
||||
|
||||
private static final float DEF_MINIMUM = Float.POSITIVE_INFINITY;
|
||||
|
||||
private static final float DEF_MAXIMUM = Float.NEGATIVE_INFINITY;
|
||||
|
||||
private float minimum = DEF_MINIMUM;
|
||||
|
||||
private float maximum = DEF_MAXIMUM;
|
||||
|
||||
public NcgribMap(String aPlugin, String aColorMapName,
|
||||
IDataRecord aDataRecord, GridGeometry2D aGridGeometry) {
|
||||
colorMapName = aColorMapName;
|
||||
dataRecord = aDataRecord;
|
||||
gridGeometry = aGridGeometry;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.edex.uengine.js.tasks.ScriptTask#execute()
|
||||
*/
|
||||
@Override
|
||||
public Object execute() {
|
||||
float max = -9999;
|
||||
float min = 9999;
|
||||
float userMin;
|
||||
float userMax;
|
||||
|
||||
float[] gribData = (float[]) dataRecord.getDataObject();
|
||||
|
||||
// ColorMap colorMap = ColorMap.getColorMap(colorMapName);
|
||||
// if (colorMap == null) {
|
||||
// throw new MicroEngineException(
|
||||
// "Invalid ColorMap name " + Util.printString(colorMapName) +
|
||||
// ", cannot decode image.");
|
||||
// }
|
||||
/*
|
||||
* subtract one since we map the GRIB values to valid pixel (grey scale)
|
||||
* values based on the color map. For example, a 32 color color map
|
||||
* requires pixel values 0 to 31.
|
||||
*/
|
||||
int colors = (int) ColorMapManager.MAX_VALUE;
|
||||
|
||||
int width = gridGeometry.getGridRange().getSpan(0);
|
||||
int height = gridGeometry.getGridRange().getSpan(1);
|
||||
|
||||
if (scaleFactor > 1.0) {
|
||||
|
||||
int len = width * height;
|
||||
Point origin = new Point(0, 0);
|
||||
|
||||
// create a float sample model
|
||||
SampleModel sampleModel = RasterFactory.createBandedSampleModel(
|
||||
DataBuffer.TYPE_FLOAT, width, height, 1);
|
||||
|
||||
// create a TiledImage using the float SampleModel
|
||||
TiledImage tiledImage = new TiledImage(0, 0, width, height, 0, 0,
|
||||
sampleModel, null);
|
||||
|
||||
// create a DataBuffer from the float[][] array
|
||||
DataBufferFloat dataBuffer = new DataBufferFloat(gribData, len);
|
||||
|
||||
// create a Raster
|
||||
Raster raster = RasterFactory.createWritableRaster(sampleModel,
|
||||
dataBuffer, origin);
|
||||
|
||||
// set the TiledImage data to that of the Raster
|
||||
tiledImage.setData(raster);
|
||||
|
||||
PlanarImage scaledImg;
|
||||
|
||||
// Interpolate the image using a scale factor and
|
||||
// the copy border extender
|
||||
ParameterBlockJAI param = new ParameterBlockJAI("Scale");
|
||||
param.addSource(tiledImage);
|
||||
param.setParameter("xScale", (float) scaleFactor);
|
||||
param.setParameter("yScale", (float) scaleFactor);
|
||||
Interpolation interpol = Interpolation
|
||||
.getInstance(Interpolation.INTERP_BILINEAR);
|
||||
param.setParameter("interpolation", interpol);
|
||||
RenderingHints hint = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
|
||||
BorderExtender.createInstance(BorderExtender.BORDER_COPY));
|
||||
scaledImg = JAI.create("Scale", param, hint);
|
||||
|
||||
// Get the floats back out
|
||||
DataBuffer newDb = scaledImg.getData().getDataBuffer();
|
||||
DataBufferFloat dbf = (java.awt.image.DataBufferFloat) newDb;
|
||||
|
||||
// Update the grib data objects for further processing
|
||||
gribData = dbf.getData();
|
||||
width = width * scaleFactor;
|
||||
height = height * scaleFactor;
|
||||
gridGeometry = new GridGeometry2D(new GeneralGridEnvelope(
|
||||
new int[] { 0, 0 }, new int[] { width, height }, false),
|
||||
gridGeometry.getEnvelope());
|
||||
}
|
||||
int pixels = gribData.length;
|
||||
|
||||
for (int i = 0; i < pixels; i++) {
|
||||
if (gribData[i] != GridUtil.GRID_FILL_VALUE) {
|
||||
if (max < gribData[i]) {
|
||||
max = gribData[i];
|
||||
}
|
||||
|
||||
if (min > gribData[i]) {
|
||||
min = gribData[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* validate the user specified minimum
|
||||
*/
|
||||
userMin = minimum;
|
||||
if (minimum != DEF_MINIMUM) {
|
||||
userMin = minimum;
|
||||
// if (userMin > min) {
|
||||
// theLogger.warn("Requested minimum [" + userMin +
|
||||
// "] larger than computed minimum. "+
|
||||
// "Using computed minimum of " + min);
|
||||
// userMin = min;
|
||||
// }
|
||||
} else {
|
||||
userMin = min;
|
||||
}
|
||||
/*
|
||||
* validate user specified maximum
|
||||
*/
|
||||
if (maximum != DEF_MAXIMUM) {
|
||||
userMax = maximum;
|
||||
// if (userMax < max) {
|
||||
// theLogger.warn("Requested maximum [" + userMax +
|
||||
// "] smaller than computed maximum. "+
|
||||
// "Using computed maximum of " + max);
|
||||
// userMax = max;
|
||||
// }
|
||||
} else {
|
||||
userMax = max;
|
||||
}
|
||||
/*
|
||||
* not sure if this can actually happen, but for completeness
|
||||
*/
|
||||
if (userMax < userMin) {
|
||||
logger.warn("Invalid minimum/maximum specified. "
|
||||
+ "Using computed values of " + min + " and " + max);
|
||||
userMin = min;
|
||||
userMax = max;
|
||||
}
|
||||
/**
|
||||
* update the minimum and maximum values
|
||||
*/
|
||||
min = userMin;
|
||||
max = userMax;
|
||||
|
||||
/*
|
||||
* remap the data
|
||||
*/
|
||||
float range = max - min;
|
||||
float diff = 0f;
|
||||
byte[] imageData = new byte[pixels];
|
||||
for (int index = 0; index < pixels; index++) {
|
||||
float pixel = gribData[index];
|
||||
if (pixel < min) {
|
||||
pixel = min;
|
||||
} else if (pixel > max) {
|
||||
pixel = max;
|
||||
}
|
||||
diff = pixel - min;
|
||||
imageData[index] = (byte) Math.abs((Math.round(colors
|
||||
* (diff / range))));
|
||||
}
|
||||
|
||||
return imageData;
|
||||
}
|
||||
|
||||
public String getColorMapName() {
|
||||
return colorMapName;
|
||||
}
|
||||
|
||||
public void setColorMapName(String aColorMapName) {
|
||||
colorMapName = aColorMapName;
|
||||
}
|
||||
|
||||
public IDataRecord getDataRecord() {
|
||||
return dataRecord;
|
||||
}
|
||||
|
||||
public void setDataRecord(IDataRecord aDataRecord) {
|
||||
dataRecord = aDataRecord;
|
||||
}
|
||||
|
||||
public float getMaximum() {
|
||||
return maximum;
|
||||
}
|
||||
|
||||
public void setMaximum(float aMaximum) {
|
||||
maximum = aMaximum;
|
||||
}
|
||||
|
||||
public float getMinimum() {
|
||||
return minimum;
|
||||
}
|
||||
|
||||
public void setMinimum(float aMinimum) {
|
||||
minimum = aMinimum;
|
||||
}
|
||||
|
||||
public int getScaleFactor() {
|
||||
return scaleFactor;
|
||||
}
|
||||
|
||||
public void setScaleFactor(int aScaleFactor) {
|
||||
scaleFactor = aScaleFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the gridGeometry
|
||||
*/
|
||||
public GridGeometry2D getGridGeometry() {
|
||||
return gridGeometry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gridGeometry
|
||||
* the gridGeometry to set
|
||||
*/
|
||||
public void setGridGeometry(GridGeometry2D gridGeometry) {
|
||||
this.gridGeometry = gridGeometry;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,142 +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 gov.noaa.nws.ncep.edex.uengine.tasks.ncgrib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
import com.raytheon.edex.uengine.tasks.ScriptTask;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.edex.core.EdexException;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.ncdatatree.NcDataTree;
|
||||
|
||||
/**
|
||||
* The NcgridCatalog script task is used to retrieve the necessary elements needed
|
||||
* to populate a grid tree. This includes center id, subcenter id, generating
|
||||
* process, parameter abbreviation, and level info.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 10, 2008 brockwoo Initial creation
|
||||
* May 1, 2009 2321 brockwoo Check if a bad row out of grib model is returned
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author brockwoo
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class NcgridCatalog extends ScriptTask {
|
||||
|
||||
protected final transient static Log logger = LogFactory
|
||||
.getLog(NcgridCatalog.class);
|
||||
|
||||
private static final String[] GRIDFIELDS = { "modelName",
|
||||
"eventName", "parm", "vcord",
|
||||
"glevel1", "glevel2" };
|
||||
|
||||
public static final String PLUGIN_NAME_QUERY = "pluginName";
|
||||
|
||||
public static final String MODEL_NAME_QUERY = "modelName";
|
||||
|
||||
public static final String EVENT_NAME_QUERY = "eventName";
|
||||
|
||||
public static final String PARAMETER_QUERY = "parm";
|
||||
|
||||
public static final String LEVEL_ID_QUERY = "vcord";
|
||||
|
||||
public static final String LEVEL_ONE_QUERY = "glevel1";
|
||||
|
||||
public static final String LEVEL_TWO_QUERY = "glevel2";
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.edex.uengine.tasks.ScriptTask#execute()
|
||||
*/
|
||||
@Override
|
||||
public Object execute() throws EdexException {
|
||||
NcDataTree ncgridTree = null;
|
||||
CoreDao ncgribDao = null;
|
||||
List<?> queryResults = null;
|
||||
ncgribDao = new CoreDao(DaoConfig.forClass(NcgribRecord.class));
|
||||
|
||||
// if we do not get a table back, just return an empty list
|
||||
ncgridTree = new NcDataTree();
|
||||
DatabaseQuery query = new DatabaseQuery(NcgribRecord.class.getName());
|
||||
|
||||
List<String> distinctFields = Arrays.asList(GRIDFIELDS);
|
||||
|
||||
query.addOrder(distinctFields.get(0), true);
|
||||
query.addDistinctParameter(distinctFields);
|
||||
queryResults = ncgribDao.queryByCriteria(query);
|
||||
if (queryResults.size() > 0) {
|
||||
for (Object gridField : queryResults) {
|
||||
if (gridField.getClass().isArray()) {
|
||||
ArrayList<Object> gridFields = new ArrayList<Object>(Arrays
|
||||
.asList((Object[]) gridField));
|
||||
String model = gridFields.get(0).toString();
|
||||
String event = gridFields.get(1).toString();
|
||||
String parm = gridFields.get(2).toString();
|
||||
String vcord = gridFields.get(3).toString();
|
||||
String level1 = gridFields.get(4).toString();
|
||||
String level2 = gridFields.get(5).toString();
|
||||
|
||||
Map<String, RequestConstraint> rcMap = new HashMap<String, RequestConstraint>();
|
||||
rcMap.put(PLUGIN_NAME_QUERY, new RequestConstraint("ncgrib"));
|
||||
rcMap.put(MODEL_NAME_QUERY,
|
||||
new RequestConstraint(model));
|
||||
rcMap.put(EVENT_NAME_QUERY,
|
||||
new RequestConstraint(event));
|
||||
rcMap.put(PARAMETER_QUERY,
|
||||
new RequestConstraint(parm));
|
||||
rcMap.put(LEVEL_ID_QUERY,
|
||||
new RequestConstraint(vcord));
|
||||
rcMap.put(LEVEL_ONE_QUERY,
|
||||
new RequestConstraint(level1));
|
||||
rcMap.put(LEVEL_TWO_QUERY,
|
||||
new RequestConstraint(level2));
|
||||
ncgridTree.addBranch(model, gridFields.get(1)
|
||||
.toString(), gridFields.get(2).toString(),
|
||||
gridFields.get(3).toString(), gridFields.get(4)
|
||||
.toString(), gridFields.get(5).toString(), rcMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ncgridTree;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* Contains JavaScript oriented μEngine tasks specific to gribs
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.uengine.tasks.ncgrib;
|
|
@ -1,191 +0,0 @@
|
|||
/**
|
||||
* This file was generated by the JavaTM Architecture for XML Binding(JAXB)
|
||||
* Reference Implementation, vJAXB 2.1.10 in JDK 6
|
||||
* See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
* any modifications to this file will be lost upon recompilation of the source schema
|
||||
* Generated on: 2010.09.10 at 11:48:39 AM EDT
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 10/2010 276 L. Lin Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* This code has been developed by the SIB for use in the AWIPS2 system.
|
||||
* @author L. Lin
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.util.grib1vcrd;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for anonymous complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType>
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element ref="{}vcrdid1" minOccurs="0"/>
|
||||
* <element ref="{}name" minOccurs="0"/>
|
||||
* <element ref="{}units" minOccurs="0"/>
|
||||
* <element ref="{}gnam" minOccurs="0"/>
|
||||
* <element ref="{}scale" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"vcrdid",
|
||||
"name",
|
||||
"units",
|
||||
"gnam",
|
||||
"scale"
|
||||
})
|
||||
@XmlRootElement(name = "grib1vcrd")
|
||||
public class Grib1Vcrd implements ISerializableObject {
|
||||
|
||||
protected Integer vcrdid;
|
||||
protected String name;
|
||||
protected String units;
|
||||
protected String gnam;
|
||||
protected String scale;
|
||||
|
||||
/**
|
||||
* Gets the value of the vcrdid property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public Integer getVcrdid() {
|
||||
return vcrdid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the vcrdid property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Integer }
|
||||
*
|
||||
public void setVcrdid(Integer value) {
|
||||
this.vcrdid = value;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets the value of the name property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the name property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets the value of the units property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getUnits() {
|
||||
return units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the units property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
public void setUnits(String value) {
|
||||
this.units = value;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets the value of the gnam property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getGnam() {
|
||||
return gnam;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the gnam property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
public void setGnam(String value) {
|
||||
this.gnam = value;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets the value of the scale property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the scale property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
public void setScale(String value) {
|
||||
this.scale = value;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/**
|
||||
* This file was generated by the JavaTM Architecture for XML Binding(JAXB)
|
||||
* Reference Implementation, vJAXB 2.1.10 in JDK 6
|
||||
* See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
* any modifications to this file will be lost upon recompilation of the source schema
|
||||
* Generated on: 2010.09.10 at 11:48:39 AM EDT
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 10/2010 276 L. Lin Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* This code has been developed by the SIB for use in the AWIPS2 system.
|
||||
* @author L. Lin
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.util.grib1vcrd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"grib1Vcrd"
|
||||
})
|
||||
@XmlRootElement(name = "grib1vcrdList")
|
||||
public class Grib1VcrdList implements ISerializableObject {
|
||||
|
||||
@XmlElement(name = "grib1vcrd")
|
||||
protected List<Grib1Vcrd> grib1Vcrd;
|
||||
|
||||
/**
|
||||
* Gets the value of the grib1Vcrd property.
|
||||
*
|
||||
* <p>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the grib1Vcrd property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getGrib1Vcrd().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link Grib1Vcrd }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<Grib1Vcrd> getGrib1Vcrd() {
|
||||
if (grib1Vcrd == null) {
|
||||
grib1Vcrd = new ArrayList<Grib1Vcrd>();
|
||||
}
|
||||
return this.grib1Vcrd;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.util.grib1vcrd;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
public class Grib1VcrdTable {
|
||||
|
||||
private static final String file = "ncgrid" + File.separator + "grib1vcrd.xml";
|
||||
|
||||
private static Grib1VcrdList g1VcrdList;
|
||||
|
||||
private static Map<Integer, Grib1Vcrd> vcordMap = null;
|
||||
|
||||
private static void readGrib1VcrdTable( String xmlFilename ) throws SerializationException{
|
||||
|
||||
g1VcrdList = (Grib1VcrdList)SerializationUtil.jaxbUnmarshalFromXmlFile(xmlFilename);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Search a g2Vcrd given a field, and search key value.
|
||||
*
|
||||
* @param sf
|
||||
* @param key
|
||||
* @return Grib2Vcrd
|
||||
*/
|
||||
public static Grib1Vcrd getGrib1VcrdById (int vcrdid ) {
|
||||
|
||||
|
||||
synchronized (Grib1VcrdTable.class) {
|
||||
if (g1VcrdList == null) {
|
||||
System.out.println("INITIALIZINGVCRD!!!!!!");
|
||||
try {
|
||||
String filename = findVcrdTable();
|
||||
readGrib1VcrdTable(filename);
|
||||
createMapOfTable();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
g1VcrdList = null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( vcordMap.containsKey(vcrdid) )
|
||||
return vcordMap.get(vcrdid);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void createMapOfTable() {
|
||||
|
||||
vcordMap = new HashMap<Integer, Grib1Vcrd>();
|
||||
|
||||
for ( Grib1Vcrd vcord : g1VcrdList.getGrib1Vcrd() ) {
|
||||
vcordMap.put(vcord.getVcrdid(), vcord);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static String findVcrdTable() throws IOException{
|
||||
String filename = null;
|
||||
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext commonStaticBase = pathMgr.getContext(
|
||||
LocalizationContext.LocalizationType.COMMON_STATIC,
|
||||
LocalizationContext.LocalizationLevel.BASE);
|
||||
|
||||
filename = pathMgr.getFile( commonStaticBase, Grib1VcrdTable.file).getCanonicalPath();
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,314 +0,0 @@
|
|||
//
|
||||
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
|
||||
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||
// Generated on: 2011.01.07 at 02:01:31 PM EST
|
||||
//
|
||||
|
||||
|
||||
package gov.noaa.nws.ncep.edex.util.grib2vars;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for anonymous complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType>
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element ref="{}g2varsid" minOccurs="0"/>
|
||||
* <element ref="{}discipline" minOccurs="0"/>
|
||||
* <element ref="{}category" minOccurs="0"/>
|
||||
* <element ref="{}pid" minOccurs="0"/>
|
||||
* <element ref="{}pdt" minOccurs="0"/>
|
||||
* <element ref="{}name" minOccurs="0"/>
|
||||
* <element ref="{}units" minOccurs="0"/>
|
||||
* <element ref="{}gnam" minOccurs="0"/>
|
||||
* <element ref="{}scale" minOccurs="0"/>
|
||||
* <element ref="{}missing" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"g2Varsid",
|
||||
"discipline",
|
||||
"category",
|
||||
"pid",
|
||||
"pdt",
|
||||
"name",
|
||||
"units",
|
||||
"gnam",
|
||||
"scale",
|
||||
"missing"
|
||||
})
|
||||
@XmlRootElement(name = "grib2vars")
|
||||
public class Grib2Vars {
|
||||
|
||||
@XmlElement(name = "g2varsid")
|
||||
protected Integer g2Varsid;
|
||||
protected Integer discipline;
|
||||
protected Integer category;
|
||||
protected Integer pid;
|
||||
protected Integer pdt;
|
||||
protected String name;
|
||||
protected String units;
|
||||
protected String gnam;
|
||||
protected Integer scale;
|
||||
protected Float missing;
|
||||
|
||||
/**
|
||||
* Gets the value of the g2Varsid property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public Integer getG2Varsid() {
|
||||
return g2Varsid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the g2Varsid property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public void setG2Varsid(Integer value) {
|
||||
this.g2Varsid = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the discipline property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public Integer getDiscipline() {
|
||||
return discipline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the discipline property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public void setDiscipline(Integer value) {
|
||||
this.discipline = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the category property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public Integer getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the category property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public void setCategory(Integer value) {
|
||||
this.category = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the pid property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public Integer getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the pid property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public void setPid(Integer value) {
|
||||
this.pid = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the pdt property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public Integer getPdt() {
|
||||
return pdt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the pdt property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public void setPdt(Integer value) {
|
||||
this.pdt = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the name property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the name property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the units property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getUnits() {
|
||||
return units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the units property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setUnits(String value) {
|
||||
this.units = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the gnam property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getGnam() {
|
||||
return gnam;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the gnam property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setGnam(String value) {
|
||||
this.gnam = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the scale property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public Integer getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the scale property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Integer }
|
||||
*
|
||||
*/
|
||||
public void setScale(Integer value) {
|
||||
this.scale = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the missing property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Float }
|
||||
*
|
||||
*/
|
||||
public Float getMissing() {
|
||||
return missing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the missing property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Float }
|
||||
*
|
||||
*/
|
||||
public void setMissing(Float value) {
|
||||
this.missing = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.util.grib2vars;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Comparator for Grib2Vars fields.
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 10/10 276 L. Lin Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author llin
|
||||
* @version 1
|
||||
*/
|
||||
|
||||
public class Grib2VarsComparator implements Comparator<Grib2Vars>, IGrib2VarsField {
|
||||
|
||||
private Grib2VarsField field;
|
||||
|
||||
public Grib2VarsComparator(Grib2VarsField f) {
|
||||
this.field = f;
|
||||
}
|
||||
|
||||
public int compare(Grib2Vars o1, Grib2Vars o2) {
|
||||
switch (field) {
|
||||
case G2VARSID:
|
||||
return o1.getG2Varsid() - o2.getG2Varsid();
|
||||
case DISCIPLINE:
|
||||
return o1.getDiscipline() - o2.getDiscipline();
|
||||
case CATEGORY:
|
||||
return o1.getCategory() - o2.getCategory();
|
||||
case PID:
|
||||
return o1.getPid() - o2.getPid();
|
||||
case PDT:
|
||||
return o1.getPdt() - o2.getPdt();
|
||||
case NAME:
|
||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
case UNITS:
|
||||
return o1.getUnits().compareToIgnoreCase(o2.getUnits());
|
||||
case GNAM:
|
||||
return o1.getGnam().compareToIgnoreCase(o2.getGnam());
|
||||
case SCALE:
|
||||
return o1.getScale() - o2.getScale();
|
||||
case MISSING:
|
||||
return o1.getMissing().compareTo(o2.getMissing());
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
/**
|
||||
* This file was generated by the JavaTM Architecture for XML Binding(JAXB)
|
||||
* Reference Implementation, vJAXB 2.1.10 in JDK 6
|
||||
* See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
* any modifications to this file will be lost upon recompilation of the source schema
|
||||
* Generated on: 2010.09.10 at 11:48:39 AM EDT
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 10/2010 276 L. Lin Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* This code has been developed by the SIB for use in the AWIPS2 system.
|
||||
* @author L. Lin
|
||||
* @version 1.0
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.util.grib2vars;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for anonymous complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType>
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element ref="{}grib2vars" maxOccurs="unbounded" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"grib2Vars"
|
||||
})
|
||||
@XmlRootElement(name = "grib2varsList")
|
||||
public class Grib2VarsList {
|
||||
|
||||
@XmlElement(name = "grib2vars")
|
||||
protected List<Grib2Vars> grib2Vars;
|
||||
|
||||
/**
|
||||
* Gets the value of the grib2Vars property.
|
||||
*
|
||||
* <p>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the grib2Vars property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getGrib2Vars().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link Grib2Vars }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<Grib2Vars> getGrib2Vars() {
|
||||
if (grib2Vars == null) {
|
||||
grib2Vars = new ArrayList<Grib2Vars>();
|
||||
}
|
||||
return this.grib2Vars;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,185 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.util.grib2vars;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
/**
|
||||
* This class reads a g2Vars table from an xml file and contains a list of g2Varss.
|
||||
* This class also provide general g2Vars search functions given g2Vars field, and
|
||||
* field value.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 10/10 276 L. Lin Initial Creation
|
||||
* 07/11 X. Guo Added getGrib2Vars4Grib1()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author llin
|
||||
* @version 1
|
||||
*/
|
||||
|
||||
public class Grib2VarsTable implements IGrib2VarsField {
|
||||
|
||||
private final String PACKAGE = "gov.noaa.nws.ncep.edex.util.grib2vars";
|
||||
|
||||
private List<Grib2Vars> g2VarsList;
|
||||
|
||||
private static Grib2VarsField last = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param tableFileName - full path of the xml table file
|
||||
*/
|
||||
public Grib2VarsTable( String tableFileName ) {
|
||||
|
||||
try{
|
||||
g2VarsList = readGrib2VarsTable( tableFileName );
|
||||
}
|
||||
catch ( JAXBException exp ){
|
||||
g2VarsList = null;
|
||||
exp.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the contents of the input g2Vars table file
|
||||
* @param xmlFilename - full path of the xml table name
|
||||
* @return - a list of g2Varss
|
||||
* @throws JAXBException
|
||||
*/
|
||||
private List<Grib2Vars> readGrib2VarsTable( String xmlFilename ) throws JAXBException{
|
||||
|
||||
File xmlFile = new File(xmlFilename);
|
||||
|
||||
JAXBContext context = JAXBContext.newInstance(
|
||||
PACKAGE);
|
||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||
Grib2VarsList g2Varslist = null;
|
||||
|
||||
try {
|
||||
g2Varslist = (Grib2VarsList)unmarshaller.unmarshal(
|
||||
new FileReader(xmlFile));
|
||||
List<Grib2Vars> listOfItems = g2Varslist.getGrib2Vars();
|
||||
return listOfItems;
|
||||
|
||||
} catch (FileNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
|
||||
} catch (NullPointerException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of the g2Varss
|
||||
* @return - the list of g2Varss
|
||||
*/
|
||||
public List<Grib2Vars> getGrib2VarsList(){
|
||||
|
||||
return g2VarsList;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Search a g2Vars given a field, and search key value.
|
||||
*
|
||||
* @param sf
|
||||
* @param key
|
||||
* @return Grib2Vars
|
||||
*/
|
||||
public Grib2Vars getGrib2Vars(int discipline, int category, int pid, int pdt) {
|
||||
|
||||
if (g2VarsList == null || g2VarsList.isEmpty()) return null;
|
||||
|
||||
for (Grib2Vars g2Vars : g2VarsList) {
|
||||
if (g2Vars.discipline == discipline &&
|
||||
g2Vars.category == category &&
|
||||
g2Vars.pid == pid &&
|
||||
g2Vars.pdt == pdt ) {
|
||||
return g2Vars;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Grib2Vars getGrib2Vars4Grib1(int discipline, int category, int pid) {
|
||||
|
||||
if (g2VarsList == null || g2VarsList.isEmpty()) return null;
|
||||
|
||||
for (Grib2Vars g2Vars : g2VarsList) {
|
||||
if (g2Vars.discipline == discipline &&
|
||||
g2Vars.category == category &&
|
||||
g2Vars.pid == pid ) {
|
||||
return g2Vars;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Search g2Vars list given a field, and search key value.
|
||||
*
|
||||
* @param sf
|
||||
* @param key
|
||||
* @return Grib2Vars
|
||||
*/
|
||||
public List<Grib2Vars> getGrib2Varss(Grib2VarsField sf, Integer key) {
|
||||
if (g2VarsList == null || g2VarsList.isEmpty()) return null;
|
||||
|
||||
Grib2VarsComparator comparator = new Grib2VarsComparator(sf);
|
||||
if (last == null || (last != null && last != sf )) {
|
||||
Collections.sort(g2VarsList, comparator);
|
||||
last = sf;
|
||||
}
|
||||
|
||||
List<Grib2Vars> list = new ArrayList<Grib2Vars>();
|
||||
|
||||
Grib2Vars s = getComparedGrib2Vars(sf, key);
|
||||
int index;
|
||||
while ((index = Collections.binarySearch(g2VarsList, s, comparator)) >= 0) {
|
||||
list.add(g2VarsList.get(index));
|
||||
g2VarsList.remove(index);
|
||||
}
|
||||
|
||||
if (list.size() > 0) {
|
||||
for (Grib2Vars st : list) {
|
||||
g2VarsList.add(st);
|
||||
}
|
||||
|
||||
last = null;
|
||||
return list;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Grib2Vars getComparedGrib2Vars(Grib2VarsField sf, Integer key){
|
||||
Grib2Vars g2Vars = new Grib2Vars();
|
||||
switch (sf) {
|
||||
case G2VARSID:
|
||||
g2Vars.setG2Varsid((Integer)key);
|
||||
break;
|
||||
}
|
||||
|
||||
return g2Vars;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,282 +0,0 @@
|
|||
/**
|
||||
* Grib2varsTableLookup - A Java class to define some known
|
||||
* both g2varsncep1.tbl and g2varswmo2.tbl.
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 10/2010 276 L. Lin Initial creation
|
||||
* 06/2011 X. Guo Added getVarGnam()
|
||||
* 07/2011 X. Guo Added getVarGnam4Grib1()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* This code has been developed by the SIB for use in the AWIPS2 system.
|
||||
* @author L. Lin
|
||||
* @version 1.0
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.util.grib2vars;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
|
||||
public class Grib2VarsTableLookup {
|
||||
|
||||
private static Grib2VarsTable grib2varsTbl = null;
|
||||
private static String name;
|
||||
private static String units;
|
||||
private static Integer scale;
|
||||
private static String gnam;
|
||||
private static float missing;
|
||||
|
||||
public Grib2VarsTableLookup() {
|
||||
}
|
||||
|
||||
public static synchronized String readG2varsTable() throws GribException {
|
||||
|
||||
Grib2VarsTable myTbl = null;
|
||||
|
||||
/*
|
||||
* Gets all predefined found in the utility directory
|
||||
*/
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext commonStaticBase = pathMgr.getContext(
|
||||
LocalizationContext.LocalizationType.COMMON_STATIC,
|
||||
LocalizationContext.LocalizationLevel.BASE);
|
||||
|
||||
String path = "";
|
||||
|
||||
try {
|
||||
path = pathMgr.getFile(commonStaticBase,
|
||||
"ncgrid" + File.separator + "grib2vars.xml")
|
||||
.getCanonicalPath();
|
||||
|
||||
// System.out.println (" grib2 vars table lookup path=" + path);
|
||||
} catch (Exception e) {
|
||||
throw new GribException(
|
||||
"Unable to unmarshal ncep grib2vars.xml file");
|
||||
}
|
||||
|
||||
File varsFile = new File(path);
|
||||
try {
|
||||
if (varsFile.exists()) {
|
||||
myTbl = new Grib2VarsTable(path);
|
||||
setG2varsTable(myTbl);
|
||||
// System.out.println("Grib2varsTableLookup- read grib2vars.xml file="
|
||||
// + path);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GribException("Unable to read ncep grib2vars file");
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given discipline, category, pid, and pdt, find g2vars entry in
|
||||
* "grib2vars.xml" and set g2varsid, name, units, scale, gnam, and missing
|
||||
* fields. .
|
||||
*
|
||||
* @param discipline
|
||||
* , category, pid and pdt are integers.
|
||||
* @return
|
||||
* @throws GribException
|
||||
*
|
||||
*/
|
||||
public static int getG2varsId(int discipline, int category, int pid, int pdt)
|
||||
throws GribException {
|
||||
Grib2Vars g2vars = null;
|
||||
int g2varsid = -1;
|
||||
// Wrap decoding in a try block, in case of exception on xml.
|
||||
try {
|
||||
// Read in the stationNumber table XML if not exists
|
||||
if (grib2varsTbl == null) {
|
||||
readG2varsTable();
|
||||
}
|
||||
|
||||
// Search station ID and return whole station record
|
||||
if (grib2varsTbl != null) {
|
||||
g2vars = grib2varsTbl.getGrib2Vars(discipline, category, pid,
|
||||
pdt);
|
||||
}
|
||||
|
||||
if (g2vars != null) {
|
||||
g2varsid = g2vars.g2Varsid;
|
||||
name = g2vars.name;
|
||||
units = g2vars.units;
|
||||
gnam = g2vars.gnam;
|
||||
scale = g2vars.scale;
|
||||
missing = g2vars.missing;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: Use central error logging if this code is kept
|
||||
throw new GribException(
|
||||
"Error occurs while finding g2vars entry from g2vars.xml table");
|
||||
}
|
||||
|
||||
return g2varsid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given discipline, category, pid, and pdt, find g2vars entry in
|
||||
* "grib2vars.xml" and set g2varsid, name, units, g2varsscale, gnam, and
|
||||
* missing fields. .
|
||||
*
|
||||
* @param discipline
|
||||
* , category, pid and pdt are integers.
|
||||
* @return
|
||||
* @throws GribException
|
||||
*
|
||||
*/
|
||||
public static int getG2varsScale(int discipline, int category, int pid,
|
||||
int pdt) throws GribException {
|
||||
Grib2Vars g2vars = null;
|
||||
int g2scale = 0;
|
||||
// Wrap decoding in a try block, in case of exception on xml.
|
||||
try {
|
||||
// Read in the stationNumber table XML if not exists
|
||||
if (grib2varsTbl == null) {
|
||||
readG2varsTable();
|
||||
}
|
||||
|
||||
// Search station ID and return whole station record
|
||||
if (grib2varsTbl != null) {
|
||||
g2vars = grib2varsTbl.getGrib2Vars(discipline, category, pid,
|
||||
pdt);
|
||||
}
|
||||
|
||||
if (g2vars != null) {
|
||||
// g2Varsid = g2vars.g2Varsid;
|
||||
name = g2vars.name;
|
||||
units = g2vars.units;
|
||||
gnam = g2vars.gnam;
|
||||
g2scale = g2vars.scale;
|
||||
missing = g2vars.missing;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: Use central error logging if this code is kept
|
||||
throw new GribException(
|
||||
"Error occurs while finding g2vars entry from g2vars.xml table");
|
||||
}
|
||||
|
||||
return g2scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the grib2varsTbl
|
||||
*/
|
||||
public static Grib2VarsTable getG2varsTable() {
|
||||
return grib2varsTbl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Grib2VarsTable
|
||||
* the grib2varsTbl to set
|
||||
*/
|
||||
public static void setG2varsTable(Grib2VarsTable grib2varsTbl) {
|
||||
Grib2VarsTableLookup.grib2varsTbl = grib2varsTbl;
|
||||
}
|
||||
|
||||
public static String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static void setName(String name) {
|
||||
Grib2VarsTableLookup.name = name;
|
||||
}
|
||||
|
||||
public static String getVarGnam( int discipline, int category, int pid, int pdt) throws GribException {
|
||||
Grib2Vars g2vars = null;
|
||||
String varName="NONE";
|
||||
// Wrap decoding in a try block, in case of exception on xml.
|
||||
try {
|
||||
// Read in the stationNumber table XML if not exists
|
||||
if (grib2varsTbl == null) {
|
||||
readG2varsTable();
|
||||
}
|
||||
|
||||
// Search station ID and return whole station record
|
||||
if (grib2varsTbl != null) {
|
||||
g2vars = grib2varsTbl.getGrib2Vars(discipline, category, pid,
|
||||
pdt);
|
||||
}
|
||||
|
||||
if (g2vars != null) {
|
||||
// g2Varsid = g2vars.g2Varsid;
|
||||
varName = g2vars.gnam;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: Use central error logging if this code is kept
|
||||
throw new GribException(
|
||||
"Error occurs while finding g2vars entry from g2vars.xml table");
|
||||
}
|
||||
|
||||
return varName;
|
||||
}
|
||||
|
||||
public static String getVarGnam4Grib1( int discipline, int category, int pid) throws GribException {
|
||||
Grib2Vars g2vars = null;
|
||||
String varName="NONE";
|
||||
// Wrap decoding in a try block, in case of exception on xml.
|
||||
try {
|
||||
// Read in the stationNumber table XML if not exists
|
||||
if (grib2varsTbl == null) {
|
||||
readG2varsTable();
|
||||
}
|
||||
|
||||
// Search station ID and return whole station record
|
||||
if (grib2varsTbl != null) {
|
||||
g2vars = grib2varsTbl.getGrib2Vars4Grib1(discipline, category, pid );
|
||||
}
|
||||
|
||||
if (g2vars != null) {
|
||||
// g2Varsid = g2vars.g2Varsid;
|
||||
varName = g2vars.gnam;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: Use central error logging if this code is kept
|
||||
throw new GribException(
|
||||
"Error occurs while finding g2vars entry from g2vars.xml table");
|
||||
}
|
||||
|
||||
return varName;
|
||||
}
|
||||
|
||||
public static String getUnits() {
|
||||
return units;
|
||||
}
|
||||
|
||||
public static void setUnits(String units) {
|
||||
Grib2VarsTableLookup.units = units;
|
||||
}
|
||||
|
||||
public static Integer getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public static void setScale(Integer scale) {
|
||||
Grib2VarsTableLookup.scale = scale;
|
||||
}
|
||||
|
||||
public static String getGnam() {
|
||||
return gnam;
|
||||
}
|
||||
|
||||
public static void setGnam(String gnam) {
|
||||
Grib2VarsTableLookup.gnam = gnam;
|
||||
}
|
||||
|
||||
public static float getMissing() {
|
||||
return missing;
|
||||
}
|
||||
|
||||
public static void setMissing(float missing) {
|
||||
Grib2VarsTableLookup.missing = missing;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.util.grib2vars;
|
||||
|
||||
public interface IGrib2VarsField {
|
||||
|
||||
public static enum Grib2VarsField {
|
||||
G2VARSID, // g2vars id
|
||||
DISCIPLINE, // The discipline
|
||||
CATEGORY, // The category
|
||||
PID, // The parameter id
|
||||
PDT, // The product definition template
|
||||
NAME, // description of this g2vars
|
||||
UNITS, // units
|
||||
GNAM, // gnam
|
||||
SCALE, // scale
|
||||
MISSING // The missing value
|
||||
}
|
||||
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
//
|
||||
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
|
||||
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||
// Generated on: 2011.01.07 at 02:01:31 PM EST
|
||||
//
|
||||
|
||||
|
||||
package gov.noaa.nws.ncep.edex.util.grib2vars;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.annotation.XmlElementDecl;
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* This object contains factory methods for each
|
||||
* Java content interface and Java element interface
|
||||
* generated in the generated package.
|
||||
* <p>An ObjectFactory allows you to programatically
|
||||
* construct new instances of the Java representation
|
||||
* for XML content. The Java representation of XML
|
||||
* content can consist of schema derived interfaces
|
||||
* and classes representing the binding of schema
|
||||
* type definitions, element declarations and model
|
||||
* groups. Factory methods for each of these are
|
||||
* provided in this class.
|
||||
*
|
||||
*/
|
||||
@XmlRegistry
|
||||
public class ObjectFactory {
|
||||
|
||||
private final static QName _Missing_QNAME = new QName("", "missing");
|
||||
private final static QName _Scale_QNAME = new QName("", "scale");
|
||||
private final static QName _Category_QNAME = new QName("", "category");
|
||||
private final static QName _Gnam_QNAME = new QName("", "gnam");
|
||||
private final static QName _G2Varsid_QNAME = new QName("", "g2varsid");
|
||||
private final static QName _Name_QNAME = new QName("", "name");
|
||||
private final static QName _Pdt_QNAME = new QName("", "pdt");
|
||||
private final static QName _Pid_QNAME = new QName("", "pid");
|
||||
private final static QName _Discipline_QNAME = new QName("", "discipline");
|
||||
private final static QName _Units_QNAME = new QName("", "units");
|
||||
|
||||
/**
|
||||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: generated
|
||||
*
|
||||
*/
|
||||
public ObjectFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Grib2Vars }
|
||||
*
|
||||
*/
|
||||
public Grib2Vars createGrib2Vars() {
|
||||
return new Grib2Vars();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Grib2VarsList }
|
||||
*
|
||||
*/
|
||||
public Grib2VarsList createGrib2VarsList() {
|
||||
return new Grib2VarsList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link Float }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "", name = "missing")
|
||||
public JAXBElement<Float> createMissing(Float value) {
|
||||
return new JAXBElement<Float>(_Missing_QNAME, Float.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "", name = "scale")
|
||||
public JAXBElement<Integer> createScale(Integer value) {
|
||||
return new JAXBElement<Integer>(_Scale_QNAME, Integer.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "", name = "category")
|
||||
public JAXBElement<Integer> createCategory(Integer value) {
|
||||
return new JAXBElement<Integer>(_Category_QNAME, Integer.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "", name = "gnam")
|
||||
public JAXBElement<String> createGnam(String value) {
|
||||
return new JAXBElement<String>(_Gnam_QNAME, String.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "", name = "g2varsid")
|
||||
public JAXBElement<Integer> createG2Varsid(Integer value) {
|
||||
return new JAXBElement<Integer>(_G2Varsid_QNAME, Integer.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "", name = "name")
|
||||
public JAXBElement<String> createName(String value) {
|
||||
return new JAXBElement<String>(_Name_QNAME, String.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "", name = "pdt")
|
||||
public JAXBElement<Integer> createPdt(Integer value) {
|
||||
return new JAXBElement<Integer>(_Pdt_QNAME, Integer.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "", name = "pid")
|
||||
public JAXBElement<Integer> createPid(Integer value) {
|
||||
return new JAXBElement<Integer>(_Pid_QNAME, Integer.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "", name = "discipline")
|
||||
public JAXBElement<Integer> createDiscipline(Integer value) {
|
||||
return new JAXBElement<Integer>(_Discipline_QNAME, Integer.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "", name = "units")
|
||||
public JAXBElement<String> createUnits(String value) {
|
||||
return new JAXBElement<String>(_Units_QNAME, String.class, null, value);
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue