fmeteo/tools/deg2card

49 lines
1.1 KiB
Bash

#!/bin/bash
# simple script to convert degreese to cardinal direction wind
# V1.0
#
n=$1
if (($(echo "$n>= 0" | bc))); then W_nc="N"; fi
if (($(echo "$n>= 22.5" | bc))); then W_nc="N-NE"; fi
if (($(echo "$n>= 45" | bc))); then W_nc="NE"; fi;
if (($(echo "$n>= 67.5" | bc))); then W_nc="E-NE"; fi;
if (($(echo "$n>= 90" | bc))); then W_nc="E"; fi;
if (($(echo "$n>= 112.5" | bc))); then W_nc="E-SE"; fi;
if (($(echo "$n>= 135" | bc))); then W_nc="SE"; fi;
if (($(echo "$n>= 157.5" | bc))); then W_nc="S-SE"; fi;
if (($(echo "$n>= 180" | bc))); then W_nc="S"; fi;
if (($(echo "$n>= 202.5" | bc))); then W_nc="S-SW"; fi;
if (($(echo "$n>= 225" | bc))); then W_nc="SW"; fi;
if (($(echo "$n>= 247.5" | bc))); then W_nc="W-SW"; fi;
if (($(echo "$n>= 270" | bc))); then W_nc="W"; fi;
if (($(echo "$n>= 292.5" | bc))); then W_nc="W-NW"; fi;
if (($(echo "$n>= 315" | bc))); then W_nc="NW"; fi;
if (($(echo "$n>= 337.5" | bc))); then W_nc="N-NW"; fi;
if (($(echo "$n== 360" | bc))); then W_nc="N"; fi;
if (($(echo "$n> 360" | bc))); then W_nc="-?-"; fi;
if (($(echo "$n< 0" | bc))); then W_nc="-?-"; fi
echo $W_nc