helios_thread
module core.threads.helios_thread
class CameraError
class HeliosInterface
method __init__
__init__(logger: Logger, camera_id: int, initialization_tries: int = 5) → None
method adjust_exposure
adjust_exposure() → None
This function will loop over all available exposures and take one image for each exposure. Then it sets exposure to the value where the overall mean pixel value color is closest to self.target_pixel_brightness
.
For every exposure:
- set new exposure 2. 0.3s sleep 3. image 1 -> 0.1s sleep -> image 2 -> 0.1s sleep -> image 3 8. calculate mean color of all 3 images 9. save images to disk
method get_available_exposures
get_available_exposures() → list[int]
Loop over every integer in [-20, ..., +20] and try to set the camera exposure to each value. Return a list of integers that the camera accepted as an exposure setting.
method run
run(
station_id: str,
edge_color_threshold: int,
target_pixel_brightness: int,
save_images_to_archive: bool,
save_current_image: bool
) → float
Take an image and evaluate the sun conditions. Run autoexposure function every 5 minutes. Returns the edge fraction.
method take_image
take_image(
retries: int = 10,
trow_away_white_images: bool = True
) → ndarray[Any, Any]
Take an image using the initialized camera. Raises an AssertionError if camera has not been set up.
Retries up to n times (camera can say "not possible") and throws away all mostly white images (overexposed) except when specified not to (used in autoexposure).
method update_camera_settings
update_camera_settings(
exposure: int,
brightness: int = 64,
contrast: int = 64,
saturation: int = 0,
gain: int = 0,
width: int = 1280,
height: int = 720
) → None
Update the settings of the connected camera. Which settings are available depends on the camera model. However, this function will throw an AssertionError, when the value could not be changed.
class HeliosThread
Thread for determining the current sun conditions in a parallel mainloop.
"Good" sun conditions with respect to EM27 measurements means direct sunlight, i.e. no clouds in front of the sun. Interferograms recored in diffuse light conditions result in a concentration timeseries (after retrieval) with a very large standard deviation.
Direct sunlight can be determined by "hard" shadows, i.e. quick transitions between light and dark surfaces. This thread periodically takes images in a special camera setup and uses edge detected to determine how many hard shadows it can find in the image.
The result of this constant sunlight evaluation is written to the StateInterface.
method get_new_thread_object
get_new_thread_object() → Thread
Return a new thread object that is to be started.
method main
main(headless: bool = False) → None
Main entrypoint of the thread. In headless mode, don't write to log files but print to console.
method should_be_running
should_be_running(config: Config) → bool
Based on the config, should the thread be running or not?