sunpeek.components.sensor.Sensor#

class sunpeek.components.sensor.Sensor(raw_name, native_unit, plant=None, description=None, accuracy_class=None, installation_condition=None, hardware_type=None, sensor_type=None, is_virtual=False, problems=None, can_calculate=None, value_replacements=None, info={})#

Bases: Base, AttrSetterMixin

Methods

__init__(raw_name, native_unit[, plant, ...])

A simple constructor that allows initialization from kwargs.

add_component_attr(name[, unit, minimum, ...])

all_subclasses([c])

define_component_attrs()

get_component_attribute(name)

get_default_unit(name)

Return default unit of a class attribute defined as ComponentParam.

has_orientation()

Returns True if sensor has sensor info with tilt and azimuth well-defined.

is_info_missing(info_item)

Make sure sensor info has an item with the specified key.

m_as(unit)

Shortcut to convert self.data from pd.Series with dtype pint to numeric array.

plot()

Create a simple development plot method for Sensor data.

q_as(unit)

Shortcut to convert self.data from pd.Series with dtype pint to pint.Quantity array, with numeric values converted to unit.

register_callback(callback_type, func)

remove_references([include_plant])

This makes sure SunPeek does not use the sensor anymore, and leaves the application in a consistent stage.

reset_cache()

s_as(unit)

Shortcut to convert self.data from pd.Series with dtype pint to normal pd.Series, with numeric values converted to unit.

set_component_attribute(name, value, array_type)

update(result_key, algo_result)

Save calculation results of virtual sensors to Context datasource.

property data#

Accessor for sensor data.

Return type:

pandas Series object with 1 data column and DateTimeIndex depending on self.plant.context properties.

Notes

Does not change data time index, e.g. values are not resampled. To resample, use sensor.get_data()

classmethod get_default_unit(name)#

Return default unit of a class attribute defined as ComponentParam.

Return type:

str

has_orientation()#

Returns True if sensor has sensor info with tilt and azimuth well-defined. Useful for radiation calculations.

is_info_missing(info_item)#

Make sure sensor info has an item with the specified key.

Return type:

bool

m_as(unit)#

Shortcut to convert self.data from pd.Series with dtype pint to numeric array. Method m_as exists also for pint.Quantity objects, so this enables same syntax for pint.Quantity and pd.Series.

property orientation#

Return dictionary with array’s “tilt” and “azim” values converted to deg, for radiation calculations.

plot()#

Create a simple development plot method for Sensor data.

q_as(unit)#

Shortcut to convert self.data from pd.Series with dtype pint to pint.Quantity array, with numeric values converted to unit.

remove_references(include_plant=True)#

This makes sure SunPeek does not use the sensor anymore, and leaves the application in a consistent stage. It does not do a database delete of the sensor.

Parameters:

include_plant (bool) – if false, method will not attempt to remove the sensor’s reference to/from it’s parent plant.

s_as(unit)#

Shortcut to convert self.data from pd.Series with dtype pint to normal pd.Series, with numeric values converted to unit.

update(result_key, algo_result)#

Save calculation results of virtual sensors to Context datasource.

Parameters:
  • result_key (pd.Series is retrieved from algo_result.output with this key.)

  • algo_result (AlgoResult object, output of virtual sensor algo run() method)

Raises:

CalculationError – If called on a normal (not virtual) sensor, or if required data not found in algo_result.

property value_replacements__native#

Return self.value_replacements, but with all Quantities converted to floats in self.native_unit