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.

Tokens
6.9K
Snippets
26
Records
63
Agent score
75%

What's inside Pyra

  1. Overview of Pyra for EM27/SUN Automation

    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).
  2. 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:

    1. Automatic mode: Measurements are triggered based on predefined conditions.
    2. Manual mode: Provides a start/stop button for user control.
    3. CLI mode: Allows an external system to provide the measurement decision via the CLI.
  3. 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'.
  4. 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.
  5. 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.
  6. Understand UI and CLI interaction constraints

    The Pyra UI interacts with the system as follows:

    1. Reading State/Logs: The UI reads logs/state.json and log files periodically using Tauri's file system API.
    2. Write Operations: All write operations (such as updating configuration) are performed by executing Pyra CLI commands via the Tauri shell interface.
    3. Python Environment: Because the Tauri shell interface does not support virtual environments, Pyra must use the global Python interpreter for these operations.
  7. Understand the Pyra Core execution loop

    Pyra Core operates using a main loop that infinitely iterates over five primary modules: MeasurementConditions, EnclosureControl, SunTracking, OpusMeasurements, and SystemChecks. 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.
  8. Run Pyra backend tests using Pytest

    Pyra uses Pytest for backend testing, with tests located in the tests/ directory. Tests are categorized into two types: CI tests (which run without hardware/config) and integration tests (which require config.json and 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.py
  9. Follow the Pyra git branching strategy

    Pyra uses a hierarchical branching model to manage development and releases:

    1. development-...: Used for active feature development. Merges into integration-x.y.z upon completion of feature sets.
    2. integration-x.y.z: Used for active station integration. Merges into main after successful integration.
    3. main: Contains the latest stable version that passed integration. Merges into release when creating a formal release.
    4. release: The official release branch.
    5. 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.
  10. 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.

  11. Set up the Helios camera

    Use the scripts located in scripts/helios-setup to identify and evaluate the Helios camera hardware:

    1. Run scripts/helios-setup/find_helios_camera.py to scan for connected cameras, capture sample images, and save them to the scripts/helios-setup/finding directory.
    2. Run scripts/helios-setup/evaluate_helios_camera.py using the camera ID identified in the first step to run the Helios evaluation and save raw/processed images to the scripts/helios-setup/evaluation directory.
    # 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>