reformat method descriptions for autodoc generation

This commit is contained in:
Michael James 2016-10-21 17:07:09 -05:00
parent 6b1cf47beb
commit 60d1027d9f
5 changed files with 108 additions and 155 deletions

View file

@ -49,13 +49,11 @@ def convertToDateTime(timeArg):
the dynamicserialize types like Date and Timestamp. Raises TypeError
if no conversion can be performed.
Args:
timeArg: a python object representing a date and time. Supported
types include datetime, struct_time, float, int, long and the
dynamicserialize types Date and Timestamp.
:param timeArg: a python object representing a date and time. Supported
types include datetime, struct_time, float, int, long and the
dynamicserialize types Date and Timestamp.
Returns:
A datetime that represents the same date/time as the passed in object.
:returns: A datetime that represents the same date/time as the passed in object.
"""
if isinstance(timeArg, datetime.datetime):
return timeArg
@ -90,12 +88,10 @@ def constructTimeRange(*args):
Builds a python dynamicserialize TimeRange object from the given
arguments.
Args:
args*: must be a TimeRange or a pair of objects that can be
converted to a datetime via convertToDateTime().
:param args*: must be a TimeRange or a pair of objects that can be
converted to a datetime via convertToDateTime().
Returns:
A TimeRange.
:returns: A TimeRange.
"""
if len(args) == 1 and isinstance(args[0], TimeRange):

View file

@ -44,9 +44,23 @@ from dynamicserialize.dstypes.com.raytheon.uf.common.time import TimeRange
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.radar.request import GetRadarDataRecordRequest
def get_datetime_str(record):
"""
Get the datetime string for a record.
:param record: the record to get data for.
:returns: datetime string.
"""
return str(record.getDataTime())[0:19].replace(" ","_") + ".0"
def get_data_type(azdat):
"""
Get the radar file type (radial or raster).
:param azdat: Boolean.
:returns: Radial or raster.
"""
if azdat:
dattyp = "radial"
else :

View file

@ -58,18 +58,26 @@ else:
router = ThriftClientRouter.ThriftClientRouter(THRIFT_HOST)
USING_NATIVE_THRIFT = True
def getForecastCycle(cycle, times):
"""
:param cycle: Forecast cycle reference time
:param times: All available times/cycles
:return: DataTime array for a single forecast run
"""
forecast_run = []
for time in times:
if time.getRefTime() == cycle.getRefTime():
forecast_run.append(time)
return forecast_run
def getAvailableTimes(request, refTimeOnly=False):
"""
Get the times of available data to the request.
Args:
request: the IDataRequest to get data for
refTimeOnly: optional, use True if only unique refTimes should be
returned (without a forecastHr)
:param request: the IDataRequest to get data for
:param refTimeOnly: optional, use True if only unique refTimes should be returned (without a forecastHr)
Returns:
a list of DataTimes
:returns: a list of DataTimes
"""
return router.getAvailableTimes(request, refTimeOnly)
@ -79,13 +87,10 @@ def getGridData(request, times=[]):
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
:param request: the IDataRequest to get data for
:param times: a list of DataTimes, a TimeRange, or None if the data is time agnostic
Returns:
a list of IGridData
:returns: a list of IGridData
"""
return router.getGridData(request, times)
@ -95,13 +100,10 @@ def getGeometryData(request, 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
:param request: the IDataRequest to get data for
:param times: a list of DataTimes, a TimeRange, or None if the data is time agnostic
Returns:
a list of IGeometryData
:returns: a list of IGeometryData
"""
return router.getGeometryData(request, times)
@ -110,11 +112,9 @@ 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
:param request: the request to find matching location names for
Returns:
a list of strings of available location names.
:returns: a list of strings of available location names.
"""
return router.getAvailableLocationNames(request)
@ -123,11 +123,9 @@ def getAvailableParameters(request):
Gets the available parameters names that match the request without actually
requesting the data.
Args:
request: the request to find matching parameter names for
:param request: the request to find matching parameter names for
Returns:
a list of strings of available parameter names.
:returns: a list of strings of available parameter names.
"""
return router.getAvailableParameters(request)
@ -136,11 +134,9 @@ def getAvailableLevels(request):
Gets the available levels that match the request without actually
requesting the data.
Args:
request: the request to find matching levels for
:param request: the request to find matching levels for
Returns:
a list of strings of available levels.
:returns: a list of strings of available levels.
"""
return router.getAvailableLevels(request)
@ -149,11 +145,9 @@ def getRequiredIdentifiers(datatype):
Gets the required identifiers for this datatype. These identifiers
must be set on a request for the request of this datatype to succeed.
Args:
datatype: the datatype to find required identifiers for
:param datatype: the datatype to find required identifiers for
Returns:
a list of strings of required identifiers
:returns: a list of strings of required identifiers
"""
return router.getRequiredIdentifiers(datatype)
@ -161,29 +155,25 @@ def getOptionalIdentifiers(datatype):
"""
Gets the optional identifiers for this datatype.
Args:
datatype: the datatype to find optional identifiers for
:param datatype: the datatype to find optional identifiers for
Returns:
a list of strings of optional identifiers
:returns: a list of strings of optional identifiers
"""
return router.getOptionalIdentifiers(datatype)
def newDataRequest(datatype=None, **kwargs):
""""
"""
Creates a new instance of IDataRequest suitable for the runtime environment.
All args are optional and exist solely for convenience.
Args:
datatype: the datatype to create a request for
parameters: a list of parameters to set on the request
levels: a list of levels to set on the request
locationNames: a list of locationNames to set on the request
envelope: an envelope to limit the request
**kwargs: any leftover kwargs will be set as identifiers
:param datatype: the datatype to create a request for
:param parameters: a list of parameters to set on the request
:param levels: a list of levels to set on the request
:param locationNames: a list of locationNames to set on the request
:param envelope: an envelope to limit the request
:param kwargs: any leftover kwargs will be set as identifiers
Returns:
a new IDataRequest
:returns: a new IDataRequest
"""
return router.newDataRequest(datatype, **kwargs)
@ -191,8 +181,7 @@ def getSupportedDatatypes():
"""
Gets the datatypes that are supported by the framework
Returns:
a list of strings of supported datatypes
:returns: a list of strings of supported datatypes
"""
return router.getSupportedDatatypes()
@ -203,8 +192,7 @@ def changeEDEXHost(newHostName):
works if using the native Python client implementation, otherwise, this
method will throw a TypeError.
Args:
newHostHame: the EDEX host to connect to
:param newHostHame: the EDEX host to connect to
"""
if USING_NATIVE_THRIFT:
global THRIFT_HOST

View file

@ -42,24 +42,18 @@ from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import Lev
def getSounding(modelName, weatherElements, levels, samplePoint, refTime=None, timeRange=None):
""""
"""
Performs a series of Data Access Framework requests to retrieve a sounding object
based on the specified request parameters.
Args:
modelName: the grid model datasetid to use as the basis of the sounding.
weatherElements: a list of parameters to return in the sounding.
levels: a list of levels to sample the given weather elements at
samplePoint: a lat/lon pair to perform the sampling of data at.
refTime: (optional) the grid model reference time to use for the sounding.
If not specified, the latest ref time in the system will be used.
timeRange: (optional) a TimeRange to specify which forecast hours to use.
If not specified, will default to all forecast hours.
:param modelName: the grid model datasetid to use as the basis of the sounding.
:param weatherElements: a list of parameters to return in the sounding.
:param levels: a list of levels to sample the given weather elements at
:param samplePoint: a lat/lon pair to perform the sampling of data at.
:param refTime: (optional) the grid model reference time to use for the sounding. If not specified, the latest ref time in the system will be used.
:param timeRange: (optional) a TimeRange to specify which forecast hours to use. If not specified, will default to all forecast hours.
Returns:
A _SoundingCube instance, which acts a 3-tiered dictionary, keyed
by DataTime, then by level and finally by weather element. If no
data is available for the given request parameters, None is returned.
:returns: A _SoundingCube instance, which acts a 3-tiered dictionary, keyed by DataTime, then by level and finally by weather element. If no data is available for the given request parameters, None is returned.
"""
(locationNames, parameters, levels, envelope, refTime, timeRange) = \
@ -87,8 +81,7 @@ def setEDEXHost(host):
"""
Changes the EDEX host the Data Access Framework is communicating with.
Args:
host: the EDEX host to connect to
:param host: the EDEX host to connect to
"""
if host:
@ -174,8 +167,7 @@ class _SoundingCube(object):
"""
Returns the valid times for this sounding.
Returns:
A list containing the valid DataTimes for this sounding in order.
:returns: A list containing the valid DataTimes for this sounding in order.
"""
return self._sortedTimes
@ -213,8 +205,7 @@ class _SoundingTimeLayer(object):
"""
Returns the DataTime for this sounding cube layer.
Returns:
The DataTime for this sounding layer.
:returns: The DataTime for this sounding layer.
"""
return self._dataTime
@ -222,9 +213,7 @@ class _SoundingTimeLayer(object):
"""
Returns the valid levels for this sounding.
Returns:
A list containing the valid levels for this sounding in order of
closest to surface to highest from surface.
:returns: A list containing the valid levels for this sounding in order of closest to surface to highest from surface.
"""
sortedLevels = [Level(level) for level in list(self._dataDict.keys())]
sortedLevels.sort()
@ -259,8 +248,7 @@ class _SoundingTimeAndLevelLayer(object):
"""
Returns the level for this sounding cube layer.
Returns:
The level for this sounding layer.
:returns: The level for this sounding layer.
"""
return self._level
@ -268,8 +256,7 @@ class _SoundingTimeAndLevelLayer(object):
"""
Returns the valid parameters for this sounding.
Returns:
A list containing the valid parameter names.
:returns: A list containing the valid parameter names.
"""
return list(self._parameters.keys())
@ -277,7 +264,6 @@ class _SoundingTimeAndLevelLayer(object):
"""
Returns the DataTime for this sounding cube layer.
Returns:
The DataTime for this sounding layer.
:returns: The DataTime for this sounding layer.
"""
return self._time

View file

@ -52,8 +52,7 @@ class IDataRequest(with_metaclass(abc.ABCMeta, object)):
"""
Sets the datatype of the request.
Args:
datatype: A string of the datatype, such as "grid", "radar", "gfe", "obs"
:param datatype: A string of the datatype, such as "grid", "radar", "gfe", "obs"
"""
return
@ -63,9 +62,8 @@ class IDataRequest(with_metaclass(abc.ABCMeta, object)):
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
:param key: the string key of the identifier
:param value: the value of the identifier
"""
return
@ -74,8 +72,7 @@ class IDataRequest(with_metaclass(abc.ABCMeta, object)):
"""
Sets the parameters of data to request.
Args:
params: a list of strings of parameters to request
:param params: a list of strings of parameters to request
"""
return
@ -84,8 +81,7 @@ class IDataRequest(with_metaclass(abc.ABCMeta, object)):
"""
Sets the levels of data to request. Not all datatypes support levels.
Args:
levels: a list of strings of level abbreviations to request
:param levels: a list of strings of level abbreviations to request
"""
return
@ -96,8 +92,7 @@ class IDataRequest(with_metaclass(abc.ABCMeta, object)):
the data returned for the request will be constrained to only the data
within the envelope.
Args:
env: a shapely geometry
:param env: a shapely geometry
"""
return
@ -106,7 +101,6 @@ class IDataRequest(with_metaclass(abc.ABCMeta, object)):
"""
Sets the location names of the request.
Args:
locationNames: a list of strings of location names to request
"""
return
@ -116,8 +110,7 @@ class IDataRequest(with_metaclass(abc.ABCMeta, object)):
"""
Gets the datatype of the request
Returns:
the datatype set on the request
:returns: the datatype set on the request
"""
return
@ -126,8 +119,7 @@ class IDataRequest(with_metaclass(abc.ABCMeta, object)):
"""
Gets the identifiers on the request
Returns:
a dictionary of the identifiers
:returns: a dictionary of the identifiers
"""
return
@ -136,8 +128,7 @@ class IDataRequest(with_metaclass(abc.ABCMeta, object)):
"""
Gets the levels on the request
Returns:
a list of strings of the levels
:returns: a list of strings of the levels
"""
return
@ -146,8 +137,7 @@ class IDataRequest(with_metaclass(abc.ABCMeta, object)):
"""
Gets the location names on the request
Returns:
a list of strings of the location names
:returns: a list of strings of the location names
"""
return
@ -156,8 +146,7 @@ class IDataRequest(with_metaclass(abc.ABCMeta, object)):
"""
Gets the envelope on the request
Returns:
a rectangular shapely geometry
:returns: a rectangular shapely geometry
"""
return
@ -173,11 +162,9 @@ class IData(with_metaclass(abc.ABCMeta, object)):
"""
Gets an attribute of the data.
Args:
key: the key of the attribute
:param key: the key of the attribute
Returns:
the value of the attribute
:returns: the value of the attribute
"""
return
@ -186,8 +173,7 @@ class IData(with_metaclass(abc.ABCMeta, object)):
"""
Gets the valid attributes for the data.
Returns:
a list of strings of the attribute names
:returns: a list of strings of the attribute names
"""
return
@ -196,8 +182,7 @@ class IData(with_metaclass(abc.ABCMeta, object)):
"""
Gets the data time of the data.
Returns:
the data time of the data, or None if no time is associated
:returns: the data time of the data, or None if no time is associated
"""
return
@ -206,8 +191,7 @@ class IData(with_metaclass(abc.ABCMeta, object)):
"""
Gets the level of the data.
Returns:
the level of the data, or None if no level is associated
:returns: the level of the data, or None if no level is associated
"""
return
@ -216,8 +200,7 @@ class IData(with_metaclass(abc.ABCMeta, object)):
"""
Gets the location name of the data.
Returns:
the location name of the data, or None if no location name is
:returns: the location name of the data, or None if no location name is
associated
"""
return
@ -234,8 +217,7 @@ class IGridData(IData):
"""
Gets the parameter of the data.
Returns:
the parameter of the data
:returns: the parameter of the data
"""
return
@ -244,8 +226,7 @@ class IGridData(IData):
"""
Gets the unit of the data.
Returns:
the string abbreviation of the unit, or None if no unit is associated
:returns: the string abbreviation of the unit, or None if no unit is associated
"""
return
@ -254,8 +235,7 @@ class IGridData(IData):
"""
Gets the grid data as a numpy array.
Returns:
a numpy array of the data
:returns: a numpy array of the data
"""
return
@ -264,8 +244,7 @@ class IGridData(IData):
"""
Gets the lat/lon coordinates of the grid data.
Returns:
a tuple where the first element is a numpy array of lons, and the
:returns: a tuple where the first element is a numpy array of lons, and the
second element is a numpy array of lats
"""
return
@ -282,8 +261,7 @@ class IGeometryData(IData):
"""
Gets the geometry of the data.
Returns:
a shapely geometry
:returns: a shapely geometry
"""
return
@ -291,8 +269,7 @@ class IGeometryData(IData):
def getParameters(self):
"""Gets the parameters of the data.
Returns:
a list of strings of the parameter names
:returns: a list of strings of the parameter names
"""
return
@ -301,11 +278,9 @@ class IGeometryData(IData):
"""
Gets the string value of the specified param.
Args:
param: the string name of the param
:param param: the string name of the param
Returns:
the string value of the param
:returns: the string value of the param
"""
return
@ -314,11 +289,9 @@ class IGeometryData(IData):
"""
Gets the number value of the specified param.
Args:
param: the string name of the param
:param param: the string name of the param
Returns:
the number value of the param
:returns: the number value of the param
"""
return
@ -327,11 +300,9 @@ class IGeometryData(IData):
"""
Gets the unit of the specified param.
Args:
param: the string name of the param
:param param: the string name of the param
Returns:
the string abbreviation of the unit of the param
:returns: the string abbreviation of the unit of the param
"""
return
@ -340,12 +311,10 @@ class IGeometryData(IData):
"""
Gets the type of the param.
Args:
param: the string name of the param
:param param: the string name of the param
Returns:
a string of the type of the parameter, such as
"STRING", "INT", "LONG", "FLOAT", or "DOUBLE"
:returns: a string of the type of the parameter, such as
"STRING", "INT", "LONG", "FLOAT", or "DOUBLE"
"""
return