Weather & Sky Intelligence

Safety weather data, independent sky analysis, meteors and public sky images.

CloudWatcher Solo: safety conditions

Logic
How it works

AAG CloudWatcher Solo: the main weather reference

The AAG CloudWatcher Solo supplies the meteorological information used to assess observing conditions: sky temperature/cloud evidence, rain, wind, humidity and other available environmental indicators. N.I.N.A.’s Safety Monitor evaluates the weather status together with the UPS/incoming-mains status. Loss of incoming mains therefore makes the monitor Unsafe even if the Solo still reports safe weather, starting the roof-closing sequence while UPS reserve remains. Home Assistant separately monitors power and UPS state and supervises the roof outcome.

Rain protection also has a separate Hydreon RG-11 sensor inside the observatory, connected through a Shelly Plus i4 input. This is not another outdoor weather reading: detected water means it has entered the enclosure and could be wetting the instruments. If its rain-alarm input persists for 10 seconds while the roof is not confirmed closed, Home Assistant immediately starts emergency closure, independently of the Solo's weather state and five-minute Unsafe backup.

An important distinction is that the Solo's global weather Safe/Unsafe flag is not the same thing as its cloud-specific reading or N.I.N.A.’s broader Safety Monitor state. Rain, wind or humidity can make Solo weather unsafe even with a visually clear sky; separately, loss of incoming mains can make N.I.N.A.’s Safety Monitor Unsafe while Solo weather remains Safe. For this reason, the independent Clouds Advisor described below deliberately evaluates the clouds parameter rather than treating the overall Safe/Unsafe flag as a ground truth for cloud classification.

Home Assistant also displays Solo configuration values and synchronises them with dashboard input controls. Another automation alerts if the Raspberry-side API used to read the Solo configuration stops responding for two minutes, distinguishing a Raspberry outage, an unreachable Solo and an API/software failure where both devices are reachable.

The Cloud Watcher card shows the combined Safe/Unsafe state and individual readings for ambient temperature, clouds, humidity, pressure, wind, rain and SQM, with the configured limits beside them. A separate AAG Solo – Config card exposes editable limits for clouds, wind, rain, light, humidity and pressure, plus the Unsafe and cloud-detection delays; an explicit action sends the selected configuration to the Solo. The 30-second refresh intervals described below are Home Assistant read intervals, not the Solo’s measurement cycle or safety delays.

Home Assistant data refresh

These are Home Assistant's REST polling intervals. The configuration request refreshes the settings displayed on the dashboard; neither interval sets the Solo's own measurement cycle or its Safe/Unsafe delays.

AllSky-based Clouds Advisor

Logic
How it works

Independent sky classification

The Solo uses an infrared sky-temperature reading to help separate clear conditions from cloudy ones. However, the sky-temperature threshold that works best is not necessarily fixed across seasons, ambient temperature, transparency or moonlight conditions. A threshold that is too strict may reject a genuinely clear sky; one that is too permissive may allow acquisition through clouds.

A separate Python analysis service uses the AllSky camera as an independent visual reference. It tries to classify the actual sky from images and compare that result with the Solo's cloud measurement. It then prepares a recommendation for adjusting the Solo's Clouds threshold—not an unreviewed automatic change.

Nightly Python analysis cycle

The script runs on the AllSky Raspberry Pi inside a dedicated Python environment. A scheduler checks approximately once a minute, but that does not mean it sends an advisory every minute. It maintains a persistent record of the night and produces the principal advisory once per night, when all required input data are available.

The program identifies the relevant observing night from the timestamps of the original AllSky photographs, rather than assuming the civil-date boundary at midnight is the start of a new observing session. It only analyses images when the Sun is below −12° and requires at least ten usable frames. This excludes unsuitable twilight images.

If the necessary ten clean frames cannot be assembled, or if the Solo's values cannot be read, the run does not invent a conclusion; it may try again on a later scheduler pass.

What is measured in an AllSky photograph?

The analysis is restricted to a circular region of interest centred on the useful sky, with a radius of about 40% of the shorter image dimension. This excludes much of the ground, buildings and other unwanted outer regions. The useful area is divided into a 4×4 grid, giving sixteen spatial sectors.

For each image the Python program estimates the median background brightness, the median absolute deviation (MAD) of the background, candidate stars and the number of sectors occupied by detected stars. Its detection process uses a high-pass representation—subtracting a blurred version of the image—so point-like stellar structures are easier to distinguish from diffuse background illumination.

On the final group of ten frames, it calculates average, minimum and maximum star count, star-count variability, mean occupied sectors and their variation, and the level and temporal stability of the sky background. These measurements capture both the number of stars and how stable their distribution remains over time.

Filtering out contaminated frames

Not every bright or dark AllSky image represents cloud coverage. Passing vehicle lights, reflections and isolated disturbances can corrupt an individual frame. Before classification, the script considers up to fifteen recent candidates and selects ten valid images.

A robust filter compares background and MAD against the typical group. Strong outliers are rejected before computing averages, deciding on a sky class or building the mosaic. The star count alone is not used as the primary exclusion rule: a reflection or artificial light can itself produce false point-like detections.

This distinction is central to the design. A transient contamination should not dominate the night's cloud classification, whereas truly persistent clouds should not be discarded merely because they appear in many successive frames.

Clear, Cloudy or Uncertain—and why the Moon matters

The classifier has three possible outcomes: CLEAR, CLOUDY and UNCERTAIN. Its early calibration was checked against manually graded AllSky mosaics, with a human clear-sky reference of approximately 7.5/10 or higher.

Without significant moonlight, the classifier uses an average star-count threshold of approximately 5,000 to identify clearly cloudy conditions. A secondary rule looks for a more subtle signature: fewer than 9,000 stars, mean sky background of at least 65, background standard deviation no more than 3, and star-count coefficient of variation of at least 0.08. Otherwise the frame group can be classified as CLEAR. These numbers are calibrated to the current AllSky camera and processing pipeline, not intended as universal meteorological thresholds.

The Moon complicates this dramatically. A bright Moon can increase the background and sharply reduce the number of detected stars even when the sky is genuinely clear. the Clouds Advisor Python service uses Astropy to calculate the Moon's elevation and approximate illumination. It then derives a moon-strength indicator using illuminated fraction and the sine of lunar elevation.

The lunar branch applies when the Moon is at least 5° above the horizon, is at least 25% illuminated, and its computed strength reaches 0.12. Under these conditions, the script does not use a simple absolute star-count threshold to declare the sky cloudy.

Instead, it studies temporal stability:

  • Cloudy if the variation in occupied sectors is high (standard deviation approximately 0.8 or above) or the star-count coefficient of variation is 0.25 or above.
  • Clear when the occupied-sector variation is low (0.5 or below) and star-count coefficient of variation is 0.20 or below.
  • Uncertain in the intermediate range. An uncertain classification cannot create an automatic threshold-adjustment proposal.

This is an example of a physically informed algorithm: the same numerical star count may mean different things depending on lunar illumination.

Cloud threshold proposals and approval

Logic
How it works

Comparing the sky class to the Solo's Clouds threshold

Once the ten-image sky class is available, the advisor reads the Solo's cloud-related sky temperature, the configured Clouds switching threshold and a supplementary clear-sky value if available. The program calculates a possible threshold adjustment according to the threshold decision cases.

The specific proposal depends on whether the AllSky is CLEAR or CLOUDY and on which side of the currently configured threshold the Solo's sky temperature lies. The system applies the following decision table, where T is the currently measured Solo sky temperature and “threshold” means the current Clouds switching threshold:

Case AllSky result and comparison Proposed threshold
A CLEAR and T is below current threshold Round T + 1°C upward to the next whole degree
B CLEAR and T is above current threshold Round T + 1°C upward to the next whole degree
C CLOUDY and T is above current threshold Round T − 2°C downward to the preceding whole degree
D CLOUDY and T is below current threshold Round T − 4°C downward to the preceding whole degree

These rules are calibrated to this installation, rather than universal CloudWatcher settings. The program does not use global Safe/Unsafe to decide what to change: a wind or rain warning must not alter the cloud-threshold recommendation.

If the proposed value already equals the Solo's current setting, no change is suggested. If the AllSky classification is UNCERTAIN, there is no automatic change proposal.

Telegram approval and the Python application server

The system deliberately requires a two-stage human confirmation. A nighttime Telegram report shows the classification, measurements, moon-related diagnostics, current Solo cloud value and (where warranted) a proposed new threshold. A 5×2 mosaic of the ten accepted frames accompanies the result, so a person can judge whether the classification is credible.

If a change is offered, the user first requests APPLY. Home Assistant asks a local Python approval service to retrieve the pending proposal and presents the current and proposed values for a second explicit confirmation. Only that second confirmation allows the Python approval service to write the updated Clouds setting through the instrument configuration interface.

The server checks that a proposal is valid, has not already been used and has not expired. The proposal remains valid for 12 hours. This prevents a stale Telegram message from silently modifying the sensor long after conditions have changed.

The Python services have separate responsibilities: sky classification and proposal, validation of explicit approval, and application of the new Clouds setting. Each stage must succeed before the change is considered complete.

Cloud-analysis statistical archive

Besides the once-per-night advisory, the system stores periodic dataset samples approximately every 30 minutes. Each sample includes the accepted-image mosaic and statistical values used for the assessment. This history allows the algorithm to be compared with manually reviewed skies across different seasons, moon phases and transparency conditions.

The distinction between the frequent scheduler checks, half-hourly dataset samples and single nightly advisory is intentional. They are three different cadences serving three different purposes.

Meteor detection and artifact rejection

Logic
How it works

Meteor candidates from AllSky images

A second Python application runs on the AllSky Raspberry Pi and searches the archived nighttime images for meteor candidates. It is deliberately a candidate detector, not a claim of perfectly automated physical identification: a human still reviews the annotated images.

The main idea is to analyse three consecutive photographs:

  1. PREV — the frame immediately before a possible event.
  2. CURR — the frame that may contain the meteor.
  3. NEXT — the frame immediately after it.

A meteor should be a transient structure visible in CURR but absent, or substantially fainter, in both neighbouring frames. The algorithm therefore combines the positive difference between CURR and PREV with the positive difference between CURR and NEXT. Persistent cloud bands, stars and many ordinary lighting variations are less likely to survive both comparisons.

Why image alignment comes before differencing

Stars shift slightly between consecutive exposures because of apparent celestial motion. A naive pixel-by-pixel subtraction would therefore produce many false residuals around ordinary stars. the meteor-detection Python service first aligns the images using ORB image features, binary matching and RANSAC geometry, bringing CURR and NEXT into a common reference frame with PREV.

It then normalises overall image brightness using background statistics. A circular useful-sky mask excludes much of the horizon and terrestrial landscape; a local mask handles a recurring stray-light source. Large bright regions such as moonlight halos can also be handled through dynamically generated exclusion areas.

The transient mask is cleaned with morphological operations. Candidate contours are evaluated by area, length, width, aspect ratio and fill factor, rather than accepting every bright cluster. The geometric screening bounds include an area of roughly 28–3,000 pixels in the reduced image, a major axis of at least 35 pixels, a minor axis no wider than 30 pixels, a minimum length-to-width ratio of 2.8, and a minimum fill factor of 0.06. These are only geometric preselection criteria: passing them does not by itself confirm a meteor.

Rejecting clouds, vehicle headlights and repeated artifacts

Candidate detection goes beyond geometric shape. A narrow bright streak may be part of a passing cloud edge, artificial glare or an aircraft-related effect. The detector therefore tests local low-frequency cloud context, the persistence of activity in a similar position across neighbouring frames, and broader lighting changes near the outer sky region.

Two specific peripheral checks target terrestrial lights: one measures unusually extensive illumination changes near the perimeter, while another examines the angular sector containing a candidate close to the boundary. A candidate is not discarded merely because it is close to the horizon; there must be actual evidence of a widespread light change.

The Hough transform may still be recorded for diagnostics of linear features, but the detector does not use Hough alone as a rejection gate. The decision depends on the combined transient, geometry, persistence, cloud-context and illumination evidence.

Meteor outputs and scheduling

For each accepted candidate, the Python program saves an annotated image with the suspected streak identified, together with intermediate diagnostic images and CSV reports explaining which tests succeeded or failed. Telegram can deliver the candidate image and a summary of its measurements; a final scan report closes the run.

The detector is launched by a systemd timer, with a daily scan at approximately 08:00, generally analysing the previous night's archived frames. A detector that misses an unusual meteor or accepts an artifact is still possible; false positives and missed events remain possible.

Sky darkness statistics

Logic
How it works

SQM: a night-darkness record

The observatory also records Sky Quality Meter (SQM) readings in Home Assistant. The tracking window is based on the Sun's elevation: when the Sun falls below −18° the nightly peak is reset, and subsequent SQM updates can replace the stored maximum. When the Sun rises above the same astronomical-night boundary, HA sends a summary including the peak darkness reading and its timestamp.

This is a statistical report of the readings received, not a replacement for reviewing cloud cover, moonlight, instrument calibration or the context of the measurement.

Public AllSky publishing

Logic
How it works

Publishing the AllSky image without exposing the Raspberry

A separate scheduled process publishes only the selected AllSky JPEG to a Cloudflare R2 object. It uses a local shell script, the scheduled AllSky upload process, that runs approximately once per minute. Each upload replaces the same public object name instead of accumulating an endless collection of photographs.

The public Webador page reads the image from Cloudflare, not directly from the Raspberry's management interface. The Raspberry initiates an outbound connection; no inbound access to the internal AllSky host is needed for this publication task.

Home Assistant’s separate All Sky view places the camera image beside observing context such as capture time and location, Sun and Moon information, visible planets, camera settings and camera-computer temperature, fan and heater status.

Home Assistant also monitors the reported upload health. In the automation, a persistent DOWN state for five minutes can generate an alert, allowing a stale public image to be distinguished from a real-time sky update.

Why the three sky systems complement one another

CloudWatcher Solo determines operational weather safety; Clouds Advisor independently evaluates whether the cloud threshold makes sense; Meteor Detector searches for transient astronomical events; SQM records sky darkness; and the R2 publishing process displays an accessible recent image. They serve different purposes and none should be mistaken for a replacement for the roof's independent safety mechanisms.