This final chapter introduces two real-world cases that have taken advantage of Streamlit to develop web applications in some capacity. The first case covers the technical development of a data manager application for wind farms for Iberdrola – a renewable energy firm. We can observe how this application is being used to estimate electrical losses during production and to obtain valuable insights from Iberdrola’s SCADA data. The second case divulges the utility of Streamlit for industrial applications with maxon Group – a manufacturer of high-precision electronic motors. Specifically, we can see that Streamlit can be used to create a command and control dashboard application to control the maxon motors of a surgical scope adapter system both locally and remotely.
12.1 Streamlit in Clean Energy: Iberdrola
Iberdrola is a multinational electric utility with operations in more than 30 countries in the world. Since its inception, Iberdrola has been dedicated to developing a clean and reliable business model based on investments in renewable energy and is now one of the world’s largest renewable energy operators in terms of installed capacity. Iberdrola’s renewable energy activities are one of its three strategic business units, alongside networks and wholesale/retail solutions.
12.1.1 Visualizing Operational Performance of Wind Farms
Daniel Paredes and Jerome Dumont, both members of the Energy Resource department, have spent years developing algorithms and tailor-made software to analyze Iberdrola’s wind farms. In particular, the use case being discussed here focuses on a program that analyzes wind farm operational data to obtain energy yield assessment and identify variations. Operational performance studies and energy yield assessments are integral and essential components within the life cycle management of a wind farm. At Iberdrola, the utmost attention is paid to the running and optimization of wind farms, which are constantly inspected for deviations.
To this end, a novel and in-house software solution was rendered to address the needs of operational performance analysis – the Operational Wind Farm data manager hereinafter referred to as OWFdm. The presence of such software adds value by automating and streamlining computations that would be otherwise done manually, accommodating the requirements of operational technicians and engineers alike. Initially developed with Python and the QT GUI framework, OWFdm was able to address the needs of operational analysis; however, a complete deployment to the cloud would provide greater potential and pave the way to accommodate additional utilities for the end users. The justification for migrating the OWFdm to the cloud as a web application included technical reasons (scalability, accessibility, access to network resources and databases) as well as the need for a more powerful visualization library that would largely replace the role of Matplotlib and QT. As all the algorithms were already implemented in Python, a web framework was required to interface with the web browser. For this purpose, Streamlit was introduced to take on the role of creating the frontend interface. As a pure Python package, Streamlit required a very shallow learning curve and reduced the burden of the developers of having to code in HTML or CSS. In addition, Streamlit provided an integrated development environment (IDE) that allowed for rapid development.
In collaboration with Iberdrola Innovation Middle East, a research center devoted to developing innovative solutions in smart grids and distributed renewable energy integration, a redesign and enhancement of the functionality of the OWFdm tool was developed. In the following sections, we will look at some of the Streamlit-based graphical representations utilized by the Iberdrola wind engineers.
12.1.2 Wind Turbine Power Curves
Wind turbines are mechanical devices that convert kinetic energy (energy due to movement) in wind into electrical power. They do this by using three main components: a rotor, a generator, and a tower. The blades of a turbine are connected to the rotor. When the blades move, they cause the shaft of the generator to spin. The type of wire used in wind turbines is known as a multistrand wire and is composed of many individual strands of copper wire twisted together and covered with an outer protective covering.
The power output for a wind turbine depends on the density of the air, which is affected by both altitude and climate. The power output for wind turbines ranges from a few kW to the 14MW of the GE Haliade-X offshore, which is the most powerful turbine available in the market at the time of the writing of this book [17, 18]. A large industrial-type onshore wind turbine such as those populating our countryside usually ranges between 2 and 4MW, with a rotor diameter ranging around 130 meters. The power output for small wind turbines is typically measured in watts (W), while large industrial types are often measured in megawatts (MW). A wind turbine with a 100W power output will meet the needs of an average household, while one that has 3000W can power anything from a small business to an entire neighborhood. A turbine’s energy production is proportional to the third power of its blade length, so doubling the blade length would produce eight times as much power. Doubling the blade span (the length of the arc that the blades sweep through when making a full rotation) would produce 16 times as much power.
The power curve of a wind turbine is a graph that shows how much electrical energy the turbine will generate at different wind speeds. Power curves for wind turbines are usually created by testing an actual turbine at specific sites under similar wind conditions and measuring its electrical output at each point either with a wattmeter or a power analyzer. Wind turbines are tested at different wind speeds, and the turbine’s power output is measured and recorded as a function of wind speed to generate a wind speed vs. power curve for that particular site. A power curve is typically represented as a graph with wind speed on the x axis and turbine power output on the y axis. The wind speed axis can be given in either actual or average (rated) values. A rated value is the speed at which the turbine’s power output matches its maximum capability during normal weather conditions at that site. The typical power curve for a modern industrial three-blade horizontal axis wind turbine is shown in Figure 12-2.
The power curve as provided by the manufacturer, operational power curve in the legend
The real or measured power curve, operational power curve (meas) in the legend
The three-sigma variance of the real power curve, operational power curve 3Sigmas in the legend
All the data points obtained during the period, P-v recorded in the legend
Graphs displayed with Plotly and wrapped with Streamlit can provide an interactive lasso tool that can be used to manually filter outliers. Thanks to the Streamlit framework, a two-way communication between this chart and other components is executed seamlessly.
12.1.3 Wind Roses
A wind rose is a graphical depiction of the frequency with which the wind speed and direction are dispersed at a certain location. Meteorologists use wind roses to give a concise view of how wind speed and direction are typically distributed at a particular location. Modern wind roses normally contain the wind speed, wind direction, time period for which wind data is valid, and other related information. To construct a wind rose, wind observations from anemometers or wind vanes attached to a building or similar structure are plotted on a polar coordinate wind rose. The wind rose contains both the average wind speed and direction during a certain period for a given location. Wind roses typically use 16 cardinal directions, such as NNW (north-northwest), SSW (south-southwest), and so forth, or divide the 360 degrees into sectors.
12.1.4 Heat Maps
12.1.5 Closing Remarks
Beyond the visualization capabilities, Streamlit has proven to be a highly versatile tool for Iberdrola renewables, enabling us to render multiple datasets on demand by prompting the user to select what data they want to display, as opposed to having to manually program that into the source code. A two-way communication with charts in pure Python is also of great value, for instance, implementing the functionality provided by the lasso tool for manual filtering used in Figure 12-3 would have required some integration efforts with JavaScript or other workarounds. A final advantage is a possibility of rendering charts as HTML on a website, making them interactable with other widgets, as opposed to running it stand-alone locally without any other third-party interactions.
This publication is supported by Iberdrola S.A. as part of its innovation department research studies. Its contents are solely the responsibility of the authors and do not necessarily represent the official views of Iberdrola Group.
12.2 Streamlit in Industry: maxon Group
12.2.1 Developing a Novel Surgical Scope Adapter System for Minimally Invasive Laparoscopy
Minimally invasive surgery, otherwise known as laparoscopy, is becoming increasingly prevalent as the operation of choice for surgeries on the abdomen. Given the small size of the incisions that are made to the body, laparoscopy affords patients a shorter recovery period and a mitigated possibility of developing complications during and after the surgery. Currently, such operations are conducted manually with a surgical assistant holding and articulating the endoscope that is inserted into the abdomen to view the region being operated on in real time (shown in Figure 12-8). Considering that a human operator is involved in this arrangement, a high level of dexterity and hand-eye coordination is required; any inaccuracy, however slight, may introduce unwarranted error into the operation.
Consequently, a novel scope adapter concept (shown in Figure 12-9) was developed and prototyped by Dr. Nikhil Navkar and Mohammad Khorasani to mitigate the effects of including a human operator in the feedback loop. In this implementation, the endoscope and associated camera head are held and controlled via a UR5 robotic arm offering six degrees of freedom, with an additional two degrees of freedom built into the adapter itself enabling the rotation of the scope and camera head around its axis and the angulation of the scope tip. The rotation is powered by a maxon ECX brushless motor, while the angulation is powered by a maxon brushed DCX motor. Each motor is coupled with a reduction gearbox that offers a top speed of 20 and 16 RPM for the rotation and angulation motors, respectively, and a three-channel optical encoder that provides a resolution of 4096 and 2048 steps per revolution, respectively.
Ability to support different endoscopes, camera heads, and robotic arms
Can be controlled with a variety of inputs including a joystick or by tracking optical markers attached to the surgeon’s head
Can be programmed to reduce human error and unintended movements
Reduces operator strain and fatigue by eliminating the need to manually hold the scope
12.2.2 Streamlit Command and Control Dashboard
12.2.3 Closing Remarks
While Streamlit is branded as a framework for machine learning and data science applications, it does possess enough versatility to be used for a variety of purposes. As shown in this instance, Streamlit was effectively utilized to bridge several nontrivial subsystems together into one contiguous system. Specifically, Streamlit was used to interface the maxon motors with a joystick, enable remote control over the local area network as well as the Internet, and also to provide a real-time dashboard displaying the motors’ position and speed all in a few lines of code.
This work was supported by National Priority Research Program (NPRP) award (NPRP13S-0116-200084) from the Qatar National Research Fund (a member of The Qatar Foundation) and IRGC-04-JI-17-138 award from Medical Research Center (MRC) at Hamad Medical Corporation (HMC). All opinions, findings, conclusions, or recommendations expressed in this work are those of the authors and do not necessarily reflect the views of our sponsors.
12.3 Summary
In this final chapter, we have been acquainted with two real-world instances of Streamlit being utilized effectively for commercial and industrial activities. Namely, the first case demonstrates how Iberdrola – a renewable energy firm – is using Streamlit to create a corporate data management application for their wind farms, to estimate electrical losses during production. The second case expands on an industrial use case whereby high-precision electronic motors manufactured by maxon Group are being commanded and controlled via a Streamlit application, for use within a surgical scope adapter system. Both examples serve to provide evidence of the utility that Streamlit is offering to the corporate world and beyond.