Modified "upload IQ files to Dropbox script" selecting satellites with linear transponders

Nice work.

Here is a slight modification, if you want a “cleaner” way to check the list of interesting satellites:

#!/bin/bash
#############################################
#          KK4YEL                           #
# script to upload raw IQ files to proper   #
# format for use with SDRSharp program      #
# modified script based on one from user    #
# mfalkvidd https://bit.ly/3d12Hvl          #
# thanks to skaflux and Mobilinkd           #
#                                           #
#############################################
# remote is the name of the rclone remote instance
RC_REMOTE=remote
# IQ_files is the name of the directory on Dropbox I want rclone to copy the raw IQ files to
DB_DIR=IQ_files
# the arguments passed into the post-observation script by satnogs are
# $1 is ID, $2 is FREQ, $3 is TLE, which is in JSON
# $4 is TIMESTAMP, $5 is BAUD, $6 is SCRIPT_NAME
# below are the NORAD IDs for the current (as of April 2020) satellites with linear transponders
# found at https://www.amsat.org/linear-satellite-frequency-summary/
if [ -n "$IQ_DUMP_FILENAME" ] && [ -f "$IQ_DUMP_FILENAME" ]
then
   # this command gets the satellite name from the JSON TLE Object, replaces spaces with an underscore, and then
   # gets rid of any character that is not alphanumeric a period or underscore or dash
   SATNAME=$(echo "$3" | jq .tle0 | sed -e 's/ /_/g' | sed -e 's/[^A-Za-z0-9._-]//g')
   # this command gets the NORAD ID for the sat
   NORAD_ID=$(echo "$3" | jq .tle1 | awk '{printf "%d", $2;}')
   # this command looks for a match.
   for SAT in $(cut -f1 -d'#' < /home/pi/interesting_satellites)
   do
      if [ "$NORAD_ID" == "$SAT" ]; then
         INTERESTING=true
         break
      fi
   done
   if [ "$INTERESTING" = true ]
   then
        IQ_DIR=$(dirname "${IQ_DUMP_FILENAME}")
        IQ_NAME="$1"_"$SATNAME".wav
        IQ_FILE="$IQ_DIR"/"$IQ_NAME"
        # sox complains unless the file ends in .wav
        TEMPFILE=$(mktemp -p /tmp/.satnogs/ XXXXXXXX.wav)
        # the sox command formats the raw IQ file in the proper way for playback in SDRsharp
        sox -t raw -b16 -e signed-integer -r 48000 -c 2 "$IQ_DUMP_FILENAME" "$TEMPFILE"
        mv "$TEMPFILE" "$IQ_FILE"
        # move the file from the RasPi SD card to Dropbox using rclone
        rclone move "$IQ_FILE" "$RC_REMOTE:$DB_DIR"
   fi
fi
# next line turns off the bias T in the RTL-SDR UNO
/home/pi/rtl-sdr-blog/build/src/rtl_biast -b 0

/home/pi/interesting_satellites could look like this:

7530 # AO07
39444 # AO73
24278 # FO29
40903 # XW2A
40911 # XW2B
40907 # XW2D
40910 # XW2F
41557 # LO87
42017 # EO88
42761 # CAS4A
42759 # CAS4B
43803 # JO97
43937 # FO99
44419 # JAISAT1
99823 # CAS6
45119 # HUSKYSAT1

(The # and the comment is not required, but might be useful when updating the file in the future)

I find the shellcheck tool (apt-get install shellcheck or www.shellcheck.net) useful when writing scripts.

3 Likes