~kris/dots

srice

ref: e9b48d06a8541f3eda5c4db90382ab3c77183afb srice/.local/bin/monitoring/ocean-heat-content-index -rwxr-xr-x 4.0 KiB
e9b48d06 — Kris Yotam xprofile: systemd-aware pipewire start + blueman-applet; sb-internet: tolerate missing /proc/net/wireless 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
# Ocean Heat Content Index
# Tracks integrated ocean heat from Climate Reanalyzer
# Alias: ohc

export DISPLAY=:0

# NOAA Coral Reef Watch SST URLs (working)
# Note: NOAA only provides anomaly maps, not raw SST
url_sst_anom="https://coralreefwatch.noaa.gov/data_current/5km/v3.1_op/daily/png/ct5km_ssta_v3.1_global_current.png"
url_sst_pacific="https://coralreefwatch.noaa.gov/data_current/5km/v3.1_op/daily/png/ct5km_ssta_v3.1_pacific_current.png"
url_sst_atlantic="https://coralreefwatch.noaa.gov/data_current/5km/v3.1_op/daily/png/ct5km_ssta_v3.1_satlantic_current.png"
url_sst_indian="https://coralreefwatch.noaa.gov/data_current/5km/v3.1_op/daily/png/ct5km_ssta_v3.1_indian_current.png"

# NOAA CPC ENSO/Nino monitoring
url_sst_nino="https://www.cpc.ncep.noaa.gov/products/analysis_monitoring/enso_update/sstweek_c.gif"

# Cache locations
cache_dir="$HOME/.cache/maritime/ohc"
cache_sst_anom="$cache_dir/sst_anom.png"
cache_sst_nino="$cache_dir/sst_nino.gif"
cache_sst_pacific="$cache_dir/sst_pacific.png"
cache_sst_atlantic="$cache_dir/sst_atlantic.png"
cache_sst_indian="$cache_dir/sst_indian.png"

# Ensure cache dir exists
mkdir -p "$cache_dir"

# Update all data
update() {
    echo "Fetching ocean heat content data..."
    curl -sLo "$cache_sst_anom" "$url_sst_anom" &
    curl -sLo "$cache_sst_nino" "$url_sst_nino" &
    curl -sLo "$cache_sst_pacific" "$url_sst_pacific" &
    curl -sLo "$cache_sst_atlantic" "$url_sst_atlantic" &
    curl -sLo "$cache_sst_indian" "$url_sst_indian" &
    wait
    notify-send -t 3000 -i "$cache_sst_anom" "Ocean Heat Updated" "All data refreshed from NOAA"
}

# Show specific visualization
show() {
    local target="$cache_sst_anom"
    local title="SST Anomaly - Global"

    case "$1" in
        global|g|anom*|a|"")
            target="$cache_sst_anom"
            title="SST Anomaly - Global"
            ;;
        nino|enso|n)
            target="$cache_sst_nino"
            title="Nino 3.4 Region SST"
            ;;
        atlantic|atl)
            target="$cache_sst_atlantic"
            title="Atlantic SST Anomaly"
            ;;
        pacific|pac)
            target="$cache_sst_pacific"
            title="Pacific SST Anomaly"
            ;;
        indian|ind)
            target="$cache_sst_indian"
            title="Indian Ocean SST Anomaly"
            ;;
    esac

    setsid -f mpv --title="$title" --autofit=70% "$target"
}

# Show all in slideshow
show_all() {
    setsid -f mpv --title="Ocean Heat Content Overview" --idle --autofit=60% \
        --loop-playlist --image-display-duration=5 \
        "$cache_sst_anom" "$cache_sst_nino" \
        "$cache_sst_pacific" "$cache_sst_atlantic" "$cache_sst_indian"
}

# Display help
help() {
    cat << EOF
Ocean Heat Content Index
Usage: ohc [OPTION]

Options:
  update, u          Update all ocean heat data
  show, s [TYPE]     Show specific visualization:
    global, g        Global SST anomaly (default)
    nino, n          Nino 3.4 region (ENSO indicator)
    atlantic, atl    Atlantic SST anomaly
    pacific, pac     Pacific SST anomaly
    indian, ind      Indian Ocean SST anomaly
  all                Show all visualizations
  help, h            Show this help

Data Source: NOAA Coral Reef Watch 5km SST
             NOAA CPC ENSO Monitoring

Key Indicators:
  - Global SST anomaly shows deviation from baseline
  - Nino 3.4 is primary ENSO (El Nino/La Nina) indicator
  - Warm anomalies indicate ocean heat content trends
EOF
}

# Status bar output
tobar() {
    echo "OHC"
}

# Handle arguments
case "$1" in
    u*) update ;;
    show|s) shift; show "$1" ;;
    all|a) show_all ;;
    h*|--help) help ;;
    "") tobar ;;
    *) show "$1" ;;
esac

# Status bar click handlers
case $BLOCK_BUTTON in
    1) notify-send -t 60000 -i "$cache_sst_anom" "Ocean Heat - SST Anomaly" "Global sea surface temperature anomaly vs 1982-2011 baseline" ;;
    2) update ;;
    3) notify-send -t 60000 -i "$cache_ts_world" "Ocean Heat - Time Series" "Historical SST trends" ;;
    4) show "nino" ;;
    5) show "ts" ;;
    6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac