moonbit-ocean-qc

    Composable, explainable, and traceable quality control for ocean observations.

    ocean
    quality-control
    provenance
    observations
    Download zip
    Author
    Version
    0.3.0
    License
    Apache-2.0
    Last updated
    2 months ago
    Downloads
    34

    No dependencies

    #MoonBit Ocean QC

    The repository provides a MoonBit-native quality-control model for ocean observations. A finding carries its rule, flag, severity, original value, reason, processing time, and provenance.

    #Quick start

    moon check --deny-warn moon test --deny-warn moon run cmd/main

    The executable example is kept in cmd/main/main.mbt; the public package API is documented in the generated interface file.

    #Package map

    • The root package owns observations, rules, findings, summaries, and provenance.
    • profile owns variable aliases, canonical units, physical envelopes, and validation.
    • stats owns online descriptive statistics and distribution helpers.
    • stream owns bounded batch processing.
    • report owns deterministic text, CSV, and JSON-lines output.

    #Development

    Run moon fmt, moon check --deny-warn, moon info, and moon test --deny-warn before submitting changes. The CI workflow repeats these checks on the default and native targets.

    #License

    Apache-2.0.

    Finding

    pub(all) struct Finding {
    observation_id : String
    rule : RuleKind
    flag : QualityFlag
    severity : Severity
    reason : String
    original_value : Double?
    processed_at : Int
    provenance : Provenance
    } derive(
    Debug
    )

    Observation

    pub(all) struct Observation {
    id : String
    timestamp : Int
    latitude : Double
    longitude : Double
    variable : String
    value : Double?
    unit : String
    platform : String
    } derive(
    Debug
    )

    Observation::new

    fn Observation::new(id~ : String, timestamp~ : Int, latitude~ : Double, longitude~ : Double, variable~ : String, value~ : Double?, unit~ : String, platform~ : String) -> Observation

    Provenance

    pub(all) struct Provenance {
    source : String
    dataset : String
    observed_at : Int
    processor : String
    version : String
    } derive(
    Debug
    )

    QcSummary

    pub(all) struct QcSummary {
    total : Int
    good : Int
    missing : Int
    suspect : Int
    bad : Int
    findings : Array[Finding]
    } derive(
    Debug
    )

    QualityFlag

    pub(all) enum QualityFlag {
    Good
    Missing
    Suspect
    Bad
    } derive(Eq,
    Debug
    )

    RuleConfig

    pub(all) struct RuleConfig {
    range_min : Double?
    range_max : Double?
    max_delta : Double?
    max_interval : Int?
    max_speed : Double?
    climate_min : Double?
    climate_max : Double?
    duplicate_window : Int
    processing_time : Int
    } derive(
    Debug
    )

    RuleConfig::default

    fn RuleConfig::default() -> RuleConfig

    RuleKind

    pub(all) enum RuleKind {
    Range
    Missing
    Spike
    Duplicate
    Interval
    SpatialJump
    ClimateAnomaly
    Multivariate
    } derive(Eq,
    Debug
    )

    Severity

    pub(all) enum Severity {
    Info
    Warning
    Error
    } derive(Eq,
    Debug
    )

    inspect

    fn inspect(observations : Array[Observation], config : RuleConfig) -> QcSummary

    render_report

    fn render_report(summary : QcSummary) -> String