pyIUDX.rs package

Submodules

pyIUDX.rs.item module

class pyIUDX.rs.item.GeoProperty(name)[source]

Bases: object

Container 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

setDynamicGeo(time, coordinates)[source]

Set Value for this geoProperty

To be used only when this geoProperty is time varying

Parameters:
  • time (datetime.datetime()) – Time index
  • value (float) – Value
setStaticGeo(geoProperty)[source]

Static points

sort()[source]

Sort time series

class pyIUDX.rs.item.Item(catUrl, rsUrl, resourceItemId, dataModel=None)[source]

Bases: object

class 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 bus
Parameters:
  • attr (string) – The name of the attribute
  • val (string) – The value of the attribute
Returns:

Returns back the updated object

Return type:

self (object)

num_time_indices = None

Read item properties

populateValue(data)[source]

Helper function to populate a QuantitativeProperty’s value array

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)

valueBetween(attrName, minval, maxVal)[source]

Get all data during which this attribute was between min and max val

Parameters:
  • attrName (string) – name of the attribute
  • minVal (int) – minimum value
  • minVal – maximum value
class pyIUDX.rs.item.Items(catUrl, rsUrl, items=None)[source]

Bases: collections.abc.MutableSequence

class 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

during(startTime, endTime)[source]

Get data during a set interval

For all resource items of this instance and 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)

getDuring(obj, startTime, endTime)[source]

Multiprocessed job

getLatest(obj)[source]

Multiprocessed job

initItem(catUrl, rsUrl, item, objList)[source]

Multiprocessed job

insert(ii, val)[source]

S.insert(index, value) – insert value before index

latest()[source]

Get latest data

For all resource items of this instance and for all properties belonging to this item

Returns:Returns back the updated object
Return type:self (object)
class pyIUDX.rs.item.Property(name, properties)[source]

Bases: object

Container class for a Property

Property is an aspect of a resource item that describes it or its current value

reset()[source]
setValue(value, time=None)[source]

Set State for this Property :param value: Value :type value: string :param time: Time index :type time: datetime.datetime()

sort()[source]

Sort time series

class pyIUDX.rs.item.QuantitativeProperty(obj, name, properties)[source]

Bases: object

Container 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)

reset(num_time_indices)[source]

Reset value of this Property

setValue(time, value)[source]

Set Value for this Property :param time: Time index :type time: datetime.datetime() :param value: Value :type value: float

sort(updatedAtIdx)[source]

Sort time series

valueBetween(minval, maxVal)[source]

Get all data during which this attribute was between min and max val :param minVal: minimum value :type minVal: int :param minVal: maximum value :type minVal: int

Returns:numpy 2d array with 0th column as time
Return type: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])

getStatus(id, token=None)[source]

Get Status of a resource item

Parameters:id (string) – id of the resource item
Returns:True if up
Return type:status (bool)

TODO:

getUrl()[source]

Get rs constructed url

Returns:rs constructed url
Return type:url (string)
search(url, data)[source]

Use requests library to make a search request

Returns:Response body
Return type:resp (object)

Module contents