Spaces:
Sleeping
Download docs/architecture.md from climateexploer/wmonormals: direct link, hf CLI and curl.
- Browser
- Download file 4.11 kB
-
https://huggingface.co/spaces/climateexploer/wmonormals/resolve/main/docs/architecture.md
- Command line
-
hf download hf://spaces/climateexploer/wmonormals/docs/architecture.md
-
curl -L -o architecture.md https://huggingface.co/spaces/climateexploer/wmonormals/resolve/main/docs/architecture.md
WMO Normals Explorer Architecture
This document briefly outlines the core functionalities, technical implementation, and primary data workflows powering the WMO Normals Explorer application.
1. Overview
The WMO Normals Explorer is an R/Shiny interactive web application designed to visualize and investigate the WMO Climatological Standard Normals (1991-2020). It allows users to quickly cross-filter by country, station, weather parameter, and time period, and seamlessly switch between map-based overviews and deep-dive dashboard analytics.
2. Interface Layer (UI)
The application leverages the bslib framework alongside Bootstrap 5 for modern, responsive layouts and unified UI styling.
- Map View: The primary interface focuses on an interactive MapLibre map rendering thousands of stations as dynamic points coloured automatically by ECMWF and standard palettes based on weather parameter intensity. It features layer controls (switching between Positron, Bright, and Sentinel-2 satellite formats).
- Dashboard Panel: The deep-dive view features a responsive
bslib::card()metadata header that mimics top-tier portals (such as MeteoGate). It displays WMO and local identifying strings, exact coordinates, and allows bulk CSV/Excel exports of the matrices. Below the metadata are modular parameter tables (usingDT) and flexibleplotlygraphical windows (Walter-Lieth climate diagrams, time series).
3. Server Logic (Back-end)
The core logic resides in server.R handling map reactive filtering across potentially large datasets without bogging down the main thread.
- Reactive Filtering Architecture: Instead of processing all data, the server holds robust pre-loaded
sf(Simple Features) spatial vectors mapping variables (e.g.tavg_sf,prcp_sf). Filters systematically cascade downactive_dataset()->filtered_stations_by_country()->final_filtered_stations(). - Dynamic Selection Management: Whenever a station is clicked via
input$station_map_feature_click, the application zooms smoothly, draws a highlight halo over the station, transitions immediately to the Dashboard panel, and cross-references its exactWMO_IDto populate matrix arrays over the diverse variables present. - Cross-Dataset Extraction: A unified helper iterates across independent parameter DataFrames, plucking exact monthly arrays for the active WMO ID and securely binding them to construct the final wide-format table presented strictly to the user.
4. Metadata Utility Workflows
Because WMO Normals files often only contain legacy WMO IDs, the explorer requires supplementary utilities to ingest modern identification semantics (like WIGOS identifiers and standardized coordinate precision from the ultimate authority).
WIGOS Metadata Lookup (misc/fetch_wigos_metadata.R)
This CLI script enriches our local datasets with WMO OSCAR/Surface parameters.
- Bulk Extraction Optimization: Point querying individual stations against the OSCAR
<api/search/station>endpoint triggers long API timeouts due to the massive payloads (30MB+ JSON). The script solves this by immediately triggering a bulk-download of the entire database on first run, saving it intooscar_station_cache.json. - Dplyr Matrix Filtering: When queried, the script performs near-instant local indexing against the cached payload.
allStrategy Mode: RunningRscript misc/fetch_wigos_metadata.R allfrom the terminal traverses the localdata/directory, extracts every distinctWMO_ID(orID) from the.csvnormals datasets, looks them up in the cached OSCAR matrix forwigosId,name,elevation, and exact GPS decimal combinations, and dumps a unified reference table locally (wigos_metadata_all.csv).
5. Technology Stack
- R / Shiny: Main orchestration engine.
- bslib / htmltools: Rapid, responsive grid layouts.
- sf / maplibre: Accelerated point rendering for geospatial logic without slowing R.
- plotly / DT: High-density interactive widgets.
- httr / jsonlite: High-performance HTTP request tooling for metadata APIs.