Utilities

json_utils

Helper functions for JSON objects.

helios.utilities.json_utils.merge_json(data, keys)[source]

Merge JSON fields into a single list.

Keys can either be a single string or a list of strings signifying a chain of “keys” into the dictionary.

Parameters:
  • data (list) – Dictionary to merge data from.
  • keys (str or sequence of strs) – A chain of keys into the dictionary to get to the field that will be merged.
Returns:

Merged values.

Return type:

list

helios.utilities.json_utils.read_json_file(json_file, **kwargs)[source]

Read a json file.

Parameters:
  • json_file (str) – Full path to JSON file.
  • **kwargs – Any keyword argument from the json.load method.
Returns:

JSON formatted dictionary.

Return type:

dict

helios.utilities.json_utils.read_json_string(json_string, **kwargs)[source]

Convert JSON formatted string to JSON.

Parameters:
  • json_string (str) – JSON formatted string.
  • **kwargs – Any keyword argument from the json.loads method.
Returns:

JSON formatted dictionary.

Return type:

dict

helios.utilities.json_utils.write_json(json_dict, file_name, **kwargs)[source]

Write JSON dictionary to file.

Parameters:
  • json_dict (dict) – JSON formatted dictionary.
  • file_name (str) – Output file name.
  • **kwargs – Any keyword argument from the json.dump method.
Returns:

None

parsing_utils

Helper functions for paths and URLs.

helios.utilities.parsing_utils.parse_camera(data)[source]

Parse camera name from a URL or image name.

Parameters:data (str) – Image URL or name.
Returns:Camera name.
Return type:str
helios.utilities.parsing_utils.parse_image_name(url)[source]

Parse image name from a URL.

Parameters:url (str) – Image URL.
Returns:Image name.
Return type:str
helios.utilities.parsing_utils.parse_time(data)[source]

Parse time from a URL or image name.

Parameters:data (str) – Image URL or name.
Returns:The parsed time as a datetime object.
Return type:datetime.datetime
helios.utilities.parsing_utils.parse_url(url)[source]

Parse a URL into its components.

Parameters:url (str) – Image URL.
Returns:Parsed URL.
Return type:urllib.parse.ParseResult

data_utils

Utilities for working with SDK results.

helios.utilities.data_utils.concatenate_feature_collections(*args)[source]

Concatenates FeatureCollections.

import helios
from helios.utilities.data_utils import concatenate_feature_collections

cameras = helios.client('cameras')
results1, failed = cameras.index(state='new york')
results2, failed = cameras.index(state='maryland')
combined = concatenate_feature_collections((results1, results2))
Parameters:args – (fc0, fc1, fc2, …) FeatureCollections to be combined. All FeatureCollections must be of the same type.
Returns:FeatureCollection of the same API type as the input.
Return type:FeatureCollection