VLab Issue #3720 - NCEP EDEX and EDEX Common delivery for 14.3.1

Table updates for GRIB decoding; Updates to gpd, mcidas, pafm, and pgen
plugins

Change-Id: Ic6874210998d7f5a6b164ef45c6918246388ee68

Former-commit-id: ca9b7c8dfc [formerly 4602f86f47 [formerly bd2dad11b5] [formerly ca9b7c8dfc [formerly 3c904361e7176592cc873a3414c18ad5107aea54]]]
Former-commit-id: 4602f86f47 [formerly bd2dad11b5]
Former-commit-id: 4602f86f47
Former-commit-id: 80c8dae07c
This commit is contained in:
Stephen Gilbert 2014-05-15 14:50:35 -04:00
parent 52e1ad897c
commit 86ee4b88ee
50 changed files with 11509 additions and 11271 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -32,7 +32,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
31,HAR,126,HARRISBURG,PA,US,40.23,-77.02
32,DCA,306,WASHINGTON,DC,US,38.86,-77.04
33,RIC,229,RICHMOND,VA,US,37.5,-77.32
34,CSN,299,CASSANOVA,VA,US,38.64,-77.87
34,CSN,299,CASANOVA,VA,US,38.64,-77.87
35,ILM,135,WILMINGTON,NC,US,34.35,-77.87
36,SLT,252,SLATE_RUN,PA,US,41.51,-77.97
37,PSB,368,PHILLIPSBURG,PA,US,40.92,-77.99
@ -50,7 +50,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
49,EWC,326,ELLWOOD_CITY,PA,US,40.83,-80.21
50,ERI,92,ERIE,PA,US,42.02,-80.3
51,MIA,176,MIAMI,FL,US,25.8,-80.3
52,VRB,276,VERO_BEACH,FL,US,27.68,-80.49
52,TRV,276,TREASURE,FL,US,27.68,-80.49
53,PSK,369,DUBLIN,VA,US,37.09,-80.71
54,AIR,280,BELLAIRE,OH,US,40.02,-80.82
55,CLT,59,CHARLOTTE,NC,US,35.22,-80.93
@ -62,7 +62,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
61,ORL,204,ORLANDO,FL,US,28.54,-81.34
62,CRG,298,JACKSONVILLE,FL,US,30.34,-81.51
63,EYW,96,KEY_WEST,FL,US,24.59,-81.8
64,FMY,104,FT_MEYERS,FL,US,26.58,-81.87
64,RSW,104,LEE_COUNTY,FL,US,26.53,-81.78
65,SPA,380,SPARTANBURG,SC,US,35.03,-81.93
66,HNN,339,HENDERSON,WV,US,38.75,-82.03
67,HMV,337,HOLSTON_MOUNTAIN,TN,US,36.44,-82.13
@ -83,7 +83,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
82,ROD,373,ROSEWOOD,OH,US,40.29,-84.04
83,MBS,168,SAGINAW,MI,US,43.53,-84.08
84,LOZ,160,LONDON,KY,US,37.03,-84.12
85,ABY,4,ALBANY,GA,US,31.65,-84.3
85,PZD,4,PECAN,GA,US,31.66,-84.29
86,SSM,255,SAULT_STE_MARIE,MI,US,46.41,-84.31
87,TLH,264,TALLAHASSEE,FL,US,30.56,-84.37
88,ATL,19,ATLANTA,GA,US,33.63,-84.44
@ -93,7 +93,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
92,LGC,350,LA_GRANGE,GA,US,33.05,-85.21
93,GRR,332,GRAND_RAPIDS,MI,US,42.79,-85.5
94,TVC,270,TRAVERSE_CITY,MI,US,44.67,-85.55
95,LOU,159,LOUISVILLE,KY,US,38.1,-85.58
95,IIU,159,LOUISVILLE,KY,US,38.1,-85.58
96,MKG,179,MUSKEGON,MI,US,43.17,-86.04
97,PMM,366,PULLMAN,MI,US,42.47,-86.11
98,GIJ,330,NILES,MI,US,41.77,-86.32
@ -115,7 +115,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
114,SJI,378,SEMMNES,AL,US,30.73,-88.36
115,IGB,133,BIGBEE,MS,US,33.48,-88.52
116,MEI,172,MERIDIAN,MS,US,32.38,-88.8
117,DEC,70,DECATUR,IL,US,39.74,-88.86
117,AXC,70,ADDERS,IL,US,39.74,-88.86
118,YQT,393,THUNDER_BAY,ON,CN,48.37,-89.32
119,DYR,83,DYERSBURG,TN,US,36.02,-89.32
120,RHI,228,RHINELANDER,WI,US,45.63,-89.45
@ -123,8 +123,8 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
122,DLL,310,DELLS,WI,US,43.55,-89.76
123,MEM,173,MEMPHIS,TN,US,35.06,-89.98
124,LEV,349,GRAND_ISLE,LA,US,29.18,-90.1
125,JAN,142,JACKSON,MS,US,32.51,-90.17
126,MSY,195,NEW_ORLEANS,LA,US,30,-90.27
125,MHZ,142,MAGNOLIA,MS,US,32.43,-90.1
126,HRV,195,HARVEY,LA,US,29.85,-90
127,FAM,97,FARMINGTON,MO,US,37.67,-90.23
128,MCB,169,MC_COMB,MS,US,31.3,-90.26
129,SQS,381,SIDON,MS,US,33.46,-90.28
@ -156,7 +156,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
155,FSM,108,FT_SMITH,AR,US,35.38,-94.27
156,FOD,105,FT_DODGE,IA,US,42.61,-94.29
157,BUM,45,BUTLER,MO,US,38.27,-94.49
158,MKC,177,KANSAS_CITY,MO,US,39.28,-94.59
158,MCI,177,KANSAS_CITY,MO,US,39.29,-94.74
159,LFK,155,LUFKIN,TX,US,31.16,-94.72
160,GGG,115,LONGVIEW,TX,US,32.42,-94.75
161,BJI,33,BEMIDJI,MN,US,47.58,-95.02
@ -170,7 +170,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
169,PSX,219,PALACIOS,TX,US,28.76,-96.31
170,FSD,107,SIOUX_FALLS,SD,US,43.65,-96.78
171,FAR,98,FARGO,ND,US,46.75,-96.85
172,DFW,72,DALLAS-FT_WORTH,TX,US,32.87,-97.03
172,TTT,72,MAVERICK,TX,US,32.87,-97.04
173,ADM,8,ARDMORE,OK,US,34.21,-97.17
174,GFK,114,GRAND_FORKS,ND,US,47.95,-97.19
175,YWG,397,WINNIPEG,MB,CN,49.9,-97.23
@ -180,7 +180,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
179,ICT,132,WICHITA,KS,US,37.75,-97.58
180,OKC,198,OKLAHOMA_CITY,OK,US,35.36,-97.61
181,SLN,251,SALINA,KS,US,38.93,-97.62
182,AUS,20,AUSTIN,TX,US,30.3,-97.7
182,CWK,20,CENTEX,TX,US,30.38,-97.53
183,END,321,VANCE_AFB,OK,US,36.35,-97.92
184,OBH,358,WOLBACH,NE,US,41.38,-98.35
185,ABR,3,ABERDEEN,SD,US,45.42,-98.37
@ -190,7 +190,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
189,LRD,161,LAREDO,TX,US,27.48,-99.42
190,JCT,144,JUNCTION,TX,US,30.6,-99.82
191,ABI,1,ABILENE,TX,US,32.48,-99.86
192,GAG,110,GAGE,OK,US,36.34,-99.88
192,MMB,110,MITBEE,OK,US,36.34,-99.88
193,ANW,282,AINSWORTH,NE,US,42.57,-99.99
194,PIR,214,PIERRE,SD,US,44.4,-100.17
195,HLC,335,HILL_CITY,KS,US,39.26,-100.23
@ -222,11 +222,11 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
221,ISN,140,WILLISTON,ND,US,48.18,-103.63
222,MRF,190,MARFA,TX,US,30.3,-103.95
223,PUB,220,PUEBLO,CO,US,38.29,-104.43
224,ROW,233,ROSWELL,NM,US,33.34,-104.62
224,CME,233,CHISUM,NM,US,33.34,-104.62
225,DEN,71,DENVER,CO,US,39.81,-104.66
226,CYS,301,CHEYENNE,WY,US,41.21,-104.77
227,CIM,297,CIMARRON,NM,US,36.49,-104.87
228,LVS,163,LAS_VEGAS,NM,US,35.66,-105.14
228,FTI,163,FT_UNION,NM,US,35.66,-105.14
229,LAR,148,LARAMIE,WY,US,41.33,-105.72
230,ALS,13,ALAMOSA,CO,US,37.35,-105.82
231,MLS,182,MILES_CITY,MT,US,46.38,-105.95
@ -242,7 +242,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
241,CHE,54,HAYDEN,CO,US,40.52,-107.31
242,DMN,76,DEMING,NM,US,32.28,-107.6
243,YYN,400,SWIFT_CURRENT,SA,CN,50.28,-107.68
244,FMN,103,FARMINGTON,NM,US,36.75,-108.1
244,RSK,103,RATTLESNAKE,NM,US,36.75,-108.1
245,BOY,290,BOYSEN_RESV.,WY,US,43.46,-108.3
246,BIL,31,BILLINGS,MT,US,45.81,-108.63
247,JNC,347,GRAND_JUNCTION,CO,US,39.06,-108.79
@ -312,7 +312,7 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
311,OAK,356,OAKLAND,CA,US,37.73,-122.22
312,RBL,225,RED_BLUFF,CA,US,40.1,-122.24
313,SEA,243,SEATTLE,WA,US,47.44,-122.31
314,BLI,35,BELLINGHAM,WA,US,48.95,-122.58
314,HUH,35,WHATCOM,WA,US,48.95,-122.58
315,PDX,208,PORTLAND,OR,US,45.58,-122.6
316,PYE,371,POINT_REYES,CA,US,38.08,-122.87
317,OED,362,MEDFORD,OR,US,42.48,-122.91
@ -388,3 +388,4 @@ COPY stns.VORS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LO
387,LIH,0,LIHUE,HI,US,21.97,-159.34
388,SOK,0,SOUTH_KAUAI,HI,US,21.9,-159.53
\.

View file

@ -9010,4 +9010,15 @@
<grib2Value>14</grib2Value>
</grib1Parameter>
<!-- end ukmetHR -->
<!-- cmc RELH -->
<grib1Parameter>
<center>54</center>
<grib1TableVersion>2</grib1TableVersion>
<grib1Value>52</grib1Value>
<grib2discipline>0</grib2discipline>
<grib2category>1</grib2category>
<grib2Value>1</grib2Value>
</grib1Parameter>
<!-- end CMC -->
</grib1ParameterSet>

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
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.
-->
<polarStereoGridCoverage>
<name>493399001</name>
<description>15km HR CMC</description>
<la1>32.548</la1>
<lo1>-134.62</lo1>
<firstGridPointCorner>LowerLeft</firstGridPointCorner>
<nx>493</nx>
<ny>399</ny>
<dx>15</dx>
<dy>15</dy>
<spacingUnit>km</spacingUnit>
<minorAxis>6367470.0</minorAxis>
<majorAxis>6367470.0</majorAxis>
<lov>-111.0</lov>
<lad>60</lad>
</polarStereoGridCoverage>

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
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.
-->
<polarStereoGridCoverage>
<name>825553001</name>
<description>ESTOFS HIRES - 6 km Alaska</description>
<la1>40.530101</la1>
<lo1>-178.571</lo1>
<firstGridPointCorner>LowerLeft</firstGridPointCorner>
<nx>825</nx>
<ny>553</ny>
<dx>5.953125</dx>
<dy>5.953125</dy>
<spacingUnit>km</spacingUnit>
<minorAxis>6371229.0</minorAxis>
<majorAxis>6371229.0</majorAxis>
<lov>-150.0</lov>
<lad>60</lad>
</polarStereoGridCoverage>

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
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.
-->
<mercatorGridCoverage>
<name>321225001</name>
<description>Extratropical Storm and Tide Operation Forecast System (Hawaii)</description>
<la1>18.067</la1>
<lo1>-161.525</lo1>
<firstGridPointCorner>LowerLeft</firstGridPointCorner>
<nx>321</nx>
<ny>225</ny>
<dx>2.5</dx>
<dy>2.5</dy>
<spacingUnit>km</spacingUnit>
<minorAxis>6371229.0</minorAxis>
<majorAxis>6371229.0</majorAxis>
<latin>20.0</latin>
<la2>23.082</la2>
<lo2>-153.969</lo2>
</mercatorGridCoverage>

View file

@ -10,6 +10,26 @@
<gribModelSet>
<!-- SUBCENTER 0 -->
<model>
<name>estofsHW</name>
<center>7</center>
<subcenter>4</subcenter>
<grid>321225001</grid>
<process>
<id>14</id>
</process>
</model>
<model>
<name>estofsAK</name>
<center>7</center>
<subcenter>4</subcenter>
<grid>825553001</grid>
<process>
<id>14</id>
</process>
</model>
<model>
<name>estofsPR</name>
<center>7</center>
@ -2390,16 +2410,6 @@
<!-- END SUBCENTER 2: NCEP ENSEMBLE PRODUCTS -->
<model>
<name>hysplit</name>
<center>7</center>
<subcenter>3</subcenter>
<grid>36928220</grid>
<process>
<id>3</id>
</process>
</model>
<!-- SUBCENTER 4: ENVIRONMENTAL MODELING CENTER -->
<model>

View file

@ -12,6 +12,16 @@
<!-- SUBCENTER 0 -->
<model>
<name>cmcHR</name>
<center>53</center>
<subcenter>0</subcenter>
<grid>493399001</grid>
<process>
<id>36</id>
</process>
</model>
<model>
<name>CanadianModel</name>
<center>54</center>

View file

@ -1,4 +1,4 @@
<?xml version="2.0" encoding="UTF-8" standalone="yes"?>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.

View file

@ -140,5 +140,4 @@
<alias base="SP">SPXX</alias>
<alias base="IDRL">IDRL</alias>
<alias base="SRCS">SRCS</alias>
<alias base="NTAT">NTAT</alias>
</aliasList>
</aliasList>

View file

@ -355,6 +355,7 @@
<alias base="USWRF48hr">SWRU48</alias>
<alias base="uW">UREL</alias>
<alias base="vW">VREL</alias>
<alias base="VAFTAD1hr">VASH01</alias>
<alias base="VAPP">VAPR</alias>
<alias base="VFLX">VRELFX</alias>
<alias base="VFLX1hr">VRELFX01</alias>
@ -399,4 +400,4 @@
<alias base="WVDIR">DRCTWW</alias>
<alias base="WVHGT">HGHTWW</alias>
<alias base="WVPER">PERDWW</alias>
</aliasList>
</aliasList>

View file

@ -0,0 +1,175 @@
#!/usr/bin/env python
##
# This script is a collection of utility function to be used for extracting PGEN
# products from EDEX and to store PGEN activities to EDEX.
#
# Users can override the default EDEX server and port name by specifying them
# in the $DEFAULT_HOST and $DEFAULT_PORT shell environment variables.
#
##
import os
import re
import xml.etree.ElementTree as ET
import lib.CommHandler as CH
class ActivityUtil:
#
# Sends a CatalogQuery to the EDEX uEngine to get a list of
# PGEN Activity Types, Subtypes, Labels, refTimes, and associated
# dataURIs in the pgen database tables.
#
def getActivityMap(self):
script='''import CatalogQuery
query = CatalogQuery.CatalogQuery("pgen")
query.addReturnedField("activityType")
query.addReturnedField("activitySubtype")
query.addReturnedField("activityLabel")
query.addReturnedField("dataTime.refTime")
query.addReturnedField("activityName")
query.addReturnedField("dataURI")
return query.execute()'''
service = '/services/pyproductjaxb'
host = os.getenv("DEFAULT_HOST", "localhost")
port = os.getenv("DEFAULT_PORT", "9581")
connection=str(host+":"+port)
ch = CH.CommHandler(connection,service)
ch.process(script)
if not ch.isGoodStatus():
print ch.formatResponse()
exit(1)
return self.__generateMap( ch.getContents() )
#
# Generates a map of activity types/subtypes, labels, refTimes, and dataURIs from
# the XML returned from EDEX uEngine
#
# The map is a dictionary (dict) of Activity Types in form of "type(subtype)" whose values
# are a list of dicts which have keys "activityType", "activityLabel", "dataTime.refTime",
# and "dataURI".
#
def __generateMap(self, xml):
aMap = dict()
tree = ET.fromstring(xml)
for item in tree.iter('items'):
record = dict()
for attr in item.iter('attributes'):
record.update( {attr.attrib['field'] : attr.attrib['value'] } )
atype = record['activityType']
stype = record['activitySubtype']
if ( stype != None and len(stype.lstrip()) > 0):
atype = atype + "(" + stype.lstrip() + ")"
if aMap.has_key(atype):
aMap[atype].append(record)
else:
aMap.update( {atype: [record]} )
return aMap
#
# Compare if a command line string matches an string in activity.
# This uses string methods.
#
def matcher(self, cmdstr, activitystr):
matched = False
if cmdstr == None:
matched = True
else:
if activitystr == None:
matched = False;
else:
realstr = cmdstr.strip("*")
if ( cmdstr.startswith("*") ):
if ( cmdstr.endswith("*") ):
if ( activitystr.find( realstr ) >= 0 ):
matched = True
else:
if activitystr.endswith( realstr):
matched = True
elif cmdstr.endswith("*"):
if activitystr.startswith( realstr):
matched = True
else:
if ( activitystr == cmdstr ):
matched = True
return matched
#
# Compare if a command line string matches an string in activity.
# This uses regular expression matching.
#
# cmdstr - input from command line, could use "*" anywhere to match one or more character.
# activitystr - value saved in PGEN DB for an activity, such as type, label, ...
#
def stringMatcher(self, cmdstr, activitystr):
matched = False
if cmdstr == None:
matched = True
elif activitystr == None:
matched = False
else:
#parenthese should be escaped.
ps = cmdstr.replace("(", "\(")
pe = ps.replace(")", "\)")
# "*" could match any one or more characters.
pn = pe.replace("*", "(.*)")
mb = re.match(pn, activitystr)
if mb != None:
matched = True
return matched
#
# This method sends a CatalogQuery request to the EDEX uEngine
# for the dataURI associated with the given activity type and label
#
def getDataURI( self, atype, label):
script='''import CatalogQuery
query = CatalogQuery.CatalogQuery("pgen")
query.addConstraint("activityType","{0}","=")
query.addConstraint("activityLabel","{1}","=")
query.addReturnedField("dataURI")
query.addReturnedField("dataTime.refTime")
return query.execute()'''.format(atype,label)
service = '/services/pyproductjaxb'
host = os.getenv("DEFAULT_HOST", "localhost")
port = os.getenv("DEFAULT_PORT", "9581")
connection=str(host+":"+port)
ch = CH.CommHandler(connection,service)
ch.process(script)
if not ch.isGoodStatus():
print ch.formatResponse()
exit(1)
logger.debug( ch.getContents() )
return __parseResponse( ch.getContents() )
#
# Parses the XML response from the uEngine and extracts
# the value for the dataURI field. If multiple are returned, the last
# one is used.
#
def __parseResponse(self, xml):
tree = ET.fromstring(xml)
for attr in tree.iter('attributes'):
if attr.attrib['field'] == 'dataURI':
duri = attr.attrib['value']
return duri

View file

@ -11,6 +11,7 @@ class ProductRetriever:
def __init__(self,dataURI,label):
self.dataURI = dataURI
self.label = label
self.fullpath = False
self.outdir = os.getcwd()
self.host = os.getenv("DEFAULT_HOST", "localhost")
self.port = os.getenv("DEFAULT_PORT", "9581")
@ -18,6 +19,9 @@ class ProductRetriever:
def setOutputDir(self, outdir):
self.outdir = outdir
def setFullpath(self, fullpath):
self.fullpath = fullpath
def _writeout(self,filename,bytes):
outname = self.outdir + str(os.sep) + filename
@ -39,12 +43,18 @@ class ProductRetriever:
filename = self.label + ".xml"
else:
filename = item.getName()
print "Extracting... " + filename
if ( self.fullpath ):
path = self.dataURI
fname = path.replace("/", ".") + "$" + filename
filename = fname.lstrip().strip(".").replace("..", ".")
if isinstance(item, StringDataRecord):
self._writeout(filename,item.getStringData()[0])
elif isinstance(item, ByteDataRecord):
self._writeout(filename,item.getByteData())
print "Extracted... " + filename
return resp

View file

@ -2,9 +2,9 @@
##
# This script is used to extract PGEN products from EDEX.
# It can be run in batch mode by specifying the "-l" and "-t" options on the
# command line. Optionally, users can run it in interactive mode by invoking it
# with no argument.
# It can be run in batch mode by specifying the "-l", "-t", "-d", "-st", "-n", and
# "-p" options on the command line. Optionally, users can run it in interactive
# mode by invoking it with no argument.
#
# Users can override the default EDEX server and port name by specifying them
# in the $DEFAULT_HOST and $DEFAULT_PORT shell environment variables.
@ -19,6 +19,7 @@ from Tkinter import *
from ufpy import UsageArgumentParser
import lib.CommHandler as CH
import ProductRetriever
import ActivityUtil
logger = None
def __initLogger():
@ -33,68 +34,53 @@ def __initLogger():
ch.setFormatter(formatter)
logger.addHandler(ch)
#
# Parses command line input and store in "options".
#
def __parseCommandLine():
parser = UsageArgumentParser.UsageArgumentParser(prog='retrieveActivity',description="Retrieve PGEN Activities from EDEX. When invoked without any arguments, retrieveActivity is run in interactive mode.")
bgroup = parser.add_argument_group(title='batch',description='For running in scripts and/or batch mode.')
bgroup.add_argument("-l", action="store", dest="label",
bgroup.add_argument("-l*", action="store", dest="label",
help="Activity Label being requested",
required=False, metavar="label")
bgroup.add_argument("-t", action="store", dest="type",
bgroup.add_argument("-t*", action="store", dest="type",
help="Activity Type being requested",
required=False, metavar="type")
bgroup.add_argument("-st", action="store", dest="subtype",
help="Activity Subtype being requested",
required=False, metavar="subtype")
bgroup.add_argument("-d*", action="store", dest="reftime",
help="Activity Ref Time being requested (YYYY-MM-DD_HH:MM)",
required=False, metavar="reftime")
bgroup.add_argument("-n*", action="store", dest="name",
help="Activity Name being requested",
required=False, metavar="name")
bgroup.add_argument("-f", action="store", dest="fullpath",
help="Write out XML with full path? (Yes/No)",
required=False, metavar="fullpath")
bgroup = parser.add_argument_group(title='Note',description='Pattern match with "*" is allowed for -l, -t, -d, and -n. E.g, -l "*CCFP*3*" will match any activities whose label contains CCFP and 3.')
options = parser.parse_args()
options.interactive = False
if options.label == None and options.type == None :
options.interactive = True
elif options.label == None or options.type == None :
print "Must enter values for both arguments -l and -t"
exit(0)
if (options.label == None and options.type == None and
options.reftime == None and options.subtype == None and
options.fullpath == None and options.name == None):
options.interactive = True
else:
if (options.label == None and options.type == None and
options.reftime == None and options.name == None):
print "Must enter values for at least one of -l, -t, -d, or -n"
exit(0)
logger.debug("Command-line arguments: " + str(options))
return options
#
# This method sends a CatalogQuery request to the EDEX uEngine
# for the dataURI associated with the given activity type and label
# Main program.
#
def __getDataURI( type, label):
script='''import CatalogQuery
query = CatalogQuery.CatalogQuery("pgen")
query.addConstraint("activityType","{0}","=")
query.addConstraint("activityLabel","{1}","=")
query.addReturnedField("dataURI")
query.addReturnedField("dataTime.refTime")
return query.execute()'''.format(type,label)
service = '/services/pyproductjaxb'
host = os.getenv("DEFAULT_HOST", "localhost")
port = os.getenv("DEFAULT_PORT", "9581")
connection=str(host+":"+port)
ch = CH.CommHandler(connection,service)
ch.process(script)
if not ch.isGoodStatus():
print ch.formatResponse()
exit(1)
logger.debug( ch.getContents() )
return __parseResponse( ch.getContents() )
#
# Parses the XML response from the uEngine and extracts
# the value for the dataURI field. If multiple are returned, the last
# one is used.
#
def __parseResponse(xml):
tree = ET.fromstring(xml)
for attr in tree.iter('attributes'):
if attr.attrib['field'] == 'dataURI':
duri = attr.attrib['value']
return duri
def main():
__initLogger()
logger.info("Starting retrieveActivity.")
@ -109,21 +95,51 @@ def main():
app.mainloop()
root.destroy()
else:
# Retrieve products for given activity type and label
logger.info("looking for Product: " + options.type + " - " + options.label)
dataURI = __getDataURI(options.type, options.label)
logger.debug("Found dataURI = " + dataURI)
# Retrieve all activities abnd build a map of record using
# type(subtype) as key.
mu = ActivityUtil.ActivityUtil()
activityMap = mu.getActivityMap()
reqtype = None
if ( options.type != None ):
reqtype = options.type;
if ( options.subtype != None ) :
reqtype = options.type + "(" + options.subtype + ")"
records = []
for key in activityMap.iterkeys():
recs = activityMap[key]
for rec in recs:
if ( mu.stringMatcher(options.label, rec["activityLabel"]) and
mu.stringMatcher(reqtype, key ) and
mu.stringMatcher(options.name, rec["activityName"] ) ):
#Remove sec.msec from record's refTime
dbRefTime = rec["dataTime.refTime"]
dotIndex = dbRefTime.rfind(":")
if ( dotIndex > 0 ):
shortTime = dbRefTime[:dotIndex]
else:
shortTime = dbRefTime
#Replace the "_" with a whitespace in reftime.
optionTime = options.reftime.replace("_", " ")
if ( mu.stringMatcher( optionTime, shortTime ) ):
records.append( rec )
for rec in records:
pr = ProductRetriever.ProductRetriever(rec["dataURI"], rec["activityLabel"])
if options.fullpath != None and options.fullpath.upper().startswith("Y"):
pr.setFullpath(True)
pr.getProducts()
pr = ProductRetriever.ProductRetriever(dataURI, options.label)
outdir = os.getcwd() + str(os.sep) + options.type + str(os.sep) + options.label + str(os.sep)
#pr.setOutputDir(outdir)
pr.getProducts()
#print "Products were written to directory: " + outdir
logger.info("retrieveActivity is complete.")
#
# Interactive GUI for PGEN activity retrieval
#
class RetrieveGui(Frame):
""" Interactive GUI for PGEN product retrieval """
""" Interactive GUI for PGEN activity retrieval """
def __init__(self, master=None):
""" Initialize Frame and create widgets """
@ -136,15 +152,16 @@ class RetrieveGui(Frame):
# if an activity type and label have been selected, get products and write them out.
if len(self.typeList.curselection()) != 0 and len(self.nameList.curselection()) != 0:
type = self.typeList.get(self.typeList.curselection())
label = self.nameList.get(self.nameList.curselection())
labelindex = int(self.nameList.curselection()[0])
dataURI = self.activityMap[type][labelindex]['dataURI']
pr = ProductRetriever.ProductRetriever(dataURI, label)
#outdir = os.getcwd() + str(os.sep) + options.type + str(os.sep) + options.label + str(os.sep)
#pr.setOutputDir(outdir)
pr.getProducts()
items = self.nameList.curselection()
for i in items :
idx = int(i)
label = self.nameList.get(idx)
dataURI = self.activityMap[type][idx]['dataURI']
pr = ProductRetriever.ProductRetriever(dataURI, label)
pr.getProducts()
def createWidgets(self):
activityType = Label(self)
activityType["text"] = "Activity Type"
@ -172,7 +189,7 @@ class RetrieveGui(Frame):
frame2 = Frame(self)
vscrollbar2 = Scrollbar(frame2, orient=VERTICAL)
hscrollbar2 = Scrollbar(frame2, orient=HORIZONTAL)
self.nameList = Listbox(frame2,yscrollcommand=vscrollbar2.set,xscrollcommand=hscrollbar2.set,exportselection=0, width=50,height=15,bg="white")
self.nameList = Listbox(frame2,yscrollcommand=vscrollbar2.set,xscrollcommand=hscrollbar2.set,exportselection=0, width=50,height=15,bg="white", selectmode=EXTENDED)
vscrollbar2.config(command=self.nameList.yview)
hscrollbar2.config(command=self.nameList.xview)
vscrollbar2.pack(side=RIGHT, fill=Y)
@ -197,7 +214,7 @@ class RetrieveGui(Frame):
# Get all Activity Types and Labels from EDEX for use in selection ListBoxes.
# Insert list of Types in Type Listbox
#
self.activityMap = self.__getActivityMap()
self.activityMap = ActivityUtil.ActivityUtil().getActivityMap()
self.typeList.delete(0,END)
for key in self.activityMap.iterkeys():
self.typeList.insert(END,key)
@ -225,62 +242,8 @@ class RetrieveGui(Frame):
def typeList_has_changed(self, index):
self.nameList.delete(0,END)
for label in self.activityMap[ self.typeList.get(index) ]:
#print label
self.nameList.insert(END, label['activityLabel'])
#
# Sends a CatalogQuery to the EDEX uEngine to get a list of
# PGEN Activity TYpes, Labels, and associated dataURIs
# in the pgen database tables.
#
def __getActivityMap(self):
script='''import CatalogQuery
query = CatalogQuery.CatalogQuery("pgen")
query.addReturnedField("activityType")
query.addReturnedField("activityLabel")
query.addReturnedField("dataURI")
return query.execute()'''
service = '/services/pyproductjaxb'
host = os.getenv("DEFAULT_HOST", "localhost")
port = os.getenv("DEFAULT_PORT", "9581")
connection=str(host+":"+port)
ch = CH.CommHandler(connection,service)
ch.process(script)
if not ch.isGoodStatus():
print ch.formatResponse()
exit(1)
logger.debug( ch.getContents() )
return self.__generateMap( ch.getContents() )
#
# Generates a map of activity types, label, and dataURIs from
# the XML returned from EDEX uEngine for use in the activity type and label
# Listboxes.
#
# The map is a dictionary (dict) of Activity Types whose values are a list of dicts
# which have keys "activityType", "activityLabel", and "dataURI".
#
def __generateMap(self, xml):
aMap = dict()
tree = ET.fromstring(xml)
for item in tree.iter('items'):
#print item.attrib['key']
record = dict()
for attr in item.iter('attributes'):
record.update( {attr.attrib['field'] : attr.attrib['value'] } )
#print record
atype = record['activityType']
if aMap.has_key(atype):
aMap[atype].append(record)
else:
aMap.update( {atype: [record]} )
return aMap
if __name__ == '__main__':
main()
main()

View file

@ -56,14 +56,69 @@ def __parseCommandLine():
logger.debug("Command-line arguments: " + str(options))
return options
def __getActivityInfo(options):
#
# create an ActivityInfo object from command line input and
# activityXML. If no input was found from command line, the
# info in activityXML will be used.
#
def __getActivityInfo(xml, options):
ainfo = ActivityInfo()
ainfo.setActivityLabel(options.filename)
ainfo.setActivityName(options.activityName)
ainfo.setActivityType(options.activityType)
ainfo.setActivitySubtype(options.activitySubtype)
ainfo.setForecaster(options.forecaster)
ainfo.setSite(options.site)
tree = ET.fromstring(xml)
product = tree.find('Product')
# strip the path from file and use it as activityLabel
fullname = options.filename
lastslash = fullname.rfind("/")
filename = fullname
if ( lastslash >=0 ):
filename = fullname[lastslash+1:]
ainfo.setActivityLabel(filename)
if ( options.forecaster != None ):
ainfo.setForecaster(options.forecaster)
else:
ainfo.setForecaster(product.attrib['forecaster'])
if ( options.site != None ):
ainfo.setSite(options.site)
else:
ainfo.setSite(product.attrib['center'])
# set activity type and subtype
if ( options.activityType != None ):
ainfo.setActivityType(options.activityType)
if ( options.activitySubtype != None ):
ainfo.setActivitySubtype(options.activitySubtype)
else:
ainfo.setActivitySubtype("")
else:
if (product.attrib['type'].find("(") < 0 ):
ainfo.setActivityType( product.attrib['type'] )
ainfo.setActivitySubtype( "" )
else:
fulltyp = product.attrib['type']
start = fulltyp.find("(")
end = fulltyp.find(")")
ainfo.setActivityType( fulltyp[0:start] )
ainfo.setActivitySubtype( fulltyp[start+1:end] )
# set activityName
if ( options.activityName != None ):
ainfo.setActivityName(options.activityName)
else:
if ( options.activityType != None ):
aname = options.activityType;
if ( options.activitySubtype != None ):
aname = aname + "(" + options.activitySubtype + ")"
ainfo.setActivityName( aname )
else:
ainfo.setActivityName( product.attrib['name'] )
return ainfo
# Update Product tag attributes with options given on command line
@ -72,9 +127,13 @@ def __updateXML(xml, options):
product = tree.find('Product')
if options.activityName != None:
product.attrib['name'] = options.activityName
if options.activityType != None:
product.attrib['type'] = options.activityType
if options.activitySubtype != None:
ntype = options.activityType + '(' + options.activitySubtype + ')'
product.attrib['type'] = ntype
else:
product.attrib['type'] = options.activityType
if options.filename != None:
product.attrib['outputFile'] = options.filename
@ -84,11 +143,12 @@ def __updateXML(xml, options):
if options.site != None:
product.attrib['center'] = options.site
return ET.tostring(tree)
def main():
__initLogger()
logger.info("Starting retrieveActivity.")
logger.info("Starting storeActivity.")
options = __parseCommandLine()
# read in XML from input file
@ -98,7 +158,7 @@ def main():
# generate an activityInfo object and update XML with options
# from command line
actinfo = __getActivityInfo(options)
actinfo = __getActivityInfo(activityXML, options)
activityXML = __updateXML(activityXML, options)
# Store Activity to EDEX
@ -110,4 +170,4 @@ def main():
if __name__ == '__main__':
main()
main()

View file

@ -14,6 +14,7 @@ Import-Package: com.raytheon.edex.uengine.tasks.query,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.edex.pointdata,
gov.noaa.nws.ncep.edex.common.sounding,
org.apache.commons.logging
Export-Package: gov.noaa.nws.ncep.common.dataplugin.gpd,
gov.noaa.nws.ncep.common.dataplugin.gpd.dao,

View file

@ -1,4 +1,8 @@
/**
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
@ -30,7 +34,10 @@ public class GenericPointDataConstants {
// db filed defined in GenericPointDataRecord
public static final String DB_PROD_NAME= "productInfo.name";
public static final String DB_MASTER_LEVEL_NAME= "productInfo.masterLevel.name";
public static final String DB_REFTIME_NAME= "dataTime.refTime";
public static final String DB_REF_TIME= "dataTime.refTime";
public static final String DB_FORECAST_TIME= "dataTime.fcstTime";
public static final String DB_RANGESTART_TIME= "dataTime.validPeriod.start";
public static final String DB_UTILITY_FLAGS= "dataTime.utilityFlags";
public static final String DB_PRODUCT_VERSION = "productVersion";
public static final String DB_STN_CATALOGTYPE = "location.catalogType";
public static final String DB_SLAT = "slat";

View file

@ -1,3 +1,24 @@
/**
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 05/30/2013 Chin J. Chen Initial coding
*
* </pre>
*
* @author Chin J. Chen
* @version 1.0
*/
package gov.noaa.nws.ncep.common.dataplugin.gpd;
import gov.noaa.nws.ncep.common.dataplugin.gpd.product.GenericPointDataProductInfo;
@ -31,23 +52,6 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.time.DataTime;
/**
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 05/30/2013 Chin J. Chen Initial coding
*
* </pre>
*
* @author Chin J. Chen
* @version 1.0
*/
@Entity
// @Table(name = "gpd", uniqueConstraints = { @UniqueConstraint(columnNames = {
// "dataURI" }) })
@ -144,6 +148,7 @@ public class GenericPointDataRecord extends PersistablePluginDataObject
this.slat = slat;
this.slon = slon;
this.pointDataView = pointDataView;
// this.pluginName = "gpd";
// System.out.println("GenericPointDataRecord(3) entered");
}
@ -157,6 +162,7 @@ public class GenericPointDataRecord extends PersistablePluginDataObject
this.pointDataView = pointDataView;
this.dataTime = dataTime;
this.productVersion = productVersion;
// this.pluginName = "gpd";
// System.out.println("GenericPointDataRecord(4) entered");
}
@ -300,13 +306,10 @@ public class GenericPointDataRecord extends PersistablePluginDataObject
this.productVersion = productVersion;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.common.dataplugin.PluginDataObject#getPluginName()
*/
@Override
public String getPluginName() {
return "gpd";
// TODO Auto-generated method stub
return null;
}
}

View file

@ -1,5 +1,8 @@
/**
*
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
*
@ -26,8 +29,13 @@ import gov.noaa.nws.ncep.common.dataplugin.gpd.product.GenericPointDataProductIn
import gov.noaa.nws.ncep.common.dataplugin.gpd.product.GenericPointDataStationProduct;
import gov.noaa.nws.ncep.common.dataplugin.gpd.query.GenericPointDataQuery;
import gov.noaa.nws.ncep.common.dataplugin.gpd.query.GenericPointDataReqMsg.GenericPointDataQueryKey;
import gov.noaa.nws.ncep.common.dataplugin.gpd.query.GenericPointDataReqMsg.GenericPointDataReqType;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingStnInfo;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingStnInfoCollection;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingTimeLines;
import java.io.File;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -36,6 +44,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.bind.JAXBException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
@ -47,6 +57,7 @@ import org.hibernate.criterion.Restrictions;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.common.parameter.Parameter;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.pointdata.PointDataDescription;
@ -75,7 +86,7 @@ public class GenericPointDataDao extends
@Override
public String[] getKeysRequiredForFileName() {
return new String[] { GenericPointDataConstants.DB_REFTIME_NAME,
return new String[] { GenericPointDataConstants.DB_REF_TIME,
GenericPointDataConstants.DB_PROD_NAME,
GenericPointDataConstants.DB_MASTER_LEVEL_NAME };
}
@ -96,7 +107,9 @@ public class GenericPointDataDao extends
@Override
public String getPointDataFileName(GenericPointDataRecord p) {
Date refTime = (p.getDataTime().getRefTime());
String dateStr = hdfFileDateFormat.format(refTime);
int forecasttime = p.getDataTime().getFcstTime();
String dateStr = hdfFileDateFormat.format(refTime) + "-f"
+ forecasttime;
// System.out.println("gpd getPointDataFileName1 called and return: "+"gpd-"+p.getProductInfo().getName()+dateStr+/*"-"+p.getReportType().getMasterLevel().getName()+*/".h5");
return "gpd-" + p.getProductInfo().getName() + dateStr + ".h5";
}
@ -123,10 +136,12 @@ public class GenericPointDataDao extends
public String getPointDataFileName(Map<String, Object> dbResults) {
String reportname = (String) dbResults
.get(GenericPointDataConstants.DB_PROD_NAME);
// String lmName=
// (String)dbResults.get(GenericPointDataConstants.DB_MASTER_LEVEL_NAME);
int forecasttime = (Integer) dbResults
.get(GenericPointDataConstants.DB_FORECAST_TIME);
String dateStr = hdfFileDateFormat.format(dbResults
.get(GenericPointDataConstants.DB_REFTIME_NAME));
.get(GenericPointDataConstants.DB_REF_TIME))
+ "-f"
+ forecasttime;
String filename = PLUGIN_HDF5_DIR + reportname + File.separator
// + lmName + File.separator
+ this.pluginName + "-" + reportname + /* "-"+lmName+ */dateStr
@ -158,7 +173,10 @@ public class GenericPointDataDao extends
Date refTime = ((PluginDataObject) persistable).getDataTime()
.getRefTime();
String dateStr = hdfFileDateFormat.format(refTime);
int forecasttime = ((PluginDataObject) persistable).getDataTime()
.getFcstTime();
String dateStr = hdfFileDateFormat.format(refTime) + "-f"
+ forecasttime;
String fileName = persistable.getPluginName() + "-"
+ rec.getProductInfo().getName() + /*
* "-"+rec.getReportType().
@ -174,11 +192,17 @@ public class GenericPointDataDao extends
/*
* This function is for development testing.. not used in production code
*/
public PointDataDescription getPointDataDescription()
throws SerializationException {
public PointDataDescription getPointDataDescription() throws JAXBException {
if (pdd == null) {
pdd = PointDataDescription.fromStream(this.getClass()
.getResourceAsStream("/res/pointdata/gpd.xml"));
try {
pdd = PointDataDescription.fromStream(this.getClass()
.getResourceAsStream("/res/pointdata/gpd.xml"));
} catch (SerializationException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
// statusHandler.handle(Priority.PROBLEM,
// e.getLocalizedMessage(), e);
}
}
return pdd;
}
@ -415,6 +439,7 @@ public class GenericPointDataDao extends
Criterion nameCrit = Restrictions.eq("name", prod.getName());
crit.add(nameCrit);
// query
List<?> vals = crit.list();
if (vals.size() > 0) {
// the product is already in DB
@ -440,7 +465,7 @@ public class GenericPointDataDao extends
// prod version > 0, disallow update prod info
} else {
// TBD...do we need clone it?
returnProdInfo = dbProdInfo;// .clone();
returnProdInfo = dbProdInfo;
}
} else if (createProd) {
@ -630,6 +655,15 @@ public class GenericPointDataDao extends
GenericPointDataQueryKey quertKey, String stnId, float slat,
float slon, GenericPointDataProductInfo prodInfo, int productVersion)
throws Exception {
return (getPointDataContainer(refTime, null, quertKey, stnId, slat,
slon, prodInfo, productVersion));
}
private PointDataContainer getPointDataContainer(Date refTime,
Date rangeStartTime, GenericPointDataQueryKey quertKey,
String stnId, float slat, float slon,
GenericPointDataProductInfo prodInfo, int productVersion)
throws Exception {
String prodName = prodInfo.getName();
PointDataContainer pdc = null;
@ -648,15 +682,14 @@ public class GenericPointDataDao extends
}
returnParametersString.append(parameter);
}
// also add the 3 HDF5 mandatory datasets
// also add the 3 HDF5 mandatory data sets
returnParametersString.append(","
+ GenericPointDataConstants.HDF5_LEVEL_VALUE);
returnParametersString.append(","
+ GenericPointDataConstants.HDF5_NUM_LEVEL);
returnParametersString.append(","
+ GenericPointDataConstants.HDF5_STN_ID);
System.out.println("gpd dao hdf5 parameterlist="
+ returnParametersString.toString());
// System.out.println("gpd dao hdf5 parameterlist="+returnParametersString.toString());
// 2nd:: add return fields form DB. the parameter name need to be
// defined in
@ -666,7 +699,10 @@ public class GenericPointDataDao extends
+ GenericPointDataConstants.DB_STN_CATALOGTYPE);
returnParametersString.append("," + GenericPointDataConstants.DB_SLAT);
returnParametersString.append("," + GenericPointDataConstants.DB_SLON);
returnParametersString.append(","
+ GenericPointDataConstants.DB_UTILITY_FLAGS);
returnParametersString.append(","
+ GenericPointDataConstants.DB_FORECAST_TIME);
// parameters defined in
// /gov.noaa.nws.ncep.edex.plugin.gpd/utility/common_static/base/path/gpdPathKeys.xml
// AND those returned by dao.getKeysRequiredForFileName()
@ -681,25 +717,33 @@ public class GenericPointDataDao extends
if (quertKey == GenericPointDataQueryKey.BY_STN_ID)
pdq.addParameter("location.stationId", stnId, "=");
else if (quertKey == GenericPointDataQueryKey.BY_SLAT_SLON) {
pdq.addParameter("slat", Float.toString(slat + 0.001f), "<");
pdq.addParameter("slon", Float.toString(slon + 0.001f), "<");
pdq.addParameter("slat", Float.toString(slat - 0.001f), ">");
pdq.addParameter("slon", Float.toString(slon - 0.001f), ">");
pdq.addParameter("slat", Float.toString(slat), "=");
pdq.addParameter("slon", Float.toString(slon), "=");
}
String dateStr = dbRefTimeFormat.format(refTime);
pdq.addParameter("dataTime.refTime", dateStr, "=");
pdq.addParameter("productVersion", Integer.toString(productVersion),
"=");
System.out.println("requestig refTime = " + dateStr);
pdq.addParameter(GenericPointDataConstants.DB_REF_TIME, dateStr, "=");
if (rangeStartTime != null) {
String rangedateStr = dbRefTimeFormat.format(rangeStartTime);
pdq.addParameter(GenericPointDataConstants.DB_RANGESTART_TIME,
rangedateStr, "=");
}
pdq.addParameter(GenericPointDataConstants.DB_PRODUCT_VERSION,
Integer.toString(productVersion), "=");
// System.out.println("requestig refTime = "+ dateStr);
pdq.requestAllLevels();
pdc = pdq.execute();
try {
pdc = pdq.execute();
} catch (StorageException e) {
System.out.println("HDF5 query StorageException " + e);
}
return pdc;
}
/*
* TBM...Chin delet this leter...not used public
* TBM...Chin delete this later...not used public
* GenericPointDataProductContainer getGpdProduct(Date refTime, String
* prodName,boolean useSpecifiedProductVersion, int productVersion)throws
* Exception{ GenericPointDataProductInfo prodInfo = getGpdProdInfo(
@ -791,6 +835,7 @@ public class GenericPointDataDao extends
GenericPointDataQueryKey key, String stnId, float slat, float slon,
String prodName, boolean useSpecifiedProductVersion,
int productVersion) throws Exception {
long t01 = System.currentTimeMillis();
GenericPointDataProductInfo prodInfo = getGpdProdInfo(prodName);
if (prodInfo == null) {
System.out.println("report is not in DB");
@ -809,7 +854,7 @@ public class GenericPointDataDao extends
System.out.println("pdc is null");
return null;
}
System.out.println("pdc CurrentSz()=" + pdc.getCurrentSz());
// System.out.println("pdc CurrentSz()="+pdc.getCurrentSz());
GenericPointDataProductContainer prodCon = new GenericPointDataProductContainer();
prodCon.setProductInfo(prodInfo);
prodCon.setRefTime(refTime);
@ -891,6 +936,19 @@ public class GenericPointDataDao extends
// slon value is retrieved already, so drop it here
parameters.remove(GenericPointDataConstants.DB_SLON);
}
String utFlag = null;
if (parameters.contains(GenericPointDataConstants.DB_UTILITY_FLAGS)) {
utFlag = pdv
.getString(GenericPointDataConstants.DB_UTILITY_FLAGS);
// System.out.println("utFlag= "+ utFlag);
parameters.remove(GenericPointDataConstants.DB_UTILITY_FLAGS);
}
int forecastTime = 0;
if (parameters.contains(GenericPointDataConstants.DB_FORECAST_TIME)) {
forecastTime = pdv
.getInt(GenericPointDataConstants.DB_FORECAST_TIME);
parameters.remove(GenericPointDataConstants.DB_FORECAST_TIME);
}
// PDV id is not returned back to user, so drop it here
parameters.remove(GenericPointDataConstants.HDF5_PDV_ID);
@ -904,6 +962,8 @@ public class GenericPointDataDao extends
stnPd.setNumLevel(numLevel);
stnPd.setSlat(rtnslat);
stnPd.setSlon(rtnslon);
stnPd.setForecastTime(forecastTime);
stnPd.setUtilityFlag(utFlag);
for (String parm : parameters) {
if (numLevel > 1) {
// these parameters are data parameters and should be 2
@ -920,6 +980,7 @@ public class GenericPointDataDao extends
levelList.get(j).getGpdParameters().add(gpdParm);
}
} else {
// System.out.println("parm ="+parm);
GenericPointDataParameter gpdParm = new GenericPointDataParameter(
parm, pdv.getFloat(parm));
levelList.get(0).getGpdParameters().add(gpdParm);
@ -927,6 +988,10 @@ public class GenericPointDataDao extends
}
prodCon.getStnProdLst().add(stnPd);
}
long t02 = System.currentTimeMillis();
System.out.println("ThrifClient: getGpdProduct() took " + (t02 - t01)
+ " ms in total for query stn=" + stnId);
return prodCon;
}
@ -952,8 +1017,8 @@ public class GenericPointDataDao extends
System.out.println("pdc is null");
continue;
}
System.out.println(refTime.toString() + " pdc CurrentSz()="
+ pdc.getCurrentSz());
// System.out.println(refTime.toString()
// +" pdc CurrentSz()="+pdc.getCurrentSz());
for (int i = 0; i < pdc.getCurrentSz(); i++) {
PointDataView pdv = pdc.readRandom(i);
@ -1036,6 +1101,23 @@ public class GenericPointDataDao extends
// slon value is retrieved already, so drop it here
parameters.remove(GenericPointDataConstants.DB_SLON);
}
String utFlag = null;
if (parameters
.contains(GenericPointDataConstants.DB_UTILITY_FLAGS)) {
utFlag = pdv
.getString(GenericPointDataConstants.DB_UTILITY_FLAGS);
System.out.println("utFlag= " + utFlag);
parameters
.remove(GenericPointDataConstants.DB_UTILITY_FLAGS);
}
int forecastTime = 0;
if (parameters
.contains(GenericPointDataConstants.DB_FORECAST_TIME)) {
forecastTime = pdv
.getInt(GenericPointDataConstants.DB_FORECAST_TIME);
parameters
.remove(GenericPointDataConstants.DB_FORECAST_TIME);
}
// PDV id is not returned back to user, so drop it here
parameters.remove(GenericPointDataConstants.HDF5_PDV_ID);
@ -1049,6 +1131,8 @@ public class GenericPointDataDao extends
stnPd.setNumLevel(numLevel);
stnPd.setSlat(rtnslat);
stnPd.setSlon(rtnslon);
stnPd.setForecastTime(forecastTime);
stnPd.setUtilityFlag(utFlag);
for (String parm : parameters) {
if (numLevel > 1) {
// these parameters are data parameters and should be 2
@ -1076,8 +1160,182 @@ public class GenericPointDataDao extends
return stnProdList;
}
public List<GenericPointDataStationProduct> getGpdStationModelSndProduct(
List<Date> rangeStartTimeList, Date referenceTime,
GenericPointDataQueryKey key, String stnId, float slat, float slon,
String prodName) throws Exception {
long t01 = System.currentTimeMillis();
GenericPointDataProductInfo prodInfo = getGpdProdInfo(prodName);
if (prodInfo == null) {
System.out.println("product is not in DB");
return null;
}
int productVersion = getGpdProductLatestVersion(referenceTime, prodName);
if (productVersion < 0) {
System.out.println("product version not available");
return null;
}
List<GenericPointDataStationProduct> stnProdList = new ArrayList<GenericPointDataStationProduct>();
for (Date rangeStartTime : rangeStartTimeList) {
PointDataContainer pdc = getPointDataContainer(referenceTime,
rangeStartTime, key, stnId, slat, slon, prodInfo,
productVersion);
if (pdc == null) {
System.out.println("pdc is null");
continue;
}
// System.out.println(rangeStartTime.toString()
// +" pdc CurrentSz()="+pdc.getCurrentSz());
for (int i = 0; i < pdc.getCurrentSz(); i++) {
PointDataView pdv = pdc.readRandom(i);
// System.out.println("pdv#"+i+" *********************************************");
Set<String> parameters = new HashSet<String>(pdv.getContainer()
.getParameters());
int numLevel = 0;
if (parameters
.contains(GenericPointDataConstants.HDF5_NUM_LEVEL)) {
numLevel = pdv
.getInt(GenericPointDataConstants.HDF5_NUM_LEVEL);
// System.out.println("numLevel= "+ numLevel);
// numLevel value is retrieved already, so drop it here
parameters.remove(GenericPointDataConstants.HDF5_NUM_LEVEL);
} else
continue; // level number is 0, no need to continue on this
// PDV.
List<GenericPointDataLevel> levelList;
if (parameters
.contains(GenericPointDataConstants.HDF5_LEVEL_VALUE)) {
levelList = new ArrayList<GenericPointDataLevel>(numLevel);
if (numLevel > 1) {
Number[] num = pdv
.getNumberAllLevels(GenericPointDataConstants.HDF5_LEVEL_VALUE);// pdv.getNumberAllLevels(parm,numLevel);
int count = 0;
for (Number n : num) {
count++;
if (count > numLevel)
break;
// System.out.println("Level " +count+
// " value="+n.floatValue());
GenericPointDataLevel gpdLevel = new GenericPointDataLevel();
gpdLevel.setLevelValue(n.floatValue());
levelList.add(gpdLevel);
}
} else {
GenericPointDataLevel gpdLevel = new GenericPointDataLevel();
gpdLevel.setLevelValue(pdv
.getFloat(GenericPointDataConstants.HDF5_LEVEL_VALUE));
levelList.add(gpdLevel);
}
// level value is retrieved already, so drop it here
parameters
.remove(GenericPointDataConstants.HDF5_LEVEL_VALUE);
} else
continue; // no level value, no need to continue on this
// PDV.
int stnCatalogType = ObStation.CAT_TYPE_MESONET;
if (parameters
.contains(GenericPointDataConstants.DB_STN_CATALOGTYPE)) {
stnCatalogType = pdv
.getInt(GenericPointDataConstants.DB_STN_CATALOGTYPE);
// System.out.println("stnCatalogType= "+ stnCatalogType);
// DB_STN_CATALOGTYPE value is retrieved already, so drop it
// here
parameters
.remove(GenericPointDataConstants.DB_STN_CATALOGTYPE);
}
String rtnstnId = stnId;
if (parameters.contains(GenericPointDataConstants.HDF5_STN_ID)) {
rtnstnId = pdv
.getString(GenericPointDataConstants.HDF5_STN_ID);
// System.out.println("stnId= "+ rtnstnId);
// stnId is input parameter, can drop it here.
parameters.remove(GenericPointDataConstants.HDF5_STN_ID);
}
float rtnslat = slat;
if (parameters.contains(GenericPointDataConstants.DB_SLAT)) {
rtnslat = pdv.getFloat(GenericPointDataConstants.DB_SLAT);
// System.out.println("slat= "+ rtnslat);
// slat value is retrieved already, so drop it here
parameters.remove(GenericPointDataConstants.DB_SLAT);
}
float rtnslon = slon;
if (parameters.contains(GenericPointDataConstants.DB_SLON)) {
rtnslon = pdv.getFloat(GenericPointDataConstants.DB_SLON);
// System.out.println("slon= "+ rtnslon);
// slon value is retrieved already, so drop it here
parameters.remove(GenericPointDataConstants.DB_SLON);
}
String utFlag = null;
if (parameters
.contains(GenericPointDataConstants.DB_UTILITY_FLAGS)) {
utFlag = pdv
.getString(GenericPointDataConstants.DB_UTILITY_FLAGS);
System.out.println("utFlag= " + utFlag);
parameters
.remove(GenericPointDataConstants.DB_UTILITY_FLAGS);
}
int forecastTime = 0;
if (parameters
.contains(GenericPointDataConstants.DB_FORECAST_TIME)) {
forecastTime = pdv
.getInt(GenericPointDataConstants.DB_FORECAST_TIME);
parameters
.remove(GenericPointDataConstants.DB_FORECAST_TIME);
}
// PDV id is not returned back to user, so drop it here
parameters.remove(GenericPointDataConstants.HDF5_PDV_ID);
GenericPointDataStationProduct stnPd = new GenericPointDataStationProduct();
stnPd.setProductName(prodName);
stnPd.setRefTime(referenceTime);
stnPd.setLevelLst(levelList);
stnPd.setProductVersion(productVersion);
stnPd.getLocation().setStationId(rtnstnId);
stnPd.getLocation().setCatalogType(stnCatalogType);
stnPd.setNumLevel(numLevel);
stnPd.setSlat(rtnslat);
stnPd.setSlon(rtnslon);
stnPd.setForecastTime(forecastTime);
stnPd.setUtilityFlag(utFlag);
for (String parm : parameters) {
if (numLevel > 1) {
// these parameters are data parameters and should be 2
// dimensional float value per design
// If a new "meta" data is queried, then we should take
// care of that data specifically before here.
Number[] num = pdv.getNumberAllLevels(parm);// ,numLevel);
// System.out.println("parm ="+parm);
for (int j = 0; j < numLevel; j++) {
Number n = num[j];
// System.out.println(" value="+n.floatValue());
GenericPointDataParameter gpdParm = new GenericPointDataParameter(
parm, n.floatValue());
levelList.get(j).getGpdParameters().add(gpdParm);
}
} else {
GenericPointDataParameter gpdParm = new GenericPointDataParameter(
parm, pdv.getFloat(parm));
levelList.get(0).getGpdParameters().add(gpdParm);
}
}
stnProdList.add(stnPd);
}
}
long t02 = System.currentTimeMillis();
System.out.println("ThrifClient: getGpdStationModelSndProduct() took "
+ (t02 - t01) + " ms in total for query stn=" + stnId);
return stnProdList;
}
/*
* TBM...Chin delet this leter...not used public
* TBM...Chin delete this later...not used public
* GenericPointDataStationProduct getGpdStationProduct(Date refTime,
* GenericPointDataQueryKey key, String stnId, double slat, double slon,
* String reportName,boolean useSpecifiedProductVersion, int
@ -1291,8 +1549,9 @@ public class GenericPointDataDao extends
GenericPointDataRecord rec = (GenericPointDataRecord) pdo;
String directory = PLUGIN_HDF5_DIR
+ rec.getProductInfo().getName();
String dateStr = hdfFileDateFormat.format(refTime);
int forecasttime = rec.getDataTime().getFcstTime();
String dateStr = hdfFileDateFormat.format(refTime)
+ "-f" + forecasttime;
String fileName = this.pluginName + "-"
+ rec.getProductInfo().getName() + dateStr
+ ".h5";
@ -1343,4 +1602,123 @@ public class GenericPointDataDao extends
return results;
}
/*
* Return distinct reference time lines for one product
*/
public NcSoundingTimeLines getGpdProductTimeline(String prodName) {
Object[] synopTimeAry = null;
NcSoundingTimeLines tl = new NcSoundingTimeLines();
String queryStr;
queryStr = new String(
"Select Distinct reftime FROM gpd where productinfo_name='"
+ prodName + "' ORDER BY reftime DESC");
synopTimeAry = (Object[]) executeSQLQuery(queryStr);
tl.setTimeLines(synopTimeAry);
return tl;
}
/*
* Return distinct rangestart times for one product at one reference time.
* Input reference time string format is "yyyy-mm-dd HH"
*/
public NcSoundingTimeLines getGpdProductRangestartTimes(String prodName,
String refTimeStr) {
Object[] refTimeAry = null;
NcSoundingTimeLines tl = new NcSoundingTimeLines();
String queryStr = new String(
"Select Distinct rangestart FROM gpd where productinfo_name='"
+ prodName + "' AND reftime='" + refTimeStr + ":00:00'"
+ " ORDER BY rangestart");
refTimeAry = (Object[]) executeSQLQuery(queryStr);
tl.setTimeLines(refTimeAry);
return tl;
}
/*
* Return distinct station id(s) for one product at one reference time
*/
public NcSoundingStnInfoCollection getGpdStationInfoCollection(
String selectedRefTime, String selectedRangeStartTime,
String prodName) {
NcSoundingStnInfoCollection stnInfoCol = new NcSoundingStnInfoCollection();
List<NcSoundingStnInfo> stationInfoList = new ArrayList<NcSoundingStnInfo>();
String queryStr;
Object[] rtnobjArray;
queryStr = new String(
"Select Distinct slat, slon, id, location_gid, reftime, rangestart FROM gpd where reftime='"
+ selectedRefTime
+ "' AND rangestart='"
+ selectedRangeStartTime
+ "' AND productinfo_name='"
+ prodName
+ "' AND slat BETWEEN -89.9 AND 89.9 AND slon BETWEEN -179.9 AND 179.9");
rtnobjArray = executeSQLQuery(queryStr);
String stnId = "";
Double slat, slon;
Timestamp synoptictime = null, rsTime = null;
for (int j = 0; j < rtnobjArray.length; j++) {
Object[] objArray = (Object[]) rtnobjArray[j];
// ids.add(((Integer)objArray[2]));
// We save lat/lon as float in DB.
// To make sure the double number get the same precision as the
// float number saved in DB
// we have to do the following conversion.
slat = new Double(objArray[0].toString());
slon = new Double(objArray[1].toString());
stnId = (String) objArray[3];
stnId = stnId.replace("1000-", "");
synoptictime = (Timestamp) objArray[4];
rsTime = (Timestamp) objArray[5];
NcSoundingStnInfo stn = stnInfoCol.getNewStnInfo();
stn.setStnId(stnId);
stn.setStationLongitude(slon);
stn.setStationLatitude(slat);
stn.setSynopTime(synoptictime);
stn.setRangeStartTime(rsTime);
stationInfoList.add((NcSoundingStnInfo) stn);
}
NcSoundingStnInfo[] stationInfoAry = new NcSoundingStnInfo[stationInfoList
.size()];
stnInfoCol.setStationInfo(stationInfoList.toArray(stationInfoAry));
// *System.out.println("stn size = "+
// stnInfoCol.getStationInfo().length);
return stnInfoCol;
}
public Object[] getGpdAvailProducts(GenericPointDataReqType reqType) {
String queryStr;
Object[] rtnobjArray;
switch (reqType) {
case GET_GPD_AVAILABLE_OBSERVED_SOUNDING_PRODUCTS:
queryStr = new String(
"Select Distinct productinfo_name FROM gpd where productinfo_name IN (Select Distinct name FROM gpd_productinfo where maxnumberoflevel > 8) AND gpd.utilityflags = '[]'");
break;
case GET_GPD_AVAILABLE_MODEL_SOUNDING_PRODUCTS:
queryStr = new String(
"Select Distinct productinfo_name FROM gpd where productinfo_name IN (Select Distinct name FROM gpd_productinfo where maxnumberoflevel > 8) AND gpd.utilityflags = '[FCST_USED]'");
break;
case GET_GPD_AVAILABLE_SURFACE_PRODUCTS:
queryStr = new String(
"Select Distinct name FROM gpd_productinfo where maxnumberoflevel=1");
break;
case GET_GPD_ALL_AVAILABLE_PRODUCTS:
queryStr = new String("Select Distinct name FROM gpd_productinfo");
break;
default:
return null;
}
rtnobjArray = executeSQLQuery(queryStr);
// List<String> prodList = new ArrayList<String>();
// for (int j =0; j <rtnobjArray.length; j++){
// Object[] objArray = (Object[] )rtnobjArray[j];
// System.out.println("prod="+rtnobjArray[j]);
// String prodName= (String)rtnobjArray[j];
// prodList.add(prodName);
// }
return rtnobjArray;
}
}

View file

@ -1,5 +1,9 @@
/**
*
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
*

View file

@ -1,4 +1,8 @@
/**
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.

View file

@ -1,5 +1,9 @@
/**
*
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
*

View file

@ -1,6 +1,11 @@
/**
*
*
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
*
* <pre>

View file

@ -1,5 +1,9 @@
/**
*
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
*
@ -19,6 +23,7 @@ package gov.noaa.nws.ncep.common.dataplugin.gpd.product;
import java.util.ArrayList;
import java.util.Date;
import java.util.EnumSet;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@ -30,6 +35,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.time.DataTime.FLAG;
@DynamicSerialize
@XmlAccessorType(XmlAccessType.NONE)
@ -65,6 +71,20 @@ public class GenericPointDataStationProduct {
@XmlAttribute
protected Date refTime;
@DynamicSerializeElement
@XmlAttribute
//set to -1, if forecast time is not used, foe example, for observed surface, observed snd type of data.
//set forecast time in second.Its value is computed starting from reference time. So,
//if forecastTime =0, means its forecast time is the same time as reference time
//if forecastTime =3600, means its forecast time is one hour after the reference time
//When saving data, this value is actually saved to DataTime in PluginDataObject Object. And
//utilityFlags is set to "FCST_USED" to indicate forecast time is used or not.
protected int forecastTime;
@DynamicSerializeElement
@XmlAttribute
private String utilityFlag = null;
//list of master level values
@DynamicSerializeElement
@XmlElement(name="GPD-Level-Parameters")
@ -104,7 +124,7 @@ public class GenericPointDataStationProduct {
return slat;
}
public void setSlat(float slat) {
this.slat = slat;
}
@ -177,4 +197,25 @@ public class GenericPointDataStationProduct {
}
public int getForecastTime() {
return forecastTime;
}
public void setForecastTime(int forecastTime) {
this.forecastTime = forecastTime;
}
public String getUtilityFlag() {
return utilityFlag;
}
public void setUtilityFlag(String utilityFlag) {
this.utilityFlag = utilityFlag;
}
}

View file

@ -1,4 +1,8 @@
/**
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
@ -156,7 +160,7 @@ public class GenericPointDataQuery extends PointDataQuery {
ids.get(listIndex).add(id);
indexes.get(listIndex).add(idx);
}
long t0 = System.currentTimeMillis();
//long t0 = System.currentTimeMillis();
for (int i = 0; i < files.size(); i++) {
File file = new File(files.get(i));
//for(String att: hdf5attribList){
@ -180,10 +184,10 @@ public class GenericPointDataQuery extends PointDataQuery {
masterPDC.setCurrentSz(masterPDC.getAllocatedSz());
}
}
long t1 = System.currentTimeMillis();
System.out
.println("Total time (ms) spent on pointdata hdf5 retrieval (all files): "
+ (t1 - t0));
//long t1 = System.currentTimeMillis();
//System.out
// .println("Total time (ms) spent on pointdata hdf5 retrieval (all files): "
// + (t1 - t0));
}
if (!dbParamDesc.isEmpty()) {

View file

@ -1,5 +1,9 @@
package gov.noaa.nws.ncep.common.dataplugin.gpd.query;
/**
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
@ -33,13 +37,24 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
@XmlAccessorType(XmlAccessType.NONE)
public class GenericPointDataReqMsg implements IServerRequest {
public static enum GenericPointDataReqType{
// get GPD in Java Object format
// get GPD data in Java Object format
GET_GPD_PRODUCT_OBJECT,
GET_GPD_STATION_PRODUCT_OBJECT,
GET_GPD_MOVING_PRODUCT_OBJECT,
GET_GPD_STATION_PRODUCT_OBJECT_LIST,
GET_GPD_MOVING_PRODUCT_OBJECT_LIST,
GET_GPD_STATION_MDL_SND_PRODUCT_OBJECT_LIST,
GET_GPD_MOVING_MDL_SND_PRODUCT_OBJECT_LIST,
GET_GPD_PRODUCT_INFO_OBJECT,
GET_GPD_PRODUCT_TIMELINE_OBJECT,
GET_GPD_PRODUCT_RANGESTART_TIME_OBJECT,
GET_GPD_STATION_INFO_COLLECTION_OBJECT,
GET_GPD_ALL_AVAILABLE_PRODUCTS,
GET_GPD_AVAILABLE_MODEL_SOUNDING_PRODUCTS, //GPD pfc sounding
GET_GPD_AVAILABLE_OBSERVED_SOUNDING_PRODUCTS,
GET_GPD_AVAILABLE_SURFACE_PRODUCTS,
//The following request types should not be used by CAVA JAVA applications
//get/save product in XML format
GET_GPD_PRODUCT_XML,
GET_GPD_STATION_PRODUCT_XML,
@ -52,6 +67,9 @@ public class GenericPointDataReqMsg implements IServerRequest {
GET_GPD_MOVING_PRODUCT_GEMPAK_TBL,
GET_GPD_PRODUCT_INFO_GEMPAK_TBL,
STORE_GPD_PRODUCT_FROM_GEMPAK_TBL,
STORE_GPD_MDL_SND_PRODUCT_FROM_GEMPAK_TBL,
STORE_GPD_OBS_SND_PRODUCT_FROM_GEMPAK_TBL,
STORE_GPD_OBS_SFC_PRODUCT_FROM_GEMPAK_TBL,
//Purge GPD DB
PURGE_GPD_PRODUCT_ONETIME,
PURGE_GPD_PRODUCT_ALLTIME,
@ -61,9 +79,9 @@ public class GenericPointDataReqMsg implements IServerRequest {
public static enum GenericPointDataQueryKey{
BY_STN_ID,
BY_SLAT_SLON,
BY_REPORT_NAME
BY_PRODUCT_NAME
}
//required for all
@DynamicSerializeElement
@XmlAttribute(required = true)
@ -117,9 +135,20 @@ public class GenericPointDataReqMsg implements IServerRequest {
@DynamicSerializeElement
private String gpdDataString;
// used for query a list of time line for one station or moving product
// used for query a list of time line's sounding data for one station or moving product
//con be a list of reference time (for observed data) or a list of range start time (for pfc data)
// used for CAVE Java query only...for now
@DynamicSerializeElement
private List<Date> refTimeList;
private List<Date> queryTimeList;
//used for query station collection, forecast time, or pfc sounding data
// used for CAVE Java query only...for now
@DynamicSerializeElement
private String refTimeStr;
//used for query station collection for model/pfc sounding
// used for CAVE Java query only...for now
@DynamicSerializeElement
private String rangeStartTimeStr;
public GenericPointDataReqMsg() {
super();
@ -320,12 +349,24 @@ public class GenericPointDataReqMsg implements IServerRequest {
this.maxNumLevel = maxNumLevel;
}
public List<Date> getRefTimeList() {
return refTimeList;
public List<Date> getQueryTimeList() {
return queryTimeList;
}
public void setRefTimeList(List<Date> refTimeList) {
this.refTimeList = refTimeList;
public void setQueryTimeList(List<Date> queryTimeList) {
this.queryTimeList = queryTimeList;
}
public String getRefTimeStr() {
return refTimeStr;
}
public void setRefTimeStr(String refTimeStr) {
this.refTimeStr = refTimeStr;
}
public String getRangeStartTimeStr() {
return rangeStartTimeStr;
}
public void setRangeStartTimeStr(String rangeStartTimeStr) {
this.rangeStartTimeStr = rangeStartTimeStr;
}

View file

@ -16,6 +16,7 @@
* 05/2010 144 L. Lin Migration to TO11DR11.
* 11/2013 1066 G. Hull call constructCRSfromWKT
* Nov 14, 2013 2393 bclement added getGridGeometry()
* 03/2014 TTR957 B. Yin Modified getGridGeometry() to handle native navigation
* </pre>
*/
@ -72,6 +73,9 @@ public class McidasMapCoverage extends PersistableDataObject implements
private static final long serialVersionUID = 1;
// projection id for native satellite navigation
public static final int GVAR = 7585;
@Id
private int pid;
@ -371,14 +375,33 @@ public class McidasMapCoverage extends PersistableDataObject implements
public GridGeometry2D getGridGeometry()
throws MismatchedDimensionException, FactoryException,
TransformException {
int nx = getNx();
int ny = getNy();
if (Double.isNaN(this.minX) || Double.isNaN(this.minY)) {
findMins();
GridEnvelope gridRange;
Envelope crsRange;
if (projection == McidasMapCoverage.GVAR) { // for native projection
minX = getUpperLeftElement();
int maxX = getUpperLeftElement() + (getNx() * getElementRes());
minY = getUpperLeftLine() + (getNy() * getLineRes());
minY = -minY;
int maxY = -1 * getUpperLeftLine();
gridRange = new GridEnvelope2D(0, 0, nx, ny);
crsRange = new Envelope2D(getCrs(), new Rectangle2D.Double(minX,
minY, maxX, maxY));
}
GridEnvelope gridRange = new GridEnvelope2D(0, 0, nx, ny);
Envelope crsRange = new Envelope2D(getCrs(), new Rectangle2D.Double(
minX, minY, nx * getDx(), ny * getDy()));
else {
int nx = getNx();
int ny = getNy();
if (Double.isNaN(this.minX) || Double.isNaN(this.minY)) {
findMins();
}
gridRange = new GridEnvelope2D(0, 0, nx, ny);
crsRange = new Envelope2D(getCrs(), new Rectangle2D.Double(minX,
minY, nx * getDx(), ny * getDy()));
}
return new GridGeometry2D(gridRange, crsRange);
}

View file

@ -10,6 +10,7 @@
* 10/2009 144 T. Lee Created
* 12/2009 144 T. Lee Migrated to TO11D6
* 11/2013 1066 G. Hull constructCRSfromWKT (from McidasMapCoverage)
* 03/2014 TTR957 B. Yin Moved constructCRSfromWKT to McidasCRSBuilder
*
* </pre>
*
@ -19,10 +20,8 @@
package gov.noaa.nws.ncep.common.dataplugin.mcidas;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import gov.noaa.nws.ncep.common.dataplugin.mcidas.dao.McidasMapCoverageDao;
import gov.noaa.nws.ncep.edex.util.McidasCRSBuilder;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
@ -30,9 +29,6 @@ import org.apache.commons.logging.LogFactory;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.referencing.operation.DefaultMathTransformFactory;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.NoSuchIdentifierException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.ProjectedCRS;
import org.opengis.referencing.operation.MathTransform;
@ -380,8 +376,8 @@ public class McidasSpatialFactory {
ProjectedCRS crs = null;
// Get the correct CRS
if (mapProjection == 7585) {
crs = constructCRS(type, encodedNav);
if (mapProjection == McidasMapCoverage.GVAR) {
crs = McidasCRSBuilder.constructCRS(type, encodedNav);
}
// Construct the polygon constructor String
@ -413,66 +409,8 @@ public class McidasSpatialFactory {
return new String(coded);
}
public ProjectedCRS constructCRSfromWKT( String crsWKT) {
Pattern p = Pattern.compile("PROJCS\\[\"MCIDAS\\sAREA\\s(.*)\"");
Matcher m = p.matcher(crsWKT);
m.find();
ProjectedCRS crsObject=null;
if ( m.groupCount() == 1 ) {
String type = m.group(1);
//System.out.println("FOUND PROJCS:"+m.group(0)+":"+type);
p = Pattern.compile("\\[\"NAV_BLOCK_BASE64\",\\s\"(.*)\"\\]");
m = p.matcher(crsWKT);
boolean found = m.find();
//System.out.println(m.group());
//System.out.println(m.groupCount()+m.group(1));
if ( found ) {
String navBlock = m.group(1);
crsObject = McidasSpatialFactory.getInstance().constructCRS(type, navBlock);
}
}
return crsObject;
}
public ProjectedCRS constructCRS(String type, String encoded) {
ParameterValueGroup pvg = null;
DefaultMathTransformFactory dmtFactory = new DefaultMathTransformFactory();
try {
pvg = dmtFactory.getDefaultParameters("MCIDAS_AREA_NAV");
} catch (NoSuchIdentifierException e1) {
e1.printStackTrace();
}
/*
* semi_major and semi_minor parameters are set to 1, so that no global
* scaling is performed during coordinate transforms by
* org.geotools.referencing.operation.projection.MapProjection based on
* the radius of earth
*/
pvg.parameter("semi_major").setValue(1.0);
pvg.parameter("semi_minor").setValue(1.0);
pvg.parameter("central_meridian").setValue(0.0);
// pvg.parameter("scale_factor").setValue(1.0);
pvg.parameter("NAV_BLOCK_BASE64").setValue(encoded);
// System.out.println(pvg.toString() );
String projectionName = "MCIDAS AREA " + type;
ProjectedCRS mcidasCRS = null;
try {
mcidasCRS = MapUtil.constructProjection(projectionName, pvg);
} catch (NoSuchIdentifierException e) {
e.printStackTrace();
} catch (FactoryException e) {
e.printStackTrace();
}
return mcidasCRS;
public ProjectedCRS constructCRSfromWKT(String crsWKT) {
return McidasCRSBuilder.constructCRSfromWKT(crsWKT);
}
}

View file

@ -17,6 +17,7 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 22, 2013 sgilbert Initial creation
* Jan 25, 2014 jwu Set default in accordance with those in "Product"
*
* </pre>
*
@ -27,31 +28,31 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
public class ActivityInfo implements IServerRequest {
@DynamicSerializeElement
private String activityName = "defaultName";
private String activityName = "Default";
@DynamicSerializeElement
private String activityType = "defaultType";
private String activityType = "Default";
@DynamicSerializeElement
private String activitySubtype = "defaultSubtype";
private String activitySubtype = "";
@DynamicSerializeElement
private String activityLabel = "defaultLabel";
private String activityLabel = "Default";
@DynamicSerializeElement
private String site = "site1";
private String site = "";
@DynamicSerializeElement
private String desk = "desk1";
private String desk = "";
@DynamicSerializeElement
private String forecaster = "person1";
private String forecaster = "";
@DynamicSerializeElement
private Calendar refTime = Calendar.getInstance();
@DynamicSerializeElement
private String mode = "Unknown";
private String mode = "OPERATIONAL";
@DynamicSerializeElement
private String status = "Unknown";

View file

@ -34,6 +34,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Jun 26, 2013 bhebbard Added SequenceGenerator annotation
* Jul 22, 2013 1977 rjpeter Added getDataURI and annotations.
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Jan,29, 2014 1105 jwu Added ACTIVITY_SUBTYPE
* </pre>
*
* @author sgilbert
@ -53,6 +54,8 @@ public class PgenRecord extends PersistablePluginDataObject {
public static final String ACTIVITY_TYPE = "activityType";
public static final String ACTIVITY_SUBTYPE = "activitySubtype";
public static final String ACTIVITY_LABEL = "activityLabel";
public static final String ACTIVITY_NAME = "activityName";

View file

@ -17,92 +17,124 @@ import java.util.List;
import java.util.Set;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.MultiPolygon;
import com.vividsolutions.jts.geom.Polygon;
/**
* Interface that contains all methods to load NCEP static data.
* This interface is also used to look up the data provider service in client side, such as PGEN.
* Interface that contains all methods to load NCEP static data. This interface
* is also used to look up the data provider service in client side, such as
* PGEN.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 02/12 ? B. Yin Initial Creation.
* 02/12 ? B. Yin Initial Creation.
* 05/12 734 J. Zeng add getAllRfcs() and getAllCwas()
* 08/12 #770 Q. Zhou added loadContWatchNum()
* 09/12 ? B. Yin Changed county cluster return type.
* 01/13 #966 B. Yin Added methods to load bounds into.
* 03/14 Trac 1112 S. Russell Added getActiveCounties()
* </pre>
*
* @author B. Yin
* @author B. Yin
*/
public interface IStaticDataProvider {
public StationTable getSfStnTbl();
public StationTable getAnchorTbl();
public StationTable getVorTbl();
public StationTable getVolcanoTbl();
public HashMap<String,Set<String>> getClstTbl();
public List<SPCCounty> getSPCCounties();
public SPCCounty findCounty( String fips);
public List<SPCCounty> getCountiesInGeometry(Geometry geo );
public List<USState> getAllstates();
public List<USState> loadStateTable();
public ArrayList<USState> statesInGeometry(Geometry geo);
public List<Rfc> getAllRfcs();
public List<Rfc> loadRfcTable();
public ArrayList<Rfc> rfcsInGeometry(Geometry geo);
public boolean isRfcLoaded();
public List<Cwa> getAllCwas();
public List<Cwa> loadCwaTable();
public ArrayList<Cwa> cwasInGeometry(Geometry geo);
public HashMap<String, String> getStateAbrvMap();
//localization
public String getPgenLocalizationRoot();
public String getFileAbsolutePath(String fileLoczlizationPath);
public File getFile(String fileLoczlizationPath);
public LocalizationFile getStaticLocalizationFile( String fileName );
public LocalizationFile getLocalizationFile( LocalizationContext context, String fileName );
public StationTable getSfStnTbl();
public LocalizationContext getLocalizationContext( LocalizationType type, LocalizationLevel level);
public File getStaticFile( String fname );
public File getGeogFile();
public File getSfcStnFile();
public File getFirBoundsFile();
public StationTable getAnchorTbl();
//This is for sigmet
public List<Object[]> queryNcepDB(String field, String table);
//for TCA
public HashMap<String, String> getZoneMap();
public StationTable getVorTbl();
//for GFA
public List<FAArea> getFAAreas();
public List<FAArea> getFAAreaX();
public List<FARegion> getFARegions();
public List<GreatLake> getGreatLakes();
public List<CostalWater> getCostalWaters();
public StationTable getVolcanoTbl();
//for g2g
public ArrayList<MultiPolygon> getG2GBounds(String tableAlias, String columnName, String columnValue);
public HashMap<String, Set<String>> getClstTbl();
//for continuing watches
public List<String> loadContWatchNum();
//for clipping bounds
public List<String> getBoundsTableList();
public List<String> getBoundsNames( String table );
public Polygon loadBounds( String boundsTable, String boundsName );
public List<SPCCounty> getSPCCounties();
public SPCCounty findCounty(String fips);
public List<SPCCounty> getCountiesInGeometry(Geometry geo);
public List<USState> getAllstates();
public List<USState> loadStateTable();
public ArrayList<USState> statesInGeometry(Geometry geo);
public List<Rfc> getAllRfcs();
public List<Rfc> loadRfcTable();
public ArrayList<Rfc> rfcsInGeometry(Geometry geo);
public boolean isRfcLoaded();
public List<Cwa> getAllCwas();
public List<Cwa> loadCwaTable();
public ArrayList<Cwa> cwasInGeometry(Geometry geo);
public HashMap<String, String> getStateAbrvMap();
// TRAC 1112
public List<String> getActiveCounties(int watchNum, List<SPCCounty> oldCountyList);
// localization
public String getPgenLocalizationRoot();
public String getFileAbsolutePath(String fileLoczlizationPath);
public File getFile(String fileLoczlizationPath);
public LocalizationFile getStaticLocalizationFile(String fileName);
public LocalizationFile getLocalizationFile(LocalizationContext context, String fileName);
public LocalizationContext getLocalizationContext(LocalizationType type, LocalizationLevel level);
public File getStaticFile(String fname);
public File getGeogFile();
public File getSfcStnFile();
public File getFirBoundsFile();
// This is for sigmet
public List<Object[]> queryNcepDB(String field, String table);
// for TCA
public HashMap<String, String> getZoneMap();
// for GFA
public List<FAArea> getFAAreas();
public List<FAArea> getFAAreaX();
public List<FARegion> getFARegions();
public List<GreatLake> getGreatLakes();
public List<CostalWater> getCostalWaters();
// for g2g
public ArrayList<MultiPolygon> getG2GBounds(String tableAlias, String columnName, String columnValue);
// for continuing watches
public List<String> loadContWatchNum();
// for clipping bounds
public List<String> getBoundsTableList();
public List<String> getBoundsNames(String table);
public Polygon loadBounds(String boundsTable, String boundsName);
}

View file

@ -1,15 +1,12 @@
package gov.noaa.nws.ncep.edex.common.metparameters;
import java.text.ParseException;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import javax.measure.unit.UnitFormat;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.adapters.UnitAdapter;
@ -17,7 +14,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* Class used to hold a value and its units.
* Class used to hold a value and its units.
*
* <pre>
* SOFTWARE HISTORY
@ -27,6 +24,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* 10/16/2011 G Hull make sure types of missing data and value are the same;
* make value private
* 11/14/2011 B Hebbard Resolve unit serialization issues
* 04/01/2014 #1040 B Hebbard In syncUnits(), map unitStr "count" to Unit.ONE
*
* </pre>
*
@ -38,84 +36,85 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class Amount implements ISerializableObject {
/**
/**
*
*/
private static final long serialVersionUID = -7742796238434954463L;
private static final long serialVersionUID = -7742796238434954463L;
// TODO : add capability to let user set their own missing data value.
@DynamicSerializeElement
private Number missing_data_value = new Double( -9999 );
// TODO : add capability to let user set their own missing data value.
@DynamicSerializeElement
private Number missing_data_value = new Double(-9999);
@DynamicSerializeElement
private Number value = missing_data_value;
@DynamicSerializeElement
private Number value = missing_data_value;
// Following should always be the string representation of below
// "unit"; that is, these must be kept in sync. (We use the String
// due to problems serializing the Unit<?>)
@DynamicSerializeElement
private String unitStr = "";
// Following should always be the string representation of below
// "unit"; that is, these must be kept in sync. (We use the String
// due to problems serializing the Unit<?>)
@DynamicSerializeElement
private String unitStr = "";
private transient Unit<?> unit;
private transient Unit<?> unit;
// To simplify the
public Amount( Number val, Unit<?> unit) {
//System.out.println("Constructor 0 called -- val " + val + " unit " + unit);
initMissingDataSentinel();
setValue( val, unit );
}
public Amount( Unit<?> u ) {
//System.out.println("Constructor 1 called -- u " + u);
setValue( missing_data_value, u );
}
// To simplify the
public Amount(Number val, Unit<?> unit) {
// System.out.println("Constructor 0 called -- val " + val + " unit " +
// unit);
initMissingDataSentinel();
public Amount(String unitStr) {
//System.out.println("Constructor 2 called -- unitStr " + unitStr);
try {
Unit<?> u = new UnitAdapter().unmarshal(unitStr);
setValue( missing_data_value, u );
} catch (Exception e) {
e.printStackTrace();
}
}
public Amount() {
//System.out.println("Constructor 3 called");
// TODO Auto-generated constructor stub
}
setValue(val, unit);
}
// TODO Should we allow access to the value without the units? Or
// can we let the user assume the stored units for convienience?
public Number getValue() {
return value;
}
public Amount(Unit<?> u) {
// System.out.println("Constructor 1 called -- u " + u);
setValue(missing_data_value, u);
}
// call hasValidValue before calling this method.
//
public Number getValueAs( Unit<?> unitNeeded ) {
if( unitNeeded != unit && unitNeeded.isCompatible( unit ) ) {
double newValue = unit.getConverterTo(unitNeeded).convert( value.doubleValue() );
return newValue;
}
else {
return value;
}
}
public Amount(String unitStr) {
// System.out.println("Constructor 2 called -- unitStr " + unitStr);
try {
Unit<?> u = new UnitAdapter().unmarshal(unitStr);
setValue(missing_data_value, u);
} catch (Exception e) {
e.printStackTrace();
}
}
//public Unit<?> getUnit() {
// return unit;
//}
public Amount() {
// System.out.println("Constructor 3 called");
// TODO Auto-generated constructor stub
}
public Unit<?> getUnit() {
// TODO Should we allow access to the value without the units? Or
// can we let the user assume the stored units for convienience?
public Number getValue() {
return value;
}
// call hasValidValue before calling this method.
//
public Number getValueAs(Unit<?> unitNeeded) {
if (unitNeeded != unit && unitNeeded.isCompatible(unit)) {
double newValue = unit.getConverterTo(unitNeeded).convert(
value.doubleValue());
return newValue;
} else {
return value;
}
}
// public Unit<?> getUnit() {
// return unit;
// }
public Unit<?> getUnit() {
if (this.unitStr == null)
return Unit.ONE;
if (this.unit == null) {
try {
this.unit = (Unit<?>) UnitFormat.getUCUMInstance()
.parseObject(this.unitStr);
this.unit = (Unit<?>) UnitFormat.getUCUMInstance().parseObject(
this.unitStr);
} catch (ParseException e) {
// logger.warn("ParseException while parsing unit string: "
// + this.unit + " defaulting to unit: " + Unit.ONE);
@ -125,239 +124,234 @@ public class Amount implements ISerializableObject {
return this.unit;
}
public void setValue( Amount v ) {
//System.out.println("Amount.setValue(Amount v) called with v " + v);
setValue( v.value, v.unit );
}
public void setValue(Amount v) {
// System.out.println("Amount.setValue(Amount v) called with v " + v);
setValue(v.value, v.unit);
}
public void setValue( Number n ) {
//System.out.println("Amount.setValue(Number n) called with n " + n + " and unit " + unit);
//setValue( n, unit );
value = n;
}
public void setValue(Number n) {
// System.out.println("Amount.setValue(Number n) called with n " + n +
// " and unit " + unit);
// setValue( n, unit );
value = n;
}
/**
* @return the missing_data_value
*/
public final Number getMissing_data_value() {
return missing_data_value;
}
/**
* @return the missing_data_value
*/
public final Number getMissing_data_value() {
return missing_data_value;
}
/**
* @param missing_data_value the missing_data_value to set
*/
public final void setMissing_data_value(Number missing_data_value) {
this.missing_data_value = missing_data_value;
}
/**
* @param missing_data_value
* the missing_data_value to set
*/
public final void setMissing_data_value(Number missing_data_value) {
this.missing_data_value = missing_data_value;
}
public void setValueAs(Number n, String unitStr) {
try {
Unit<?> u = new UnitAdapter().unmarshal(unitStr);
setValue(n, u);
} catch (Exception e) {
e.printStackTrace();
}
}
//
public void setValue(Number n, Unit<?> u) {
value = n;
// unit = u;
setUnitPair(u);
public void setValueAs ( Number n, String unitStr ) {
try {
Unit<?> u = new UnitAdapter().unmarshal(unitStr);
setValue( n, u );
} catch (Exception e) {
e.printStackTrace();
}
}
//
public void setValue( Number n, Unit<?> u ) {
value = n;
//unit = u;
setUnitPair(u);
// to make the hasValidValue method simpler, ensure that the types
// of the value and missing data value are the same.
// (wonder if there is a nicer way to do this for all Number types?)
if (!value.getClass().equals(missing_data_value.getClass())) {
if (value instanceof Double) {
missing_data_value = new Double(
missing_data_value.doubleValue());
} else if (value instanceof Float) {
missing_data_value = new Float(missing_data_value.floatValue());
} else if (value instanceof Short) {
missing_data_value = new Short(missing_data_value.shortValue());
} else if (value instanceof Integer) {
missing_data_value = new Integer(missing_data_value.intValue());
} else if (value instanceof Long) {
missing_data_value = new Long(missing_data_value.longValue());
} else if (value instanceof Byte) {
missing_data_value = new Byte(missing_data_value.byteValue());
} else {
System.out
.println("Amount: missing_data_value and value are of different types?");
}
}
// to make the hasValidValue method simpler, ensure that the types
// of the value and missing data value are the same.
// (wonder if there is a nicer way to do this for all Number types?)
if( !value.getClass().equals( missing_data_value.getClass() ) ) {
if( value instanceof Double ) {
missing_data_value = new Double( missing_data_value.doubleValue() );
}
else if( value instanceof Float ) {
missing_data_value = new Float( missing_data_value.floatValue() );
}
else if( value instanceof Short ) {
missing_data_value = new Short( missing_data_value.shortValue() );
}
else if( value instanceof Integer ) {
missing_data_value = new Integer( missing_data_value.intValue() );
}
else if( value instanceof Long ) {
missing_data_value = new Long( missing_data_value.longValue() );
}
else if( value instanceof Byte ) {
missing_data_value = new Byte( missing_data_value.byteValue() );
}
else {
System.out.println("Amount: missing_data_value and value are of different types?");
}
}
// if( hasValidValue() ) {
// System.out.println( getClass().getName() +" has valid value "+ n.toString() );
// }
}
// if( hasValidValue() ) {
// System.out.println( getClass().getName() +" has valid value "+
// n.toString() );
// }
}
// make sure the missing data sentinal and the stored value are of the
// same type so that the comparisons will work.
//
public void initMissingDataSentinel( ) { // Number mds ) {
// limit the number of
if( value instanceof Double ) {
missing_data_value = new Double( -9999 );
}
else if( value instanceof Float ) {
missing_data_value = new Float( -9999 );
}
else if( value instanceof Integer ) {
missing_data_value = new Integer( -9999 );
}
else if( value instanceof Long ) {
missing_data_value = new Long( -9999 );
}
else if( value instanceof Short ) {
missing_data_value = new Short( (short)-9999 );
}
else {
System.out.println("Error: Number object in Amount is not one of the supported types: "+
"Double, Float, Integer, Long or Short" );
}
}
public void setMissingDataSentinel( Number mds ) {
missing_data_value = mds;
}
// make sure the missing data sentinal and the stored value are of the
// same type so that the comparisons will work.
//
public void initMissingDataSentinel() { // Number mds ) {
// limit the number of
if (value instanceof Double) {
missing_data_value = new Double(-9999);
} else if (value instanceof Float) {
missing_data_value = new Float(-9999);
} else if (value instanceof Integer) {
missing_data_value = new Integer(-9999);
} else if (value instanceof Long) {
missing_data_value = new Long(-9999);
} else if (value instanceof Short) {
missing_data_value = new Short((short) -9999);
} else {
System.out
.println("Error: Number object in Amount is not one of the supported types: "
+ "Double, Float, Integer, Long or Short");
}
}
public Number getMissingValueSentinel() {
return missing_data_value;
}
// convenience method used by PRLibrary.
// TODO : replace calls with getValue().doubleValue
public double doubleValue() {
return value.doubleValue();
}
public void setMissingDataSentinel(Number mds) {
missing_data_value = mds;
}
public boolean hasValidValue() {
if (unit == null) {
return false;
}
if( !value.getClass().equals(missing_data_value.getClass() ) ) {
//TODO: Do we care? See a lot of Double/Float differences
//System.out.println("value and missingDataValue are of different types.");
}
if( value == null ||
value.equals( missing_data_value ) ) {
//|| value.doubleValue() <= missing_data_value.doubleValue()) ) {
return false;
}
return true;
}
public void setValueToMissing( ) {
value = missing_data_value;
}
public Number getMissingValueSentinel() {
return missing_data_value;
}
public void setUnit( Unit<?> u ) {
// Set the unit field only, but not the associated string.
/*DEBUG
String oldUnitStr = (unitStr == null ? "NULL" : UnitFormat.getUCUMInstance().format(unit));
String newUnitStr = UnitFormat.getUCUMInstance().format(u);
if (oldUnitStr.equals("Pa") && newUnitStr.equals("hPa")) {
System.out.println("In setUnit for... " + this.getClass());
System.out.println("...changing from Pa to hPa...");
}
if (oldUnitStr.equals("hPa") && newUnitStr.equals("Pa")) {
System.out.println("In setUnit for... " + this.getClass());
System.out.println("...changing from hPa to Pa...");
}
DEBUG*/
unit = u;
}
// convenience method used by PRLibrary.
// TODO : replace calls with getValue().doubleValue
public double doubleValue() {
return value.doubleValue();
}
public void setUnitPair( Unit<?> u ) {
// Set the unit object and string, but do not convert existing value.
unit = u;
/*DEBUG
String newUnitStr = UnitFormat.getUCUMInstance().format(u);
if (unitStr.equals("Pa") && newUnitStr.equals("hPa")) {
System.out.println("In setUnitPair for... " + this.getClass());
System.out.println("...changing from Pa to hPa...");
}
if (unitStr.equals("hPa") && newUnitStr.equals("Pa")) {
System.out.println("In setUnitPair for... " + this.getClass());
System.out.println("...changing from hPa to Pa...");
}
unitStr = newUnitStr;
DEBUG*/
unitStr = UnitFormat.getUCUMInstance().format(u);
}
public boolean hasValidValue() {
if (unit == null) {
return false;
}
if (!value.getClass().equals(missing_data_value.getClass())) {
// TODO: Do we care? See a lot of Double/Float differences
// System.out.println("value and missingDataValue are of different types.");
}
if (value == null || value.equals(missing_data_value)) {
// || value.doubleValue() <= missing_data_value.doubleValue()) ) {
return false;
}
return true;
}
public void setUnitPairAndConvertValue( Unit<?> u ) {
// Set the unit object and string, and convert an existing value to
// the new unit
if( hasValidValue() ) {
value = getValueAs( u );
}
unit = u;
/*DEBUG
String newUnitStr = UnitFormat.getUCUMInstance().format(u);
if (unitStr.equals("Pa") && newUnitStr.equals("hPa")) {
System.out.println("In setUnitPairAndConvertValue for... " + this.getClass());
System.out.println("...changing from Pa to hPa...");
}
if (unitStr.equals("hPa") && newUnitStr.equals("Pa")) {
System.out.println("In setUnitPairAndConvertValue for... " + this.getClass());
System.out.println("...changing from hPa to Pa...");
}
unitStr = newUnitStr;
DEBUG*/
unitStr = UnitFormat.getUCUMInstance().format(u);
}
public void syncUnits() {
Unit<?> u;
try {
u = new UnitAdapter().unmarshal(unitStr);
} catch (Exception e) {
e.printStackTrace();
//System.out.println("Amount.syncUnits(): 'unitStr' invalid!!");
return;
}
if (unit == null) {
//System.out.println("Amount.syncUnits(): 'unit' NULL, using unitStr value " + unitStr);
unit = u;
}
else if (!unit.equals(u)) {
//System.out.println("Amount.syncUnits(): 'unit' is " + u + ", but unitStr is " + unitStr + " using the latter");
unit = u;
}
else {
//System.out.println("Amount.syncUnits(): Good! 'unit' is " + u + ", and unitStr is " + unitStr);
}
}
public void setValueToMissing() {
value = missing_data_value;
}
public String getUnitStr() {
return unitStr;
}
public void setUnit(Unit<?> u) {
// Set the unit field only, but not the associated string.
/*
* DEBUG String oldUnitStr = (unitStr == null ? "NULL" :
* UnitFormat.getUCUMInstance().format(unit)); String newUnitStr =
* UnitFormat.getUCUMInstance().format(u); if (oldUnitStr.equals("Pa")
* && newUnitStr.equals("hPa")) {
* System.out.println("In setUnit for... " + this.getClass());
* System.out.println("...changing from Pa to hPa..."); } if
* (oldUnitStr.equals("hPa") && newUnitStr.equals("Pa")) {
* System.out.println("In setUnit for... " + this.getClass());
* System.out.println("...changing from hPa to Pa..."); } DEBUG
*/
unit = u;
}
public void setUnitStr(String unitStr) {
this.unitStr = unitStr;
}
public void setUnitPair(Unit<?> u) {
// Set the unit object and string, but do not convert existing value.
unit = u;
/*
* DEBUG String newUnitStr = UnitFormat.getUCUMInstance().format(u); if
* (unitStr.equals("Pa") && newUnitStr.equals("hPa")) {
* System.out.println("In setUnitPair for... " + this.getClass());
* System.out.println("...changing from Pa to hPa..."); } if
* (unitStr.equals("hPa") && newUnitStr.equals("Pa")) {
* System.out.println("In setUnitPair for... " + this.getClass());
* System.out.println("...changing from hPa to Pa..."); } unitStr =
* newUnitStr; DEBUG
*/
unitStr = UnitFormat.getUCUMInstance().format(u);
}
// // convert the current value to
// public void changeUnits( Unit<?> u ) {
// if( value != MISSING_DATA_VALUE ) {
// unit = u;
// }
// else {
//
// }
// }
// TODO : Do we need to worry about rounding errors here?
// public Boolean isMissingValue( ) {
// return value.doubleValue() == MISSING_DATA_VALUE;
// }
public void setUnitPairAndConvertValue(Unit<?> u) {
// Set the unit object and string, and convert an existing value to
// the new unit
if (hasValidValue()) {
value = getValueAs(u);
}
unit = u;
/*
* DEBUG String newUnitStr = UnitFormat.getUCUMInstance().format(u); if
* (unitStr.equals("Pa") && newUnitStr.equals("hPa")) {
* System.out.println("In setUnitPairAndConvertValue for... " +
* this.getClass());
* System.out.println("...changing from Pa to hPa..."); } if
* (unitStr.equals("hPa") && newUnitStr.equals("Pa")) {
* System.out.println("In setUnitPairAndConvertValue for... " +
* this.getClass());
* System.out.println("...changing from hPa to Pa..."); } unitStr =
* newUnitStr; DEBUG
*/
unitStr = UnitFormat.getUCUMInstance().format(u);
}
public void syncUnits() {
Unit<?> u;
if (unitStr.equals("count")) {
u = Unit.ONE;
} else {
try {
u = new UnitAdapter().unmarshal(unitStr);
} catch (Exception e) {
e.printStackTrace();
// System.out.println("Amount.syncUnits(): 'unitStr' string '"
// + unitStr + "' invalid!!");
return;
}
}
if (unit == null) {
// System.out.println("Amount.syncUnits(): 'unit' NULL, using unitStr value "
// + unitStr);
unit = u;
} else if (!unit.equals(u)) {
// System.out.println("Amount.syncUnits(): 'unit' is " + u +
// ", but unitStr is " + unitStr + " using the latter");
unit = u;
} else {
// System.out.println("Amount.syncUnits(): Good! 'unit' is " + u +
// ", and unitStr is " + unitStr);
}
}
public String getUnitStr() {
return unitStr;
}
public void setUnitStr(String unitStr) {
this.unitStr = unitStr;
}
// // convert the current value to
// public void changeUnits( Unit<?> u ) {
// if( value != MISSING_DATA_VALUE ) {
// unit = u;
// }
// else {
//
// }
// }
// TODO : Do we need to worry about rounding errors here?
// public Boolean isMissingValue( ) {
// return value.doubleValue() == MISSING_DATA_VALUE;
// }
}

View file

@ -1,4 +1,5 @@
package gov.noaa.nws.ncep.edex.common.sounding;
/**
*
* gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer
@ -13,8 +14,9 @@ package gov.noaa.nws.ncep.edex.common.sounding;
*
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 09/13/2010 229 Chin Chen Initial coding
* 11/2010 301 T. Lee Moved Comparator to SoundingUtil
* 09/13/2010 229 Chin Chen Initial coding
* 11/2010 301 T. Lee Moved Comparator to SoundingUtil
* 03/2014 1116 T. Lee Added constructor argument for DPD
*
* </pre>
*
@ -24,7 +26,6 @@ package gov.noaa.nws.ncep.edex.common.sounding;
import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
import java.util.Comparator;
import java.util.HashMap;
import javax.xml.bind.annotation.XmlAccessType;
@ -39,55 +40,54 @@ import com.vividsolutions.jts.geom.Coordinate;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class NcSoundingLayer implements ISerializableObject, Cloneable{
@DynamicSerializeElement
public class NcSoundingLayer implements ISerializableObject, Cloneable {
@DynamicSerializeElement
private static final long serialVersionUID = 1324632468L;
public static final float MISSING = IDecoderConstantsN.UAIR_FLOAT_MISSING;//-9999.f;
public static final float MISSING = IDecoderConstantsN.UAIR_FLOAT_MISSING;// -9999.f;
public static final float LEGACY_MISSING = -999.f;
//UAIR (standard) data type definitions
// UAIR (standard) data type definitions
public static enum DataType {
TTAA, TTBB, TTCC, TTDD, PPAA, PPBB, PPCC, PPDD,
UUAA, UUBB, UUCC, UUDD, MAXWIND_A,MAXWIND_C, TROPOPAUSE_A, TROPOPAUSE_C, ALLDATA
}
//mapping from UAIR (standard) data type to BUFRUA data type.
public static HashMap<String,Integer > dataTypeMap = new HashMap<String,Integer>();
static {
dataTypeMap.put(DataType.TTAA.toString(), 2020); //Mandatory, Troppause, MaxWind
dataTypeMap.put(DataType.TTCC.toString(), 2030); //Mandatory, Troppause, MaxWind
dataTypeMap.put(DataType.TTBB.toString(), 2022); //SigT
dataTypeMap.put(DataType.TTDD.toString(), 2032); //SigT
dataTypeMap.put(DataType.PPBB.toString(), 2021); //SigW
dataTypeMap.put(DataType.PPDD.toString(), 2031); //SigW
dataTypeMap.put(DataType.PPAA.toString(), 0000); //TBD, BUFRUA does not support this now
dataTypeMap.put(DataType.PPCC.toString(), 0000); //TBD, BUFRUA does not support this now
dataTypeMap.put(DataType.MAXWIND_A.toString(), 2020);
dataTypeMap.put(DataType.TROPOPAUSE_A.toString(), 2020);
dataTypeMap.put(DataType.MAXWIND_C.toString(), 2030);
dataTypeMap.put(DataType.TROPOPAUSE_C.toString(), 2030);
TTAA, TTBB, TTCC, TTDD, PPAA, PPBB, PPCC, PPDD, UUAA, UUBB, UUCC, UUDD, MAXWIND_A, MAXWIND_C, TROPOPAUSE_A, TROPOPAUSE_C, ALLDATA
}
/* Chin's Note: user should use either the following string or, for example,
// mapping from UAIR (standard) data type to BUFRUA data type.
public static HashMap<String, Integer> dataTypeMap = new HashMap<String, Integer>();
static {
dataTypeMap.put(DataType.TTAA.toString(), 2020); // Mandatory,
// Troppause, MaxWind
dataTypeMap.put(DataType.TTCC.toString(), 2030); // Mandatory,
// Troppause, MaxWind
dataTypeMap.put(DataType.TTBB.toString(), 2022); // SigT
dataTypeMap.put(DataType.TTDD.toString(), 2032); // SigT
dataTypeMap.put(DataType.PPBB.toString(), 2021); // SigW
dataTypeMap.put(DataType.PPDD.toString(), 2031); // SigW
dataTypeMap.put(DataType.PPAA.toString(), 0000); // TBD, BUFRUA does not
// support this now
dataTypeMap.put(DataType.PPCC.toString(), 0000); // TBD, BUFRUA does not
// support this now
dataTypeMap.put(DataType.MAXWIND_A.toString(), 2020);
dataTypeMap.put(DataType.TROPOPAUSE_A.toString(), 2020);
dataTypeMap.put(DataType.MAXWIND_C.toString(), 2030);
dataTypeMap.put(DataType.TROPOPAUSE_C.toString(), 2030);
}
/*
* Chin's Note: user should use either the following string or, for example,
* DataType.TTAA.toString() for "data type" coding.
*
public static String TTAA = "TTAA";
public static String TTBB = "TTBB";
public static String TTCC = "TTCC";
public static String TTDD = "TTDD";
public static String PPAA = "PPAA";
public static String PPBB = "PPBB";
public static String PPCC = "PPCC";
public static String PPDD = "PPDD";
public static String MAXWIND = "MAXWIND";
public static String TROPOPAUSE = "TROPOPAUSE";
public static String ALLDATA = "ALLDATA";
public static String UUAA = "UUAA";
public static String UUBB = "UUBB";
public static String UUCC = "UUCC";
public static String UUDD = "UUDD";
*/
* public static String TTAA = "TTAA"; public static String TTBB = "TTBB";
* public static String TTCC = "TTCC"; public static String TTDD = "TTDD";
* public static String PPAA = "PPAA"; public static String PPBB = "PPBB";
* public static String PPCC = "PPCC"; public static String PPDD = "PPDD";
* public static String MAXWIND = "MAXWIND"; public static String TROPOPAUSE
* = "TROPOPAUSE"; public static String ALLDATA = "ALLDATA"; public static
* String UUAA = "UUAA"; public static String UUBB = "UUBB"; public static
* String UUCC = "UUCC"; public static String UUDD = "UUDD";
*/
public static String DATATYPE_MISSING = "";
// Pressure of the layer, in hectoPascals (milliBars), if known.
@ -106,7 +106,7 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
@DynamicSerializeElement
private float dewpoint;
// Wind speed, in Knots
// Wind speed, in Knots
@DynamicSerializeElement
private float windSpeed;
@ -122,20 +122,23 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
@DynamicSerializeElement
private float windV;
// Vertical velocity,
// Vertical velocity,
@DynamicSerializeElement
private float omega;
// specific humidity
@DynamicSerializeElement
private float specHumidity;
//relative humidity
// relative humidity
@DynamicSerializeElement
private float relativeHumidity;
public NcSoundingLayer() {
// dewpoint depression
@DynamicSerializeElement
private float dpd;
public NcSoundingLayer() {
this.pressure = MISSING;
this.geoHeight = MISSING;
this.temperature = MISSING;
@ -147,47 +150,48 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
this.omega = MISSING;
this.specHumidity = MISSING;
this.relativeHumidity = MISSING;
this.dpd = MISSING;
}
/**
* @param pressure
* @param geoHeight
* @param temperature
* @param dewpoint
* @param windSpeed
* @param windDirection
* @param windU
* @param windV
* @param omega
* @param specHumidity
* @param dataType
*/
public NcSoundingLayer(float pressure, float geoHeight, float temperature,
float dewpoint, float windSpeed, float windDirection, float windU,
float windV, float omega, float specHumidity, float relativeHumidity) {
super();
this.pressure = pressure;
this.geoHeight = geoHeight;
this.temperature = temperature;
this.dewpoint = dewpoint;
this.windSpeed = windSpeed;
this.windDirection = windDirection;
this.windU = windU;
this.windV = windV;
this.omega = omega;
this.specHumidity = specHumidity;
this.relativeHumidity = relativeHumidity;
}
/*
public String getDataType() {
return dataType;
}
* @param pressure
* @param geoHeight
* @param temperature
* @param dewpoint
* @param windSpeed
* @param windDirection
* @param windU
* @param windV
* @param omega
* @param specHumidity
* @param dewDepression
* @param dataType
*/
public NcSoundingLayer(float pressure, float geoHeight, float temperature,
float dewpoint, float windSpeed, float windDirection, float windU,
float windV, float omega, float specHumidity,
float relativeHumidity, float dpd) {
super();
this.pressure = pressure;
this.geoHeight = geoHeight;
this.temperature = temperature;
this.dewpoint = dewpoint;
this.windSpeed = windSpeed;
this.windDirection = windDirection;
this.windU = windU;
this.windV = windV;
this.omega = omega;
this.specHumidity = specHumidity;
this.relativeHumidity = relativeHumidity;
this.dpd = dpd;
public void setDataType(String dataType) {
this.dataType = dataType;
}
*/
}
/*
* public String getDataType() { return dataType; }
*
* public void setDataType(String dataType) { this.dataType = dataType; }
*/
/**
* @return the pressure in hectoPascals (milliBars)
*/
@ -200,10 +204,10 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
* the pressure in hectoPascals (milliBars)
*/
public void setPressure(float pressure) {
if (pressure == LEGACY_MISSING)
this.pressure = MISSING;
else
this.pressure = pressure;
if (pressure == LEGACY_MISSING)
this.pressure = MISSING;
else
this.pressure = pressure;
}
/**
@ -218,10 +222,10 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
* the geoHeight in meters
*/
public void setGeoHeight(float geoHeight) {
if (geoHeight == LEGACY_MISSING)
this.geoHeight = MISSING;
else
this.geoHeight = geoHeight;
if (geoHeight == LEGACY_MISSING)
this.geoHeight = MISSING;
else
this.geoHeight = geoHeight;
}
/**
@ -236,10 +240,10 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
* the temperature in Celsius
*/
public void setTemperature(float temperature) {
if (temperature == LEGACY_MISSING)
this.temperature = MISSING;
else
this.temperature = temperature;
if (temperature == LEGACY_MISSING)
this.temperature = MISSING;
else
this.temperature = temperature;
}
/**
@ -254,10 +258,10 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
* the dewpoint in Celsius
*/
public void setDewpoint(float dewpoint) {
if (dewpoint == LEGACY_MISSING)
this.dewpoint = MISSING;
else
this.dewpoint = dewpoint;
if (dewpoint == LEGACY_MISSING)
this.dewpoint = MISSING;
else
this.dewpoint = dewpoint;
}
/**
@ -272,10 +276,10 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
* the windSpeed inKnots
*/
public void setWindSpeed(float windSpeed) {
if (windSpeed == LEGACY_MISSING)
this.windSpeed = MISSING;
else
this.windSpeed = windSpeed;
if (windSpeed == LEGACY_MISSING)
this.windSpeed = MISSING;
else
this.windSpeed = windSpeed;
computeUV();
}
@ -291,10 +295,10 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
* the windDirection in angular degrees
*/
public void setWindDirection(float windDirection) {
if (windDirection == LEGACY_MISSING)
this.windDirection = MISSING;
else
this.windDirection = windDirection;
if (windDirection == LEGACY_MISSING)
this.windDirection = MISSING;
else
this.windDirection = windDirection;
computeUV();
}
@ -342,32 +346,37 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
* the vertical velocity in millibars/sec??
*/
public void setOmega(float omega) {
if (omega == LEGACY_MISSING)
this.omega = MISSING;
else
this.omega = omega;
if (omega == LEGACY_MISSING)
this.omega = MISSING;
else
this.omega = omega;
}
public float getSpecHumidity() {
return specHumidity;
}
return specHumidity;
}
public void setSpecHumidity(float specHumidity) {
this.specHumidity = specHumidity;
}
public void setSpecHumidity(float specHumidity) {
this.specHumidity = specHumidity;
}
public float getRelativeHumidity() {
return relativeHumidity;
}
public float getRelativeHumidity() {
return relativeHumidity;
}
public void setRelativeHumidity(float relativeHumidity) {
this.relativeHumidity = relativeHumidity;
}
public void setRelativeHumidity(float relativeHumidity) {
this.relativeHumidity = relativeHumidity;
}
private void computeUV() {
public float getDpd() {
return dpd;
}
public void setDpd(float dpd) {
this.dpd = dpd;
}
private void computeUV() {
if (windSpeed > MISSING && windDirection > MISSING) {
Coordinate uv = uvComp(windSpeed, windDirection);
windU = (float) uv.x;
@ -443,20 +452,19 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
return retValue;
}
/**
* Create a clone of this object.
*
* @return The cloned data.
*/
@Override
public String toString() {
return "Pressure=" + getPressure() + "mb:Z="
+ getGeoHeight() + "m:T=" + getTemperature() + "\u00B0C:Td="
+ getDewpoint() + "\u00B0C:WS=" + getWindSpeed() + "m/s:WD="
+ getWindDirection() + "\u00B0:SH="+ getSpecHumidity() ;
return "Pressure=" + getPressure() + "mb:Z=" + getGeoHeight() + "m:T="
+ getTemperature() + "\u00B0C:Td=" + getDewpoint()
+ "\u00B0C:WS=" + getWindSpeed() + "m/s:WD="
+ getWindDirection() + "\u00B0:SH=" + getSpecHumidity()
+ "\u00B0C" + getDpd();
}
@ -478,6 +486,7 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
result = prime * result + Float.floatToIntBits(windSpeed);
result = prime * result + Float.floatToIntBits(specHumidity);
result = prime * result + Float.floatToIntBits(relativeHumidity);
result = prime * result + Float.floatToIntBits(dpd);
return result;
}
@ -506,7 +515,7 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
.floatToIntBits(other.geoHeight)) {
return false;
}
if (Float.floatToIntBits(omega) != Float.floatToIntBits(other.omega)) {
return false;
}
@ -531,13 +540,15 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
return false;
}
if (Float.floatToIntBits(relativeHumidity) != Float
.floatToIntBits(other.relativeHumidity)) {
return false;
.floatToIntBits(other.relativeHumidity)) {
return false;
}
if (Float.floatToIntBits(dpd) != Float.floatToIntBits(other.dpd)) {
return false;
}
return true;
}
/**
* Convert wind speed and direction to U/V components.
*
@ -561,6 +572,7 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
}
return new Coordinate(spd, dir);
}
/**
* Create a clone of this object.
*
@ -571,5 +583,4 @@ public class NcSoundingLayer implements ISerializableObject, Cloneable{
return super.clone();
}
}

View file

@ -0,0 +1,99 @@
/*
* gov.noaa.nws.ncep.edex.util.McidasCRSBuilder
*
* March 2014
*
* This code has been developed by the NCEP/SIB for use in the AWIPS2 system.
*/
package gov.noaa.nws.ncep.edex.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.geotools.referencing.operation.DefaultMathTransformFactory;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.NoSuchIdentifierException;
import org.opengis.referencing.crs.ProjectedCRS;
import com.raytheon.uf.common.geospatial.MapUtil;
/**
* Class to construct CRS for mcidas.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 03/2014 TTR957 B. Yin Moved from McidasSpatialFactory.
*
* </pre>
*
* @author byin
*/
public class McidasCRSBuilder {
public static ProjectedCRS constructCRSfromWKT(String crsWKT) {
Pattern p = Pattern.compile("PROJCS\\[\"MCIDAS\\sAREA\\s(.*)\"");
Matcher m = p.matcher(crsWKT);
m.find();
ProjectedCRS crsObject = null;
if (m.groupCount() == 1) {
String type = m.group(1);
// System.out.println("FOUND PROJCS:"+m.group(0)+":"+type);
p = Pattern.compile("\\[\"NAV_BLOCK_BASE64\",\\s\"(.*)\"\\]");
m = p.matcher(crsWKT);
boolean found = m.find();
// System.out.println(m.group());
// System.out.println(m.groupCount()+m.group(1));
if (found) {
String navBlock = m.group(1);
crsObject = McidasCRSBuilder.constructCRS(type, navBlock);
}
}
return crsObject;
}
public static ProjectedCRS constructCRS(String type, String encoded) {
ParameterValueGroup pvg = null;
DefaultMathTransformFactory dmtFactory = new DefaultMathTransformFactory();
try {
pvg = dmtFactory.getDefaultParameters("MCIDAS_AREA_NAV");
} catch (NoSuchIdentifierException e1) {
e1.printStackTrace();
}
/*
* semi_major and semi_minor parameters are set to 1, so that no global
* scaling is performed during coordinate transforms by
* org.geotools.referencing.operation.projection.MapProjection based on
* the radius of earth
*/
pvg.parameter("semi_major").setValue(1.0);
pvg.parameter("semi_minor").setValue(1.0);
pvg.parameter("central_meridian").setValue(0.0);
// pvg.parameter("scale_factor").setValue(1.0);
pvg.parameter("NAV_BLOCK_BASE64").setValue(encoded);
// System.out.println(pvg.toString() );
String projectionName = "MCIDAS AREA " + type;
ProjectedCRS mcidasCRS = null;
try {
mcidasCRS = MapUtil.constructProjection(projectionName, pvg);
} catch (NoSuchIdentifierException e) {
e.printStackTrace();
} catch (FactoryException e) {
e.printStackTrace();
}
return mcidasCRS;
}
}

View file

@ -59,6 +59,7 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
* because it is a dead code.
* Aug 08, 2013 1028 G. Hull rm underscores from reportType and set mndTime in URI
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Mar 21, 2103 1112 S. Russell *.WCN files, get the watch number
* </pre>
*
* This code has been developed by the SIB for use in the AWIPS2 system.
@ -78,8 +79,7 @@ public class AwwDecoder extends AbstractDecoder {
public AwwDecoder() throws DecoderException {
}
public PluginDataObject[] decode(byte[] data, Headers headers)
throws DecoderException {
public PluginDataObject[] decode(byte[] data, Headers headers) throws DecoderException {
String traceId = "";
if (headers != null) {
@ -108,10 +108,8 @@ public class AwwDecoder extends AbstractDecoder {
messageData = sep.next();
String theMessage = new String(messageData);
/*
* May have multiple duplicate bulletins, only get the first bulletin
* and eliminate the remaining bulletins after the first bulletin.
*/
/* May have multiple duplicate bulletins, only get the first bulletin
* and eliminate the remaining bulletins after the first bulletin. */
Scanner cc = new Scanner(theMessage).useDelimiter(etx);
if (cc.hasNext()) {
theBulletin = cc.next();
@ -144,6 +142,13 @@ public class AwwDecoder extends AbstractDecoder {
// Break the bulletin message into segments by a "$$"
Scanner sc = new Scanner(theBulletin).useDelimiter(segmentDelim);
boolean isWCN = false;
String wcnLbl = AwwRecord.AwwReportType.WATCH_COUNTY_NOTIFICATION.name();
wcnLbl = wcnLbl.replace("_", " ");
if (reportType.equals(wcnLbl)) {
isWCN = true;
}
while (sc.hasNext()) {
String segment = sc.next();
Matcher ugcMatcher = ugcPattern.matcher(segment);
@ -162,43 +167,46 @@ public class AwwDecoder extends AbstractDecoder {
Matcher ugcMatcher = ugcPattern.matcher(segment);
AwwUgc ugc = null;
if (ugcMatcher.find()) {
ugc = AwwParser.processUgc(ugcMatcher.group(), segment,
mndTime, watchesList);
} else if (isWtchFlag) {
ugc = AwwParser.processUgcForWtch(
AwwParser.WTCH_BOX_UGC_LINE, segment, mndTime,
record.getIssueOffice(), watchesList);
// TRAC 1112
if (isWCN) {
String watchNumber = AwwParser.retrieveWatchNumberFromWCN(segment);
if (watchNumber != null) {
record.setWatchNumber(watchNumber);
if (ugcMatcher.find()) {
ugc = AwwParser.processUgc(ugcMatcher.group(), segment, mndTime, watchesList);
}
}
}
// local forecast
else if (isWtchFlag) {
ugc = AwwParser.processUgcForWtch(AwwParser.WTCH_BOX_UGC_LINE, segment, mndTime, record.getIssueOffice(), watchesList);
// else if(isSevereWeatherStatusFlag)
// ugc =
// AwwParser.processUgcForSereveWeatherStatus(ugcMatcher.group(),
// segment, mndTime, record.getIssueOffice(),
// watchesList);
String watchNumber = AwwParser
.processUgcToRetrieveWatchNumberForThunderstormOrTornado(segment);
String watchNumber = AwwParser.processUgcToRetrieveWatchNumberForThunderstormOrTornado(segment);
record.setWatchNumber(watchNumber);
// } else if(isSevereWeatherStatusFlag) {
// String watchNumber =
// AwwParser.processUgcToRetrieveWatchNumberForStatusReport(segment);
// record.setWatchNumber(watchNumber);
} else if (ugcMatcher.find()) {
ugc = AwwParser.processUgc(ugcMatcher.group(), segment, mndTime, watchesList);
}
if (ugc != null) {
record.addAwwUGC(ugc);
/*
* Collect watch numbers which are the event tracking
/* Collect watch numbers which are the event tracking
* numbers in VTEC lines as one of primary keys in AWW
* record to prevent not writing raw data to DB note: 1.
* each bulletin may have multiple segments 2. each
* segment has one UGC line but may have multiple VTEC
* lines and have more than one watch number
*/
/*
* not quite sure the following logic is correct to
* lines and have more than one watch number */
/* not quite sure the following logic is correct to
* retrieve and then store the watch number. thus
* comment it out now. M. Gao
*/
* comment it out now. M. Gao */
// if (watchesList.size() > 0) {
// String collectWatches = null;
// for (int idxWatch = 0; idxWatch < watchesList.size();
@ -221,63 +229,47 @@ public class AwwDecoder extends AbstractDecoder {
// record.setWatchNumber("0000");
// }
/*
* construct VTEC object and then add it to the current
* Ugc for SevereWeatherStatus aww reocrd
*/
/* construct VTEC object and then add it to the current
* Ugc for SevereWeatherStatus aww reocrd */
if (AwwParser.isSegmentTextValid(segment)) {
/*
* parse and then set the Watch Number for Status
* Report
*/
String watchNumber = AwwParser
.processUgcToRetrieveWatchNumberForStatusReport(segment);
/* parse and then set the Watch Number for Status
* Report */
String watchNumber = AwwParser.processUgcToRetrieveWatchNumberForStatusReport(segment);
record.setWatchNumber(watchNumber);
AwwVtec awwVtec = AwwParser
.processVtectForSevereWeatherStatus(
theBulletin, record.getIssueTime(),
record.getIssueOffice());
AwwVtec awwVtec = AwwParser.processVtectForSevereWeatherStatus(theBulletin, record.getIssueTime(), record.getIssueOffice());
Set<AwwVtec> awwVtecSet = new HashSet<AwwVtec>();
awwVtecSet.add(awwVtec);
ugc.setAwwVtecLine(awwVtecSet);
/*
* now calculate status latlon info and then add to
* ugc
*/
List<AwwLatlons> pointAwwLatLonsList = AwwLatLonUtil
.getAwwLatLonsListBySereveWeatherStatusPointLine(awwVtec
.getVtecLine());
/* now calculate status latlon info and then add to
* ugc */
List<AwwLatlons> pointAwwLatLonsList = AwwLatLonUtil.getAwwLatLonsListBySereveWeatherStatusPointLine(awwVtec.getVtecLine());
for (AwwLatlons eachAwwLatlons : pointAwwLatLonsList) {
ugc.addAwwLatLon(eachAwwLatlons);
}
}
}
}
} catch (Exception e) {
logger.error("Error processing decoded sigmet", e);
logger.error("Error processing decoded segment", e);
record = null;
}
}
/*
* Check the AWW record object. If not, throws exception.
*/
/* Check the AWW record object. If not, throws exception. */
if (record != null) {
// T976 - check if the record has a valid UGC. If not return an
// empty PluginDataObject array
if ((record.getAwwUGC() == null)
|| (record.getAwwUGC().size() == 0)) {
if ((record.getAwwUGC() == null) || (record.getAwwUGC().size() == 0)) {
return new PluginDataObject[0];
}
record.setReportType(reportType.trim());
record.setTraceId(traceId);
// Set MND remark before the URI is constructed
if ((mt.getMndTimeString() == null)
|| mt.getMndTimeString().trim().isEmpty()) {
if ((mt.getMndTimeString() == null) || mt.getMndTimeString().trim().isEmpty()) {
record.setMndTime("unknown");
} else {
record.setMndTime(mt.getMndTimeString());
@ -297,10 +289,8 @@ public class AwwDecoder extends AbstractDecoder {
// Replace special characters to a blank so that it may be readable.
if (theBulletin.length() < 40000) {
record.setBullMessage(UtilN.removeLeadingWhiteSpaces(theBulletin
.replace('\r', ' ').replace('\003', ' ')
.replace('\000', ' ').replace('\001', ' ')
.replace('\036', ' ')));
record.setBullMessage(UtilN
.removeLeadingWhiteSpaces(theBulletin.replace('\r', ' ').replace('\003', ' ').replace('\000', ' ').replace('\001', ' ').replace('\036', ' ')));
}
// Return the AwwRecord record object.
@ -309,11 +299,9 @@ public class AwwDecoder extends AbstractDecoder {
// } else {
// return new PluginDataObject[] {record};
// }
/*
* The reason the above is commented out is the check to see if record
/* The reason the above is commented out is the check to see if record
* == null is a dead code. It will never get executed according the
* logic before the if statement.
*/
* logic before the if statement. */
return new PluginDataObject[] { record };
}

View file

@ -6,8 +6,8 @@ import java.util.HashMap;
import java.util.Map;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.pointdata.PointDataView;
import com.raytheon.uf.common.pointdata.PointDataDescription.Type;
import com.raytheon.uf.common.pointdata.PointDataView;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.edex.pointdata.PointDataQuery;
@ -19,7 +19,7 @@ public class StationDataRequestHandler implements
private static final String REF_TIME = "dataTime.refTime";
private static final String REF_HOUR = "refHour";
private static final String REP_TYPE = "reportType";
@Override
@ -35,10 +35,12 @@ public class StationDataRequestHandler implements
query.setParameters(request.getParmList());
query.addParameter(STATION_ID, request.getStationId(), "=");
query.addParameter(REF_HOUR, request.getRefTime().toString(), "=");
if (!request.getPluginName().equalsIgnoreCase("bufrua")) {
query.addParameter(REF_HOUR, request.getRefTime().toString(), "=");
}
query.addParameter(REF_TIME, request.getRefTime().toString(), "<=");
if ( ! request.getPartNumber().equals("0") ) {
query.addParameter(REP_TYPE, request.getPartNumber(), "=");
if (!request.getPartNumber().equals("0")) {
query.addParameter(REP_TYPE, request.getPartNumber(), "=");
}
query.requestAllLevels();
@ -56,21 +58,21 @@ public class StationDataRequestHandler implements
int dimensions = pdv.getDimensions(param);
Type t = pdv.getType(param);
switch (t) {
case FLOAT:
case DOUBLE:
case INT:
case LONG:
case FLOAT:
case DOUBLE:
case INT:
case LONG:
if (dimensions == 2) {
params.put(param, pdv.getNumberAllLevels(param));
params.put(param, pdv.getNumberAllLevels(param));
} else {
params.put(param, pdv.getNumber(param));
params.put(param, pdv.getNumber(param));
}
break;
case STRING:
case STRING:
if (dimensions == 2) {
params.put(param, pdv.getStringAllLevels(param));
params.put(param, pdv.getStringAllLevels(param));
} else {
params.put(param, pdv.getString(param));
params.put(param, pdv.getString(param));
}
break;
}

View file

@ -11,10 +11,12 @@ Import-Package: com.raytheon.edex.exception,
com.raytheon.uf.common.parameter,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.serialization.comm,
gov.noaa.nws.ncep.edex.common.sounding,
javax.measure.unit
Require-Bundle: com.raytheon.edex.common;bundle-version="1.12.1174",
gov.noaa.nws.ncep.common.dataplugin.gpd;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174",
com.raytheon.uf.common.pointdata;bundle-version="1.12.1174",
com.raytheon.uf.edex.pointdata;bundle-version="1.12.1174",
com.raytheon.uf.edex.ingest;bundle-version="1.12.1174"
com.raytheon.uf.edex.ingest;bundle-version="1.12.1174",
org.apache.commons.io;bundle-version="2.4.0"

View file

@ -1,4 +1,8 @@
/**
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
@ -25,6 +29,7 @@ import gov.noaa.nws.ncep.common.dataplugin.gpd.product.GenericPointDataParameter
import gov.noaa.nws.ncep.common.dataplugin.gpd.product.GenericPointDataProductContainer;
import gov.noaa.nws.ncep.common.dataplugin.gpd.product.GenericPointDataProductInfo;
import gov.noaa.nws.ncep.common.dataplugin.gpd.product.GenericPointDataStationProduct;
import gov.noaa.nws.ncep.common.dataplugin.gpd.query.GenericPointDataReqMsg.GenericPointDataReqType;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@ -34,6 +39,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -48,6 +54,8 @@ import javax.xml.bind.Unmarshaller;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.io.IOUtils;
import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.AbstractDecoder;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
@ -262,7 +270,7 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
********************************************************************************************
*
*/
private String parseSoundingTable(String prodTblString,String prodName,int versionNum, int levelNumMax){
private String parseSoundingTable(String prodTblString,String prodName,int versionNum, int levelNumMax, GenericPointDataReqType reqType){
if( levelNumMax < 2) {//should set to a minimum of 2, see comments in parseSurfaceTable()
return "Bad input, max number of level should be greater than 1";
}
@ -331,10 +339,14 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
//remainDataString: point to data starting from first STID
String remainDataString = prodTblString.substring(stnIdIndex);
//split remaining data and parse data for each station.
Date date=null;
//Chin NOTE: current time is reference time for OBS SND (e.g. Uair) and is forecast time for Model SND (for example pfc-nam)
Date currentTime=null;
//Chin Note: reference time is indeed reference time for Model SND. Currently, we use the first decoded TIME
// as reference time.
Date refTime=null;
boolean firstRoundOfPersistence = true;
PointDataDescription pdd=null;
int blockCount=0;
//int blockCount=0;
List<GenericPointDataStationProduct> stnProdList = new ArrayList<GenericPointDataStationProduct>();
/*
* Chin Note: To speed up HDF5 persistence speed and also avoid out of heap memory problem,
@ -354,7 +366,9 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
else {
stnDataString = remainDataString;
found = false;
//System.out.println("reach last station, contents= \n"+stnDataString);
}
boolean goodStation = true;
//System.out.println(stnDataString);
int stnSndParmIndex = stnDataString.indexOf(sndParmArray[0]);
//System.out.println("stnSndParmIndex=" + stnSndParmIndex);
@ -390,7 +404,7 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
int i=0;
GenericPointDataStationProduct stnProd = new GenericPointDataStationProduct(versionNum,prodName);
boolean reftimeNotAvail = true, stnIdNotAvail=true;
String stid="", reftime="";
String stid="", timeStr="";
for(String pm: stnMetaArray){
//System.out.println("Metainfo="+pm);
if(pm.equals(GenericPointDataConstants.SND_STN_ID)){
@ -450,16 +464,32 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
SimpleDateFormat df = new SimpleDateFormat("yyMMdd/HHmm");
try {
date = df.parse(stnMetaArray[i+1]);
reftime = stnMetaArray[i+1];
//For PFC sounding, reference time and forecast time may be different
//We use the first station's "TIME" decoded as reference time for all time lines / stations in
//one GEMPAK file..
// The rest decoded TIME is decoded as forecast time for each time line.
//However, for UAIR, all decoded "TIME" are treated as reference time for that station/time line
if(refTime == null)
refTime = df.parse(stnMetaArray[i+1]);
currentTime = df.parse(stnMetaArray[i+1]);
timeStr = stnMetaArray[i+1];
//System.out.println("date="+date.toString());
reftimeNotAvail=false;
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(date!=null)
stnProd.setRefTime(date);
if(currentTime!=null){
if(GenericPointDataReqType.STORE_GPD_MDL_SND_PRODUCT_FROM_GEMPAK_TBL == reqType){
stnProd.setRefTime(refTime);
int forecastTime= (int)((currentTime.getTime() - refTime.getTime())/1000);
stnProd.setForecastTime(forecastTime);
}
else {// should be (GenericPointDataReqType.STORE_GPD_OBS_SND_PRODUCT_FROM_GEMPAK_TBL == reqType){
stnProd.setRefTime(currentTime);
stnProd.setForecastTime(-1);
}
}
else {
//no mandatory reference time found
returnStatus = "*****************************************\nDropped one station product. TIME not found. \n"+ stnMetaDataStr + "\n";
@ -543,9 +573,9 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
}
else{
//Chin NOTE: with this simple error handling design,
//When a missing line in input table, we will drop all data for its station after the missing line.
//When a missing parameter in line, we will drop all data for this level.
//System.out.println("sdnParmlength="+stnSndDataParmAtCurLineArray.length+" should be"+ numSndParmAtLine);
returnStatus = returnStatus +"Dropped incomplete sounding data line @ "+ stid+ " Time="+reftime+"\n"+ lineStr + "\n";
returnStatus = returnStatus +"Dropped incomplete sounding data level, missing data at line @ "+ stid+ " Time="+timeStr+"\n"+ lineStr + "\n stnStr="+stnDataString+"\n found="+found;
goodLevel = false;
break;
}
@ -553,10 +583,24 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
}
if(goodLevel)
stnProd.getLevelLst().add(gpdLevel);
else{
//if there is a bad level, we drop this station
goodStation = false;
break;
}
}
stnProdList.add(stnProd);
if(goodStation)
stnProdList.add(stnProd);
}
if(firstRoundOfPersistence == true ){
int latestProdVersion = gpdDao.getGpdProductLatestVersion(currentTime, prodName);
if(versionNum <= latestProdVersion)
//input product should not have version smaller or equal to same product's latest product version in DB
//If a new product, its product version should be 0 and latestProdVersion should be -1.
return "Data persistence failed. Input version number "+ versionNum+ " DB latest version number "+latestProdVersion;
prodInfo = gpdDao.lookupUpdateGpdProdInfo(prodInfo, true, versionNum);
if(prodInfo == null)
return "Data persistence failed. Bad Product info\n";
//NOte: we assume at first round, we will already have max level set for generating
// pdd
pdd = createPointDataDescription(prodInfo);
@ -564,7 +608,7 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
if(pdd != null && stnProdList.size() >=BLOCKSIZE ){
try {
String sts = performPersist( prodInfo,stnProdList
,versionNum, date, pdd, firstRoundOfPersistence) ;
,versionNum, pdd) ;
if(sts.equals(OK)== false){
//either product info or version is not right, stop parsing.
@ -576,7 +620,7 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
// TODO Auto-generated catch block
e.printStackTrace();
}
blockCount++;
//blockCount++;
}
}
//System.out.println("Prod " + prodName+": persisted "+ (blockCount*BLOCKSIZE + stnProdList.size())+ " records.");
@ -585,7 +629,7 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
if(pdd!=null && stnProdList.size() > 0 ){
try {
String sts = performPersist( prodInfo,stnProdList
,versionNum, date, pdd, firstRoundOfPersistence) ;
,versionNum, pdd) ;
if(sts.equals(OK)== false){
//either product info or version is not right, stop parsing.
return returnStatus+ sts;
@ -828,7 +872,7 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
//to here means that this is a none numeric string, then it should be a station id line, ie. the first line of a record
//add first line to stnTbl
System.out.println(" line: "+stnlineStr + " length="+ stnlineStr.length());
//System.out.println(" line: "+stnlineStr + " length="+ stnlineStr.length());
stnTbl.add((new ArrayList(Arrays.asList(stnparmArry))));
currentIndex++;
@ -876,7 +920,7 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
}
// get stnId value and drop it from table
String stnIdStr = stnTbl.get(0).get(0);
System.out.println("stnId="+stnIdStr);
//System.out.println("stnId="+stnIdStr);
if(stnIdStr.length()<=0){
returnStatus =returnStatus + "Dropped one station product. STN not found \n"+ stnTbl.get(0) + "\n";
stnTbl.clear();
@ -893,14 +937,16 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
}
try {
date = df.parse(refTime);
System.out.println("date="+date.toString());
//System.out.println("date="+date.toString());
} catch (ParseException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
System.out.println("bad reftime"+refTime);
}
if(date!=null)
if(date!=null){
newstnProd.setRefTime(date);
newstnProd.setForecastTime(-1);
}
else{
returnStatus = returnStatus + "Dropped one station product. Time in bad format \n"+ stnTbl.get(0) + "\n";
stnTbl.clear();
@ -945,13 +991,21 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
stnIndexInBlock++;
stnTbl.clear();
if(firstRoundOfPersistence == true ){
int latestProdVersion = gpdDao.getGpdProductLatestVersion(stnProdList.get(0).getRefTime(), prodName);
if(versionNum <= latestProdVersion)
//input product should not have version smaller or equal to same product's latest product version in DB
//If a new product, its product version should be 0 and latestProdVersion should be -1.
return "Data persistence failed. Input version number "+ versionNum+ " DB latest version number "+latestProdVersion;
prodInfo = gpdDao.lookupUpdateGpdProdInfo(prodInfo, true, versionNum);
if(prodInfo == null)
return "Data persistence failed. Bad Product info\n";
pdd = createPointDataDescription(prodInfo);
}
if(pdd != null && stnIndexInBlock >=BLOCKSIZE ){
try {
String sts = performPersist( prodInfo,stnProdList
,versionNum, stnProdList.get(0).getRefTime(), pdd, firstRoundOfPersistence) ;
,versionNum, pdd) ;
if(sts.equals(OK)== false){
//either product info or version is not right, stop parsing.
return returnStatus+ sts;
@ -971,7 +1025,7 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
if(pdd!=null && stnIndexInBlock > 0 ){
try {
String sts = performPersist( prodInfo,stnProdList
,versionNum, stnProdList.get(0).getRefTime(), pdd, firstRoundOfPersistence) ;
,versionNum, pdd) ;
if(sts.equals(OK)== false){
//either product info or version is not right, stop parsing.
return returnStatus+ sts;
@ -989,19 +1043,10 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
* Return status: OK or error status
*/
private String performPersist(GenericPointDataProductInfo prodInfo,List<GenericPointDataStationProduct> stnProdLst
, int prodVersion, Date refTime, PointDataDescription pdd, boolean firstRoundOfPersist) throws PluginException {
, int prodVersion, PointDataDescription pdd) throws PluginException {
String prodName = prodInfo.getName();
List<PluginDataObject> rtObLst =null;
if(firstRoundOfPersist == true){
int latestProdVersion = gpdDao.getGpdProductLatestVersion(refTime, prodName);
if(prodVersion <= latestProdVersion)
//input product should not have version smaller or equal to same product's latest product version in DB
//If a new product, its product version should be 0 and latestProdVersion should be -1.
return "Data persistence failed. Wrong version number!\n";
prodInfo = gpdDao.lookupUpdateGpdProdInfo(prodInfo, true, prodVersion);
if(prodInfo == null)
return "Data persistence failed. Bad Product info\n";
}
DataTime dataTime;
//System.out.println("GenericPointDataProductInfo is obtained! report name="+prodInfo.getName()+
@ -1024,7 +1069,12 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
stnPd.setNumLevel(numLevel);
PointDataView view = createPointDataView(pdd, stnPd);
if(view !=null){
dataTime = new DataTime(stnPd.getRefTime());
Date refTime = stnPd.getRefTime();
int forecastTimeSec = stnPd.getForecastTime();
if(forecastTimeSec == -1)
dataTime = new DataTime(stnPd.getRefTime());
else
dataTime = new DataTime(stnPd.getRefTime(), (int)forecastTimeSec);
gpdRec= new GenericPointDataRecord(prodInfo,location,stnPd.getSlat(), stnPd.getSlon(),view, dataTime, prodVersion);
rtObLst.add(gpdRec);
}
@ -1037,9 +1087,9 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
long t1 = System.currentTimeMillis();
gpdDao.persistToDatabase(recordObjects);
long t2 = System.currentTimeMillis();
System.out.println("\nTime spent to persist "+recordObjects.length+ " records to HDF5: "
+ (t1 - t0)+" persist to Postgres: "
+ (t2 - t1));
//System.out.println("\nTime spent to persist "+recordObjects.length+ " records to HDF5: "
// + (t1 - t0)+" persist to Postgres: "
// + (t2 - t1));
totalHDF5Time = totalHDF5Time + (t1 - t0);
}
return OK;
@ -1051,11 +1101,17 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
* @throws DecoderException
* @throws PluginException
*/
public String decodeTblProdFmCli(String prodTblString, String ProdName,int versionNum, int maxNumOfLevel)throws DecoderException, PluginException {
public String decodeGempakTblProdFmCli(String prodTblString, String ProdName,int versionNum, int maxNumOfLevel, GenericPointDataReqType reqType)throws DecoderException, PluginException {
long tin = System.currentTimeMillis();
String returnStatus="";
totalHDF5Time=0;
if ( prodTblString !=null) {
//check to see what type of product is
if(reqType == GenericPointDataReqType.STORE_GPD_OBS_SFC_PRODUCT_FROM_GEMPAK_TBL)
returnStatus = parseSurfaceTable(prodTblString, ProdName,versionNum);
else if(reqType == GenericPointDataReqType.STORE_GPD_OBS_SND_PRODUCT_FROM_GEMPAK_TBL||reqType == GenericPointDataReqType.STORE_GPD_MDL_SND_PRODUCT_FROM_GEMPAK_TBL)
returnStatus= parseSoundingTable(prodTblString, ProdName, versionNum,maxNumOfLevel,reqType);
/*
if(prodTblString.contains(GenericPointDataConstants.SND_PARM)){
//"SNPARM" is an unique string in sounding table file
totalHDF5Time=0;
@ -1065,7 +1121,7 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
totalHDF5Time=0;
//"YYMMDD/HHMM" is an unique string in surface table file
returnStatus = parseSurfaceTable(prodTblString, ProdName,versionNum);
}
}*/
else{
return("Decode failed! Bad product type, can not tell what product type is input!");
}
@ -1134,7 +1190,7 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
if(prodInfo == null)
return "Data persistence failed. Bad Product info";
DataTime dataTime = new DataTime(gpdc.getRefTime());
System.out.println("GenericPointDataProductInfo is obtained! report name="+prodInfo.getName()+
System.out.println("GenericPointDataProductInfo is obtained! report name="+prodInfo.getName()+ " number of param="+prodInfo.getParameterLst().size() +
" Reftime="+ dataTime.getRefTimeAsCalendar().getTime()+" in ms="+ dataTime.getRefTimeAsCalendar().getTimeInMillis()+ " stnLstSize="+lstSize + " numMaxLvls="+prodInfo.getMaxNumberOfLevel());
PointDataDescription pdd = createPointDataDescription(prodInfo);
@ -1178,9 +1234,9 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
toObjIx = fromObjIx+ 50;
}
recordObjects = rtObLst.subList(fromObjIx, toObjIx).toArray(new PluginDataObject[toObjIx-fromObjIx]);
EDEXUtil.checkPersistenceTimes(recordObjects);
gpdDao.persistToHDF5(recordObjects);
gpdDao.persistToDatabase(recordObjects);
EDEXUtil.checkPersistenceTimes(recordObjects);
gpdDao.persistToHDF5(recordObjects);
gpdDao.persistToDatabase(recordObjects);
fromObjIx = fromObjIx + 50;
}
@ -1358,6 +1414,33 @@ SNPARM = PRES;TMPC;DWPT;HGHT;DRCT;SKNT;TMPK;RELH;MIXR;UKNT;VKNT;THTA;THTE
}
return INPUT_TYPE.GPD_UNKNOWN;
}
public void decodeGempakProdFmSbn(File inputFile)throws DecoderException, PluginException {
System.out.println("GPD decodeGempakProdFmSbn() entered!");
if(inputFile.getName().equals("test")){
test(inputFile);
return;// returnObjects;
}
InputStream is = null;
try {
is = new FileInputStream(inputFile);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return;// returnObjects;
}
StringWriter writer = new StringWriter();
try {
IOUtils.copy(is, writer, "UTF-8");
String gempakFileStr = writer.toString();
String status = decodeGempakTblProdFmCli(gempakFileStr, "nampfc", 0, 100, GenericPointDataReqType.STORE_GPD_MDL_SND_PRODUCT_FROM_GEMPAK_TBL);
System.out.println(status);
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Decode GPD XML file input from SBN/gpd
* @param inputProdStr : XML file

View file

@ -1,4 +1,8 @@
/**
* This code has unlimited rights, and is provided "as is" by the National Centers
* for Environmental Prediction, without warranty of any kind, either expressed or implied,
* including but not limited to the implied warranties of merchantability and/or fitness
* for a particular purpose.
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
@ -390,7 +394,7 @@ public class GenericPointDataRequestHandler implements IRequestHandler<GenericPo
if(gpdDao== null)
return null;
GenericPointDataReqType msgType = request.getReqType();
String reportName;
String prodName= request.getProductName();;
Date refTime;
float slon ;
float slat;
@ -399,9 +403,8 @@ public class GenericPointDataRequestHandler implements IRequestHandler<GenericPo
case GET_GPD_PRODUCT_INFO_GEMPAK_TBL:
case GET_GPD_PRODUCT_INFO_OBJECT:
case GET_GPD_PRODUCT_INFO_XML:
reportName = request.getProductName();
if(reportName !=null){
GenericPointDataProductInfo prodInfo = gpdDao.getGpdProdInfo(reportName);
if(prodName !=null){
GenericPointDataProductInfo prodInfo = gpdDao.getGpdProdInfo(prodName);
//*System.out.println(" report name= "+prodInfo.getName()+ " master="+prodInfo.getMasterLevel().getName()+ " maxLevel="+prodInfo.getMaxNumberOfLevel());
//for(Parameter pam: prodInfo.getParameterLst() ){
// System.out.println("parm ="+pam.getAbbreviation());
@ -418,10 +421,9 @@ public class GenericPointDataRequestHandler implements IRequestHandler<GenericPo
case GET_GPD_STATION_PRODUCT_GEMPAK_TBL:
case GET_GPD_STATION_PRODUCT_OBJECT:
case GET_GPD_STATION_PRODUCT_XML:
reportName = request.getProductName();
String stnId = request.getStnId();
refTime = request.getRefTime();
stnProd=gpdDao.getGpdProduct(refTime,GenericPointDataQueryKey.BY_STN_ID, stnId,-9999,-9999,reportName,request.isQuerySpecifiedProductVersion(), request.getProductVersion());
stnProd=gpdDao.getGpdProduct(refTime,GenericPointDataQueryKey.BY_STN_ID, stnId,-9999,-9999,prodName,request.isQuerySpecifiedProductVersion(), request.getProductVersion());
//System.out.println("stnProduct id="+ stnProd.getLocation().getStationId());
if(stnProd!=null)
if(msgType.equals(GenericPointDataReqType.GET_GPD_STATION_PRODUCT_OBJECT)){
@ -438,11 +440,10 @@ public class GenericPointDataRequestHandler implements IRequestHandler<GenericPo
case GET_GPD_MOVING_PRODUCT_GEMPAK_TBL:
case GET_GPD_MOVING_PRODUCT_OBJECT:
case GET_GPD_MOVING_PRODUCT_XML:
reportName = request.getProductName();
slon = request.getSlon();
slat = request.getSlat();
refTime = request.getRefTime();
stnProd=gpdDao.getGpdProduct(refTime,GenericPointDataQueryKey.BY_SLAT_SLON,null, slat,slon,reportName,request.isQuerySpecifiedProductVersion(), request.getProductVersion());
stnProd=gpdDao.getGpdProduct(refTime,GenericPointDataQueryKey.BY_SLAT_SLON,null, slat,slon,prodName,request.isQuerySpecifiedProductVersion(), request.getProductVersion());
//System.out.println("stnProduct id="+ stnProd.getLocation().getStationId());
if(stnProd!=null)
if(msgType.equals(GenericPointDataReqType.GET_GPD_MOVING_PRODUCT_OBJECT)){
@ -459,9 +460,8 @@ public class GenericPointDataRequestHandler implements IRequestHandler<GenericPo
case GET_GPD_PRODUCT_GEMPAK_TBL:
case GET_GPD_PRODUCT_OBJECT:
case GET_GPD_PRODUCT_XML:
reportName = request.getProductName();
refTime = request.getRefTime();
GenericPointDataProductContainer pdCon=gpdDao.getGpdProduct(refTime,GenericPointDataQueryKey.BY_REPORT_NAME,null, -9999,-9999,reportName,request.isQuerySpecifiedProductVersion(), request.getProductVersion());//(refTime, reportName,request.isQuerySpecifiedProductVersion(), request.getProductVersion());
GenericPointDataProductContainer pdCon=gpdDao.getGpdProduct(refTime,GenericPointDataQueryKey.BY_PRODUCT_NAME,null, -9999,-9999,prodName,request.isQuerySpecifiedProductVersion(), request.getProductVersion());//(refTime, reportName,request.isQuerySpecifiedProductVersion(), request.getProductVersion());
//System.out.println("stnProduct id="+ stnProd.getLocation().getStationId());
if(pdCon!=null)
if(msgType.equals(GenericPointDataReqType.GET_GPD_PRODUCT_OBJECT)){
@ -476,27 +476,45 @@ public class GenericPointDataRequestHandler implements IRequestHandler<GenericPo
}
break;
case GET_GPD_STATION_PRODUCT_OBJECT_LIST:
reportName = request.getProductName();
stnId = request.getStnId();
return (Object)gpdDao.getGpdStationProduct(request.getRefTimeList(),GenericPointDataQueryKey.BY_STN_ID, stnId,-9999,-9999,reportName);
return (Object)gpdDao.getGpdStationProduct(request.getQueryTimeList(),GenericPointDataQueryKey.BY_STN_ID, stnId,-9999,-9999,prodName);
case GET_GPD_STATION_MDL_SND_PRODUCT_OBJECT_LIST:
stnId = request.getStnId();
//System.out.println("GET_GPD_STATION_MDL_SND_PRODUCT_OBJECT_LIST stnProduct id="+ stnId);
return (Object)gpdDao.getGpdStationModelSndProduct(request.getQueryTimeList(),request.getRefTime(),GenericPointDataQueryKey.BY_STN_ID, stnId,-9999,-9999,prodName);
//System.out.println("stnProduct id="+ stnProd.getLocation().getStationId());
case GET_GPD_MOVING_PRODUCT_OBJECT_LIST:
reportName = request.getProductName();
slon = request.getSlon();
slat = request.getSlat();
return (Object)gpdDao.getGpdStationProduct(request.getRefTimeList(),GenericPointDataQueryKey.BY_SLAT_SLON, null,slat,slon,reportName);
//System.out.println("stnProduct id="+ stnProd.getLocation().getStationId());
return (Object)gpdDao.getGpdStationProduct(request.getQueryTimeList(),GenericPointDataQueryKey.BY_SLAT_SLON, null,slat,slon,prodName);
case GET_GPD_MOVING_MDL_SND_PRODUCT_OBJECT_LIST:
slon = request.getSlon();
slat = request.getSlat();
return (Object)gpdDao.getGpdStationModelSndProduct(request.getQueryTimeList(),request.getRefTime(),GenericPointDataQueryKey.BY_SLAT_SLON, null,slat,slon,prodName);
case STORE_GPD_PRODUCT_FROM_XML:
return (decoder.decodeXmlProdFmCli(request.getGpdDataString()));
case STORE_GPD_PRODUCT_FROM_GEMPAK_TBL:
return (decoder.decodeTblProdFmCli(request.getGpdDataString(), request.getProductName(), request.getProductVersion(), request.getMaxNumLevel()));
case STORE_GPD_OBS_SFC_PRODUCT_FROM_GEMPAK_TBL:
case STORE_GPD_OBS_SND_PRODUCT_FROM_GEMPAK_TBL:
case STORE_GPD_MDL_SND_PRODUCT_FROM_GEMPAK_TBL:
return (decoder.decodeGempakTblProdFmCli(request.getGpdDataString(), prodName, request.getProductVersion(), request.getMaxNumLevel(), msgType));
case PURGE_GPD_EXPIRED_PRODUCT:
gpdDao.purgeExpiredData();
break;
case PURGE_GPD_ALL_PRODUCTS:
gpdDao.purgeAllData();
break;
case GET_GPD_PRODUCT_TIMELINE_OBJECT:
return (Object)(gpdDao.getGpdProductTimeline(prodName));
case GET_GPD_PRODUCT_RANGESTART_TIME_OBJECT:
return (Object)(gpdDao.getGpdProductRangestartTimes(prodName,request.getRefTimeStr()));
case GET_GPD_STATION_INFO_COLLECTION_OBJECT:
return (Object)(gpdDao.getGpdStationInfoCollection(request.getRefTimeStr(), request.getRangeStartTimeStr(),prodName));
case GET_GPD_ALL_AVAILABLE_PRODUCTS:
case GET_GPD_AVAILABLE_OBSERVED_SOUNDING_PRODUCTS:
case GET_GPD_AVAILABLE_MODEL_SOUNDING_PRODUCTS:
case GET_GPD_AVAILABLE_SURFACE_PRODUCTS:
return (Object) (gpdDao.getGpdAvailProducts(msgType));
default:
break;
}

View file

@ -1,30 +1,81 @@
<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">
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&amp;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 id="ncgribFilenameProcessor" class="gov.noaa.nws.ncep.edex.plugin.ncgrib.NcgribFileNameProcessor"/>
<bean factory-bean="clusteredCamelContextMgr"
factory-method="register">
<constructor-arg ref="ncgrib-file-endpoint" />
</bean>
<bean id="ncgribGridPointLock" class="com.raytheon.edex.plugin.grib.GribGridPointLock">
<constructor-arg value="${ncgrib-decode.count.gridpoints}"/>
<constructor-arg value="${ncgrib-decode.count.threads}"/>
</bean>
<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&amp;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.ncGrib"/>
</route>
</camelContext>
<camelContext id="ncgrib-qpid-endpoint" xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler"
autoStartup="false">
<endpoint id="ncgribJmsEndpoint" uri="jms-durable:queue:Ingest.ncGrib?concurrentConsumers=${ncgrib-decode.count.threads}"/>
<route id="ncgribFileNameConsumerRoute">
<from ref="ncgribJmsEndpoint"/>
<doTry>
<pipeline>
<bean ref="ncgribFilenameProcessor"/>
<setHeader headerName="pluginName">
<constant>grid</constant>
</setHeader>
<bean ref="stringToFile"/>
<split streaming="true">
<method bean="gribSplitter" method="split"/>
<doTry>
<pipeline>
<bean ref="ncgribGridPointLock" method="reserve"/>
<bean ref="gribDecoder"/>
<bean ref="gribPostProcessor" method="process"/>
<to uri="direct-vm:persistIndexAlert"/>
</pipeline>
<doCatch>
<exception>java.lang.Throwable</exception>
<to uri="log:ncgrib?level=ERROR"/>
</doCatch>
<doFinally>
<bean ref="ncgribGridPointLock" method="release"/>
</doFinally>
</doTry>
</split>
</pipeline>
<doCatch>
<exception>java.lang.Throwable</exception>
<to uri="log:ncgrib?level=ERROR"/>
</doCatch>
</doTry>
</route>
</camelContext>
<bean id="ncgribDecodeCamelRegistered" factory-bean="contextManager"
factory-method="register" depends-on="persistCamelRegistered">
<constructor-arg ref="ncgrib-qpid-endpoint"/>
</bean>
<bean factory-bean="clusteredCamelContextMgr"
factory-method="register">
<constructor-arg ref="ncgrib-file-endpoint"/>
</bean>
</beans>

View file

@ -0,0 +1,7 @@
# the number of ncgrib decode threads.
ncgrib-decode.count.threads=8
# Maximum number of grid points to decode at one time for all threads. Large
# grib files may cause the decoder to reach this limit and then some threads
# will have to wait. This can be used to control the amount of memory used by
# the decoder.
ncgrib-decode.count.gridpoints=36000000

View file

@ -1,4 +1,5 @@
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.
@ -19,6 +20,7 @@ package gov.noaa.nws.ncep.edex.plugin.ncgrib;
* further licensing information.
**/
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -40,7 +42,9 @@ import org.apache.camel.Processor;
* 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
* Oct 15, 2012 2473 bsteffen Move to ncgrib plugin
* 5/2014 S. Gilbert Removed absolute path from fileName
* 5/2014 T. Lee Added HYSPLIT
*
* </pre>
*
@ -52,36 +56,61 @@ 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})$");
.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})$");
.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("^\\d{10}_([a-z]*)\\d{1,2}[lewcs]$");
// For hysplit model
private static final Pattern HYSPLIT_PATTERN = Pattern
.compile("^e\\d{10}$");
private static NcgribModelNameMap modelMap = null;
@Override
public void process(Exchange exchange) throws Exception {
String flName = (String) exchange.getIn()
.getHeader("CamelFileNameOnly");
/*
* If filename not found in Header, look in body in case it came in from
* an ingest queue
*/
if (flName == null) {
Object payload = exchange.getIn().getBody();
if (payload instanceof byte[]) {
flName = new String((byte[]) payload);
} else if (payload instanceof String) {
flName = (String) payload;
}
// Remove Path from filename
if (flName != null) {
File f = new File(flName);
flName = f.getName();
}
}
String datasetid = null;
String secondaryid = null;
String ensembleid = null;
@ -93,28 +122,28 @@ public class NcgribFileNameProcessor implements Processor {
} else if (ENSEMBLE_WAVE_PATTERN.matcher(token).find()) {
Matcher matcher = ENSEMBLE_WAVE_PATTERN.matcher(token);
matcher.find();
ensembleid = matcher.group(1);
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);
ensembleid = matcher.group(1);
} else if (FIREWXNEST_ID_PATTERN.matcher(token).find()) {
//datasetid = "NAMFIREWX";
// 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();
// 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")) {
@ -125,16 +154,19 @@ public class NcgribFileNameProcessor implements Processor {
datasetid = "HWRF";
}
} else if (HYSPLIT_PATTERN.matcher(token).find()) {
secondaryid = nameTokens[0];
datasetid = "HYSPLIT";
}
}
if ( modelMap == null ) {
modelMap = NcgribModelNameMap.load();
}
// Get model name from grib file template
if (modelMap == null) {
modelMap = NcgribModelNameMap.load();
}
// Get model name from grib file template
if (datasetid == null) {
datasetid = modelMap.getModelName(flName);
datasetid = modelMap.getModelName(flName);
}
if (datasetid != null) {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<requestPatterns xmlns:ns2="group">
<!-- regex>^FOUS5[1-5] ([A-Z]{4}) ([0-9]{6}).*\\x0d\\x0d\\x0a[AP]FM.*</regex -->
<regex>^FOUS5[1-5] ([A-Z]{4}) ([0-9]{6}).*</regex>
<regex>^FOUS5[1-6] ([A-Z]{4}) ([0-9]{6}).*</regex>
</requestPatterns>

View file

@ -31,7 +31,8 @@ import java.util.List;
* 02/28/2012 Chin Chen modify several sounding query algorithms for better performance
* 8/2012 T. Lee/NCEP Removed missing wind interpolation
* 8/2012 T. Lee/NCEP Fixed max wind merging; May fix NSHARP EL calculation
* 12/2013 T. Lee/NCEP Fixed missing height at top level before sorting
* 12/2013 1115 T. Lee/NCEP Fixed missing height at top level before sorting
* 3/2014 1116 T. Lee/NCEP Added dpdToDewpoint for cmcHR (15km) data
* </pre>
*
* @author T. Lee
@ -93,8 +94,7 @@ public class MergeSounding {
} else {
if (ppaa.size() < 1 && ttbb.size() < 1) {
System.out
.println(" Missing TTAA/TTBB and PPAA data.");
System.out.println(" Missing TTAA/TTBB and PPAA data.");
return missingSounding();
} else {
man = missingSounding();
@ -389,6 +389,33 @@ public class MergeSounding {
return sndata;
}
/*
* computes DWPC from TMPC and RELH Note: If DWPC is less than -190 degrees
* C, it is treated as missing data Code is based on GEMPAK's prrhdp.f
*/
public List<NcSoundingLayer> dpdToDewpoint(List<NcSoundingLayer> sndata) {
float temp, dpdk;
float dwpc = RMISSD;
for (NcSoundingLayer layer : sndata) {
if (layer.getDewpoint() == RMISSD) {
temp = layer.getTemperature();
dpdk = layer.getDpd();
if (temp == RMISSD || dpdk == RMISSD) {
continue;
} else {
dwpc = temp - dpdk;
layer.setDewpoint(dwpc);
// //System.out.println("rhToDewpoint dwpc: " + dwpc);
}
}
}
return sndata;
}
/*
* computes VAPR from TMPC Code is based on GEMPAK's prvapr.f
*/

View file

@ -12,11 +12,8 @@ import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
//TODO fix?
@Ignore
public class FfgParserTest {
FfgRecord record = new FfgRecord();
@ -83,11 +80,11 @@ public class FfgParserTest {
Iterator<FfgPrecip> it = ppp.iterator();
while (it.hasNext()) {
FfgPrecip pr = it.next();
assertEquals(3.0, pr.getFf01());
assertEquals(4.2, pr.getFf03());
assertEquals(4.5, pr.getFf06());
assertEquals(4.8, pr.getFf12());
assertEquals(6.0, pr.getFf24());
assertEquals(3.0, pr.getFf01(), 0.01);
assertEquals(4.2, pr.getFf03(), 0.01);
assertEquals(4.5, pr.getFf06(), 0.01);
assertEquals(4.8, pr.getFf12(), 0.01);
assertEquals(6.0, pr.getFf24(), 0.01);
}
}
@ -100,11 +97,11 @@ public class FfgParserTest {
Iterator<FfgPrecip> it = ppp.iterator();
while (it.hasNext()) {
FfgPrecip pr = it.next();
assertEquals(3.0, pr.getFf01());
assertEquals(4.2, pr.getFf03());
assertEquals(4.5, pr.getFf06());
assertEquals(4.8, pr.getFf12());
assertEquals(6.0, pr.getFf24());
assertEquals(3.0f, pr.getFf01(), 0.01);
assertEquals(4.2f, pr.getFf03(), 0.01);
assertEquals(4.5f, pr.getFf06(), 0.01);
assertEquals(4.8f, pr.getFf12(), 0.01);
assertEquals(6.0f, pr.getFf24(), 0.01);
}
}
@ -117,13 +114,13 @@ public class FfgParserTest {
Iterator<FfgPrecip> it = ppp.iterator();
while (it.hasNext()) {
FfgPrecip pr = it.next();
assertEquals(3.0, pr.getFf01());
assertEquals(3.0, pr.getFf01(), 0.01);
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
(double) pr.getFf03(), 0.0);
assertEquals(4.5, pr.getFf06());
assertEquals(4.5, pr.getFf06(), 0.01);
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
(double) pr.getFf12(), 0.0);
assertEquals(6.0, pr.getFf24());
assertEquals(6.0, pr.getFf24(), 0.01);
}
}
@ -136,7 +133,7 @@ public class FfgParserTest {
Iterator<FfgPrecip> it = ppp.iterator();
while (it.hasNext()) {
FfgPrecip pr = it.next();
assertEquals(3.0, pr.getFf01());
assertEquals(3.0, pr.getFf01(), 0.01);
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
(double) pr.getFf03(), 0.0);
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),