#!/bin/bash # wut-dl-sort-txmode # # XXX This script removes directories in data/ !!! XXX # # Populates the data/ directory from the download/dir. # Does it just for a specific transmitter mode (encoding) # # Available encodings: # 4FSK AFSK_TUBiX10 AFSK AHRPT AM APT ASK BPSK_PMT-A3 BPSK CERTO CW DBPSK DOKA # DPSK DQPSK DSTAR DUV DVB-S2 FFSK FMN FM FSK_AX.25_G3RUH FSK_AX.100_Mode_5 # FSK_AX.100_Mode_6 FSK GFSK_Rktr GFSK GFSK/BPSK GMSK_USP GMSK HRPT LRPT LSB # LoRa MFSK MSK_AX.100_Mode_5 MSK_AX.100_Mode_6 MSK OFDM OQPSK PSK31 PSK63 PSK # QPSK31 QPSK63 QPSK SSTV USB WSJT # # Encoding list generator: # for i in `curl --silent https://db.satnogs.org/api/modes/ | jq '.[] | .name' | sort -V | sed -e 's/"//g' -e 's/ /_/g' -e 's/\//_/g'` ; do echo -n "$i " ; done ; echo # # Usage: # wut-dl-sort-txmode [Encoding] [Minimum Observation ID] [Maximum Observation ID] # Example: # wut-dl-sort-txmode CW 1467000 1470000 # For December, 2019 Example: # wut-dl-sort-txmode CW 1292461 1470525 # For July, 2022 Example: # wut-dl-sort-txmode BPSK1k2 6154228 6283338 # # * Takes the files in the download/ dir. # * Looks at the JSON files to see if it is :good", "bad", or "failed". # * Hard link it in the appropriate data/ directory. # * File is randomly copied to either data/train or data/val directory. # # Possible vetted_status: bad, failed, good, null, unknown. OBSENC="$1" OBSIDMIN="$2" OBSIDMAX="$3" OBSID=$OBSIDMIN DATADIR="/srv/satnogs/data/txmodes/$OBSENC" DOWNDIR="/srv/satnogs/download" mkdir -p $DATADIR cd $DATADIR || exit # Enable the following if you want to download waterfalls in this range: #echo "Downloading Waterfalls" #wut-water-range $OBSIDMIN $OBSIDMAX # XXX remove data/train and data/val directories XXX echo "Removing subdirectories" rm -rf train/ val/ # Create new empty dirs mkdir -p train/good/ train/bad/ train/failed/ mkdir -p val/good/ val/bad/ val/failed/ # Then parse each file and link appropriately echo "Parsing download/ directory for observation IDs $OBSIDMIN to $OBSIDMAX" cd $DOWNDIR || exit while [ $OBSID -lt $OBSIDMAX ] do cd $OBSID VET=`cat $OBSID.json | jq --compact-output '.[0] | {vetted_status}' | cut -f 2 -d ":" | sed -e 's/}//g' -e 's/"//g'` ENC=`cat $OBSID.json | jq --compact-output '.[0] | {transmitter_mode}' | cut -f 2 -d ":" | sed -e 's/}//g' -e 's/"//g'` if [ "$OBSENC" = "$ENC" ] ; then RAND_DIR=`echo $((0 + RANDOM % 2))` if [ $RAND_DIR = 1 ] ; then CLASS_DIR="train" else CLASS_DIR="val" fi case "$VET" in bad) ln waterfall_$OBSID_*.png $DATADIR/$CLASS_DIR/$VET/ ;; good) ln waterfall_$OBSID_*.png $DATADIR/$CLASS_DIR/$VET/ ;; failed) ln waterfall_$OBSID_*.png $DATADIR/$CLASS_DIR/$VET/ ;; null) echo "null, not copying" ;; unknown) echo "unknown, not copying" ;; esac fi let OBSID=$OBSID+1 cd .. done