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 the dynamicserialize types like Date and Timestamp. Raises TypeError
if no conversion can be performed. if no conversion can be performed.
Args: :param timeArg: a python object representing a date and time. Supported
timeArg: a python object representing a date and time. Supported
types include datetime, struct_time, float, int, long and the types include datetime, struct_time, float, int, long and the
dynamicserialize types Date and Timestamp. dynamicserialize types Date and Timestamp.
Returns: :returns: A datetime that represents the same date/time as the passed in object.
A datetime that represents the same date/time as the passed in object.
""" """
if isinstance(timeArg, datetime.datetime): if isinstance(timeArg, datetime.datetime):
return timeArg return timeArg
@ -90,12 +88,10 @@ def constructTimeRange(*args):
Builds a python dynamicserialize TimeRange object from the given Builds a python dynamicserialize TimeRange object from the given
arguments. arguments.
Args: :param args*: must be a TimeRange or a pair of objects that can be
args*: must be a TimeRange or a pair of objects that can be
converted to a datetime via convertToDateTime(). converted to a datetime via convertToDateTime().
Returns: :returns: A TimeRange.
A TimeRange.
""" """
if len(args) == 1 and isinstance(args[0], 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 from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.radar.request import GetRadarDataRecordRequest
def get_datetime_str(record): 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" return str(record.getDataTime())[0:19].replace(" ","_") + ".0"
def get_data_type(azdat): def get_data_type(azdat):
"""
Get the radar file type (radial or raster).
:param azdat: Boolean.
:returns: Radial or raster.
"""
if azdat: if azdat:
dattyp = "radial" dattyp = "radial"
else : else :

View file

@ -58,18 +58,26 @@ else:
router = ThriftClientRouter.ThriftClientRouter(THRIFT_HOST) router = ThriftClientRouter.ThriftClientRouter(THRIFT_HOST)
USING_NATIVE_THRIFT = True 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): def getAvailableTimes(request, refTimeOnly=False):
""" """
Get the times of available data to the request. Get the times of available data to the request.
Args: :param request: the IDataRequest to get data for
request: the IDataRequest to get data for :param refTimeOnly: optional, use True if only unique refTimes should be returned (without a forecastHr)
refTimeOnly: optional, use True if only unique refTimes should be
returned (without a forecastHr)
Returns: :returns: a list of DataTimes
a list of DataTimes
""" """
return router.getAvailableTimes(request, refTimeOnly) return router.getAvailableTimes(request, refTimeOnly)
@ -79,13 +87,10 @@ def getGridData(request, times=[]):
combination of parameter, level, and dataTime will be returned as a combination of parameter, level, and dataTime will be returned as a
separate IGridData. separate IGridData.
Args: :param request: the IDataRequest to get data for
request: the IDataRequest to get data for :param times: a list of DataTimes, a TimeRange, or None if the data is time agnostic
times: a list of DataTimes, a TimeRange, or None if the data is time
agnostic
Returns: :returns: a list of IGridData
a list of IGridData
""" """
return router.getGridData(request, times) 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 Each combination of geometry, level, and dataTime will be returned as a
separate IGeometryData. separate IGeometryData.
Args: :param request: the IDataRequest to get data for
request: the IDataRequest to get data for :param times: a list of DataTimes, a TimeRange, or None if the data is time agnostic
times: a list of DataTimes, a TimeRange, or None if the data is time
agnostic
Returns: :returns: a list of IGeometryData
a list of IGeometryData
""" """
return router.getGeometryData(request, times) return router.getGeometryData(request, times)
@ -110,11 +112,9 @@ def getAvailableLocationNames(request):
Gets the available location names that match the request without actually Gets the available location names that match the request without actually
requesting the data. requesting the data.
Args: :param request: the request to find matching location names for
request: the request to find matching location names for
Returns: :returns: a list of strings of available location names.
a list of strings of available location names.
""" """
return router.getAvailableLocationNames(request) return router.getAvailableLocationNames(request)
@ -123,11 +123,9 @@ def getAvailableParameters(request):
Gets the available parameters names that match the request without actually Gets the available parameters names that match the request without actually
requesting the data. requesting the data.
Args: :param request: the request to find matching parameter names for
request: the request to find matching parameter names for
Returns: :returns: a list of strings of available parameter names.
a list of strings of available parameter names.
""" """
return router.getAvailableParameters(request) return router.getAvailableParameters(request)
@ -136,11 +134,9 @@ def getAvailableLevels(request):
Gets the available levels that match the request without actually Gets the available levels that match the request without actually
requesting the data. requesting the data.
Args: :param request: the request to find matching levels for
request: the request to find matching levels for
Returns: :returns: a list of strings of available levels.
a list of strings of available levels.
""" """
return router.getAvailableLevels(request) return router.getAvailableLevels(request)
@ -149,11 +145,9 @@ def getRequiredIdentifiers(datatype):
Gets the required identifiers for this datatype. These identifiers Gets the required identifiers for this datatype. These identifiers
must be set on a request for the request of this datatype to succeed. must be set on a request for the request of this datatype to succeed.
Args: :param datatype: the datatype to find required identifiers for
datatype: the datatype to find required identifiers for
Returns: :returns: a list of strings of required identifiers
a list of strings of required identifiers
""" """
return router.getRequiredIdentifiers(datatype) return router.getRequiredIdentifiers(datatype)
@ -161,29 +155,25 @@ def getOptionalIdentifiers(datatype):
""" """
Gets the optional identifiers for this datatype. Gets the optional identifiers for this datatype.
Args: :param datatype: the datatype to find optional identifiers for
datatype: the datatype to find optional identifiers for
Returns: :returns: a list of strings of optional identifiers
a list of strings of optional identifiers
""" """
return router.getOptionalIdentifiers(datatype) return router.getOptionalIdentifiers(datatype)
def newDataRequest(datatype=None, **kwargs): def newDataRequest(datatype=None, **kwargs):
"""" """
Creates a new instance of IDataRequest suitable for the runtime environment. Creates a new instance of IDataRequest suitable for the runtime environment.
All args are optional and exist solely for convenience. All args are optional and exist solely for convenience.
Args: :param datatype: the datatype to create a request for
datatype: the datatype to create a request for :param parameters: a list of parameters to set on the request
parameters: a list of parameters to set on the request :param levels: a list of levels to set on the request
levels: a list of levels to set on the request :param locationNames: a list of locationNames to set on the request
locationNames: a list of locationNames to set on the request :param envelope: an envelope to limit the request
envelope: an envelope to limit the request :param kwargs: any leftover kwargs will be set as identifiers
**kwargs: any leftover kwargs will be set as identifiers
Returns: :returns: a new IDataRequest
a new IDataRequest
""" """
return router.newDataRequest(datatype, **kwargs) return router.newDataRequest(datatype, **kwargs)
@ -191,8 +181,7 @@ def getSupportedDatatypes():
""" """
Gets the datatypes that are supported by the framework Gets the datatypes that are supported by the framework
Returns: :returns: a list of strings of supported datatypes
a list of strings of supported datatypes
""" """
return router.getSupportedDatatypes() return router.getSupportedDatatypes()
@ -203,8 +192,7 @@ def changeEDEXHost(newHostName):
works if using the native Python client implementation, otherwise, this works if using the native Python client implementation, otherwise, this
method will throw a TypeError. method will throw a TypeError.
Args: :param newHostHame: the EDEX host to connect to
newHostHame: the EDEX host to connect to
""" """
if USING_NATIVE_THRIFT: if USING_NATIVE_THRIFT:
global THRIFT_HOST 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): def getSounding(modelName, weatherElements, levels, samplePoint, refTime=None, timeRange=None):
"""" """
Performs a series of Data Access Framework requests to retrieve a sounding object Performs a series of Data Access Framework requests to retrieve a sounding object
based on the specified request parameters. based on the specified request parameters.
Args: :param modelName: the grid model datasetid to use as the basis of the sounding.
modelName: the grid model datasetid to use as the basis of the sounding. :param weatherElements: a list of parameters to return in the sounding.
weatherElements: a list of parameters to return in the sounding. :param levels: a list of levels to sample the given weather elements at
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.
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.
refTime: (optional) the grid model reference time to use for the sounding. :param timeRange: (optional) a TimeRange to specify which forecast hours to use. If not specified, will default to all forecast hours.
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.
Returns: :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.
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) = \ (locationNames, parameters, levels, envelope, refTime, timeRange) = \
@ -87,8 +81,7 @@ def setEDEXHost(host):
""" """
Changes the EDEX host the Data Access Framework is communicating with. Changes the EDEX host the Data Access Framework is communicating with.
Args: :param host: the EDEX host to connect to
host: the EDEX host to connect to
""" """
if host: if host:
@ -174,8 +167,7 @@ class _SoundingCube(object):
""" """
Returns the valid times for this sounding. Returns the valid times for this sounding.
Returns: :returns: A list containing the valid DataTimes for this sounding in order.
A list containing the valid DataTimes for this sounding in order.
""" """
return self._sortedTimes return self._sortedTimes
@ -213,8 +205,7 @@ class _SoundingTimeLayer(object):
""" """
Returns the DataTime for this sounding cube layer. Returns the DataTime for this sounding cube layer.
Returns: :returns: The DataTime for this sounding layer.
The DataTime for this sounding layer.
""" """
return self._dataTime return self._dataTime
@ -222,9 +213,7 @@ class _SoundingTimeLayer(object):
""" """
Returns the valid levels for this sounding. Returns the valid levels for this sounding.
Returns: :returns: A list containing the valid levels for this sounding in order of closest to surface to highest from surface.
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 = [Level(level) for level in list(self._dataDict.keys())]
sortedLevels.sort() sortedLevels.sort()
@ -259,8 +248,7 @@ class _SoundingTimeAndLevelLayer(object):
""" """
Returns the level for this sounding cube layer. Returns the level for this sounding cube layer.
Returns: :returns: The level for this sounding layer.
The level for this sounding layer.
""" """
return self._level return self._level
@ -268,8 +256,7 @@ class _SoundingTimeAndLevelLayer(object):
""" """
Returns the valid parameters for this sounding. Returns the valid parameters for this sounding.
Returns: :returns: A list containing the valid parameter names.
A list containing the valid parameter names.
""" """
return list(self._parameters.keys()) 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 cube layer.
Returns: :returns: The DataTime for this sounding layer.
The DataTime for this sounding layer.
""" """
return self._time return self._time

View file

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