SHARE
TWEET

Untitled

a guest Jul 1st, 2017 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. export TZ='UTC date'
  3. #clear array
  4. unset var1[@]
  5.  
  6. if [ -z $1 ]; then
  7.     echo "Must specify which bird"
  8.     exit 1
  9. fi
  10. if [ -z $2 ]; then
  11.     echo "Must specify frequency in MHz"
  12.     exit 1
  13. fi
  14.  
  15. #get command line arg for bird/freq
  16. bird=$1
  17. freq=$2
  18.  
  19. #calculate best passes
  20. for i in {00..23}
  21. do
  22. var1[10#$i]=$(predict -t ~/wxsat/weather.txt -p "NOAA ${bird}" $(date -d "+$i hour" +%s) | awk '{ if($5>=20) print $0}' |sort -u | head -1)
  23. done
  24.  
  25. #calculate start-end for each pass
  26. for x in $(printf -- '%s\n' "${var1[@]}" | grep : | awk '{print $1,$3$4}' | cut -d : -f 1,2 | sort -uk 2 | awk '{print $1}')
  27. do
  28. recstart=$(predict -t ~/wxsat/weather.txt -p "NOAA ${bird}" $x | awk '{ if($5>=10) print $0}' | head -1 | awk '{print $1}')
  29. recend=$(predict -t ~/wxsat/weather.txt -p "NOAA ${bird}" $x | awk '{ if($5>=10) print $0}' | tail -1 | awk '{print $1}')
  30. rectime=$(awk "BEGIN {print $recend-$recstart}")
  31. init=$(date -d "@$recstart" +%y%m%d%H%M)
  32. #create at file
  33. cat << EOF > ~/wxsat/noaa${bird}.at
  34. export TZ='UTC date'
  35. recdate=\$(date +%Y%m%d-%H%M)
  36. mapdate=\$(date '+%d %m %Y %H:%M')
  37. timeout $rectime /usr/local/bin/rtl_fm -d 0 -f ${freq}M -s 48000 -g 49.6 -p 1 -F 9 -A fast -E DC ~/wxsat/recordings/NOAA${bird}-\$recdate.raw
  38. /usr/bin/sox -t raw -r 48000 -es -b16 -c1 -V1 ~/wxsat/recordings/NOAA${bird}-\$recdate.raw ~/wxsat/recordings/NOAA${bird}-\$recdate.wav rate 11025
  39. touch -r ~/wxsat/recordings/NOAA${bird}-\$recdate.raw ~/wxsat/recordings/NOAA${bird}-\$recdate.wav
  40. /usr/local/bin/wxmap -T "NOAA ${bird}" -H ~/wxsat/weather.txt -L "13.66/-15.21/400" -c l:0xffff00 -p0 -o "\$mapdate" ~/wxsat/noaa${bird}map.png
  41. /usr/local/bin/wxtoimg -e MCIR -c -m ~/wxsat/noaa${bird}map.png ~/wxsat/recordings/NOAA${bird}-\$recdate.wav ~/wxsat/images/NOAA${bird}-MCIR-\$recdate.png
  42. /usr/local/bin/wxtoimg -e HVCT -c -m ~/wxsat/noaa${bird}map.png ~/wxsat/recordings/NOAA${bird}-\$recdate.wav ~/wxsat/images/NOAA${bird}-HVCT-\$recdate.png
  43. bash ~/wxsat/Dropbox-Uploader/dropbox_uploader.sh upload ~/wxsat/images/NOAA${bird}-*-\$recdate.png /
  44. rm ~/wxsat/recordings/NOAA${bird}-\$recdate.raw
  45. EOF
  46. #schedule at
  47. at -f ~/wxsat/noaa${bird}.at -t $init
  48. done
  49.  
  50. #clear array
  51. unset var1[@]
RAW Paste Data
Top