self_driving_lab_demo.utils package

Submodules

self_driving_lab_demo.utils.channel_info module

Information about AS7341 Channels

self_driving_lab_demo.utils.data_logging module

self_driving_lab_demo.utils.data_logging.log_to_mongodb(document: dict, url: str, api_key: str, cluster_name: str, database_name: str, collection_name: str, verbose: bool = True, retries: int = 2)[source]

self_driving_lab_demo.utils.observe module

Based on the following resource: https://www.steves-internet-guide.com/receiving-messages-mqtt-python-clientq=Queue() # noqa: E501

self_driving_lab_demo.utils.observe.get_paho_client(sensor_topic, username=None, password=None, hostname=None, port=8883, tls=True)[source]
self_driving_lab_demo.utils.observe.liquid_dummy_observe_sensor_data(R, Y, B, **kwargs)[source]
self_driving_lab_demo.utils.observe.liquid_observe_sensor_data(R: float, Y: float, B: float, water: float = 0.0, prerinse_power: float = 0.5, prerinse_time: float = 20.0, runtime: float = 10.0, atime: int = 100, astep: int = 999, gain: int | float = 128, pico_id=None, session_id=None, timeout=3600, queue_timeout=60, client=None, username: str | None = None, password: str | None = None, hostname=None, port=8883, tls=True)[source]
self_driving_lab_demo.utils.observe.mqtt_observe_sensor_data(R: int, G: int, B: int, atime: int = 100, astep: int = 999, gain: int | float = 128, pico_id: str | None = None, session_id: str | None = None, timeout: int = 3600, queue_timeout: int = 60, client=None, username: str | None = None, password: str | None = None, hostname=None, port=8883, tls=True, mongodb=True, extra_info: dict | None = None)[source]
self_driving_lab_demo.utils.observe.nonwireless_pico_observe_sensor_data(R, G, B, astep=100, atime=999, gain=128, com=None)[source]
self_driving_lab_demo.utils.observe.pico_server_observe_sensor_data(R: int, G: int, B: int, atime: int = 100, astep: int = 999, gain: int = 128, url='http://192.168.0.111/')[source]

self_driving_lab_demo.utils.plotting module

self_driving_lab_demo.utils.plotting.line(error_y_mode=None, **kwargs)[source]

Extension of plotly.express.line to use error bands.

Source: https://stackoverflow.com/a/69587615/13697228

Example

>>> import plotly.express as px
>>> import pandas
>>>
>>> df = px.data.gapminder().query('continent=="Americas"')
>>> df = df[df['country'].isin({'Argentina','Brazil','Colombia'})]
>>> df['lifeExp std'] = df['lifeExp']*.1 # Invent some error data...
>>>
>>> for error_y_mode in {'band', 'bar'}:
>>>     fig = line(
>>>         data_frame = df,
>>>         x = 'year',
>>>         y = 'lifeExp',
>>>         error_y = 'lifeExp std',
>>>         error_y_mode = error_y_mode,
>>>         color = 'country',
>>>         title = f'Using error {error_y_mode}',
>>>         markers = '.',
>>>     )
>>>     fig.show()
self_driving_lab_demo.utils.plotting.matplotlibify(fig: Figure, size: int = 24, width_inches: float | int = 3.5, height_inches: float | int = 3.5, dpi: int = 142, return_scale: bool = False) Figure[source]

Make plotly figures look more like matplotlib for academic publishing.

modified from: https://medium.com/swlh/fa56ddd97539

Parameters:
  • fig (go.Figure) – Plotly figure to be matplotlibified

  • size (int, optional) – Font size for layout and axes, by default 24

  • width_inches (Union[float, int], optional) – Width of matplotlib figure in inches, by default 3.5

  • height_inches (Union[float, int], optional) – Height of matplotlib figure in Inches, by default 3.5

  • dpi (int, optional) – Dots per inch (resolution) of matplotlib figure, by default 142. Leave as default unless you’re willing to verify nothing strange happens with the output.

  • return_scale (bool, optional) – If true, then return scale which is a quantity that helps with creating a high-resolution image at the specified absolute width and height in inches. More specifically: >>> width_default_px = fig.layout.width >>> targ_dpi = 300 >>> scale = width_inches / (width_default_px / dpi) * (targ_dpi / dpi) Feel free to ignore this parameter.

Returns:

fig – The matplotlibified plotly figure.

Return type:

go.Figure

Examples

>>> import plotly.express as px
>>> df = px.data.tips()
>>> fig = px.histogram(df, x="day")
>>> fig.show()
>>> fig = matplotlibify(fig, size=24, width_inches=3.5, height_inches=3.5, dpi=142)
>>> fig.show()

Note the difference between https://user-images.githubusercontent.com/45469701/171044741-35591a2c-dede-4df1-ae47-597bbfdb89cf.png # noqa: E501 and https://user-images.githubusercontent.com/45469701/171044746-84a0deb0-1e15-40bf-a459-a5a7d3425b20.png, # noqa: E501 which are both static exports of interactive plotly figures.

self_driving_lab_demo.utils.plotting.plot_and_save(fig_path, fig, mpl_kwargs={}, show=False, update_legend=False)[source]

self_driving_lab_demo.utils.search module

self_driving_lab_demo.utils.search.ax_bayesian_optimization(sdl, num_iter, objective_name='frechet')[source]

Module contents