Green Button Package¶
Submodules¶
seed.green_button.xml_importer module¶
Takes a value, returns that value if it is not a string and is an Iterable, and returns a list containing that value if it is not an Iterable or if it is a string. Returns None when val is None.
Parameters: val – any value Returns: list containing val or val if it is Iterable and not a string.
Extracts information about a building from a Green Button XML file.
Parameters: xml_data – dictionary returned by xmltodict.parse when called on the contents of a Green Button XML file Returns: dictionary - building information for a Green Button XML file
- information describing the meter used for collection
- list of time series meter reading data
Create a BuildingSnapshot, a CanonicalBuilding, and a Meter. Then, create TimeSeries models for each meter reading in data.
Parameters: - data – dictionary of building data from a Green Button XML file in the form returned by xml_importer.building_data
- import_file – ImportFile referencing the original xml file; needed for linking to BuildingSnapshot and for determining super_organization
Returns: the created CanonicalBuilding
Returns the seed model energy type corresponding to the green button service category.
Parameters: service_category – int that is a green button service_category (string args will be converted to integers) Returns: int in seed.models.ENERGY_TYPES
Returns the seed model energy unit corresponding to the green button uom.
Parameters: uom – int that is the green button uom number corresponding to the energy units supported by the green button schema (string args will be converted to integers) Returns: int in seed.models.ENERGY_UNITS
Given an import_file referencing a raw Green Button XML file, extracts building and time series information from the file and constructs required database models.
Parameters: import_file – a seed.models.ImportFile instance representing a Green Button XML file that has been previously uploaded Returns: the created CanonicalBuilding Inst.
Takes a dictionary containing the contents of an IntervalBlock node from a Green Button XML file and returns a dictionary containing the start_time of the time series collection, the duration of the collection, and a list of readings containing the time series data from a meter.
Parameters: ib_xml_data – dictionary of the contents of an IntervalBlock from a Green Button XML file Returns: dictionary containing meta data about an entire collection period and a list of the specific meter readings
Takes a dictionary representing the contents of an IntervalReading XML node and pulls out data for a single time series reading. The dictionary will be a sub-dictionary of the dictionary returned by xmltodict.parse when called on a Green Button XML file. Returns a flat dictionary containing the interval data.
Parameters: reading_xml_data – dictionary of IntervalReading XML node content in format specified by the xmltodict library. Returns: dictionary representing a time series reading with keys ‘cost’, ‘value’, ‘start_time’, and ‘duration’.
Takes a dictionary representing the contents of the entry node in a Green Button XML file that specifies the meta data about the meter that was used to record time series data for that file. Returns a flat dictionary containing the meter meta data.
Parameters: raw_meter_meta – dictionary of the contents of the meter specification entry node in a Green Button XML file Returns: dictionary containing information about a meter with keys ‘currency’, ‘power_of_ten_multiplier’, and ‘uom’