Skip to content

Instantly share code, notes, and snippets.

@cmj
Last active November 8, 2024 13:41
Show Gist options
  • Save cmj/b0923393a9e63c9542791d752dc36fbd to your computer and use it in GitHub Desktop.
Save cmj/b0923393a9e63c9542791d752dc36fbd to your computer and use it in GitHub Desktop.
Check for atmospheric inversion via KSEA soundings
#!/bin/bash
# Check for atmospheric inversion via KSEA soundings
# ex:
# +.08 - 41.78° @ 867.55 feet
# +.88 - 42.58° @ 1064.47 feet
# +.84 - 42.54° @ 1295.16 feet
# Portland, OR (KPDX) - https://a.atmos.washington.edu/mm5rt/rt/showsounding_d3.cgi?initmodel=GFS&yyyymmddhh=timeindep&reqhr=12&loc=kpdx&locname=Portland,OR&latlon=45.59N,122.6W
sounding=$(curl -s 'https://a.atmos.washington.edu/mm5rt/rt/showsounding_d3.cgi?initmodel=GFS&yyyymmddhh=timeindep&reqhr=12&loc=ksea&locname=Sea-Tac,WA&latlon=47.44N,122.31W')
out=$(grep -A 30 TMPF <<< "${sounding}" | tail -30 | awk '{print $4,$10}')
floor=$(head -1 <<< "${out}" | cut -d\ -f1)
while read temp elev; do
if (( $(bc <<< "$floor < $temp") )); then
diff=$(echo "$temp - $floor" | bc)
echo "+$diff - $temp° @ $elev feet"
fi
done <<< "${out}"
#!/bin/bash
# Check for atmospheric inversion via KSEA soundings
# ex:
# +.08 - 41.78° @ 867.55 feet
# +.88 - 42.58° @ 1064.47 feet
# +.84 - 42.54° @ 1295.16 feet
sounding=$(curl -s 'https://a.atmos.washington.edu/mm5rt/rt/showsounding_d3.cgi?initmodel=GFS&yyyymmddhh=timeindep&reqhr=12&loc=ksea&locname=Sea-Tac,WA&latlon=47.44N,122.31W')
out=$(grep -A 30 TMPF <<< "${sounding}" | tail -30 | cat -n | tac | awk '{print $1,$5,$11}')
floor=$(tail -1 <<< "${out}" | cut -d\ -f2)
while read layer temp elev; do
if (( $(bc <<< "$floor < $temp") )); then
diff=$(echo "$temp - $floor" | bc)
bar=$(perl -e 'print " " x '"$diff"', "|"';)
echo "$layer,+$diff,$temp°,@,${elev}, $bar"
else
echo "$layer,,$temp°,@,${elev}, |" |
sed 's/^1,,/1,surface,/'
fi
done <<< "${out}" |
column -s, -t |
lolcat -F .2 -p 1000 -S 43
@cmj
Copy link
Author

cmj commented Nov 8, 2024

sounding.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment