Issue #1871 add default values for times so they don't need to be sent in from
Python, move getLatLonCoords() Change-Id: Ic37728e269a9899adaf8be1c6d86cd644f417ba1 Former-commit-id:3af61d7117
[formerly3af61d7117
[formerly 01971b490beee0cc87df4ed478c3a66bbad2158f]] Former-commit-id:b44ee44664
Former-commit-id:c95e825d35
This commit is contained in:
parent
af190ad278
commit
7b25f73a9a
4 changed files with 252 additions and 21 deletions
|
@ -1,4 +1,4 @@
|
|||
##
|
||||
# #
|
||||
# This software was developed and / or modified by Raytheon Company,
|
||||
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
#
|
||||
|
@ -16,7 +16,7 @@
|
|||
#
|
||||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
# further licensing information.
|
||||
##
|
||||
# #
|
||||
|
||||
|
||||
#
|
||||
|
@ -37,6 +37,7 @@ import JData
|
|||
|
||||
from com.raytheon.uf.common.geospatial.interpolation.data import FloatArrayWrapper, UnitConvertingDataDestination
|
||||
from com.raytheon.uf.common.python import PythonNumpyFloatArray
|
||||
from com.raytheon.uf.common.geospatial import LatLonReprojection
|
||||
from javax.measure.unit import UnitFormat
|
||||
|
||||
class JGridData(IGridData, JData.JData):
|
||||
|
@ -79,4 +80,22 @@ class JGridData(IGridData, JData.JData):
|
|||
ny = self.jobj.getGridGeometry().getGridRange().getSpan(1);
|
||||
pnfa = PythonNumpyFloatArray(dest.getArray(), nx, ny)
|
||||
return pnfa.__numpy__[0]
|
||||
|
||||
def getLatLonCoords(self):
|
||||
"""
|
||||
Gets the lat/lon coordinates of the grid data.
|
||||
|
||||
Returns:
|
||||
a tuple where the first element is a numpy array of lons, and the
|
||||
second element is a numpy array of lats
|
||||
"""
|
||||
gridGeometry = self.jobj.getGridGeometry()
|
||||
if gridGeometry is None :
|
||||
return None
|
||||
latlons = LatLonReprojection.getLatLons(gridGeometry)
|
||||
nx = gridGeometry.getGridRange().getSpan(0)
|
||||
ny = gridGeometry.getGridRange().getSpan(1)
|
||||
latndarray = PythonNumpyFloatArray(latlons.getLats(), nx, ny).__numpy__[0]
|
||||
lonndarray = PythonNumpyFloatArray(latlons.getLons(), nx, ny).__numpy__[0]
|
||||
return (lonndarray, latndarray)
|
||||
|
||||
|
|
|
@ -87,20 +87,6 @@ def getGeometryData(request, times):
|
|||
data.append(JGeometryData.JGeometryData(jd))
|
||||
return data
|
||||
|
||||
def getLatLonCoords(gridData):
|
||||
'''
|
||||
@return: a tuple where the first element is a numpy array of lons, and the second element is a numpy array of lats
|
||||
'''
|
||||
gridGeometry = gridData.toJavaObj().getGridGeometry()
|
||||
if gridGeometry is None :
|
||||
return None
|
||||
latlons = LatLonReprojection.getLatLons(gridGeometry)
|
||||
nx = gridGeometry.getGridRange().getSpan(0)
|
||||
ny = gridGeometry.getGridRange().getSpan(1)
|
||||
latndarray = PythonNumpyFloatArray(latlons.getLats(), nx, ny).__numpy__[0]
|
||||
lonndarray = PythonNumpyFloatArray(latlons.getLons(), nx, ny).__numpy__[0]
|
||||
return (lonndarray, latndarray)
|
||||
|
||||
def getAvailableLocationNames(request):
|
||||
return JavaDataAccessLayer.getAvailableLocationNames(request.toJavaObj())
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
# 12/10/12 njensen Initial Creation.
|
||||
# Feb 14, 2013 1614 bsteffen refactor data access framework
|
||||
# to use single request.
|
||||
# 4/10/13 1871 mnash move getLatLonCoords to JGridData and add default args
|
||||
#
|
||||
#
|
||||
#
|
||||
|
@ -47,21 +48,69 @@ else:
|
|||
|
||||
|
||||
def getAvailableTimes(request):
|
||||
"""
|
||||
Get the times of available data to the request.
|
||||
|
||||
Args:
|
||||
request: the IDataRequest to get data for
|
||||
|
||||
Returns:
|
||||
a list of DataTimes
|
||||
"""
|
||||
return router.getAvailableTimes(request)
|
||||
|
||||
def getGridData(request, times):
|
||||
def getGridData(request, times=[]):
|
||||
"""
|
||||
Gets the grid data that matches the request at the specified times. Each
|
||||
combination of parameter, level, and dataTime will be returned as a
|
||||
separate IGridData.
|
||||
|
||||
Args:
|
||||
request: the IDataRequest to get data for
|
||||
times: a list of DataTimes, a TimeRange, or None if the data is time
|
||||
agnostic
|
||||
|
||||
Returns:
|
||||
a list of IGridData
|
||||
"""
|
||||
return router.getGridData(request, times)
|
||||
|
||||
def getGeometryData(request, times):
|
||||
def getGeometryData(request, times=[]):
|
||||
"""
|
||||
Gets the geometry data that matches the request at the specified times.
|
||||
Each combination of geometry, level, and dataTime will be returned as a
|
||||
separate IGeometryData.
|
||||
|
||||
Args:
|
||||
request: the IDataRequest to get data for
|
||||
times: a list of DataTimes, a TimeRange, or None if the data is time
|
||||
agnostic
|
||||
|
||||
Returns:
|
||||
a list of IGeometryData
|
||||
"""
|
||||
return router.getGeometryData(request, times)
|
||||
|
||||
def getLatLonCoords(gridData):
|
||||
return router.getLatLonCoords(gridData)
|
||||
|
||||
def getAvailableLocationNames(request):
|
||||
"""
|
||||
Gets the available location names that match the request without actually
|
||||
requesting the data.
|
||||
|
||||
Args:
|
||||
request: the request to find matching location names for
|
||||
|
||||
Returns:
|
||||
a list of strings of available location names.
|
||||
"""
|
||||
return router.getAvailableLocationNames(request)
|
||||
|
||||
def newDataRequest():
|
||||
""""
|
||||
Creates a new instance of IDataRequest suitable for the runtime environment.
|
||||
|
||||
Returns:
|
||||
a new IDataRequest
|
||||
"""
|
||||
return router.newDataRequest()
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
# 12/10/12 njensen Initial Creation.
|
||||
# Feb 14, 2013 1614 bsteffen refactor data access framework
|
||||
# to use single request.
|
||||
# Apr 09, 2013 1871 njensen Add doc strings
|
||||
#
|
||||
#
|
||||
#
|
||||
|
@ -41,114 +42,290 @@ __all__ = [
|
|||
import abc
|
||||
|
||||
class IDataRequest(object):
|
||||
"""
|
||||
An IDataRequest to be submitted to the DataAccessLayer to retrieve data.
|
||||
"""
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def setDatatype(self, datatype):
|
||||
"""
|
||||
Sets the datatype of the request.
|
||||
|
||||
Args:
|
||||
datatype: A string of the datatype, such as "grid", "radar", "gfe", "obs"
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def addIdentifier(self, key, value):
|
||||
"""
|
||||
Adds an identifier to the request. Identifiers are specific to the
|
||||
datatype being requested.
|
||||
|
||||
Args:
|
||||
key: the string key of the identifier
|
||||
value: the value of the identifier
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def setParameters(self, params):
|
||||
"""
|
||||
Sets the parameters of data to request.
|
||||
|
||||
Args:
|
||||
params: a list of strings of parameters to request
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def setLevels(self, levels):
|
||||
"""
|
||||
Sets the levels of data to request. Not all datatypes support levels.
|
||||
|
||||
Args:
|
||||
levels: a list of strings of level abbreviations to request
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def setEnvelope(self, env):
|
||||
"""
|
||||
Sets the envelope of the request. If supported by the datatype factory,
|
||||
the data returned for the request will be constrained to only the data
|
||||
within the envelope.
|
||||
|
||||
Args:
|
||||
env: a shapely geometry
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def setLocationNames(self, locationNames):
|
||||
"""
|
||||
Sets the location names of the request.
|
||||
|
||||
Args:
|
||||
locationNames: a list of strings of location names to request
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getDatatype(self):
|
||||
"""
|
||||
Gets the datatype of the request
|
||||
|
||||
Returns:
|
||||
the datatype set on the request
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getIdentifiers(self):
|
||||
"""
|
||||
Gets the identifiers on the request
|
||||
|
||||
Returns:
|
||||
a dictionary of the identifiers
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getLevels(self):
|
||||
"""
|
||||
Gets the levels on the request
|
||||
|
||||
Returns:
|
||||
a list of strings of the levels
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getLocationNames(self):
|
||||
"""
|
||||
Gets the location names on the request
|
||||
|
||||
Returns:
|
||||
a list of strings of the location names
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getEnvelope(self):
|
||||
"""
|
||||
Gets the envelope on the request
|
||||
|
||||
Returns:
|
||||
a rectangular shapely geometry
|
||||
"""
|
||||
return
|
||||
|
||||
|
||||
|
||||
class IData(object):
|
||||
"""
|
||||
An IData representing data returned from the DataAccessLayer.
|
||||
"""
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def getAttribute(self, key):
|
||||
"""
|
||||
Gets an attribute of the data.
|
||||
|
||||
Args:
|
||||
key: the key of the attribute
|
||||
|
||||
Returns:
|
||||
the value of the attribute
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getDataTime(self):
|
||||
"""
|
||||
Gets the data time of the data.
|
||||
|
||||
Returns:
|
||||
the data time of the data, or None if no time is associated
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getLevel(self):
|
||||
"""
|
||||
Gets the level of the data.
|
||||
|
||||
Returns:
|
||||
the level of the data, or None if no level is associated
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getLocationName(self, param):
|
||||
"""
|
||||
Gets the location name of the data.
|
||||
|
||||
Returns:
|
||||
the location name of the data, or None if no location name is
|
||||
associated
|
||||
"""
|
||||
return
|
||||
|
||||
|
||||
|
||||
class IGridData(IData):
|
||||
"""
|
||||
An IData representing grid data that is returned by the DataAccessLayer.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def getParameter(self):
|
||||
"""
|
||||
Gets the parameter of the data.
|
||||
|
||||
Returns:
|
||||
the parameter of the data
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getUnit(self):
|
||||
"""
|
||||
Gets the unit of the data.
|
||||
|
||||
Returns:
|
||||
the string abbreviation of the unit, or None if no unit is associated
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getRawData(self):
|
||||
"""
|
||||
Gets the grid data as a numpy array.
|
||||
|
||||
Returns:
|
||||
a numpy array of the data
|
||||
"""
|
||||
return
|
||||
|
||||
|
||||
|
||||
class IGeometryData(IData):
|
||||
"""
|
||||
An IData representing geometry data that is returned by the DataAccessLayer.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def getGeometry(self):
|
||||
"""
|
||||
Gets the geometry of the data.
|
||||
|
||||
Returns:
|
||||
a shapely geometry
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getParameters(self):
|
||||
"""Gets the parameters of the data.
|
||||
|
||||
Returns:
|
||||
a list of strings of the parameter names
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getString(self, param):
|
||||
"""
|
||||
Gets the string value of the specified param.
|
||||
|
||||
Args:
|
||||
param: the string name of the param
|
||||
|
||||
Returns:
|
||||
the string value of the param
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getNumber(self, param):
|
||||
"""
|
||||
Gets the number value of the specified param.
|
||||
|
||||
Args:
|
||||
param: the string name of the param
|
||||
|
||||
Returns:
|
||||
the number value of the param
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getUnit(self, param):
|
||||
"""
|
||||
Gets the unit of the specified param.
|
||||
|
||||
Args:
|
||||
param: the string name of the param
|
||||
|
||||
Returns:
|
||||
the string abbreviation of the unit of the param
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getType(self, param):
|
||||
"""
|
||||
Gets the type of the param.
|
||||
|
||||
Args:
|
||||
param: the string name of the param
|
||||
|
||||
Returns:
|
||||
a string of the type of the parameter, such as
|
||||
"STRING", "INT", "LONG", "FLOAT", or "DOUBLE"
|
||||
"""
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue