pyIUDX.rs package¶
Submodules¶
pyIUDX.rs.item module¶
-
class
pyIUDX.rs.item.GeoProperty(name)[source]¶ Bases:
objectContainer class for a Geo property GeoProperty is a spatial property having further attributes such as coordinates for either a point or a polygon.
-
name= None¶ Type in case geoProperty is static
-
reset()[source]¶ Reset coordinates This is only invoked in case where this geoProperty is time varying TODO: Workaround for type
-
-
class
pyIUDX.rs.item.Item(catUrl, resourceItemId, dataModel=None)[source]¶ Bases:
objectclass for an iudx resource item
A resource item has it’s static attribute representation in a catalogue and a dynamic “data” representation in a resource server. This class presents an abstraction layer combining both
-
cat= None¶ get rs from catalogue item
Type: TODO
-
during(start, end)[source]¶ Get data during a set interval for all properties belonging to this item
Parameters: - startTime (string) – Start time
- endTime (string) – End time
Returns: numpy 2d array with 0th column as time
Return type: value (ndarray)
-
latest()[source]¶ Get latest data for all properties belonging to this item
Returns: Returns back the updated object Return type: self (object)
-
latestWith(attr, val)[source]¶ Get latest data for all properties belonging to this item with a specific attribute
This method will give latest data where an attribute is specified. For e.g attr = “ROUTE_ID”, val = “110” will give latest data for that busParameters: - attr (string) – The name of the attribute
- val (string) – The value of the attribute
Returns: Returns back the updated object
Return type: self (object)
-
quantitativeProperties= None¶ Load datamodel properties
-
reset()[source]¶ Reset data of all quantitative attributes of this item :returns: Returns back the updated object :rtype: self (object)
-
timeProperty= None¶ Read item properties
-
-
class
pyIUDX.rs.item.Items(catUrl, items=None)[source]¶ Bases:
collections.abc.MutableSequenceclass for a list of iudx resource items.
This class extends a list to provide Class Item style functionality coupled with multiprocessing pool to allow for faster data access
-
class
pyIUDX.rs.item.Property(name, properties)[source]¶ Bases:
objectContainer class for a Property
Property is an aspect of a resource item that describes it or its current value
-
class
pyIUDX.rs.item.QuantitativeProperty(obj, name, properties)[source]¶ Bases:
objectContainer class for a quantitative property QuantitativeProperty is a measureable property having further attributes such as units. Values are always indexed with time.
-
during(startTime, endTime)[source]¶ Get data during a set interval for this property :param startTime: Start time :type startTime: string :param endTime: End time :type endTime: string
Returns: numpy 2d array with 0th column as time Return type: value (ndarray)
-
latest()[source]¶ Get latest data for this property :returns: numpy 2d array with 0th column as time :rtype: value (ndarray)
-
pyIUDX.rs.rs module¶
-
class
pyIUDX.rs.rs.ResourceServer(rsUrl, cert=None, key=None)[source]¶ Bases:
object-
dispParams()[source]¶ Display rs initalization parameter
Returns: version string Return type: (rsDomain, rsPort, rsVersion) (string, string, string)
-
download(url, data)[source]¶ Use requests library to make a search request
Returns: Response body Return type: resp (object)
-
downloadData(groupId, opts=None, token=None)[source]¶ Download data from a resource server
An optional options dictionary can be passed to get more specific data. The options dictionary follows the schema: https://raw.githubusercontent.com/iudx/pyIUDX/rs/pyIUDX/rs/opts.json
Parameters: - groupId (string) – id of the resource item
- opts (Dict) – dictionary of various options
Returns: rs constructed url
Return type: url (string)
-
getData(id, opts=None, token=None)[source]¶ Get data from a resource server
An optional options dictionary can be passed to get more specific data. The options dictionary follows the schema: https://raw.githubusercontent.com/iudx/pyIUDX/rs/pyIUDX/rs/opts.json
Parameters: - id (string) – id of the resource item
- opts (Dict) – dictionary of various options
Returns: rs constructed url
Return type: url (string)
-
getDataAfter(id, time, token=None)[source]¶ Get data after a given time
Parameters: - id (string) – id of the resource item
- time (string) – Starting from
Returns: - Array with a time indexed dictionary
item corresponding to the data
Return type: data (List[Dict])
-
getDataAroundDuring(id, point, radius, startTime, endTime, token=None)[source]¶ Get data around a specific point(lat, lon) and radius(meters) and during a time
Parameters: - id (string) – id of the resource item
- point (List[Float]) – point [lat, lon]
- radius (int) – radius in meters
- startTime (string) – Starting from
- endTime (string) – Till
Returns: - Array with a time indexed dictionary
item corresponding to the data
Return type: data (List[Dict])
-
getDataBefore(id, time, token=None)[source]¶ Get data before a given time
Parameters: - id (string) – id of the resource item
- time (string) – Ending at
Returns: - Array with a time indexed dictionary
item corresponding to the data
Return type: data (List[Dict])
-
getDataDuring(id, startTime, endTime, token=None)[source]¶ Get data during a time interval
Parameters: - id (string) – id of the resource item
- startTime (string) – Starting from
- endTime (string) – Till
Returns: - Array with a time indexed dictionary
item corresponding to the data
Return type: data (List[Dict])
-
getDataValuesBetween(id, attribute, minVal, maxVal, token=None)[source]¶ Get data of an item for which an attribute is between minVal and maxVal
Parameters: - id (string) – id of the resource item
- attribute (string) – attribute name
- minVal (float) – minimum value
- maxVal (float) – maximum value
Returns: - Array with a time indexed dictionary
item corresponding to the data
Return type: data (List[Dict])
-
getDataValuesGreater(id, attribute, minVal, token=None)[source]¶ Get data of an item for which an attribute is greater than minVal
Parameters: - id (string) – id of the resource item
- attribute (string) – attribute name
- minVal (float) – minimum value
Returns: - Array with a time indexed dictionary
item corresponding to the data
Return type: data (List[Dict])
-
getDataValuesLesser(id, attribute, maxVal, token=None)[source]¶ Get data of an item for which an attribute is lesser than maxVal
Parameters: - id (string) – id of the resource item
- attribute (string) – attribute name
- maxVal (float) – maximum value
Returns: - Array with a time indexed dictionary
item corresponding to the data
Return type: data (List[Dict])
-
getDataValuesLikeDuring(id, attribute, val, startTime, endTime, token=None)[source]¶ Get data of an item for which an attribute is like value between a time
Parameters: - id (string) – id of the resource item
- attribute (string) – attribute name
- val (string) – value
Returns: - Array with a time indexed dictionary
item corresponding to the data
Return type: data (List[Dict])
-
getLatestData(id, token=None)[source]¶ Get latest data
Parameters: id (string) – id of the resource item Returns: - Array with a single dictionary
- item corresponding to the data
Return type: data (List[Dict])
-
getLatestDataAround(id, point, radius, token=None)[source]¶ Get data around a specific point(lat, lon) and radius(meters)
Parameters: - id (string) – id of the resource item
- point (List[Float]) – point [lat, lon]
- radius (int) – radius in meters
Returns: - Array with a time indexed dictionary
item corresponding to the data
Return type: data (List[Dict])
-
getLatestDataAroundLike(id, point, radius, attributeName, attributeValue, token=None)[source]¶ Get data around a specific point(lat, lon) and radius(meters) which has an attribute like
Parameters: - id (string) – id of the resource item
- point (List[Float]) – point [lat, lon]
- radius (int) – radius in meters
Returns: - Array with a time indexed dictionary
item corresponding to the data
Return type: data (List[Dict])
-
getLatestDataValuesLike(id, attribute, val, token=None)[source]¶ Get latest data of an item for which an attribute is like value
Parameters: - id (string) – id of the resource item
- attribute (string) – attribute name
- val (string) – value
Returns: - Array with a time indexed dictionary
item corresponding to the data
Return type: data (List[Dict])
-