Pyra: Automated EM27/SUN Greenhouse Gas Measurements
website·Indexed 29 days ago
https://pyra-4-documentation.netlify.app/docs/Documentation for Pyra, a system for automated EM27/SUN greenhouse gas measurements. Includes user guides for measurement modes, Automatic Peak Positioning (APP), and the pyra-cli command line interface, as well as developer guides covering architecture, internal interfaces, and integration with OPUS and CamTracker.
What's inside Pyra
- Pyra is a standalone software application designed to automate the operation of EM27/SUN measurement setups, enabling 24/7 autonomous operation of these devices. It is licensed under GPLv3 and is intended to be run as a standalone program rather than imported as a library. Programmatic interaction with Pyra 4 should be performed via its Command Line Interface (CLI).
Configure Pyra measurement modes via Condition Assessment System (CAS)
Pyra uses a Condition Assessment System (CAS) to decide whether measurements should run. The measurement mode is selected in the overview tab. There are three available modes:
- Automatic mode: Measurements are triggered based on predefined conditions.
- Manual mode: Provides a start/stop button for user control.
- CLI mode: Allows an external system to provide the measurement decision via the CLI.
Understand Helios sun-state evaluation
Helios is hardware used to determine if sunlight is direct or diffuse. This is critical because EM27/SUN applications require direct sunlight for useful data, and CamTracker may lose track of the sun in diffuse light, requiring a restart. The system works by taking images through a transparent globe with black stripes and a translucent milky glass; it processes these images using a Canny edge filter to detect 'fast transitions between light and dark'. If the count of these pixels exceeds a configurable threshold, sunlight conditions are categorized as 'good'.Understand the Pyra system architecture
Pyra consists of three primary components that work together to manage automation steps:
- Pyra Core: The background engine that executes automation steps infinitely at defined intervals.
- Pyra CLI: A Command Line Interface used to interact with and control Pyra Core.
- Pyra UI: A Graphical User Interface used to interact with Pyra Core and execute Pyra CLI commands.
Understand Pyra's role in EM27/SUN measurement automation
Pyra acts as the automation bridge for EM27/SUN setups, coordinating the interaction between two primary software components: CamTracker (which tracks sun position and operates mirrors) and OPUS (which sends commands to the EM27/SUN and collects output data into interferogram files). Pyra determines whether to initiate measurements based on time, sun angle, sun conditions, manual UI triggers, or external logic passed via CLI commands.Understand UI and CLI interaction constraints
The Pyra UI interacts with the system as follows:
- Reading State/Logs: The UI reads
logs/state.jsonand log files periodically using Tauri's file system API. - Write Operations: All write operations (such as updating configuration) are performed by executing Pyra CLI commands via the Tauri shell interface.
- Python Environment: Because the Tauri shell interface does not support virtual environments, Pyra must use the global Python interpreter for these operations.
- Reading State/Logs: The UI reads
Understand the Pyra Core execution loop
Pyra Core operates using a main loop that infinitely iterates over five primary modules:MeasurementConditions,EnclosureControl,SunTracking,OpusMeasurements, andSystemChecks. Additionally, the Core manages the lifecycle of the Upload and Helios threads, starting them when required by configuration; these threads are designed to terminate themselves based on the provided configuration settings.Run Pyra backend tests using Pytest
Pyra uses Pytest for backend testing, with tests located in thetests/directory. Tests are categorized into two types: CI tests (which run without hardware/config) and integration tests (which requireconfig.jsonand hardware setup).# Run tests that do not require hardware/config python -m pytest -m "ci" tests # Run tests that require config.json and hardware setup python -m pytest -m "integration" tests # Specifically test emailing configuration python -m pytest tests/integration/test_emailing.py # Specifically test upload configuration python -m pytest tests/integration/test_upload.pyFollow the Pyra git branching strategy
Pyra uses a hierarchical branching model to manage development and releases:
development-...: Used for active feature development. Merges intointegration-x.y.zupon completion of feature sets.integration-x.y.z: Used for active station integration. Merges intomainafter successful integration.main: Contains the latest stable version that passed integration. Merges intoreleasewhen creating a formal release.release: The official release branch.prerelease: A development branch used to run the CI-Pipeline on demand (e.g., to bundle the UI). It is not merged back into other branches.
Set up OPUS and CamTracker dependencies
Pyra is integrated with OPUS (tested versions 7.8, 8.2, 8.9) and CamTracker (tested version 3.9.2015.02.03).
Critical Requirement: Normal users must have write-access to the directory where the CamTracker executable is stored. Without this permission, CamTracker cannot be stopped gracefully, resulting in errors in the UI logs when turning off the PYRA core.
Set up the Helios camera
Use the scripts located in
scripts/helios-setupto identify and evaluate the Helios camera hardware:- Run
scripts/helios-setup/find_helios_camera.pyto scan for connected cameras, capture sample images, and save them to thescripts/helios-setup/findingdirectory. - Run
scripts/helios-setup/evaluate_helios_camera.pyusing the camera ID identified in the first step to run the Helios evaluation and save raw/processed images to thescripts/helios-setup/evaluationdirectory.
# Step 1: Find the camera python scripts/helios-setup/find_helios_camera.py # Step 2: Evaluate the specific camera ID python scripts/helios-setup/evaluate_helios_camera.py --id <CAMERA_ID>- Run
Install Pyra dependencies using PDM
Pyra uses PDM for dependency management. To install all dependencies (including development dependencies) in the currently active interpreter environment, run the install command with the--devflag.pdm install --dev