powersimdata.utility package¶
Subpackages¶
Submodules¶
powersimdata.utility.config module¶
- class powersimdata.utility.config.Config[source]¶
Bases:
object
Base class for configuration data. It should contain all expected keys, defaulting to None when not universally applicable.
- BACKUP_DATA_ROOT_DIR = None¶
- DATA_ROOT_DIR = '/mnt/bes/pcm'¶
- ENGINE_DIR = None¶
- EXECUTE_DIR = 'tmp'¶
- INPUT_DIR = ('data', 'input')¶
- LOCAL_DIR = '/root/ScenarioData/'¶
- MODEL_DIR = None¶
- OUTPUT_DIR = ('data', 'output')¶
- SERVER_ADDRESS = None¶
- SERVER_SSH_PORT = None¶
- class powersimdata.utility.config.ContainerConfig[source]¶
Bases:
Config
Values specific to containerized environment
- SERVER_ADDRESS = 'reisejl'¶
- class powersimdata.utility.config.DeploymentMode[source]¶
Bases:
object
Constants representing the type of installation being used
- CONFIG_MAP = {'CONTAINER': <class 'powersimdata.utility.config.ContainerConfig'>, 'LOCAL': <class 'powersimdata.utility.config.LocalConfig'>, 'SERVER': <class 'powersimdata.utility.config.ServerConfig'>}¶
- Container = 'CONTAINER'¶
- Local = 'LOCAL'¶
- Server = 'SERVER'¶
- class powersimdata.utility.config.LocalConfig[source]¶
Bases:
Config
Values specific to native installation
- DATA_ROOT_DIR = '/root/ScenarioData/'¶
- ENGINE_DIR = None¶
- class powersimdata.utility.config.ServerConfig[source]¶
Bases:
Config
Values specific to internal client/server usage
- MODEL_DIR = '/home/bes/pcm'¶
- SERVER_ADDRESS = 'becompute01.gatesventures.com'¶
- SERVER_SSH_PORT = 22¶
powersimdata.utility.distance module¶
- powersimdata.utility.distance.angular_distance(uv1, uv2)[source]¶
Calculate the angular distance between two vectors.
- powersimdata.utility.distance.find_closest_neighbor(point, neighbors)[source]¶
Locates the closest neighbor.
- Parameters:
point (tuple) – (lon, lat) in degrees.
neighbors (list) – each element of the list are the (lon, lat) of potential neighbor.
- Returns:
(int) – id of the closest neighbor
- powersimdata.utility.distance.great_circle_distance(x)[source]¶
Calculates distance between two sites.
- Parameters:
x (pandas.dataFrame) – start and end point coordinates of branches.
- Returns:
(float) – length of branch (in km.).
- powersimdata.utility.distance.haversine(point1, point2)[source]¶
Given two lat/long pairs, return distance in miles.
- Parameters:
point1 (tuple) – first point, (lat, long) in degrees.
point2 (tuple) – second point, (lat, long) in degrees.
- Returns:
(float) – distance in miles.
- powersimdata.utility.distance.ll2uv(lon, lat)[source]¶
Convert (longitude, latitude) to unit vector.
- Parameters:
lon (float) – longitude of the site (in deg.) measured eastward from Greenwich, UK.
lat (float) – latitude of the site (in deg.). Equator is the zero point.
- Returns:
(list) – 3-components (x,y,z) unit vector.
powersimdata.utility.helpers module¶
- class powersimdata.utility.helpers.CacheKeyBuilder(*args, **kwargs)[source]¶
Bases:
object
Helper class to generate cache keys
- Parameters:
args – variable length arguments from which to build a key
- class powersimdata.utility.helpers.MemoryCache[source]¶
Bases:
object
Wrapper around a dict object that exposes a cache interface. Users should create a separate instance for each distinct use case.
- get(key)[source]¶
Retrieve the value associated with key if it exists.
- Parameters:
key (tuple) – the cache key
- Returns:
(Any or NoneType) – the cached value if found, or None
- powersimdata.utility.helpers.cache_key(*args, **kwargs)[source]¶
Creates a cache key from the given args. The user should ensure that the range of inputs will not result in key collisions.
- Parameters:
args – variable length argument list
- Returns:
(tuple) – a tuple containing the input in heirarchical structure